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