新しい子タブの挿入位置をサブツリーの最初か最後かで選べるようにした

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@1422 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2007-10-31 00:38:37 +00:00
parent bb40161923
commit 8b877cef23
6 changed files with 58 additions and 10 deletions

View File

@ -247,6 +247,9 @@
<preference id="extensions.treestyletab.focusMode" <preference id="extensions.treestyletab.focusMode"
name="extensions.treestyletab.focusMode" name="extensions.treestyletab.focusMode"
type="int"/> type="int"/>
<preference id="extensions.treestyletab.insertNewChildAt"
name="extensions.treestyletab.insertNewChildAt"
type="int"/>
</preferences> </preferences>
<checkbox id="extensions.treestyletab.autoCollapseExpandSubTreeOnSelect-check" <checkbox id="extensions.treestyletab.autoCollapseExpandSubTreeOnSelect-check"
@ -266,6 +269,15 @@
label="&config.focusMode;" label="&config.focusMode;"
onsyncfrompreference="return document.getElementById('extensions.treestyletab.focusMode').value == 0;" onsyncfrompreference="return document.getElementById('extensions.treestyletab.focusMode').value == 0;"
onsynctopreference="return document.getElementById('extensions.treestyletab.focusMode-check').checked ? 0 : 1 ;"/> onsynctopreference="return document.getElementById('extensions.treestyletab.focusMode-check').checked ? 0 : 1 ;"/>
<groupbox>
<caption label="&config.insertNewChildAt.caption;"/>
<radiogroup id="extensions.treestyletab.insertNewChildAt-radiogroup"
preference="extensions.treestyletab.insertNewChildAt"
orient="vertical">
<radio value="0" label="&config.insertNewChildAt.first;"/>
<radio value="1" label="&config.insertNewChildAt.last;"/>
</radiogroup>
</groupbox>
</prefpane> </prefpane>
<script src="config.js" type="application/x-javascript"/> <script src="config.js" type="application/x-javascript"/>

View File

@ -45,6 +45,9 @@ var TreeStyleTabService = {
kTABBAR_HORIZONTAL : 3, kTABBAR_HORIZONTAL : 3,
kTABBAR_VERTICAL : 12, kTABBAR_VERTICAL : 12,
kINSERT_FISRT : 0,
kINSERT_LAST : 1,
levelMargin : 12, levelMargin : 12,
levelMarginProp : 'margin-left', levelMarginProp : 'margin-left',
positionProp : 'screenY', positionProp : 'screenY',
@ -103,6 +106,7 @@ var TreeStyleTabService = {
var ownerBrowser = this.getTabBrowserFromFrame(frame); var ownerBrowser = this.getTabBrowserFromFrame(frame);
ownerBrowser.__treestyletab__readyToAttachNewTab = true; ownerBrowser.__treestyletab__readyToAttachNewTab = true;
ownerBrowser.__treestyletab__readyToAttachMultiple = aMultiple || false ; ownerBrowser.__treestyletab__readyToAttachMultiple = aMultiple || false ;
ownerBrowser.__treestyletab__multipleCount = 0;
ownerBrowser.__treestyletab__parentTab = this.getTabFromFrame(frame, ownerBrowser).getAttribute(this.kID); ownerBrowser.__treestyletab__parentTab = this.getTabFromFrame(frame, ownerBrowser).getAttribute(this.kID);
ownerBrowser.__treestyletab__insertBefore = aInsertBefore ? aInsertBefore.getAttribute(this.kID) : null ; ownerBrowser.__treestyletab__insertBefore = aInsertBefore ? aInsertBefore.getAttribute(this.kID) : null ;
}, },
@ -117,6 +121,7 @@ var TreeStyleTabService = {
var ownerBrowser = this.getTabBrowserFromFrame(frame); var ownerBrowser = this.getTabBrowserFromFrame(frame);
ownerBrowser.__treestyletab__readyToAttachNewTabGroup = true; ownerBrowser.__treestyletab__readyToAttachNewTabGroup = true;
ownerBrowser.__treestyletab__readyToAttachMultiple = true; ownerBrowser.__treestyletab__readyToAttachMultiple = true;
ownerBrowser.__treestyletab__multipleCount = 0;
}, },
stopToOpenChildTab : function(aFrameOrTabBrowser) stopToOpenChildTab : function(aFrameOrTabBrowser)
@ -128,6 +133,7 @@ var TreeStyleTabService = {
ownerBrowser.__treestyletab__readyToAttachNewTab = false; ownerBrowser.__treestyletab__readyToAttachNewTab = false;
ownerBrowser.__treestyletab__readyToAttachNewTabGroup = false; ownerBrowser.__treestyletab__readyToAttachNewTabGroup = false;
ownerBrowser.__treestyletab__readyToAttachMultiple = false; ownerBrowser.__treestyletab__readyToAttachMultiple = false;
ownerBrowser.__treestyletab__multipleCount = 0;
ownerBrowser.__treestyletab__parentTab = null; ownerBrowser.__treestyletab__parentTab = null;
ownerBrowser.__treestyletab__insertBefore = null; ownerBrowser.__treestyletab__insertBefore = null;
}, },
@ -198,9 +204,13 @@ var TreeStyleTabService = {
) { ) {
openTab = info.modifier && info.invert ? !openTab : true ; openTab = info.modifier && info.invert ? !openTab : true ;
parent = parentHost == targetHost && !internal.forceChild ? parentTab : frame ; parent = parentHost == targetHost && !internal.forceChild ? parentTab : frame ;
insertBefore = parentHost == targetHost && !internal.forceChild && ( insertBefore = parentHost == targetHost && !internal.forceChild &&
(this.getTreePref('insertNewChildAt') == this.kINSERT_FIRST ?
nextTab :
(
this.getTabById(currentTab.__treestyletab__next, b) || this.getTabById(currentTab.__treestyletab__next, b) ||
(nextTab ? (currentTab.__treestyletab__next = nextTab.getAttribute(this.kID), nextTab) : null ) (nextTab ? (currentTab.__treestyletab__next = nextTab.getAttribute(this.kID), nextTab) : null )
)
); );
} }
else if ( else if (
@ -1189,13 +1199,27 @@ catch(e) {
if (parent) if (parent)
this.attachTabTo(tab, parent); this.attachTabTo(tab, parent);
var insertBefore; var refTab;
var newIndex = -1;
if (b.__treestyletab__insertBefore && if (b.__treestyletab__insertBefore &&
(insertBefore = this.getTabById(b.__treestyletab__insertBefore, b))) { (refTab = this.getTabById(b.__treestyletab__insertBefore, b))) {
var index = insertBefore._tPos; newIndex = refTab._tPos;
if (index > tab._tPos) index--; }
else if (parent &&
this.getTreePref('insertNewChildAt') == this.kINSERT_FISRT &&
b.__treestyletab__multipleCount == 0) {
/*
子タブの最初の位置に挿入し続くタブは最初の開いたタブ
元々最初の子だったタブとの間に挿入していく */
newIndex = parent._tPos + 1;
if (refTab = this.getFirstChildTab(parent))
b.__treestyletab__insertBefore = refTab.getAttribute(this.kID);
}
if (newIndex > -1) {
if (newIndex > tab._tPos) newIndex--;
b.__treestyletab__internallyTabMoving = true; b.__treestyletab__internallyTabMoving = true;
b.moveTabTo(tab, index); b.moveTabTo(tab, newIndex);
b.__treestyletab__internallyTabMoving = false; b.__treestyletab__internallyTabMoving = false;
} }
} }
@ -1203,6 +1227,9 @@ catch(e) {
if (!b.__treestyletab__readyToAttachMultiple) { if (!b.__treestyletab__readyToAttachMultiple) {
this.stopToOpenChildTab(b); this.stopToOpenChildTab(b);
} }
else {
b.__treestyletab__multipleCount++;
}
}, },
onTabRemoved : function(aEvent) onTabRemoved : function(aEvent)

