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

Unified Diff: chrome/content/ui/ext/popup.js

Issue 5294633391226880: issue 1435 - Port popup.html from Chrome/Safari/Opera to Firefox (Closed)
Patch Set: Created Oct. 2, 2014, 7:48 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
Index: chrome/content/ui/ext/popup.js
===================================================================
new file mode 100644
--- /dev/null
+++ b/chrome/content/ui/ext/popup.js
@@ -0,0 +1,83 @@
+/*
+ * This file is part of Adblock Plus <http://adblockplus.org/>,
+ * Copyright (C) 2006-2014 Eyeo GmbH
+ *
+ * Adblock Plus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * Adblock Plus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+(function()
+{
+ let {UI} = require("ui");
+
+ let iframe = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
+ .getInterface(Components.interfaces.nsIWebNavigation)
+ .QueryInterface(Components.interfaces.nsIDocShell)
+ .chromeEventHandler;
+ let topWindow = iframe.ownerDocument.defaultView;
+
+ // Firefox doesn't adjust the size of the popup automatically to the size
+ // of its content, like when the ad counter is expanded/collapsed.
+ let resizingScheduled = false;
+
+ function updateSize()
+ {
+ if (!resizingScheduled)
+ {
+ setTimeout(function()
+ {
+ iframe.parentNode.sizeTo(document.body.scrollWidth, document.body.scrollHeight +11);
+ resizingScheduled = false;
+ }, 0);
+
+ resizingScheduled = true;
+ }
+ }
+
+ window.addEventListener("load", function()
+ {
+ updateSize();
+ new MutationObserver(updateSize).observe(document, {
+ childList: true, attributes: true,
+ characterData: true, subtree: true
+ });
+ });
+
+ ext = {
+ __proto__: ext,
+ closePopup: function()
+ {
+ iframe.parentNode.hidePopup();
+ },
+ openBlockable: function()
Thomas Greiner 2014/10/13 13:18:23 This function is no longer used to only open the d
+ {
+ if (!UI.isBottombarOpen(topWindow))
+ {
+ UI.toggleBottombar(topWindow);
+ ext.closePopup();
+ }
+ },
+ showBlockable: function()
+ {
+ return !UI.isBottombarOpen(topWindow);
+ },
+ reportIssue: function()
+ {
+ UI.openReportDialog(topWindow);
+ },
+ showReportIssue: function()
+ {
+ let location = UI.getCurrentLocation(topWindow);
+ return location && Policy.isBlockableScheme(location) && location.scheme != "mailto";
+ }
+ };
+})();

Powered by Google App Engine
This is Rietveld