OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2014 Eyeo GmbH |
| 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. |
| 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. |
| 13 * |
| 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ |
| 17 |
| 18 (function() |
| 19 { |
| 20 var {UI} = require("ui"); |
| 21 |
| 22 var iframe = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor
) |
| 23 .getInterface(Components.interfaces.nsIWebNavigation) |
| 24 .QueryInterface(Components.interfaces.nsIDocShell) |
| 25 .chromeEventHandler; |
| 26 var topWindow = iframe.ownerDocument.defaultView; |
| 27 var panel = iframe.parentNode; |
| 28 |
| 29 // Firefox doesn't adjust the size of the popup automatically to the size |
| 30 // of its content, like when the ad counter is expanded/collapsed. So we use |
| 31 // MutationObserver to do so. |
| 32 var resizingScheduled = false; |
| 33 |
| 34 function updateSize() |
| 35 { |
| 36 if (!resizingScheduled) |
| 37 { |
| 38 setTimeout(function() |
| 39 { |
| 40 resizingScheduled = false; |
| 41 |
| 42 // We need to calculate the height difference because the panel's size i
ncludes |
| 43 // the height of the arrow image and the border width of the panel conte
nt |
| 44 var heightDifference = panel.clientHeight - iframe.clientHeight; |
| 45 panel.sizeTo(document.body.scrollWidth, document.body.scrollHeight + hei
ghtDifference); |
| 46 }, 0); |
| 47 |
| 48 resizingScheduled = true; |
| 49 } |
| 50 } |
| 51 |
| 52 window.addEventListener("load", function() |
| 53 { |
| 54 updateSize(); |
| 55 new MutationObserver(updateSize).observe(document, { |
| 56 childList: true, attributes: true, |
| 57 characterData: true, subtree: true |
| 58 }); |
| 59 }); |
| 60 |
| 61 ext = { |
| 62 __proto__: ext, |
| 63 closePopup: function() |
| 64 { |
| 65 panel.hidePopup(); |
| 66 }, |
| 67 openBlockable: function() |
| 68 { |
| 69 UI.toggleBottombar(topWindow); |
| 70 ext.closePopup(); |
| 71 }, |
| 72 isBlockableOpen: function() |
| 73 { |
| 74 return UI.isBottombarOpen(topWindow); |
| 75 }, |
| 76 reportIssue: function() |
| 77 { |
| 78 UI.openReportDialog(topWindow); |
| 79 }, |
| 80 showReportIssue: function() |
| 81 { |
| 82 var location = UI.getCurrentLocation(topWindow); |
| 83 return location && Policy.isBlockableScheme(location) && location.scheme !
= "mailto"; |
| 84 } |
| 85 }; |
| 86 })(); |
OLD | NEW |