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. 27, 2014, 9:40 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
Index: chrome/content/ui/ext/popup.js
===================================================================
new file mode 100644
--- /dev/null
+++ b/chrome/content/ui/ext/popup.js
@@ -0,0 +1,86 @@
+/*
+ * 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()
+{
+ var {UI} = require("ui");
+
+ var iframe = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
+ .getInterface(Components.interfaces.nsIWebNavigation)
+ .QueryInterface(Components.interfaces.nsIDocShell)
+ .chromeEventHandler;
+ var topWindow = iframe.ownerDocument.defaultView;
+ var panel = iframe.parentNode;
+
+ // Firefox doesn't adjust the size of the popup automatically to the size
+ // of its content, like when the ad counter is expanded/collapsed. So we use
+ // MutationObserver to do so.
+ var resizingScheduled = false;
+
+ function updateSize()
+ {
+ if (!resizingScheduled)
+ {
+ setTimeout(function()
+ {
+ resizingScheduled = false;
+
+ // We need to calculate the height difference because the panel's size includes
+ // the height of the arrow image and the border width of the panel content
+ var heightDifference = panel.clientHeight - iframe.clientHeight;
+ panel.sizeTo(document.body.scrollWidth, document.body.scrollHeight + heightDifference);
+ }, 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()
+ {
+ panel.hidePopup();
+ },
+ openBlockable: function()
+ {
+ UI.toggleBottombar(topWindow);
+ ext.closePopup();
+ },
+ isBlockableOpen: function()
+ {
+ return UI.isBottombarOpen(topWindow);
+ },
+ reportIssue: function()
+ {
+ UI.openReportDialog(topWindow);
+ },
+ showReportIssue: function()
+ {
+ var location = UI.getCurrentLocation(topWindow);
+ return location && Policy.isBlockableScheme(location) && location.scheme != "mailto";
+ }
+ };
+})();

Powered by Google App Engine
This is Rietveld