From 8175f5707afd35eeb9fab462cd3d64e88a2d83b0 Mon Sep 17 00:00:00 2001 From: piro Date: Sat, 20 Oct 2007 02:44:14 +0000 Subject: [PATCH] =?UTF-8?q?=E3=83=BB=E3=83=89=E3=83=A9=E3=83=83=E3=82=B0?= =?UTF-8?q?=EF=BC=86=E3=83=89=E3=83=AD=E3=83=83=E3=83=97=E3=81=BE=E3=82=8F?= =?UTF-8?q?=E3=82=8A=E3=81=AE=E5=AE=9F=E8=A3=85=E3=82=92=E9=80=B2=E8=A1=8C?= =?UTF-8?q?=E4=B8=AD=20=E3=83=BB=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89?= =?UTF-8?q?=E5=90=8D=E3=81=AA=E3=81=A9=E3=82=92=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@1238 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/config.xul | 10 +- content/treestyletab/treestyletab.js | 628 ++++++++++++++------- defaults/preferences/treestyletab.js | 2 +- locale/en-US/treestyletab/treestyletab.dtd | 2 +- locale/ja/treestyletab/treestyletab.dtd | 2 +- skin/classic/treestyletab/treestyletab.css | 14 + 6 files changed, 453 insertions(+), 205 deletions(-) diff --git a/content/treestyletab/config.xul b/content/treestyletab/config.xul index 3a12e818..3d21b303 100644 --- a/content/treestyletab/config.xul +++ b/content/treestyletab/config.xul @@ -20,8 +20,8 @@ - - + + ) + ); + + eval('aTabBrowser.getNewIndex = '+ + aTabBrowser.getNewIndex.toSource().replace( + /\.screenX/g, '[TreeStyleTabService.positionProp]' + ).replace( + /\.width/g, '[TreeStyleTabService.sizeProp]' + ) + ); + eval('aTabBrowser.moveTabForward = '+ aTabBrowser.moveTabForward.toSource().replace( '{', '{ var nextTab;' ).replace( 'tabPos < this.browsers.length - 1', - 'nextTab = TreeStyleTabService.getNextSiblingTabOf(this.mCurrentTab)' + 'nextTab = TreeStyleTabService.getNextSiblingTab(this.mCurrentTab)' ).replace( 'tabPos + 1', 'nextTab._tPos' ).replace( 'this.moveTabTo(', <> 0', - 'prevTab = TreeStyleTabService.getPreviousSiblingTabOf(this.mCurrentTab)' + 'prevTab = TreeStyleTabService.getPreviousSiblingTab(this.mCurrentTab)' ).replace( 'tabPos - 1', 'prevTab._tPos' ).replace( 'this.moveTabToEnd();', <> + ).replace( + 'this.tabbrowser.moveTabForward();', + <> + ).replace( + 'this.tabbrowser.moveTabBackward();', + <> ) ); @@ -551,7 +603,7 @@ var TreeStyleTabService = { var parent; for (var i = 0, maxi = tabs.length; i < maxi; i++) { - parent = this.getParentTabOf(tabs[i]); + parent = this.getParentTab(tabs[i]); if (parent) this.setTabValue(tabs[i], this.kPARENT, parent.getAttribute(this.kID)); } @@ -610,7 +662,7 @@ var TreeStyleTabService = { } if (node.href && isMiddleClick) { var b = this.getTabBrowserFromChildren(aEvent.currentTarget); - b.__treestyletab__readyToAdoptNewTab = true; + b.__treestyletab__readyToAttachNewTab = true; b.__treestyletab__parentTab = b.selectedTab.getAttribute(this.kID); } return; @@ -661,13 +713,13 @@ var TreeStyleTabService = { var tab = aEvent.originalTarget; var b = this.getTabBrowserFromChildren(tab); - if (b.__treestyletab__readyToAdoptNewTab) { + if (b.__treestyletab__readyToAttachNewTab) { var parent = this.getTabById(b.__treestyletab__parentTab, b); if (parent) - this.adoptTabTo(tab, parent); + this.attachTabTo(tab, parent); } - b.__treestyletab__readyToAdoptNewTab = false; + b.__treestyletab__readyToAttachNewTab = false; b.__treestyletab__parentTab = ''; }, @@ -677,45 +729,45 @@ var TreeStyleTabService = { var b = this.getTabBrowserFromChildren(tab); if (tab.getAttribute(this.kSUBTREE_COLLAPSED)) { - var descendant = this.getDescendantTabsOf(tab); + var descendant = this.getDescendantTabs(tab); for (var i = descendant.length-1; i > -1; i--) { b.removeTab(descendant[i]); } } - var firstChild = this.getFirstChildTabOf(tab); - var parentTab = this.getParentTabOf(tab); + var firstChild = this.getFirstChildTab(tab); + var parentTab = this.getParentTab(tab); var nextFocusedTab = null; if (parentTab) { this.setTabValue(tab, this.kPARENT, parentTab.getAttribute(this.kID)); - var next = this.getNextSiblingTabOf(tab); + var next = this.getNextSiblingTab(tab); if (next) this.setTabValue(tab, this.kINSERT_BEFORE, next.getAttribute(this.kID)); } if (firstChild) { var backupChildren = this.getTabValue(tab, this.kCHILDREN); - var children = this.getChildTabsOf(tab); + var children = this.getChildTabs(tab); var self = this; - var adoption = this.getPref('extensions.treestyletab.adoptChildrenToGrandParentOnRemoveTab'); - var processTab = !adoption ? function(aTab) { - self.repudiateTab(aTab, true); + var attachion = this.getPref('extensions.treestyletab.attachChildrenToGrandParentOnRemoveTab'); + var processTab = !attachion ? function(aTab) { + self.partTab(aTab, true); self.moveTabSubTreeTo(aTab, b.mTabContainer.lastChild._tPos); } : parentTab ? function(aTab) { - self.adoptTabTo(aTab, parentTab, { insertBefore : tab, dontUpdateIndent : true }); + self.attachTabTo(aTab, parentTab, { insertBefore : tab, dontUpdateIndent : true }); } : function(aTab) { - self.repudiateTab(aTab, true); + self.partTab(aTab, true); }; for (var i = 0, maxi = children.length; i < maxi; i++) { processTab(children[i]); } this.updateTabsIndent(children); - if (adoption) { + if (attachion) { nextFocusedTab = firstChild; } this.setTabValue(tab, this.kCHILDREN, backupChildren); @@ -723,20 +775,20 @@ var TreeStyleTabService = { if (!nextFocusedTab) { if (parentTab) { - var firstSibling = this.getFirstChildTabOf(parentTab); - var lastSibling = this.getLastChildTabOf(parentTab); + var firstSibling = this.getFirstChildTab(parentTab); + var lastSibling = this.getLastChildTab(parentTab); if (tab == lastSibling) { if (tab == firstSibling) { // there is only one child nextFocusedTab = parentTab; } else { // previous sibling tab - nextFocusedTab = this.getPreviousSiblingTabOf(tab); + nextFocusedTab = this.getPreviousSiblingTab(tab); } } - this.repudiateTab(tab, true); + this.partTab(tab, true); } else { - nextFocusedTab = this.getNextSiblingTabOf(tab); + nextFocusedTab = this.getNextSiblingTab(tab); } } @@ -754,9 +806,9 @@ var TreeStyleTabService = { this.moveTabSubTreeTo(tab, tab._tPos); } - var parentTab = this.getParentTabOf(tab); + var parentTab = this.getParentTab(tab); if (parentTab && !b.__treestyletab__isSubTreeChildrenMoving) { - var children = this.getChildTabsOf(parentTab); + var children = this.getChildTabs(parentTab); children.sort(function(aA, aB) { return aA._tPos - aB._tPos; }); var self = this; this.setTabValue(parentTab, this.kCHILDREN, children.map(function(aItem) { return aItem.getAttribute(self.kID); }).join('|')); @@ -779,7 +831,7 @@ var TreeStyleTabService = { for (var i = 0, maxi = children.length; i < maxi; i++) { if (children[i] && (children[i] = this.getTabById(children[i], b))) { - this.adoptTabTo(children[i], tab, { dontExpand : true, dontUpdateIndent : true }); + this.attachTabTo(children[i], tab, { dontExpand : true, dontUpdateIndent : true }); tabs.push(children[i]); } } @@ -788,7 +840,7 @@ var TreeStyleTabService = { var parent = this.getTabValue(tab, this.kPARENT); var before = this.getTabValue(tab, this.kINSERT_BEFORE); if (parent && (parent = this.getTabById(parent, b))) { - this.adoptTabTo(tab, parent, { dontExpand : true, insertBefore : (before ? this.getTabById(before, b) : null ), dontUpdateIndent : true }); + this.attachTabTo(tab, parent, { dontExpand : true, insertBefore : (before ? this.getTabById(before, b) : null ), dontUpdateIndent : true }); this.deleteTabValue(tab, this.kPARENT); this.updateTabsIndent([tab]); } @@ -831,13 +883,13 @@ var TreeStyleTabService = { /* var p; if ((tab.getAttribute(this.kCOLLAPSED) == 'true') && - (p = this.getParentTabOf(tab))) { + (p = this.getParentTab(tab))) { b.selectedTab = p; } */ if (tab.getAttribute(this.kCOLLAPSED) == 'true') { var parentTab = tab; - while (parentTab = this.getParentTabOf(parentTab)) + while (parentTab = this.getParentTab(parentTab)) { this.collapseExpandTabSubTree(parentTab, false); } @@ -896,7 +948,27 @@ var TreeStyleTabService = { ).singleNodeValue; }, - getParentTabOf : function(aTab) + getNextVisibleTab : function(aTab) + { + var xpathResult = this.evaluateXPath( + 'following-sibling::xul:tab[not(@'+TreeStyleTabService.kCOLLAPSED+'="true")]', + aTab + ); + return xpathResult.snapshotItem(0); + }, + + getPreviousVisibleTab : function(aTab) + { + var xpathResult = this.evaluateXPath( + 'preceding-sibling::xul:tab[not(@'+TreeStyleTabService.kCOLLAPSED+'="true")]', + aTab + ); + return xpathResult.snapshotItem(xpathResult.snapshotLength-1); + }, + +/* tree */ + + getParentTab : function(aTab) { var id = aTab.getAttribute(this.kID); return this.evaluateXPath( @@ -906,17 +978,17 @@ var TreeStyleTabService = { ).singleNodeValue; }, - getNextSiblingTabOf : function(aTab) + getNextSiblingTab : function(aTab) { var id = aTab.getAttribute(this.kID); - var parentTab = this.getParentTabOf(aTab); + var parentTab = this.getParentTab(aTab); if (!parentTab) { var next = aTab; do { next = next.nextSibling; } - while (next && this.getParentTabOf(next)); + while (next && this.getParentTab(next)); return next; } @@ -933,17 +1005,17 @@ var TreeStyleTabService = { return null; }, - getPreviousSiblingTabOf : function(aTab) + getPreviousSiblingTab : function(aTab) { var id = aTab.getAttribute(this.kID); - var parentTab = this.getParentTabOf(aTab); + var parentTab = this.getParentTab(aTab); if (!parentTab) { var prev = aTab; do { prev = prev.previousSibling; } - while (prev && this.getParentTabOf(prev)); + while (prev && this.getParentTab(prev)); return prev; } @@ -960,14 +1032,7 @@ var TreeStyleTabService = { return null; }, - getDescendantTabsOf : function(aTab) - { - var tabs = []; - this.getChildTabsOf(aTab, tabs); - return tabs; - }, - - getChildTabsOf : function(aTab, aAllTabsArray) + getChildTabs : function(aTab, aAllTabsArray) { var tabs = []; var children = aTab.getAttribute(this.kCHILDREN); @@ -984,13 +1049,20 @@ var TreeStyleTabService = { if (!tab) continue; tabs.push(tab); if (aAllTabsArray) - this.getChildTabsOf(tab, tabs); + this.getChildTabs(tab, tabs); } return tabs; }, - getFirstChildTabOf : function(aTab) + getDescendantTabs : function(aTab) + { + var tabs = []; + this.getChildTabs(aTab, tabs); + return tabs; + }, + + getFirstChildTab : function(aTab) { var b = this.getTabBrowserFromChildren(aTab); var children = aTab.getAttribute(this.kCHILDREN); @@ -1006,7 +1078,7 @@ var TreeStyleTabService = { return firstChild; }, - getLastChildTabOf : function(aTab) + getLastChildTab : function(aTab) { var b = this.getTabBrowserFromChildren(aTab); var children = aTab.getAttribute(this.kCHILDREN); @@ -1022,9 +1094,130 @@ var TreeStyleTabService = { return lastChild; }, + getDropAction : function(aEvent) + { + var tab = aEvent.target; + var b = this.getTabBrowserFromChildren(tab); + var tabs = b.mTabContainer.childNodes; + var isInverted = this.isTabVertical(b) ? false : window.getComputedStyle(b.parentNode, null).direction == 'ltr'; + var info = { + tab : null, + target : null, + position : null, + index : null, + action : null + }; + + if (tab.localName != 'tab') { + if (aEvent[this.positionProp] < tabs[0].boxObject[this.positionProp]) { + info.tab = info.target = tabs[0]; + info.position = isInverted ? this.kDROP_AFTER : this.kDROP_BEFORE ; + info.index = 0; + info.action = this.kACTION_MOVE | this.kACTION_PART; + return info; + } + else if (aEvent[this.positionProp] > tabs[tabs.length-1].boxObject[this.positionProp] + tabs[tabs.length-1].boxObject[this.sizeProp]) { + info.tab = info.target = tabs[tabs.length-1]; + info.position = isInverted ? this.kDROP_BEFORE : this.kDROP_AFTER ; + info.index = tabs.length-1; + info.action = this.kACTION_MOVE | this.kACTION_PART; + return info; + } + else { + info.tab = tabs[b.getNewIndex(aEvent)]; + } + } + else { + info.tab = tab; + } + + info.target = tab; + + var boxPos = tab.boxObject[this.positionProp]; + var boxUnit = Math.round(tab.boxObject[this.sizeProp] / 3); + if (aEvent[this.positionProp] < boxPos + boxUnit) { + info.position = isInverted ? this.kDROP_AFTER : this.kDROP_BEFORE ; + } + else if (aEvent[this.positionProp] > boxPos + boxUnit + boxUnit) { + info.position = isInverted ? this.kDROP_BEFORE : this.kDROP_AFTER ; + } + else { + info.position = this.kDROP_ON; + } + + switch (info.position) + { + case this.kDROP_ON: + info.index = tab._tPos; + info.action = this.kACTION_ATTACH; + break; + + case this.kDROP_BEFORE: +/* + [TARGET ] ªpart from parent, and move + + [ ] + [TARGET ] ªattach to the parent of the previous visible, and move + + [ ] + [TARGET ] ªattach to the parent of the target, and move + + [ ] + [TARGET] ªattach to the parent of the targetm and move +*/ + var prevTab = this.getPreviousVisibleTab(tab); + if (!prevTab) { + info.index = 0; + info.action = this.kACTION_MOVE | this.kACTION_PART; + } + else { + var prevNest = Number(prevTab.getAttribute(this.kNEST)); + var targetNest = Number(tab.getAttribute(this.kNEST)); + info.index = tab._tPos; + info.action = this.kACTION_MOVE | this.kACTION_ATTACH; + info.target = (prevNest < targetNest) ? this.getParentTab(prevTab) : + (prevNest > targetNest) ? prevTab : + this.getParentTab(tab); + } + break; + + case this.kDROP_AFTER: +/* + [TARGET ] «part from parent, and move + + [TARGET] «attach to the parent of the target, and move + [ ] + + [TARGET ] «attach to the parent of the target, and move + [ ] + + [TARGET ] «attach to the target, and move + [ ] +*/ + var nextTab = this.getNextVisibleTab(tab); + if (!nextTab) { + info.index = tabs.length-1; + info.action = this.kACTION_MOVE | this.kACTION_PART; + } + else { + var targetNest = Number(tab.getAttribute(this.kNEST)); + var nextNest = Number(nextTab.getAttribute(this.kNEST)); + info.index = tab._tPos + 1; + info.action = this.kACTION_MOVE | this.kACTION_ATTACH; + info.target = (targetNest < nextNest) ? tab : + this.getParentTab(tab); + } + break; + } + + return info; + }, + /* Commands */ - - adoptTabTo : function(aChild, aParent, aInfo) + +/* attach/part */ + + attachTabTo : function(aChild, aParent, aInfo) { if (!aChild || !aParent) return; if (!aInfo) aInfo = {}; @@ -1032,7 +1225,7 @@ var TreeStyleTabService = { var id = aChild.getAttribute(this.kID); var b = this.getTabBrowserFromChildren(aParent); - this.repudiateTab(aChild, true); + this.partTab(aChild, true); var children = aParent.getAttribute(this.kCHILDREN); var newIndex; @@ -1050,7 +1243,7 @@ var TreeStyleTabService = { else { children = ((children || '')+'|'+id).replace(/^\|/, ''); var refTab = aParent; - var descendant = TreeStyleTabService.getDescendantTabsOf(aParent); + var descendant = this.getDescendantTabs(aParent); if (descendant.length) refTab = descendant[descendant.length-1]; newIndex = refTab._tPos+1; } @@ -1078,7 +1271,7 @@ var TreeStyleTabService = { do { this.collapseExpandTabSubTree(p, false); } - while (p = this.getParentTabOf(p)); + while (p = this.getParentTab(p)); } else this.collapseExpandTab(aChild, true); @@ -1095,11 +1288,11 @@ var TreeStyleTabService = { if (!aInfo.dontUpdateIndent) this.updateTabsIndent([aChild]); }, - repudiateTab : function(aChild, aDontUpdateIndent) + partTab : function(aChild, aDontUpdateIndent) { if (!aChild) return; - var parentTab = this.getParentTabOf(aChild); + var parentTab = this.getParentTab(aChild); if (!parentTab) return; var id = aChild.getAttribute(this.kID); @@ -1117,12 +1310,12 @@ var TreeStyleTabService = { if (!aTabs || !aTabs.length) return; if (aLevel === void(0)) { - var parentTab = this.getParentTabOf(aTabs[0]); + var parentTab = this.getParentTab(aTabs[0]); var aLevel = 0; while (parentTab) { aLevel++; - parentTab = this.getParentTabOf(parentTab); + parentTab = this.getParentTab(parentTab); } } @@ -1133,21 +1326,24 @@ var TreeStyleTabService = { for (var i = 0, maxi = aTabs.length; i < maxi; i++) { aTabs[i].setAttribute('style', aTabs[i].getAttribute('style')+';'+aProp+':'+indent+' !important;'); - this.updateTabsIndent(this.getChildTabsOf(aTabs[i]), aLevel+1, aProp); + aTabs[i].setAttribute(this.kNEST, aLevel); + this.updateTabsIndent(this.getChildTabs(aTabs[i]), aLevel+1, aProp); } }, - + updateTabsCount : function(aTab) { var count = document.getAnonymousElementByAttribute(aTab, 'class', this.kCOUNTER); if (count) { - count.setAttribute('value', '('+this.getDescendantTabsOf(aTab).length+')'); + count.setAttribute('value', '('+this.getDescendantTabs(aTab).length+')'); } - var parent = this.getParentTabOf(aTab); + var parent = this.getParentTab(aTab); if (parent) this.updateTabsCount(parent); }, - + +/* move */ + moveTabSubTreeTo : function(aTab, aIndex) { if (!aTab) return; @@ -1158,7 +1354,7 @@ var TreeStyleTabService = { b.moveTabTo(aTab, aIndex); b.__treestyletab__isSubTreeChildrenMoving = true; - var tabs = this.getDescendantTabsOf(aTab); + var tabs = this.getDescendantTabs(aTab); for (var i = 0, maxi = tabs.length; i < maxi; i++) { b.moveTabTo(tabs[i], aTab._tPos+i+(aTab._tPos < tabs[i]._tPos ? 1 : 0 )); @@ -1168,6 +1364,123 @@ var TreeStyleTabService = { b.__treestyletab__isSubTreeMoving = false; }, + moveTabLevel : function(aEvent) + { + var b = this.getTabBrowserFromChildren(aEvent.target); + var parentTab = this.getParentTab(b.mCurrentTab); + if (aEvent.keyCode == KeyEvent.DOM_VK_RIGHT) { + var prevTab = this.getPreviousSiblingTab(b.mCurrentTab); + if ((!parentTab && prevTab) || + (parentTab && b.mCurrentTab != this.getFirstChildTab(parentTab))) { + this.attachTabTo(b.mCurrentTab, prevTab); + b.mCurrentTab.focus(); + return true; + } + } + else if (aEvent.keyCode == KeyEvent.DOM_VK_LEFT && parentTab) { + var grandParent = this.getParentTab(parentTab); + if (grandParent) { + this.attachTabTo(b.mCurrentTab, grandParent, { insertBefore : this.getNextSiblingTab(parentTab) }); + b.mCurrentTab.focus(); + return true; + } + else { + var nextTab = this.getNextSiblingTab(parentTab); + this.partTab(b.mCurrentTab); + if (nextTab) { + b.moveTabTo(b.mCurrentTab, nextTab._tPos - 1); + } + else { + b.moveTabTo(b.mCurrentTab, b.mTabContainer.lastChild._tPos); + } + b.mCurrentTab.focus(); + return true; + } + } + return false; + }, + +/* collapse/expand */ + + collapseExpandTabSubTree : function(aTab, aCollapse) + { + if (!aTab) return; + + if (aTab.getAttribute(this.kSUBTREE_COLLAPSED) == String(aCollapse)) return; + + this.setTabValue(aTab, this.kSUBTREE_COLLAPSED, aCollapse); + + var tabs = this.getChildTabs(aTab); + for (var i = 0, maxi = tabs.length; i < maxi; i++) + { + this.collapseExpandTab(tabs[i], aCollapse); + } + }, + + collapseExpandTab : function(aTab, aCollapse) + { + if (!aTab) return; + + this.setTabValue(aTab, this.kCOLLAPSED, aCollapse); + + var b = this.getTabBrowserFromChildren(aTab); + var p; + if (aCollapse && aTab == b.selectedTab && (p = this.getParentTab(aTab))) { + b.selectedTab = p; + } + + var isSubTreeCollapsed = (aTab.getAttribute(this.kSUBTREE_COLLAPSED) == 'true'); + var tabs = this.getChildTabs(aTab); + for (var i = 0, maxi = tabs.length; i < maxi; i++) + { + if (!isSubTreeCollapsed) + this.collapseExpandTab(tabs[i], aCollapse); + } + }, + + collapseExpandTreesIntelligentlyFor : function(aTab) + { + var b = this.getTabBrowserFromChildren(aTab); + var parent = this.getParentTab(aTab); + var expandedParentTabs = [ + aTab.getAttribute(this.kID) + ]; + var parentTab = aTab; + while (parentTab = this.getParentTab(parentTab)) + { + expandedParentTabs.push(parentTab.getAttribute(this.kID)); + } + expandedParentTabs = expandedParentTabs.join('|'); + + var xpathResult = this.evaluateXPath( + 'child::xul:tab[@'+this.kCHILDREN+' and not(@'+this.kCOLLAPSED+'="true") and not(@'+this.kSUBTREE_COLLAPSED+'="true") and not(contains("'+expandedParentTabs+'", @'+this.kID+'))]', + b.mTabContainer + ); + var collapseTab; + var dontCollapse; + for (var i = 0, maxi = xpathResult.snapshotLength; i < maxi; i++) + { + dontCollapse = false; + collapseTab = xpathResult.snapshotItem(i); + + parentTab = this.getParentTab(collapseTab); + if (parentTab) { + dontCollapse = true; + do { + if (parentTab != parent) continue; + dontCollapse = false; + break; + } + while (parentTab = this.getParentTab(parentTab)); + } + + if (!dontCollapse) + this.collapseExpandTabSubTree(collapseTab, true); + } + + this.collapseExpandTabSubTree(aTab, false); + }, + removeTabSubTree : function(aTabOrTabs) { var tabs = aTabOrTabs; @@ -1178,7 +1491,7 @@ var TreeStyleTabService = { var descendant = []; for (var i = 0, maxi = tabs.length; i < maxi; i++) { - descendant = descendant.concat(this.getDescendantTabsOf(tabs[i])); + descendant = descendant.concat(this.getDescendantTabs(tabs[i])); } tabs = this.cleanUpTabsArray(tabs.concat(descendant)); @@ -1197,86 +1510,7 @@ var TreeStyleTabService = { b.removeTab(tabs[i]); } }, - - collapseExpandTabSubTree : function(aTab, aCollapse) - { - if (!aTab) return; - - if (aTab.getAttribute(this.kSUBTREE_COLLAPSED) == String(aCollapse)) return; - - this.setTabValue(aTab, this.kSUBTREE_COLLAPSED, aCollapse); - - var tabs = this.getChildTabsOf(aTab); - for (var i = 0, maxi = tabs.length; i < maxi; i++) - { - this.collapseExpandTab(tabs[i], aCollapse); - } - }, - - collapseExpandTab : function(aTab, aCollapse) - { - if (!aTab) return; - - this.setTabValue(aTab, this.kCOLLAPSED, aCollapse); - - var b = this.getTabBrowserFromChildren(aTab); - var p; - if (aCollapse && aTab == b.selectedTab && (p = this.getParentTabOf(aTab))) { - b.selectedTab = p; - } - - var isSubTreeCollapsed = (aTab.getAttribute(this.kSUBTREE_COLLAPSED) == 'true'); - var tabs = this.getChildTabsOf(aTab); - for (var i = 0, maxi = tabs.length; i < maxi; i++) - { - if (!isSubTreeCollapsed) - this.collapseExpandTab(tabs[i], aCollapse); - } - }, - - collapseExpandTreesIntelligentlyFor : function(aTab) - { - var b = this.getTabBrowserFromChildren(aTab); - var parent = this.getParentTabOf(aTab); - var expandedParentTabs = [ - aTab.getAttribute(this.kID) - ]; - var parentTab = aTab; - while (parentTab = this.getParentTabOf(parentTab)) - { - expandedParentTabs.push(parentTab.getAttribute(this.kID)); - } - expandedParentTabs = expandedParentTabs.join('|'); - - var xpathResult = this.evaluateXPath( - 'child::xul:tab[@'+this.kCHILDREN+' and not(@'+this.kCOLLAPSED+'="true") and not(@'+this.kSUBTREE_COLLAPSED+'="true") and not(contains("'+expandedParentTabs+'", @'+this.kID+'))]', - b.mTabContainer - ); - var collapseTab; - var dontCollapse; - for (var i = 0, maxi = xpathResult.snapshotLength; i < maxi; i++) - { - dontCollapse = false; - collapseTab = xpathResult.snapshotItem(i); - - parentTab = this.getParentTabOf(collapseTab); - if (parentTab) { - dontCollapse = true; - do { - if (parentTab != parent) continue; - dontCollapse = false; - break; - } - while (parentTab = this.getParentTabOf(parentTab)); - } - - if (!dontCollapse) - this.collapseExpandTabSubTree(collapseTab, true); - } - - this.collapseExpandTabSubTree(aTab, false); - }, - + /* Pref Listener */ domain : 'extensions.treestyletab', diff --git a/defaults/preferences/treestyletab.js b/defaults/preferences/treestyletab.js index fa4a6bfa..d614c77a 100644 --- a/defaults/preferences/treestyletab.js +++ b/defaults/preferences/treestyletab.js @@ -1,7 +1,7 @@ pref("extensions.treestyletab.autoCollapseExpandSubTreeOnSelect", true); pref("extensions.treestyletab.collapseExpandSubTree.dblclick", false); pref("extensions.treestyletab.autoExpandSubTreeOnAppendChild", true); -pref("extensions.treestyletab.adoptChildrenToGrandParentOnRemoveTab", true); +pref("extensions.treestyletab.attachChildrenToGrandParentOnRemoveTab", true); // 0 = default, 1 = only visible tabs pref("extensions.treestyletab.focusMode", 1); diff --git a/locale/en-US/treestyletab/treestyletab.dtd b/locale/en-US/treestyletab/treestyletab.dtd index f5d5736a..539f00d1 100644 --- a/locale/en-US/treestyletab/treestyletab.dtd +++ b/locale/en-US/treestyletab/treestyletab.dtd @@ -8,7 +8,7 @@ - + diff --git a/locale/ja/treestyletab/treestyletab.dtd b/locale/ja/treestyletab/treestyletab.dtd index b8a9a7e9..bcbef0f7 100644 --- a/locale/ja/treestyletab/treestyletab.dtd +++ b/locale/ja/treestyletab/treestyletab.dtd @@ -8,7 +8,7 @@ - + diff --git a/skin/classic/treestyletab/treestyletab.css b/skin/classic/treestyletab/treestyletab.css index 2051db27..83296e6c 100644 --- a/skin/classic/treestyletab/treestyletab.css +++ b/skin/classic/treestyletab/treestyletab.css @@ -30,3 +30,17 @@ tab[treestyletab-subtree-collapsed="true"] .treestyletab-tab-tree-twisty { padding: 0; min-width: 0; } + +/* +tab[treestyletab-drop-position="self"] { + border: 2px solid black !important; +} + +tab[treestyletab-drop-position="before"] { + border-top: 2px solid black !important; +} + +tab[treestyletab-drop-position="after"] { + border-bottom: 2px solid black !important; +} +*/