diff options
author | portix <portix@gmx.net> | 2014-03-17 00:21:20 +0100 |
---|---|---|
committer | portix <portix@gmx.net> | 2014-03-17 00:21:20 +0100 |
commit | e4499f75e168279e8a98d8f471d226470e7e36b3 (patch) | |
tree | 0994a8cb80290febcd624633fa325cad1b038309 | |
parent | 98c55b0f4c55ad1f33cab203d08b8327eb1b8ce9 (diff) | |
download | dwb-e4499f75e168279e8a98d8f471d226470e7e36b3.zip |
unique_tabs: fix navigation callback
-rw-r--r-- | extensions/unique_tabs | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/extensions/unique_tabs b/extensions/unique_tabs index 71f5f8b1..75ea6637 100644 --- a/extensions/unique_tabs +++ b/extensions/unique_tabs @@ -44,9 +44,7 @@ commandToggleAutoFocus : "ut_toggle_autofocus", //>DEFAULT_CONFIG }; -var signal; - -var removeDuplicates = function() +function removeDuplicates() { var uris = []; tabs.forEach(function(tab) { @@ -57,10 +55,9 @@ var removeDuplicates = function() execute((i+1) + "close_tab"); }); }; -var onNavigation = function(wv, frame, request) -{ +function onNavigation(wv, frame, request) { var uri = request.uri; - tabs.forEach(function(tab, i) { + return tabs.some(function(tab, i) { if (tab.uri == uri && i != wv.number) { /* defer execute, otherwise some other navigation callbacks will * fail */ @@ -72,11 +69,10 @@ var onNavigation = function(wv, frame, request) }); return true; } + return false; }); - return false; }; -var toggleAutoFocus = function() -{ +function toggleAutoFocus() { if (signal.toggle()) io.notify("unique_tabs: autofocus enabled"); else @@ -88,22 +84,21 @@ var uniqueTabs = { init : function(c) { if (c.shortcutRemoveDuplicates || c.commandRemoveDuplicates) { - bind(c.shortcutRemoveDuplicates, removeDuplicates, c.commandRemoveDuplicates); + script.own(bind(c.shortcutRemoveDuplicates, removeDuplicates, c.commandRemoveDuplicates)); } if (c.shortcutToggleAutoFocus || c.commandToggleAutoFocus) { - bind(c.shortcutToggleAutoFocus, toggleAutoFocus, c.commandToggleAutoFocus); + script.own(bind(c.shortcutToggleAutoFocus, toggleAutoFocus, c.commandToggleAutoFocus)); } - signal = new Signal("navigation", onNavigation); + var signal = new Signal("navigation", onNavigation); if (c.autoFocus) signal.connect(); + script.own(signal); return true; }, end : function() { - unbind(removeDuplicates); - unbind(toggleAutoFocus); - signal.disconnect(); + script.removeHandles(); return true; } }; |