Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: popup.js

Issue 5867629902299136: Fixed various issues in older Chrome versions (Closed)
Patch Set: Created Dec. 19, 2013, 10:46 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « popup.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
{
« no previous file with comments | « popup.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld