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

Side by Side 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. 21, 2014, 1:31 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
(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;
Wladimir Palant 2014/10/23 21:57:40 Nice trick, wasn't aware of that.
26 var topWindow = iframe.ownerDocument.defaultView;
Wladimir Palant 2014/10/23 21:57:40 Please add a variable |panel = iframe.parentNode|
saroyanm 2014/10/27 21:49:20 Done.
27
28 // 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. So we use
30 // MutationObserver to do so.
31 var resizingScheduled = false;
32
33 function updateSize()
34 {
35 if (!resizingScheduled)
36 {
37 setTimeout(function()
38 {
39 // We need to calculate the height difference because the panel's size i ncludes
40 // the height of the arrow image and the border width of the panel conte nt
41 var heightDifference = iframe.parentNode.clientHeight - iframe.clientHei ght;
42 iframe.parentNode.sizeTo(document.body.scrollWidth, document.body.scroll Height + heightDifference);
43 resizingScheduled = false;
Wladimir Palant 2014/10/23 21:57:40 Please move that line to the top of the function -
saroyanm 2014/10/27 21:49:20 Done.
44 }, 0);
45
46 resizingScheduled = true;
47 }
48 }
49
50 window.addEventListener("load", function()
51 {
52 updateSize();
53 new MutationObserver(updateSize).observe(document, {
54 childList: true, attributes: true,
55 characterData: true, subtree: true
56 });
57 });
58
59 ext = {
Wladimir Palant 2014/10/23 21:57:40 Again, please don't assign to undeclared variables
saroyanm 2014/10/27 21:49:20 the ext from common.js should be accessible here I
60 __proto__: ext,
61 closePopup: function()
62 {
63 iframe.parentNode.hidePopup();
64 },
65 openBlockable: function()
66 {
67 UI.toggleBottombar(topWindow);
68 ext.closePopup();
69 },
70 isBlockableOpen: function()
71 {
72 return UI.isBottombarOpen(topWindow);
73 },
74 reportIssue: function()
75 {
76 UI.openReportDialog(topWindow);
77 },
78 showReportIssue: function()
79 {
80 var location = UI.getCurrentLocation(topWindow);
81 return location && Policy.isBlockableScheme(location) && location.scheme ! = "mailto";
82 }
83 };
84 })();
OLDNEW

Powered by Google App Engine
This is Rietveld