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

Delta Between Two Patch Sets: chrome/content/ui/popup.js

Issue 5294633391226880: issue 1435 - Port popup.html from Chrome/Safari/Opera to Firefox (Closed)
Left Patch Set: Created Oct. 10, 2014, 11:36 a.m.
Right Patch Set: Created Oct. 27, 2014, 9:40 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 /* 1 /*
Thomas Greiner 2014/10/13 13:18:24 Keep in mind that at some point we need to merge t
saroyanm 2014/10/16 11:26:15 I guess would be nice to do it during backport, or
Thomas Greiner 2014/10/16 13:39:44 That's fine with me.
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 var backgroundPage = ext.backgroundPage.getWindow(); 18 var backgroundPage = ext.backgroundPage.getWindow();
19 window["openOptions"] = backgroundPage["openOptions"]; 19 var openOptions = backgroundPage.openOptions;
20 var page = null; 20 var page = null;
Thomas Greiner 2014/10/13 13:18:24 I assume that in one of the later reviews this var
saroyanm 2014/10/16 11:26:15 I tried to keep it like in Chrome/safari/opera ver
Thomas Greiner 2014/10/16 13:39:44 No, that's not necessary then.
21 21
22 function init() 22 function init()
23 { 23 {
24 ext.pages.query({active: true, lastFocusedWindow: true}, function(pages) 24 ext.pages.query({active: true, lastFocusedWindow: true}, function(pages)
25 { 25 {
26 page = pages[0]; 26 page = pages[0];
27
28 document.body.classList.toggle("local", !/^https?:\/\//.test(page.url));
Thomas Greiner 2014/10/13 13:18:24 This will throw an error if the pages array is emp
saroyanm 2014/10/16 11:26:15 Done.
29
30 if (page) 27 if (page)
31 { 28 {
29 document.body.classList.toggle("local", !/^https?:\/\//.test(page.url));
30
32 // Ask content script whether clickhide is active. If so, show cancel butt on. 31 // Ask content script whether clickhide is active. If so, show cancel butt on.
33 page.sendMessage({type: "get-clickhide-state"}, function(response) 32 page.sendMessage({type: "get-clickhide-state"}, function(response)
34 { 33 {
35 if (response && response.active) 34 if (response && response.active)
36 document.body.classList.add("clickhide-active"); 35 document.body.classList.add("clickhide-active");
37 }); 36 });
38 } 37 }
39 }); 38 });
40 39
41 // Initialize features 40 // Initialize features
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 }, false); 74 }, false);
76 menuItem.removeAttribute("hidden"); 75 menuItem.removeAttribute("hidden");
77 } 76 }
78 77
79 function initBlockable() 78 function initBlockable()
80 { 79 {
81 if (!("openBlockable" in ext)) 80 if (!("openBlockable" in ext))
82 return; 81 return;
83 82
84 var menuItem = document.getElementById("blockable"); 83 var menuItem = document.getElementById("blockable");
85 if (ext.isBlockableOpen()) 84 menuItem.classList.toggle("open", ext.isBlockableOpen());
86 menuItem = document.getElementById("blockable-close");
87
88 menuItem.addEventListener("click", function() 85 menuItem.addEventListener("click", function()
89 { 86 {
90 ext.openBlockable(); 87 ext.openBlockable();
91 }, false); 88 }, false);
92 menuItem.removeAttribute("hidden"); 89 menuItem.removeAttribute("hidden");
93 } 90 }
94 91
95 function activateClickHide() 92 function activateClickHide()
96 { 93 {
97 document.body.classList.add("clickhide-active"); 94 document.body.classList.add("clickhide-active");
98 ext.activateClickHide(true); 95 ext.activateClickHide(true);
99 96
100 // Close the popup after a few seconds, so user doesn't have to 97 // Close the popup after a few seconds, so user doesn't have to
101 activateClickHide.timeout = window.setTimeout(ext.closePopup, 5000); 98 activateClickHide.timeout = window.setTimeout(ext.closePopup, 5000);
102 } 99 }
103 100
104 function cancelClickHide() 101 function cancelClickHide()
105 { 102 {
106 if (activateClickHide.timeout) 103 if (activateClickHide.timeout)
107 { 104 {
108 window.clearTimeout(activateClickHide.timeout); 105 window.clearTimeout(activateClickHide.timeout);
109 activateClickHide.timeout = null; 106 activateClickHide.timeout = null;
110 } 107 }
111 document.body.classList.remove("clickhide-active"); 108 document.body.classList.remove("clickhide-active");
112 ext.activateClickHide(false); 109 ext.activateClickHide(false);
113 } 110 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld