diff options
author | monkey413 | 2013-07-12 01:26:25 +0800 |
---|---|---|
committer | monkey413 | 2013-07-12 01:26:25 +0800 |
commit | 6deea7b8b8c19133a990dae6094e41fe4f26b534 (patch) | |
tree | fb2b99192e8e5f302dbe4ebce7f6769a14ac7098 /unload-tab.js | |
parent | b9447991aa530a1ef07091d3ad4a23cf48891438 (diff) | |
download | vimperator-plugins-6deea7b8b8c19133a990dae6094e41fe4f26b534.tar.bz2 |
Thu, 11 Jul 2013 01:55:46 +0800
unload[tab] negative_number
for unload all tab without seleted tab
set tab title opacity when unload or restore
Diffstat (limited to 'unload-tab.js')
-rw-r--r-- | unload-tab.js | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/unload-tab.js b/unload-tab.js index 1bee8f4..cba9610 100644 --- a/unload-tab.js +++ b/unload-tab.js @@ -3,6 +3,13 @@ * unload[tab] num */ +/* + Thu, 11 Jul 2013 01:55:46 +0800 + unload[tab] negative_number + for unload all tab without seleted tab + set tab title opacity when unload or restore +*/ + var INFO = xml` <plugin name="unloadTab" version="0.3" @@ -45,14 +52,23 @@ function unloadTab (aTab) { commands.addUserCommand(["unload[tab]"], "Unload Tabs", function action (args) { - var str = args[0]; - var m = str.match(/^(\d+):?/); + var str = args[0]; + var m = str.match(/^(-?\d+):?/); + if (!m) return; - var tab = gBrowser.tabs[m[1]]; - if (tab && !tab.selected && !tab.linkedBrowser.__SS_restoreState) - unloadTab(tab); + if (tab && !tab.selected && !tab.linkedBrowser.__SS_restoreState) + unloadTab(tab), tab.style.opacity = 0.5 ; + + // unload other tabs + if (m[1] < 0) + for each(tab in Array.slice(gBrowser.tabs)) + if(tab && !tab.selected){ + if(!tab.linkedBrowser.__SS_restoreState) unloadTab(tab); + tab.style.opacity = 0.5 ; + } + }, { literal: 0, completer: function (context, args) { @@ -64,5 +80,10 @@ commands.addUserCommand(["unload[tab]"], "Unload Tabs", ]; } }, true); - - +// the listener for recovering opacity +gBrowser.tabContainer.addEventListener('SSTabRestored', + function tabRestored(event){ + var tab = event.originalTarget ; + tab.style.opacity = 1 ; + } +, true); |