From 7578fb9ad8e3f1af1acc7997184b8f66293c4760 Mon Sep 17 00:00:00 2001 From: piro Date: Fri, 19 Oct 2007 05:27:06 +0000 Subject: [PATCH] =?UTF-8?q?=E3=83=9E=E3=83=AB=E3=83=81=E3=83=97=E3=83=AB?= =?UTF-8?q?=E3=82=BF=E3=83=96=E3=83=8F=E3=83=B3=E3=83=89=E3=83=A9=E3=81=8C?= =?UTF-8?q?=E5=B0=8E=E5=85=A5=E3=81=95=E3=82=8C=E3=81=A6=E3=81=84=E3=82=8B?= =?UTF-8?q?=E5=A0=B4=E5=90=88=E3=80=81=E3=82=B3=E3=83=B3=E3=83=86=E3=82=AD?= =?UTF-8?q?=E3=82=B9=E3=83=88=E3=83=A1=E3=83=8B=E3=83=A5=E3=83=BC=E3=82=84?= =?UTF-8?q?=E3=82=BF=E3=83=96=E3=81=AE=E9=81=B8=E6=8A=9E=E3=83=A1=E3=83=8B?= =?UTF-8?q?=E3=83=A5=E3=83=BC=E3=81=8B=E3=82=89=E3=82=B5=E3=83=96=E3=83=84?= =?UTF-8?q?=E3=83=AA=E3=83=BC=E3=82=92=E9=96=89=E3=81=98=E3=82=89=E3=82=8C?= =?UTF-8?q?=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@1233 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- chrome.manifest | 1 + .../treestyletab/multipletabConfigOverlay.xul | 27 +++ content/treestyletab/treestyletab.js | 195 ++++++++++-------- content/treestyletab/treestyletab.xul | 16 ++ defaults/preferences/treestyletab.js | 2 + locale/en-US/treestyletab/treestyletab.dtd | 7 + locale/ja/treestyletab/treestyletab.dtd | 7 + 7 files changed, 172 insertions(+), 83 deletions(-) create mode 100644 content/treestyletab/multipletabConfigOverlay.xul diff --git a/chrome.manifest b/chrome.manifest index 4bc7a850..c51e6b3e 100644 --- a/chrome.manifest +++ b/chrome.manifest @@ -1,6 +1,7 @@ content treestyletab jar:chrome/treestyletab.jar!/content/treestyletab/ overlay chrome://browser/content/browser.xul chrome://treestyletab/content/treestyletab.xul +overlay chrome://multipletab/content/config.xul chrome://treestyletab/content/multipletabConfigOverlay.xul locale treestyletab en-US jar:chrome/treestyletab.jar!/locale/en-US/treestyletab/ locale treestyletab ja jar:chrome/treestyletab.jar!/locale/ja/treestyletab/ diff --git a/content/treestyletab/multipletabConfigOverlay.xul b/content/treestyletab/multipletabConfigOverlay.xul new file mode 100644 index 00000000..e29cd752 --- /dev/null +++ b/content/treestyletab/multipletabConfigOverlay.xul @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + diff --git a/content/treestyletab/treestyletab.js b/content/treestyletab/treestyletab.js index c018b05b..4eff2d94 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', + kMENUITEM_REMOVESUBTREE_MULTIPLETAB_SELECTION : 'multipletab-selection-item-removeTabSubTree', + kMENUITEM_REMOVESUBTREE_CONTEXT : 'context-item-removeTabSubTree', + kFOCUS_ALL : 0, kFOCUS_VISIBLE : 1, @@ -152,61 +155,22 @@ var TreeStyleTabService = { return (target.localName == 'tabbrowser') ? target : null ; }, - showHideMenuItems : function(aPopup) + cleanUpTabsArray : function(aTabs) { - var nodes = aPopup.childNodes; - var pref; + var b = this.getTabBrowserFromChildren(aTabs[0]); - var b = this.getTabBrowserFromChildren(aPopup) || this.browser; - var box = b.mTabContainer.mTabstrip || b.mTabContainer ; - var isVertical = ((box.getAttribute('orient') || window.getComputedStyle(box, '').getPropertyValue('-moz-box-orient')) == 'vertical'); + var self = this; + aTabs = aTabs.map(function(aTab) { return aTab.getAttribute(self.kID); }); + aTabs.sort(); + aTabs = aTabs.join('|').replace(/([^\|]+)(\|\1)+/g, '$1').split('|'); - var label; - - for (var i = 0, maxi = nodes.length; i < maxi; i++) + for (var i = 0, maxi = aTabs.length; i < maxi; i++) { - if ( - (isVertical && (label = nodes[i].getAttribute('label-vertical'))) || - (!isVertical && (label = nodes[i].getAttribute('label-horizontal'))) - ) - nodes[i].setAttribute('label', label); - - pref = this.getPref('extensions.multipletab.show.'+nodes[i].getAttribute('id').replace(/-tabbrowser[0-9]+$/, '')); - if (pref === null) continue; - - if (pref) - nodes[i].removeAttribute('hidden'); - else - nodes[i].setAttribute('hidden', true); - } - - var separators = this.getSeparators(aPopup); - for (var i = separators.snapshotLength-1; i > -1; i--) - { - separators.snapshotItem(i).removeAttribute('hidden'); - } - - var separator; - while (separator = this.getObsoleteSeparator(aPopup)) - { - separator.setAttribute('hidden', true); + aTabs[i] = this.getTabById(aTabs[i], b); } + return aTabs; }, - - getSeparators : function(aPopup) - { - return this.evaluateXPath('descendant::xul:menuseparator', aPopup); - }, - - getObsoleteSeparator : function(aPopup) - { - 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() @@ -222,18 +186,19 @@ var TreeStyleTabService = { this.addPrefListener(this); this.observe(null, 'nsPref:changed', 'extensions.treestyletab.'); - eval('window.nsBrowserAccess.prototype.openURI = '+ window.nsBrowserAccess.prototype.openURI.toSource().replace( /switch\s*\(aWhere\)/, <> @@ -242,6 +207,48 @@ var TreeStyleTabService = { window.QueryInterface(Components.interfaces.nsIDOMChromeWindow).browserDOMWindow = null; window.QueryInterface(Components.interfaces.nsIDOMChromeWindow).browserDOMWindow = new nsBrowserAccess(); + if ('MultipleTabService' in window) { + eval('MultipleTabService.showHideMenuItems = '+ + MultipleTabService.showHideMenuItems.toSource().replace( + /var separators = /, + <> + ) + ); + } this.initTabBrowser(gBrowser); }, @@ -275,30 +282,31 @@ var TreeStyleTabService = { /\{/, <> ) ); - var addTabMethod = 'addTab'; var removeTabMethod = 'removeTab'; if (aTabBrowser.__tabextensions__addTab) { @@ -330,25 +338,19 @@ var TreeStyleTabService = { return retVal; }; - -// var tabContextMenu = document.getAnonymousElementByAttribute(aTabBrowser, 'anonid', 'tabContextMenu'); -// tabContextMenu.addEventListener('popupshowing', this, false); - var tabs = aTabBrowser.mTabContainer.childNodes; for (var i = 0, maxi = tabs.length; i < maxi; i++) { this.initTab(tabs[i], aTabBrowser); } - delete addTabMethod; delete removeTabMethod; delete i; delete maxi; delete tabs; - }, - + initTab : function(aTab, aTabBrowser) { var id = 'tab-<'+Date.now()+'-'+parseInt(Math.random() * 65000)+'>'; @@ -395,7 +397,7 @@ var TreeStyleTabService = { this.destroyTab(tabs[i]); } }, - + destroyTabBrowser : function(aTabBrowser) { var tabs = aTabBrowser.mTabContainer.childNodes; @@ -415,11 +417,8 @@ var TreeStyleTabService = { aTabBrowser.mTabContainer.removeEventListener('mousedown', this, true); aTabBrowser.mTabContainer.removeEventListener('select', this, true); aTabBrowser.mPanelContainer.removeEventListener('click', this, true); - -// var tabContextMenu = document.getAnonymousElementByAttribute(aTabBrowser, 'anonid', 'tabContextMenu'); -// tabContextMenu.removeEventListener('popupshowing', this, false); }, - + destroyTab : function(aTab, aTabBrowser) { delete aTab.__treestyletab__linkedTabBrowser; @@ -980,6 +979,36 @@ var TreeStyleTabService = { b.__treestyletab__isSubTreeMoving = false; }, + removeTabSubTree : function(aTabOrTabs) + { + var tabs = aTabOrTabs; + if (!(tabs instanceof Array)) { + tabs = [aTabOrTabs]; + } + + var descendant = []; + for (var i = 0, maxi = tabs.length; i < maxi; i++) + { + descendant = descendant.concat(this.getDescendantTabsOf(tabs[i])); + } + tabs = this.cleanUpTabsArray(tabs.concat(descendant)); + + var max = tabs.length; + if (!max) return; + + var b = this.getTabBrowserFromChildren(tabs[0]); + if ( + max > 1 && + !b.warnAboutClosingTabs(true, max) + ) + return; + + for (var i = tabs.length-1; i > -1; i--) + { + b.removeTab(tabs[i]); + } + }, + collapseExpandTabSubTree : function(aTab, aCollapse) { if (!aTab) return; diff --git a/content/treestyletab/treestyletab.xul b/content/treestyletab/treestyletab.xul index b429b744..d4501af8 100644 --- a/content/treestyletab/treestyletab.xul +++ b/content/treestyletab/treestyletab.xul @@ -8,4 +8,20 @@