behavior of middle click on the "go" button should be customizable

This commit is contained in:
SHIMODA Hiroshi 2011-05-25 11:27:33 +09:00
parent e9900dceb0
commit 8cfadc626e
2 changed files with 46 additions and 53 deletions

View File

@ -1369,56 +1369,52 @@ var TreeStyleTabService = {
}, },
_shownPopups : [], _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) onBeforeNewTabCommand : function TSTService_onBeforeNewTabCommand(aTabBrowser)
{ {
var b = aTabBrowser || this.browser; var b = aTabBrowser || this.browser;
switch (this.getTreePref('autoAttach.newTabCommand')) this._handleNewTabCommand(b.selectedTab, 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);
}
}, },
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) onBeforeTabDuplicate : function TSTService_onBeforeTabDuplicate(aTab)
{ {
var b = this.getTabBrowserFromChild(aTab) || this.browser; var b = this.getTabBrowserFromChild(aTab) || this.browser;
var tab = aTab || b.selectedTab; this._handleNewTabCommand(aTab || b.selectedTab, this.getTreePref('autoAttach.duplicateTabCommand'));
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);
}
}, },
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) onGoButtonClick : function TSTService_onGoButtonClick(aEvent)
{ {
@ -1428,12 +1424,7 @@ var TreeStyleTabService = {
) )
return; return;
var tab = this.browser.selectedTab; this._handleNewTabCommand(this.browser.selectedTab, this.getTreePref('autoAttach.goButton'));
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);
});
}, },
/* Tree Style Tabの初期化が行われる前に復元されたセッションについてツリー構造を復元 */ /* Tree Style Tabの初期化が行われる前に復元されたセッションについてツリー構造を復元 */

View File

@ -427,8 +427,8 @@ pref("extensions.treestyletab.autoExpandSubtreeOnAppendChild", true);
*/ */
pref("extensions.treestyletab.autoAttach", true); pref("extensions.treestyletab.autoAttach", true);
/** /**
* How to treat new tabs from the Web search bar. * How to treat new tabs for search results from the Web search bar.
* 0 = Do nothing for new tabs for search results. * 0 = Open as an independent tab.
* 1 = Open the search result tab as a child of the current tab, only if the * 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. * search term equals to the selection in the current tab.
* In other words, if you do select => copy => search, then the result * 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); pref("extensions.treestyletab.autoAttach.newTabCommand", 0);
/** /**
* How to treat duplicated tabs. * How to treat duplicated tabs.
* 0 = Open as an independent tab. * Options are same to extensions.treestyletab.autoAttach.newTabCommand.
* 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.
*/ */
pref("extensions.treestyletab.autoAttach.duplicateTabCommand", 3); 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. * Focus targets for Ctrl-Tab/Ctrl-Shift-Tab.