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

Unified Diff: popup.js

Issue 29333344: Issue 3472 - Made sure that "Block element" option is shown after page load (Closed)
Patch Set: Created Jan. 8, 2016, 5:50 p.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 | « no previous file | 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
@@ -26,7 +26,7 @@
var page = null;
-function init()
+function onLoad()
{
ext.pages.query({active: true, lastFocusedWindow: true}, function(pages)
{
@@ -57,6 +57,7 @@
});
// Attach event listeners
+ ext.onMessage.addListener(onMessage);
document.getElementById("enabled").addEventListener("click", toggleEnabled, false);
document.getElementById("clickhide").addEventListener("click", activateClickHide, false);
document.getElementById("clickhide-cancel").addEventListener("click", cancelClickHide, false);
@@ -75,7 +76,18 @@
document.getElementById(collapser.dataset.collapsable).classList.add("collapsed");
}
}
-window.addEventListener("DOMContentLoaded", init, false);
+
+function onUnload()
+{
+ ext.onMessage.removeListener(onMessage);
+}
+
+function onMessage(message, sender, callback)
+{
+ if (message.type == "report-html-page"
+ && backgroundPage.htmlPages.has(page))
Sebastian Noack 2016/01/09 00:01:50 This check is redundant. Or if you want to keep it
Thomas Greiner 2016/01/12 11:35:17 Unfortunately, it's not redundant. Any page could'
Sebastian Noack 2016/01/12 16:09:16 Acknowledged.
+ document.body.classList.remove("nohtml");
+}
function toggleEnabled()
{
@@ -132,3 +144,6 @@
Prefs[collapser.dataset.option] = !Prefs[collapser.dataset.option];
collapser.parentNode.classList.toggle("collapsed");
}
+
+document.addEventListener("DOMContentLoaded", onLoad, false);
+window.addEventListener("unload", onUnload, false);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld