From d146e0062236d6e0c23b08f596ed2d74c7c992fe Mon Sep 17 00:00:00 2001 From: piro Date: Fri, 19 Oct 2007 03:05:36 +0000 Subject: [PATCH] =?UTF-8?q?Ctrl-Tab=E3=81=A7=E3=81=AE=E3=82=BF=E3=83=96?= =?UTF-8?q?=E5=88=87=E3=82=8A=E6=9B=BF=E3=81=88=E6=99=82=E3=81=AB=E3=80=81?= =?UTF-8?q?=E6=8A=98=E3=82=8A=E3=81=9F=E3=81=9F=E3=81=BE=E3=82=8C=E3=81=A6?= =?UTF-8?q?=E3=81=84=E3=81=AA=E3=81=84=E3=82=BF=E3=83=96=E3=81=AB=E3=81=A0?= =?UTF-8?q?=E3=81=91=E3=83=95=E3=82=A9=E3=83=BC=E3=82=AB=E3=82=B9=E3=81=A7?= =?UTF-8?q?=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F?= 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@1232 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/config.xul | 8 + content/treestyletab/treestyletab.js | 200 +++++++++++---------- defaults/preferences/treestyletab.js | 6 +- locale/en-US/treestyletab/treestyletab.dtd | 2 + locale/ja/treestyletab/treestyletab.dtd | 2 + 5 files changed, 123 insertions(+), 95 deletions(-) diff --git a/content/treestyletab/config.xul b/content/treestyletab/config.xul index 58170d03..67456a0b 100644 --- a/content/treestyletab/config.xul +++ b/content/treestyletab/config.xul @@ -21,6 +21,9 @@ name="extensions.treestyletab.adoptChildrenToGrandParentOnRemoveTab" type="bool" inverted="true"/> + @@ -38,6 +41,11 @@ + diff --git a/content/treestyletab/treestyletab.js b/content/treestyletab/treestyletab.js index 50716317..c018b05b 100644 --- a/content/treestyletab/treestyletab.js +++ b/content/treestyletab/treestyletab.js @@ -11,6 +11,9 @@ var TreeStyleTabService = { kTWISTY : 'treestyletab-tab-tree-twisty', kTWISTY_CONTAINER : 'treestyletab-tab-tree-twisty-container', + kFOCUS_ALL : 0, + kFOCUS_VISIBLE : 1, + levelMargin : 12, NSResolver : { @@ -40,7 +43,7 @@ var TreeStyleTabService = { _SessionStore : null, /* Utilities */ - + isEventFiredOnTabIcon : function(aEvent) { var tab = this.getTabFromEvent(aEvent); @@ -72,6 +75,30 @@ var TreeStyleTabService = { return 'SplitBrowser' ? SplitBrowser.activeBrowser : gBrowser ; }, + evaluateXPath : function(aExpression, aContext, aType) + { + if (!aType) aType = XPathResult.ORDERED_NODE_SNAPSHOT_TYPE; + try { + var xpathResult = document.evaluate( + aExpression, + aContext, + this.NSResolver, + aType, + null + ); + } + catch(e) { + return { + singleNodeValue : null, + snapshotLength : 0, + snapshotItem : function() { + return null + } + }; + } + return xpathResult; + }, + getArrayFromXPathResult : function(aXPathResult) { var max = aXPathResult.snapshotLength; @@ -165,43 +192,23 @@ var TreeStyleTabService = { separator.setAttribute('hidden', true); } }, - + getSeparators : function(aPopup) { - try { - var xpathResult = document.evaluate( - 'descendant::xul:menuseparator', - aPopup, - this.NSResolver, - XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, - null - ); - } - catch(e) { - return { snapshotLength : 0 }; - } - return xpathResult; + return this.evaluateXPath('descendant::xul:menuseparator', aPopup); }, getObsoleteSeparator : function(aPopup) { - try { - var xpathResult = document.evaluate( - 'descendant::xul:menuseparator[not(@hidden)][not(following-sibling::*[not(@hidden)]) or not(preceding-sibling::*[not(@hidden)]) or local-name(following-sibling::*[not(@hidden)]) = "menuseparator"]', - aPopup, - this.NSResolver, - XPathResult.FIRST_ORDERED_NODE_TYPE, - null - ); - } - catch(e) { - return null; - } - return xpathResult.singleNodeValue; + return this.evaluateXPath( + 'descendant::xul:menuseparator[not(@hidden)][not(following-sibling::*[not(@hidden)]) or not(preceding-sibling::*[not(@hidden)]) or local-name(following-sibling::*[not(@hidden)]) = "menuseparator"]', + aPopup, + XPathResult.FIRST_ORDERED_NODE_TYPE + ).singleNodeValue; }, /* Initializing */ - + init : function() { if (!('gBrowser' in window)) return; @@ -238,7 +245,7 @@ var TreeStyleTabService = { this.initTabBrowser(gBrowser); }, - + initTabBrowser : function(aTabBrowser) { aTabBrowser.mTabContainer.addEventListener('TreeStyleTab:TabOpen', this, true); @@ -255,8 +262,36 @@ var TreeStyleTabService = { /\{/, <> + ) + ); + + eval('aTabBrowser.mTabContainer.advanceSelectedTab = '+ + aTabBrowser.mTabContainer.advanceSelectedTab.toSource().replace( + /\{/, + <> @@ -313,7 +348,7 @@ var TreeStyleTabService = { delete tabs; }, - + initTab : function(aTab, aTabBrowser) { var id = 'tab-<'+Date.now()+'-'+parseInt(Math.random() * 65000)+'>'; @@ -391,7 +426,7 @@ var TreeStyleTabService = { }, /* Event Handling */ - + handleEvent : function(aEvent) { switch (aEvent.type) @@ -641,9 +676,9 @@ var TreeStyleTabService = { this.collapseExpandTreesIntelligentlyFor(tab); } }, - + /* Tab Utilities */ - + getTabValue : function(aTab, aKey) { var value = null; @@ -682,37 +717,21 @@ var TreeStyleTabService = { getTabById : function(aId, aTabBrowser) { - try { - var xpathResult = document.evaluate( - 'descendant::xul:tab[@'+this.kID+' = "'+aId+'"]', - aTabBrowser.mTabContainer, - this.NSResolver, - XPathResult.FIRST_ORDERED_NODE_TYPE, - null - ); - } - catch(e) { - return null; - } - return xpathResult.singleNodeValue; + return this.evaluateXPath( + 'descendant::xul:tab[@'+this.kID+' = "'+aId+'"]', + aTabBrowser.mTabContainer, + XPathResult.FIRST_ORDERED_NODE_TYPE + ).singleNodeValue; }, getParentTabOf : function(aTab) { var id = aTab.getAttribute(this.kID); - try { - var xpathResult = document.evaluate( - 'parent::*/child::xul:tab[contains(@'+this.kCHILDREN+', "'+id+'")]', - aTab, - this.NSResolver, - XPathResult.FIRST_ORDERED_NODE_TYPE, - null - ); - } - catch(e) { - return null; - } - return xpathResult.singleNodeValue; + return this.evaluateXPath( + 'parent::*/child::xul:tab[contains(@'+this.kCHILDREN+', "'+id+'")]', + aTab, + XPathResult.FIRST_ORDERED_NODE_TYPE + ).singleNodeValue; }, getNextSiblingTabOf : function(aTab) @@ -832,7 +851,7 @@ var TreeStyleTabService = { }, /* Commands */ - + adoptTabTo : function(aChild, aParent, aInfo) { if (!aChild || !aParent) return; @@ -1010,43 +1029,38 @@ var TreeStyleTabService = { expandedParentTabs.push(parentTab.getAttribute(this.kID)); } expandedParentTabs = expandedParentTabs.join('|'); - try { - var xpathResult = document.evaluate( - 'child::xul:tab[@'+this.kCHILDREN+' and not(@'+this.kCOLLAPSED+'="true") and not(@'+this.kSUBTREE_COLLAPSED+'="true") and not(contains("'+expandedParentTabs+'", @'+this.kID+'))]', - b.mTabContainer, - this.NSResolver, - XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, - null - ); - 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)); + 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; } - - if (!dontCollapse) - this.collapseExpandTabSubTree(collapseTab, true); + while (parentTab = this.getParentTabOf(parentTab)); } + + if (!dontCollapse) + this.collapseExpandTabSubTree(collapseTab, true); } - catch(e) { - } + this.collapseExpandTabSubTree(aTab, false); }, /* Pref Listener */ - + domain : 'extensions.treestyletab', observe : function(aSubject, aTopic, aPrefName) @@ -1065,7 +1079,7 @@ var TreeStyleTabService = { }, /* Save/Load Prefs */ - + get Prefs() { if (!this._Prefs) { diff --git a/defaults/preferences/treestyletab.js b/defaults/preferences/treestyletab.js index 056909cf..174e7ad0 100644 --- a/defaults/preferences/treestyletab.js +++ b/defaults/preferences/treestyletab.js @@ -1,6 +1,8 @@ -pref("extensions.treestyletab.autoCollapseExpandSubTreeOnSelect", true); -pref("extensions.treestyletab.autoExpandSubTreeOnAppendChild", true); +pref("extensions.treestyletab.autoCollapseExpandSubTreeOnSelect", true); +pref("extensions.treestyletab.autoExpandSubTreeOnAppendChild", true); pref("extensions.treestyletab.adoptChildrenToGrandParentOnRemoveTab", true); +// 0 = default, 1 = only visible tabs +pref("extensions.treestyletab.focusMode", 1); pref("browser.link.open_newwindow.restriction", 0); diff --git a/locale/en-US/treestyletab/treestyletab.dtd b/locale/en-US/treestyletab/treestyletab.dtd index cbb2b348..935b7757 100644 --- a/locale/en-US/treestyletab/treestyletab.dtd +++ b/locale/en-US/treestyletab/treestyletab.dtd @@ -9,6 +9,8 @@ + + diff --git a/locale/ja/treestyletab/treestyletab.dtd b/locale/ja/treestyletab/treestyletab.dtd index d16b996a..331a3db8 100644 --- a/locale/ja/treestyletab/treestyletab.dtd +++ b/locale/ja/treestyletab/treestyletab.dtd @@ -9,6 +9,8 @@ + +