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

Side by Side Diff: popup.js

Issue 4840054052618240: Issue 1428 - Disable "Block Element" on non-HTML pages (Closed)
Patch Set: Created Sept. 25, 2014, 4:15 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
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
(...skipping 15 matching lines...) Expand all
26 var isWhitelisted = require("whitelisting").isWhitelisted; 26 var isWhitelisted = require("whitelisting").isWhitelisted;
27 27
28 var page = null; 28 var page = null;
29 29
30 function init() 30 function init()
31 { 31 {
32 ext.pages.query({active: true, lastFocusedWindow: true}, function(pages) 32 ext.pages.query({active: true, lastFocusedWindow: true}, function(pages)
33 { 33 {
34 page = pages[0]; 34 page = pages[0];
35 35
36 // Mark page as local to hide non-relevant elements 36 // Mark page as 'local' or 'nohtml' to hide non-relevant elements
37 if (!page || !/^https?:\/\//.test(page.url)) 37 if (!page || !/^https?:\/\//.test(page.url))
38 document.body.classList.add("local"); 38 document.body.classList.add("local");
39 else if (!backgroundPage.htmlPages.has(page))
40 document.body.classList.add("nohtml");
39 41
40 // Ask content script whether clickhide is active. If so, show cancel button . 42 // Ask content script whether clickhide is active. If so, show cancel button .
41 // If that isn't the case, ask background.html whether it has cached filters . If so, 43 // If that isn't the case, ask background.html whether it has cached filters . If so,
42 // ask the user whether she wants those filters. 44 // ask the user whether she wants those filters.
43 // Otherwise, we are in default state. 45 // Otherwise, we are in default state.
44 if (page) 46 if (page)
45 { 47 {
46 if (isWhitelisted(page.url)) 48 if (isWhitelisted(page.url))
47 document.getElementById("enabled").classList.add("off"); 49 document.getElementById("enabled").classList.add("off");
48 50
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 document.body.classList.remove("clickhide-active"); 126 document.body.classList.remove("clickhide-active");
125 page.sendMessage({type: "clickhide-deactivate"}); 127 page.sendMessage({type: "clickhide-deactivate"});
126 } 128 }
127 129
128 function toggleCollapse(event) 130 function toggleCollapse(event)
129 { 131 {
130 var collapser = event.currentTarget; 132 var collapser = event.currentTarget;
131 Prefs[collapser.dataset.option] = !Prefs[collapser.dataset.option]; 133 Prefs[collapser.dataset.option] = !Prefs[collapser.dataset.option];
132 collapser.parentNode.classList.toggle("collapsed"); 134 collapser.parentNode.classList.toggle("collapsed");
133 } 135 }
OLDNEW
« include.postload.js ('K') | « include.postload.js ('k') | skin/popup.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld