Skip to content

Instantly share code, notes, and snippets.

@Infocatcher
Created August 31, 2012 09:31
Show Gist options
  • Save Infocatcher/3550790 to your computer and use it in GitHub Desktop.
Save Infocatcher/3550790 to your computer and use it in GitHub Desktop.
Advance select tab for Tree Style Tab and mouse gestures
gBrowser.tabContainer.advanceSelectedTab(1 /* 1 or -1 */, true);
if("TreeStyleTabService" in window) {
const ns = "__mouseGesturesTabsSwitcher__";
var autoExpandDelay = (
"TreeStyleTabUtils" in window
? TreeStyleTabUtils
: TreeStyleTabService
).getTreePref("autoExpandSubtreeOnSelect.whileFocusMovingByShortcut.delay") || 800;
var ts = ns in window && window[ns];
if(!ts) {
ts = window[ns] = {
timer: 0,
handleEvent: function(e) {
window.removeEventListener("mouseup", this, true);
this.clearDelayed();
delete window[ns];
},
clear: function() {
clearTimeout(this.timer);
if("treeStyleTab" in gBrowser && "cancelDelayedExpandOnTabSelect" in gBrowser.treeStyleTab)
gBrowser.treeStyleTab.cancelDelayedExpandOnTabSelect();
},
clearDelayed: function() {
setTimeout(function(_this) {
_this.clear();
}, 10, this);
}
};
window.addEventListener("mouseup", ts, true);
}
ts.clear();
ts.tab = gBrowser.selectedTab;
ts.timer = setTimeout(function() {
var tab = gBrowser.selectedTab;
if(tab == ts.tab)
gBrowser.treeStyleTab.collapseExpandSubtree(tab, false);
}, autoExpandDelay);
}
@Infocatcher
Copy link
Author

History of this script: piroor/treestyletab#232

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment