From b6bd8ed487830ba825473c397803de94fccdf9d1 Mon Sep 17 00:00:00 2001 From: piro Date: Fri, 25 Dec 2009 09:49:47 +0000 Subject: [PATCH] =?UTF-8?q?=E3=82=BF=E3=83=96=E3=83=90=E3=83=BC=E3=81=AE?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E3=81=8C=E5=A4=89=E6=9B=B4=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=82=8B=E5=89=8D=E5=BE=8C=E3=81=A7=E5=B8=B8=E3=81=AB=E3=82=A4?= =?UTF-8?q?=E3=83=99=E3=83=B3=E3=83=88=E3=82=92=E7=99=BA=E8=A1=8C=E3=81=99?= =?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@5615 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/hacks.js | 76 +++++++++++++-------- content/treestyletab/treestyletabbrowser.js | 41 ++++++----- 2 files changed, 70 insertions(+), 47 deletions(-) diff --git a/content/treestyletab/hacks.js b/content/treestyletab/hacks.js index 2ced9b4c..76f52913 100644 --- a/content/treestyletab/hacks.js +++ b/content/treestyletab/hacks.js @@ -258,6 +258,52 @@ TreeStyleTabService.overrideExtensionsOnInitBefore = function TSTService_overrid ); } + // Tabberwocky + // https://addons.mozilla.org/firefox/addon/14439 + if ('tabberwocky' in window) { + TreeStyleTabBrowser.prototype.isMultiRow = function() + { + return this.getPref('tabberwocky.multirow') && !this.isVertical; + }; + + let listener = { + handleEvent : function(aEvent) + { + switch (aEvent.type) + { + case 'TreeStyleTabTabbarPositionChanged': + var b = aEvent.originalTarget; + if (b.treeStyleTab.isVertical) + b.treeStyleTab.setPref('tabberwocky.multirow', false); + break; + + case 'unload': + window.removeEventListener('TreeStyleTabTabbarPositionChanged', this, false); + window.removeEventListener('unload', this, false); + break; + } + } + }; + window.addEventListener('TreeStyleTabTabbarPositionChanged', listener, false); + window.addEventListener('unload', listener, false); + + if ('openSelectedLinks' in tabberwocky) { + eval('tabberwocky.openSelectedLinks = '+ + tabberwocky.openSelectedLinks.toSource().replace( + 'links.forEach(', + + ).replace( + /(\}\)?)$/, + + ) + ); + } + } + }; TreeStyleTabService.overrideExtensionsOnInitAfter = function TSTService_overrideExtensionsOnInitAfter() { @@ -932,36 +978,6 @@ TreeStyleTabService.overrideExtensionsOnInitAfter = function TSTService_override } } - // Tabberwocky - // https://addons.mozilla.org/firefox/addon/14439 - if ('multirow' in window && - 'updateMultiRowTabs' in multirow) { - eval('multirow.updateMultiRowTabs = '+ - multirow.updateMultiRowTabs.toSource().replace( - 'gBrowser.mPrefs.getBoolPref("tabberwocky.multirow")', - '$& && !gBrowser.treeStyleTab.isVertical' - ) - ); - window.setTimeout('multirow.updateMultiRowTabs();', 0); - } - if ('tabberwocky' in window) { - if ('openSelectedLinks' in tabberwocky) { - eval('tabberwocky.openSelectedLinks = '+ - tabberwocky.openSelectedLinks.toSource().replace( - 'links.forEach(', - - ).replace( - /(\}\)?)$/, - - ) - ); - } - } - window.setTimeout(function(aSelf) { aSelf.overrideExtensionsDelayed(); }, 0, this); diff --git a/content/treestyletab/treestyletabbrowser.js b/content/treestyletab/treestyletabbrowser.js index 8ab9c6dc..35cce488 100644 --- a/content/treestyletab/treestyletabbrowser.js +++ b/content/treestyletab/treestyletabbrowser.js @@ -148,6 +148,9 @@ TreeStyleTabBrowser.prototype = { } } + let position = this.currentTabbarPosition; + this.fireTabbarPositionEvent('TreeStyleTabTabbarPositionChanging', 'top', position); /* PUBLIC API */ + this.initTabbar(); b.addEventListener('TabOpen', this, true); @@ -583,6 +586,8 @@ TreeStyleTabBrowser.prototype = { this.autoHide; + this.fireTabbarPositionEvent('TreeStyleTabTabbarPositionChanged', 'top', position); /* PUBLIC API */ + b = null; }, @@ -1059,6 +1064,17 @@ TreeStyleTabBrowser.prototype = { } }, 100); }, + + fireTabbarPositionEvent : function TSTBrowser_fireTabbarPositionEvent(aType, aOldPosition, aNewPosition) + { + if (aOldPosition == aNewPosition) return; + + var event = document.createEvent('Events'); + event.initEvent(aType, true, true); + event.oldPosition = aOldPosition; + event.newPosition = aNewPosition; + this.mTabBrowser.dispatchEvent(event); + }, destroy : function TSTBrowser_destroy() { @@ -1174,14 +1190,7 @@ TreeStyleTabBrowser.prototype = { { case 'extensions.treestyletab.tabbar.position': var oldPosition = b.getAttribute(this.kTABBAR_POSITION); - let (event) { - /* PUBLIC API */ - event = document.createEvent('Events'); - event.initEvent('TreeStyleTabTabbarPositionChanging', true, true); - event.oldPosition = oldPosition; - event.newPosition = value; - this.mTabBrowser.dispatchEvent(event); - } + this.fireTabbarPositionEvent('TreeStyleTabTabbarPositionChanging', oldPosition, value); /* PUBLIC API */ this.initTabbar(); tabs.forEach(function(aTab) { this.initTabAttributes(aTab); @@ -1189,14 +1198,7 @@ TreeStyleTabBrowser.prototype = { tabs.forEach(function(aTab) { this.initTabContents(aTab); }, this); - let (event) { - /* PUBLIC API */ - event = document.createEvent('Events'); - event.initEvent('TreeStyleTabTabbarPositionChanged', true, true); - event.oldPosition = oldPosition; - event.newPosition = value; - this.mTabBrowser.dispatchEvent(event); - } + this.fireTabbarPositionEvent('TreeStyleTabTabbarPositionChanged', oldPosition, value); /* PUBLIC API */ window.setTimeout(function(aSelf) { aSelf.checkTabsIndentOverflow(); }, 0, this); @@ -1698,7 +1700,12 @@ TreeStyleTabBrowser.prototype = { if ( nextFocusedTab && this._tabFocusAllowance.every(function(aFunc) { - return aFunc.call(this, b); + try { + return aFunc.call(this, b); + } + catch(e) { + return false; + } }, this) ) b.selectedTab = nextFocusedTab;