Skip to content

Commit e01a7bf

Browse files
committed
Add Ctrl+Alt+[+/-] shortcut keys for Expand/Collapse Stack
1 parent 51ba5e5 commit e01a7bf

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

chrome/content/tabutils-st.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ tabutils._stackTabs = function() {
6767

6868
gBrowser.isStackedTab = function(aTab) aTab.hasAttribute("group") && aTab.getAttribute("group-counter") != 1;
6969
gBrowser.isCollapsedStack = function(aTab) aTab.hasAttribute("group-collapsed") && aTab.getAttribute("group-counter") > 1;
70+
gBrowser.isExpandedStack = function(aTab) this.isStackedTab(aTab) && !aTab.hasAttribute("group-collapsed");
7071

7172
gBrowser.stackTabs = function stackTabs(aTabs, aTab, aExpand) {
7273
aTabs = aTabs.filter(function(aTab) !aTab.pinned)
@@ -174,7 +175,19 @@ tabutils._stackTabs = function() {
174175
};
175176

176177
gBrowser.collapseStack = function collapseStack(aTab, aForce) {
177-
if (!aTab.hasAttribute("group"))
178+
if ("length" in arguments[0]) {
179+
let aTabs = Array.filter(arguments[0], function(aTab) aTab.hasAttribute("group-selected"));
180+
if (aForce == null)
181+
aForce = !aTabs.every(function(aTab) aTab.hasAttribute("group-collapsed"));
182+
183+
let func = arguments.callee;
184+
aTabs.forEach(function(aTab) {
185+
func.call(this, aTab, aForce);
186+
}, this);
187+
return;
188+
}
189+
190+
if (!this.isStackedTab(aTab))
178191
return;
179192

180193
if (aForce == aTab.hasAttribute("group-collapsed"))

chrome/content/tabutils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2449,6 +2449,7 @@ tabutils._tabContextMenu = function() {
24492449
let collapsed = tab.hasAttribute("group-collapsed");
24502450
item.setAttribute("label", collapsed ? item.getAttribute("label_expand") : item.getAttribute("label_collapse"));
24512451
item.setAttribute("accesskey", collapsed ? item.getAttribute("accesskey_expand") : item.getAttribute("accesskey_collapse"));
2452+
item.setAttribute("key", collapsed ? item.getAttribute("key_expand") : item.getAttribute("key_collapse"));
24522453
}
24532454

24542455
var item = $("context_readTab");

chrome/content/tabutils.xul

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
<key id="key_faviconizeTab" key="I" modifiers="accel,alt" oncommand="gBrowser.faviconizeTab(gBrowser.mCurrentTab);"/>
6060
<key id="key_pinTab" key="P" modifiers="accel,alt" oncommand="gBrowser.pinTab(gBrowser.mCurrentTab, !gBrowser.mCurrentTab.pinned);"/>
6161
<key id="key_unstackTab" key="U" modifiers="accel,alt" oncommand="gBrowser.unstackTabs([gBrowser.mCurrentTab]);"/>
62+
<key id="key_expandStack" key="+" modifiers="accel,alt" oncommand="gBrowser.collapseStack(gBrowser.isCollapsedStack(gBrowser.mCurrentTab) ? gBrowser.mCurrentTab : gBrowser.allTabs, false);"/>
63+
<key id="key_collapseStack" key="-" modifiers="accel,alt" oncommand="gBrowser.collapseStack(gBrowser.isExpandedStack(gBrowser.mCurrentTab) ? gBrowser.mCurrentTab : gBrowser.allTabs, true);"/>
6264
<key id="key_moveTabBackward" oncommand="gBrowser.moveTabBackward();" keycode="VK_PAGE_UP" modifiers="accel,shift"/>
6365
<key id="key_moveTabForward" oncommand="gBrowser.moveTabForward();" keycode="VK_PAGE_DOWN" modifiers="accel,shift"/>
6466
<key id="key_moveTabToStart" oncommand="gBrowser.moveTabToStart();" keycode="VK_HOME" modifiers="accel,shift"/>
@@ -279,6 +281,8 @@
279281
label_expand="&expandStack.label;"
280282
accesskey_collapse="&collapseStack.accesskey;"
281283
accesskey_expand="&expandStack.accesskey;"
284+
key_collapse="key_collapseStack"
285+
key_expand="key_expandStack"
282286
oncommand="gBrowser.collapseStack(gBrowser.mContextTab);"/>
283287
<menuitem id="context_colorStack"
284288
label="&colorStack.label;"

defaults/preferences/prefs.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ pref("extensions.tabutils.shortcut.key_freezeTab", true);
162162
pref("extensions.tabutils.shortcut.key_faviconizeTab", true);
163163
pref("extensions.tabutils.shortcut.key_pinTab", true);
164164
pref("extensions.tabutils.shortcut.key_unstackTab", true);
165+
pref("extensions.tabutils.shortcut.key_expandStack", true);
166+
pref("extensions.tabutils.shortcut.key_collapseStack", true);
165167
pref("extensions.tabutils.shortcut.key_moveTabBackward", true);
166168
pref("extensions.tabutils.shortcut.key_moveTabForward", true);
167169
pref("extensions.tabutils.shortcut.key_moveTabToStart", true);

0 commit comments

Comments
 (0)