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

Side by Side Diff: popup.js

Issue 6257417939582976: Issue 2081 - Hide "Block element" option in the popup if the page is whitelisted (Closed)
Patch Set: Created March 3, 2015, 4:37 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
« no previous file with comments | « no previous file | skin/popup.css » ('j') | skin/popup.css » ('J')
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-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 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 28 matching lines...) Expand all
39 else if (!backgroundPage.htmlPages.has(page)) 39 else if (!backgroundPage.htmlPages.has(page))
40 document.body.classList.add("nohtml"); 40 document.body.classList.add("nohtml");
41 41
42 // 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 .
43 // 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,
44 // ask the user whether she wants those filters. 44 // ask the user whether she wants those filters.
45 // Otherwise, we are in default state. 45 // Otherwise, we are in default state.
46 if (page) 46 if (page)
47 { 47 {
48 if (isPageWhitelisted(page)) 48 if (isPageWhitelisted(page))
49 document.getElementById("enabled").classList.add("off"); 49 document.body.classList.add("disabled");
50 50
51 page.sendMessage({type: "get-clickhide-state"}, function(response) 51 page.sendMessage({type: "get-clickhide-state"}, function(response)
52 { 52 {
53 if (response && response.active) 53 if (response && response.active)
54 document.body.classList.add("clickhide-active"); 54 document.body.classList.add("clickhide-active");
55 }); 55 });
56 } 56 }
57 }); 57 });
58 58
59 // Attach event listeners 59 // Attach event listeners
(...skipping 12 matching lines...) Expand all
72 var collapser = collapsers[i]; 72 var collapser = collapsers[i];
73 collapser.addEventListener("click", toggleCollapse, false); 73 collapser.addEventListener("click", toggleCollapse, false);
74 if (!Prefs[collapser.dataset.option]) 74 if (!Prefs[collapser.dataset.option])
75 document.getElementById(collapser.dataset.collapsable).classList.add("coll apsed"); 75 document.getElementById(collapser.dataset.collapsable).classList.add("coll apsed");
76 } 76 }
77 } 77 }
78 window.addEventListener("DOMContentLoaded", init, false); 78 window.addEventListener("DOMContentLoaded", init, false);
79 79
80 function toggleEnabled() 80 function toggleEnabled()
81 { 81 {
82 var enabledButton = document.getElementById("enabled") 82 var disabled = document.body.classList.toggle("disabled");
83 var disabled = enabledButton.classList.toggle("off");
84 if (disabled) 83 if (disabled)
85 { 84 {
86 var host = getDecodedHostname(page.url).replace(/^www\./, ""); 85 var host = getDecodedHostname(page.url).replace(/^www\./, "");
87 var filter = Filter.fromText("@@||" + host + "^$document"); 86 var filter = Filter.fromText("@@||" + host + "^$document");
88 if (filter.subscriptions.length && filter.disabled) 87 if (filter.subscriptions.length && filter.disabled)
89 filter.disabled = false; 88 filter.disabled = false;
90 else 89 else
91 { 90 {
92 filter.disabled = false; 91 filter.disabled = false;
93 FilterStorage.addFilter(filter); 92 FilterStorage.addFilter(filter);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 document.body.classList.remove("clickhide-active"); 125 document.body.classList.remove("clickhide-active");
127 page.sendMessage({type: "clickhide-deactivate"}); 126 page.sendMessage({type: "clickhide-deactivate"});
128 } 127 }
129 128
130 function toggleCollapse(event) 129 function toggleCollapse(event)
131 { 130 {
132 var collapser = event.currentTarget; 131 var collapser = event.currentTarget;
133 Prefs[collapser.dataset.option] = !Prefs[collapser.dataset.option]; 132 Prefs[collapser.dataset.option] = !Prefs[collapser.dataset.option];
134 collapser.parentNode.classList.toggle("collapsed"); 133 collapser.parentNode.classList.toggle("collapsed");
135 } 134 }
OLDNEW
« no previous file with comments | « no previous file | skin/popup.css » ('j') | skin/popup.css » ('J')

Powered by Google App Engine
This is Rietveld