| Index: chrome/content/ui/ext/popup.js |
| =================================================================== |
| new file mode 100644 |
| --- /dev/null |
| +++ b/chrome/content/ui/ext/popup.js |
| @@ -0,0 +1,84 @@ |
| +/* |
| + * 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; |
| + |
| + // 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() |
| + { |
| + // 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 = iframe.parentNode.clientHeight - iframe.clientHeight; |
| + iframe.parentNode.sizeTo(document.body.scrollWidth, document.body.scrollHeight + heightDifference); |
| + 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() |
| + { |
| + 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"; |
| + } |
| + }; |
| +})(); |