From db5506a02ad6d18bd605a4e567f34c2372462882 Mon Sep 17 00:00:00 2001 From: piro Date: Fri, 30 Apr 2010 04:49:00 +0000 Subject: [PATCH] =?UTF-8?q?Minefield=203.7a5pre=E3=81=A7=E3=82=BF=E3=83=96?= =?UTF-8?q?=E3=81=AE=E4=B8=80=E8=A6=A7=E3=81=AE=E9=A0=85=E7=9B=AE=E3=81=8C?= =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=83=87=E3=83=B3=E3=83=88=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=81=AA=E3=81=8F=E3=81=AA=E3=81=A3=E3=81=A6=E3=81=84=E3=81=9F?= =?UTF-8?q?=EF=BC=88Bug=20457187=20=E2=80=93=20Make=20the=20tabs=20toolbar?= =?UTF-8?q?=20customizable=20https://bugzilla.mozilla.org/show=5Fbug.cgi?= =?UTF-8?q?=3Fid=3D457187=20=EF=BC=89?= 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@6627 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/treestyletab.js | 56 +++++++++++++++++---- content/treestyletab/treestyletabbrowser.js | 46 ++--------------- 2 files changed, 50 insertions(+), 52 deletions(-) diff --git a/content/treestyletab/treestyletab.js b/content/treestyletab/treestyletab.js index d894a576..6a9ce5b2 100644 --- a/content/treestyletab/treestyletab.js +++ b/content/treestyletab/treestyletab.js @@ -861,11 +861,11 @@ catch(e) { overrideGlobalFunctions : function TSTService_overrideGlobalFunctions() { -// window.__treestyletab__BrowserCustomizeToolbar = window.BrowserCustomizeToolbar; -// window.BrowserCustomizeToolbar = function() { -// TreeStyleTabService.destroyBar(); -// window.__treestyletab__BrowserCustomizeToolbar.call(window); -// }; + window.__treestyletab__BrowserCustomizeToolbar = window.BrowserCustomizeToolbar; + window.BrowserCustomizeToolbar = function() { + TreeStyleTabService.destroyToolbarItems(); + window.__treestyletab__BrowserCustomizeToolbar.call(window); + }; let (toolbox) { toolbox = document.getElementById('navigator-toolbox'); @@ -873,17 +873,17 @@ catch(e) { toolbox.__treestyletab__customizeDone = toolbox.customizeDone; toolbox.customizeDone = function(aChanged) { this.__treestyletab__customizeDone(aChanged); - TreeStyleTabService.initBar(); + TreeStyleTabService.initToolbarItems(); }; } if ('BrowserToolboxCustomizeDone' in window) { window.__treestyletab__BrowserToolboxCustomizeDone = window.BrowserToolboxCustomizeDone; window.BrowserToolboxCustomizeDone = function(aChanged) { window.__treestyletab__BrowserToolboxCustomizeDone.apply(window, arguments); - TreeStyleTabService.initBar(); + TreeStyleTabService.initToolbarItems(); }; } - this.initBar(); + this.initToolbarItems(); toolbox = null; } @@ -1159,7 +1159,7 @@ catch(e) { return func ? func.toSource() : null ; }, - initBar : function TSTService_initBar() + initToolbarItems : function TSTService_initToolbarItems() { var bar = document.getElementById('urlbar'); if (!bar) return; @@ -1177,6 +1177,42 @@ catch(e) { } bar = null; source = null; + + // for Firefox 3.7 or later + this.updateAllTabsButton(gBrowser); + }, + + destroyToolbarItems : function TSTService_destroyToolbarItems() + { + // Firefox 3.7 or later (restore original position) + var allTabsButton = document.getElementById('alltabs-button'); + if (allTabsButton && allTabsButton.hasChildNodes()) + allTabsButton.firstChild.setAttribute('position', 'after_end'); + }, + + updateAllTabsButton : function TSTService_updateAllTabsButton(aTabBrowser) + { + aTabBrowser = aTabBrowser || this.browser; + var allTabsButton = document.getElementById('alltabs-button') || // Firefox 3.7 or later + document.getAnonymousElementByAttribute(aTabBrowser.mTabContainer, 'class', 'tabs-alltabs-button') || // Firefox 3.6 or older + ( // Tab Mix Plus + this.getTreePref('compatibility.TMP') && + document.getAnonymousElementByAttribute(aTabBrowser.mTabContainer, 'anonid', 'alltabs-button') + ); + + if (allTabsButton && allTabsButton.hasChildNodes() && aTabBrowser.treeStyleTab) + allTabsButton.firstChild.setAttribute('position', aTabBrowser.treeStyleTab.isVertical ? 'before_start' : 'after_end' ); + }, + + updateAllTabsPopup : function TSTService_updateAllTabsPopup(aEvent) + { + if (!this.getTreePref('enableSubtreeIndent.allTabsPopup')) return; + + var items = Array.slice(aEvent.originalTarget.childNodes); + var b = this.getTabBrowserFromChild(aEvent.originalTarget) || gBrowser; + this.getTabsArray(b).forEach(function(aTab, aIndex) { + items[aIndex].style.paddingLeft = aTab.getAttribute(this.kNEST)+'em'; + }, this); }, destroy : function TSTService_destroy() @@ -1247,6 +1283,8 @@ catch(e) { aSelf.popupMenuShown = false; }, 10, this, aEvent.originalTarget); } + if ((aEvent.originalTarget.getAttribute('anonid') || aEvent.originalTarget.id) == 'alltabs-popup') + this.updateAllTabsPopup(aEvent); return; case 'popuphiding': diff --git a/content/treestyletab/treestyletabbrowser.js b/content/treestyletab/treestyletabbrowser.js index 92ad1e0e..7d456f96 100644 --- a/content/treestyletab/treestyletabbrowser.js +++ b/content/treestyletab/treestyletabbrowser.js @@ -628,11 +628,6 @@ TreeStyleTabBrowser.prototype = { } } - let (allTabPopup = document.getAnonymousElementByAttribute(b.mTabContainer, 'anonid', 'alltabs-popup')) { - if (allTabPopup) - allTabPopup.addEventListener('popupshowing', this, false); - } - /* To move up content area on the tab bar, switch tab. If we don't do it, a gray space appears on the content area by negative margin of it. */ @@ -877,11 +872,6 @@ TreeStyleTabBrowser.prototype = { var scrollInnerBox = b.mTabContainer.mTabstrip._scrollbox ? document.getAnonymousNodes(b.mTabContainer.mTabstrip._scrollbox)[0] : scrollFrame; // Tab Mix Plus - var allTabsButton = document.getAnonymousElementByAttribute(b.mTabContainer, 'class', 'tabs-alltabs-button') || - ( // Tab Mix Plus - this.getTreePref('compatibility.TMP') && - document.getAnonymousElementByAttribute(b.mTabContainer, 'anonid', 'alltabs-button') - ); this.removeTabbrowserAttribute(this.kRESIZING, b); @@ -905,9 +895,6 @@ TreeStyleTabBrowser.prototype = { b.mTabContainer.orient = b.mTabContainer.mTabstrip.orient = b.mTabContainer.mTabstrip.parentNode.orient = 'vertical'; - if (allTabsButton && allTabsButton.hasChildNodes()) { - allTabsButton.firstChild.setAttribute('position', 'before_start'); - } b.mTabContainer.setAttribute('align', 'stretch'); // for Mac OS X if (scrollInnerBox) scrollInnerBox.removeAttribute('flex'); @@ -982,9 +969,6 @@ TreeStyleTabBrowser.prototype = { b.mTabContainer.orient = b.mTabContainer.mTabstrip.orient = b.mTabContainer.mTabstrip.parentNode.orient = 'horizontal'; - if (allTabsButton && allTabsButton.hasChildNodes()) { - allTabsButton.firstChild.setAttribute('position', 'after_end'); - } b.mTabContainer.removeAttribute('align'); // for Mac OS X if (scrollInnerBox) scrollInnerBox.setAttribute('flex', 1); @@ -1036,6 +1020,7 @@ TreeStyleTabBrowser.prototype = { window.setTimeout(function(aSelf, aTabBrowser, aSplitter, aToggler) { delayedPostProcess(aSelf, aTabBrowser, aSplitter, aToggler); aSelf.updateTabbarOverflow(); + aSelf.updateAllTabsButton(aTabBrowser); delayedPostProcess = null; aSelf.mTabBrowser.style.visibility = ''; aSelf.startRendering(); @@ -1051,7 +1036,6 @@ TreeStyleTabBrowser.prototype = { toolboxContainer = null; scrollInnerBox = null; scrollInnerBox = null; - allTabsButton = null; }, _ensureNewSplitter : function TSTBrowser__ensureNewSplitter() @@ -1353,11 +1337,6 @@ TreeStyleTabBrowser.prototype = { document.getAnonymousElementByAttribute(b, 'anonid', 'tabContextMenu'); tabContextMenu.removeEventListener('popupshowing', this, false); - var allTabPopup = document.getAnonymousElementByAttribute(b.mTabContainer, 'anonid', 'alltabs-popup'); - if (allTabPopup) { - allTabPopup.removeEventListener('popupshowing', this, false); - } - if (this.tabbarCanvas) { this.tabbarCanvas.parentNode.removeChild(this.tabbarCanvas); this.tabbarCanvas = null; @@ -2745,16 +2724,8 @@ TreeStyleTabBrowser.prototype = { onPopupShowing : function TSTBrowser_onPopupShowing(aEvent) { - if (aEvent.target != aEvent.currentTarget) return; - switch (aEvent.target.getAttribute('anonid') || aEvent.target.id) - { - case 'tabContextMenu': - this.initTabContextMenu(aEvent); - break; - case 'alltabs-popup': - this.initAllTabsPopup(aEvent); - break; - } + if (aEvent.target == aEvent.currentTarget) + this.initTabContextMenu(aEvent); }, initTabContextMenu : function TSTBrowser_initTabContextMenu(aEvent) @@ -2875,17 +2846,6 @@ TreeStyleTabBrowser.prototype = { sep.setAttribute('hidden', true); } }, - - initAllTabsPopup : function TSTBrowser_initAllTabsPopup(aEvent) - { - if (!this.getTreePref('enableSubtreeIndent.allTabsPopup')) return; - var items = aEvent.target.childNodes; - var tabs = this.getTabsArray(this.mTabBrowser); - for (var i = 0, maxi = items.length; i < maxi; i++) - { - items[i].style.paddingLeft = tabs[i].getAttribute(this.kNEST)+'em'; - } - }, onTreeStyleTabPrintPreviewEntered : function TSTBrowser_onTreeStyleTabPrintPreviewEntered(aEvent) {