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) {