From 8cfadc626ebdaacec150c8ee58d8b504d683dd6e Mon Sep 17 00:00:00 2001 From: SHIMODA Hiroshi Date: Wed, 25 May 2011 11:27:33 +0900 Subject: [PATCH] behavior of middle click on the "go" button should be customizable --- content/treestyletab/treestyletab.js | 85 +++++++++++++--------------- defaults/preferences/treestyletab.js | 14 +++-- 2 files changed, 46 insertions(+), 53 deletions(-) diff --git a/content/treestyletab/treestyletab.js b/content/treestyletab/treestyletab.js index a29fd3ad..e3e8fc1f 100644 --- a/content/treestyletab/treestyletab.js +++ b/content/treestyletab/treestyletab.js @@ -1369,56 +1369,52 @@ var TreeStyleTabService = { }, _shownPopups : [], + kNEWTAB_DO_NOTHING : -1, + kNEWTAB_OPEN_AS_ORPHAN : 0, + kNEWTAB_OPEN_AS_CHILD : 1, + kNEWTAB_OPEN_AS_SIBLING : 2, + kNEWTAB_OPEN_AS_NEXT_SIBLING : 3, + _handleNewTabCommand : function TSTService_handleNewTabCommand(aBaseTab, aBehavior) + { + switch (aBehavior) + { + case this.kNEWTAB_OPEN_AS_ORPHAN: + case this.kNEWTAB_DO_NOTHING: + default: + return; + case this.kNEWTAB_OPEN_AS_CHILD: + this.readyToOpenChildTab(aBaseTab); + break; + case this.kNEWTAB_OPEN_AS_SIBLING: + let (parentTab = this.getParentTab(aBaseTab)) { + if (parentTab) + this.readyToOpenChildTab(parentTab); + else + return; + } + break; + case this.kNEWTAB_OPEN_AS_NEXT_SIBLING: + this.readyToOpenNextSiblingTab(aBaseTab); + break; + } + var self = this; + this.Deferred.next(function() { + // clear with delay, because this action can be ignored by othere reasons. + self.stopToOpenChildTab(aBaseTab); + }); + }, + onBeforeNewTabCommand : function TSTService_onBeforeNewTabCommand(aTabBrowser) { var b = aTabBrowser || this.browser; - switch (this.getTreePref('autoAttach.newTabCommand')) - { - case this.kNEWTAB_COMMAND_OPEN_AS_ORPHAN: - default: - break; - case this.kNEWTAB_COMMAND_OPEN_AS_CHILD: - return this.readyToOpenChildTab(b.selectedTab); - case this.kNEWTAB_COMMAND_OPEN_AS_SIBLING: - let (parentTab = this.getParentTab(b.selectedTab)) { - if (parentTab) - this.readyToOpenChildTab(parentTab); - } - return; - case this.kNEWTAB_COMMAND_OPEN_AS_NEXT_SIBLING: - return this.readyToOpenNextSiblingTab(b.selectedTab); - } + this._handleNewTabCommand(b.selectedTab, this.getTreePref('autoAttach.newTabCommand')); }, - kNEWTAB_COMMAND_OPEN_AS_ORPHAN : 0, - kNEWTAB_COMMAND_OPEN_AS_CHILD : 1, - kNEWTAB_COMMAND_OPEN_AS_SIBLING : 2, - kNEWTAB_COMMAND_OPEN_AS_NEXT_SIBLING : 3, onBeforeTabDuplicate : function TSTService_onBeforeTabDuplicate(aTab) { var b = this.getTabBrowserFromChild(aTab) || this.browser; - var tab = aTab || b.selectedTab; - switch (this.getTreePref('autoAttach.duplicateTabCommand')) - { - case this.kDUPLICATE_COMMAND_OPEN_AS_ORPHAN: - default: - return; - case this.kDUPLICATE_COMMAND_OPEN_AS_CHILD: - return this.readyToOpenChildTab(tab); - case this.kDUPLICATE_COMMAND_OPEN_AS_SIBLING: - let (parentTab = this.getParentTab(tab)) { - if (parentTab) - this.readyToOpenChildTab(parentTab); - } - return; - case this.kDUPLICATE_COMMAND_OPEN_AS_NEXT_SIBLING: - return this.readyToOpenNextSiblingTab(tab); - } + this._handleNewTabCommand(aTab || b.selectedTab, this.getTreePref('autoAttach.duplicateTabCommand')); }, - kDUPLICATE_COMMAND_OPEN_AS_ORPHAN : 0, - kDUPLICATE_COMMAND_OPEN_AS_CHILD : 1, - kDUPLICATE_COMMAND_OPEN_AS_SIBLING : 2, - kDUPLICATE_COMMAND_OPEN_AS_NEXT_SIBLING : 3, onGoButtonClick : function TSTService_onGoButtonClick(aEvent) { @@ -1428,12 +1424,7 @@ var TreeStyleTabService = { ) return; - var tab = this.browser.selectedTab; - var self = this; - this.readyToOpenChildTab(tab); - this.Deferred.next(function() { // clear with delay, because this action can be ignored by othere reasons. - self.stopToOpenChildTab(tab); - }); + this._handleNewTabCommand(this.browser.selectedTab, this.getTreePref('autoAttach.goButton')); }, /* Tree Style Tabの初期化が行われる前に復元されたセッションについてツリー構造を復元 */ diff --git a/defaults/preferences/treestyletab.js b/defaults/preferences/treestyletab.js index 2787e3f0..d0505c3f 100644 --- a/defaults/preferences/treestyletab.js +++ b/defaults/preferences/treestyletab.js @@ -427,8 +427,8 @@ pref("extensions.treestyletab.autoExpandSubtreeOnAppendChild", true); */ pref("extensions.treestyletab.autoAttach", true); /** - * How to treat new tabs from the Web search bar. - * 0 = Do nothing for new tabs for search results. + * How to treat new tabs for search results from the Web search bar. + * 0 = Open as an independent tab. * 1 = Open the search result tab as a child of the current tab, only if the * search term equals to the selection in the current tab. * In other words, if you do select => copy => search, then the result @@ -449,12 +449,14 @@ pref("extensions.treestyletab.autoAttach.searchResult", 1); pref("extensions.treestyletab.autoAttach.newTabCommand", 0); /** * How to treat duplicated tabs. - * 0 = Open as an independent tab. - * 1 = Open as a child tab of the source tab. - * 2 = Open as a sibling tab of the source tab. - * 3 = Open as a next sibling tab of the source tab. + * Options are same to extensions.treestyletab.autoAttach.newTabCommand. */ pref("extensions.treestyletab.autoAttach.duplicateTabCommand", 3); +/** + * How to treat new tabs from middle click (or Ctrl-click) on "Go" button. + * Options are same to extensions.treestyletab.autoAttach.newTabCommand. + */ +pref("extensions.treestyletab.autoAttach.goButton", 0); /** * Focus targets for Ctrl-Tab/Ctrl-Shift-Tab.