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

Side by Side Diff: popup.js

Issue 29338764: Issue 3842 - Split up the logic updating the icon and context menu (Closed)
Patch Set: Prevent visible delays Created March 21, 2016, 10:10 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/whitelisting.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 var require = backgroundPage.require; 19 var require = backgroundPage.require;
20 20
21 var Filter = require("filterClasses").Filter; 21 var Filter = require("filterClasses").Filter;
22 var FilterStorage = require("filterStorage").FilterStorage; 22 var FilterStorage = require("filterStorage").FilterStorage;
23 var Prefs = require("prefs").Prefs; 23 var Prefs = require("prefs").Prefs;
24 var checkWhitelisted = require("whitelisting").checkWhitelisted; 24 var checkWhitelisted = require("whitelisting").checkWhitelisted;
25 var getDecodedHostname = require("url").getDecodedHostname; 25 var getDecodedHostname = require("url").getDecodedHostname;
26 var isPageReady = require("filterComposer").isPageReady;
26 var port = require("messaging").port; 27 var port = require("messaging").port;
27 28
28 var page = null; 29 var page = null;
29 30
30 function onLoad() 31 function onLoad()
31 { 32 {
32 ext.pages.query({active: true, lastFocusedWindow: true}, function(pages) 33 ext.pages.query({active: true, lastFocusedWindow: true}, function(pages)
33 { 34 {
34 page = pages[0]; 35 page = pages[0];
35 36
36 // Mark page as 'local' or 'nohtml' to hide non-relevant elements 37 // Mark page as 'local' or 'nohtml' to hide non-relevant elements
37 if (!page || (page.url.protocol != "http:" && 38 if (!page || (page.url.protocol != "http:" &&
38 page.url.protocol != "https:")) 39 page.url.protocol != "https:"))
39 document.body.classList.add("local"); 40 document.body.classList.add("local");
40 else if (!backgroundPage.htmlPages.has(page)) 41 else if (!isPageReady(page))
41 document.body.classList.add("nohtml"); 42 document.body.classList.add("nohtml");
42 43
43 // Ask content script whether clickhide is active. If so, show cancel button . 44 // Ask content script whether clickhide is active. If so, show cancel button .
44 // If that isn't the case, ask background.html whether it has cached filters . If so, 45 // If that isn't the case, ask background.html whether it has cached filters . If so,
45 // ask the user whether she wants those filters. 46 // ask the user whether she wants those filters.
46 // Otherwise, we are in default state. 47 // Otherwise, we are in default state.
47 if (page) 48 if (page)
48 { 49 {
49 if (checkWhitelisted(page)) 50 if (checkWhitelisted(page))
50 document.body.classList.add("disabled"); 51 document.body.classList.add("disabled");
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 141
141 function toggleCollapse(event) 142 function toggleCollapse(event)
142 { 143 {
143 var collapser = event.currentTarget; 144 var collapser = event.currentTarget;
144 Prefs[collapser.dataset.option] = !Prefs[collapser.dataset.option]; 145 Prefs[collapser.dataset.option] = !Prefs[collapser.dataset.option];
145 collapser.parentNode.classList.toggle("collapsed"); 146 collapser.parentNode.classList.toggle("collapsed");
146 } 147 }
147 148
148 document.addEventListener("DOMContentLoaded", onLoad, false); 149 document.addEventListener("DOMContentLoaded", onLoad, false);
149 window.addEventListener("unload", onUnload, false); 150 window.addEventListener("unload", onUnload, false);
OLDNEW
« no previous file with comments | « lib/whitelisting.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld