Index: popup.js |
=================================================================== |
--- a/popup.js |
+++ b/popup.js |
@@ -32,50 +32,50 @@ function init() |
ext.windows.getLastFocused(function(win) |
{ |
win.getActiveTab(function(tab) |
{ |
if (!/^https?:\/\//.exec(tab.url)) |
document.body.classList.add("local"); |
}); |
}); |
- |
+ |
// Attach event listeners |
document.getElementById("enabled").addEventListener("click", toggleEnabled, false); |
document.getElementById("clickhide").addEventListener("click", activateClickHide, false); |
document.getElementById("clickhide-cancel").addEventListener("click", cancelClickHide, false); |
document.getElementById("options").addEventListener("click", function() |
{ |
openOptions(); |
}, false); |
- |
+ |
// Set up collapsing of menu items |
var collapsers = document.getElementsByClassName("collapse"); |
for (var i = 0; i < collapsers.length; i++) |
{ |
var collapser = collapsers[i]; |
collapser.addEventListener("click", toggleCollapse, false); |
if (!Prefs[collapser.dataset.option]) |
document.getElementById(collapser.dataset.collapsable).classList.add("collapsed"); |
} |
- |
+ |
// Ask content script whether clickhide is active. If so, show cancel button. |
// If that isn't the case, ask background.html whether it has cached filters. If so, |
// ask the user whether she wants those filters. |
// Otherwise, we are in default state. |
ext.windows.getLastFocused(function(win) |
{ |
win.getActiveTab(function(t) |
{ |
tab = t; |
document.getElementById("enabled").classList.toggle("off", isWhitelisted(tab.url)); |
- |
+ |
tab.sendMessage({type: "get-clickhide-state"}, function(response) |
{ |
- document.body.classList.toggle("clickhide-active", response.active); |
+ document.body.classList.toggle("clickhide-active", response && response.active); |
}); |
}); |
}); |
} |
window.addEventListener("DOMContentLoaded", init, false); |
function toggleEnabled() |
{ |
@@ -100,25 +100,25 @@ function toggleEnabled() |
while (filter) |
{ |
FilterStorage.removeFilter(filter); |
if (filter.subscriptions.length) |
filter.disabled = true; |
filter = isWhitelisted(tab.url); |
} |
} |
- |
+ |
refreshIconAndContextMenu(tab); |
} |
function activateClickHide() |
{ |
document.body.classList.add("clickhide-active"); |
tab.sendMessage({type: "clickhide-activate"}); |
- |
+ |
// Close the popup after a few seconds, so user doesn't have to |
activateClickHide.timeout = window.setTimeout(window.close, 5000); |
} |
function cancelClickHide() |
{ |
if (activateClickHide.timeout) |
{ |