View File

@ -10,6 +10,8 @@ pref("extensions.treestyletab.enableSubtreeIndent", true);
pref("extensions.treestyletab.allowSubtreeCollapseExpand", true); pref("extensions.treestyletab.allowSubtreeCollapseExpand", true);
pref("extensions.treestyletab.showBorderForFirstTab", false); pref("extensions.treestyletab.showBorderForFirstTab", false);
pref("extensions.treestyletab.levelMargin", 12); pref("extensions.treestyletab.levelMargin", 12);
// 0 = first child, 1 = last child
pref("extensions.treestyletab.insertNewChildAt", 1);
pref("extensions.treestyletab.show.openSelectionLinks", true); pref("extensions.treestyletab.show.openSelectionLinks", true);
pref("extensions.treestyletab.show.context-item-removeTabSubTree", true); pref("extensions.treestyletab.show.context-item-removeTabSubTree", true);

View File

@ -5,7 +5,7 @@
<RDF:Description RDF:about="urn:mozilla:install-manifest" <RDF:Description RDF:about="urn:mozilla:install-manifest"
em:id="treestyletab@piro.sakura.ne.jp" em:id="treestyletab@piro.sakura.ne.jp"
em:name="Tree Style Tab" em:name="Tree Style Tab"
em:version="0.3.2007103101" em:version="0.3.2007103102"
em:creator="SHIMODA Hiroshi" em:creator="SHIMODA Hiroshi"
em:description="Show tabs like a tree." em:description="Show tabs like a tree."
em:homepageURL="http://piro.sakura.ne.jp/xul/treestyletab/" em:homepageURL="http://piro.sakura.ne.jp/xul/treestyletab/"

View File

@ -67,6 +67,10 @@
<!ENTITY config.focusMode "Focus to the next/previous tab even if it is invisible, by Control(Command)-Tab"> <!ENTITY config.focusMode "Focus to the next/previous tab even if it is invisible, by Control(Command)-Tab">
<!ENTITY config.insertNewChildAt.caption "Insertion position of new child tabs">
<!ENTITY config.insertNewChildAt.first "Insert to the top of the sub tree, as the first child">
<!ENTITY config.insertNewChildAt.last "Append to the last of the sub tree">

View File

@ -67,6 +67,9 @@
<!ENTITY config.focusMode "Control(Command)-Tabでタブを切り替える時、折りたたまれたタブにもフォーカスする"> <!ENTITY config.focusMode "Control(Command)-Tabでタブを切り替える時、折りたたまれたタブにもフォーカスする">
<!ENTITY config.insertNewChildAt.caption "新しい子タブを開く位置">
<!ENTITY config.insertNewChildAt.first "サブツリーの最初の位置に挿入する">
<!ENTITY config.insertNewChildAt.last "サブツリーの末尾に追加する">