From c9a3d28c729ff9bc92247ed0c03ea0f3d390aee2 Mon Sep 17 00:00:00 2001 From: Piro / YUKI Hiroshi Date: Sun, 23 Sep 2012 14:57:29 +0900 Subject: [PATCH] Open duplicated tabs from back/forward buttons as children of the current tab --- content/treestyletab/windowHelper.js | 2 +- defaults/preferences/treestyletab.js | 10 ++++++++++ modules/window.js | 8 ++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/content/treestyletab/windowHelper.js b/content/treestyletab/windowHelper.js index b7c66bc6..504d20c5 100644 --- a/content/treestyletab/windowHelper.js +++ b/content/treestyletab/windowHelper.js @@ -267,7 +267,7 @@ var TreeStyleTabWindowHelper = { eval('window.duplicateTabIn = '+ window.duplicateTabIn.toSource().replace( '{', - '{ gBrowser.treeStyleTab.onBeforeTabDuplicate(aTab, where); ' + '{ gBrowser.treeStyleTab.onBeforeTabDuplicate(aTab, where, delta); ' ) ); } diff --git a/defaults/preferences/treestyletab.js b/defaults/preferences/treestyletab.js index 1210cfac..22b90a5d 100644 --- a/defaults/preferences/treestyletab.js +++ b/defaults/preferences/treestyletab.js @@ -507,6 +507,16 @@ pref("extensions.treestyletab.autoAttach.newTabButton", 1); * Options are same to extensions.treestyletab.autoAttach.newTabCommand. */ pref("extensions.treestyletab.autoAttach.duplicateTabCommand", 3); +/** + * How to treat duplicated tabs from "back" button. + * Options are same to extensions.treestyletab.autoAttach.newTabCommand. + */ +pref("extensions.treestyletab.autoAttach.duplicateTabCommand.back", 1); +/** + * How to treat duplicated tabs from "forward" button. + * Options are same to extensions.treestyletab.autoAttach.newTabCommand. + */ +pref("extensions.treestyletab.autoAttach.duplicateTabCommand.forward", 1); /** * How to treat new tabs from middle click (or Ctrl-click) on the "Go" button. * Options are same to extensions.treestyletab.autoAttach.newTabCommand. diff --git a/modules/window.js b/modules/window.js index 5d8ad0d5..e3cf1951 100644 --- a/modules/window.js +++ b/modules/window.js @@ -1167,13 +1167,17 @@ TreeStyleTabWindow.prototype = { }, _clickEventOnNewTabButtonHandled : false, - onBeforeTabDuplicate : function TSTWindow_onBeforeTabDuplicate(aTab, aWhere) + onBeforeTabDuplicate : function TSTWindow_onBeforeTabDuplicate(aTab, aWhere, aDelta) { if (aWhere && aWhere.indexOf('tab') != 0) return; var b = this.getTabBrowserFromChild(aTab) || this.browser; - this._handleNewTabCommand(aTab || b.selectedTab, this.getTreePref('autoAttach.duplicateTabCommand')); + var behaviorPref = !aDelta ? 'autoAttach.duplicateTabCommand' : + aDelta < 0 ? 'autoAttach.duplicateTabCommand.back' : + 'autoAttach.duplicateTabCommand.forward' + var behavior = this.getTreePref(behaviorPref); + this._handleNewTabCommand(aTab || b.selectedTab, behavior); }, onBeforeOpenLink : function TSTWindow_onBeforeOpenLink(aWhere, aOwner)