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

Unified Diff: popup.js

Issue 29338491: Issue 3823 - Split up message responder code (Closed)
Patch Set: Use require() inline Created March 21, 2016, 7:53 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 | « metadata.common ('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
@@ -37,7 +37,16 @@
page.url.protocol != "https:"))
document.body.classList.add("local");
else if (!backgroundPage.htmlPages.has(page))
+ {
document.body.classList.add("nohtml");
+ require("messaging").getPort(window).on(
+ "composer.ready", function(message, sender)
+ {
+ if (sender.page.id == page.id)
+ document.body.classList.remove("nohtml");
+ }
+ );
+ }
// 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,
@@ -56,8 +65,6 @@
}
});
- // 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);
@@ -77,17 +84,6 @@
}
}
-function onUnload()
-{
- ext.onMessage.removeListener(onMessage);
-}
-
-function onMessage(message, sender, callback)
-{
- if (message.type == "composer.ready" && sender.page.id == page.id)
- document.body.classList.remove("nohtml");
-}
-
function toggleEnabled()
{
var disabled = document.body.classList.toggle("disabled");
@@ -145,4 +141,3 @@
}
document.addEventListener("DOMContentLoaded", onLoad, false);
-window.addEventListener("unload", onUnload, false);
« no previous file with comments | « metadata.common ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld