| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 "click", activateClickHide, false | 73 "click", activateClickHide, false |
| 74 ); | 74 ); |
| 75 document.getElementById("clickhide-cancel").addEventListener( | 75 document.getElementById("clickhide-cancel").addEventListener( |
| 76 "click", cancelClickHide, false | 76 "click", cancelClickHide, false |
| 77 ); | 77 ); |
| 78 document.getElementById("options").addEventListener("click", () => | 78 document.getElementById("options").addEventListener("click", () => |
| 79 { | 79 { |
| 80 ext.showOptions(); | 80 ext.showOptions(); |
| 81 }, false); | 81 }, false); |
| 82 | 82 |
| 83 // Set up collapsing of menu items | 83 Prefs.untilLoaded.then(() => |
|
Manish Jethani
2017/08/31 15:56:57
Wait for the prefs to load.
| |
| 84 for (let collapser of document.getElementsByClassName("collapse")) | |
| 85 { | 84 { |
| 86 collapser.addEventListener("click", toggleCollapse, false); | 85 // Set up collapsing of menu items |
| 87 if (!Prefs[collapser.dataset.option]) | 86 for (let collapser of document.getElementsByClassName("collapse")) |
| 88 { | 87 { |
| 89 document.getElementById( | 88 collapser.addEventListener("click", toggleCollapse, false); |
| 90 collapser.dataset.collapsable | 89 if (Prefs[collapser.dataset.option]) |
|
Manish Jethani
2017/08/31 15:56:57
Since it's now collapsed by default, uncollapse it
| |
| 91 ).classList.add("collapsed"); | 90 { |
| 91 document.getElementById( | |
| 92 collapser.dataset.collapsable | |
| 93 ).classList.remove("collapsed"); | |
| 94 } | |
|
Thomas Greiner
2017/08/31 16:39:08
FYI: IIRC we've avoided using `Element.classList.t
| |
| 92 } | 95 } |
| 93 } | 96 }); |
| 94 } | 97 } |
| 95 | 98 |
| 96 function toggleEnabled() | 99 function toggleEnabled() |
| 97 { | 100 { |
| 98 let disabled = document.body.classList.toggle("disabled"); | 101 let disabled = document.body.classList.toggle("disabled"); |
| 99 if (disabled) | 102 if (disabled) |
| 100 { | 103 { |
| 101 let host = getDecodedHostname(page.url).replace(/^www\./, ""); | 104 let host = getDecodedHostname(page.url).replace(/^www\./, ""); |
| 102 let filter = Filter.fromText("@@||" + host + "^$document"); | 105 let filter = Filter.fromText("@@||" + host + "^$document"); |
| 103 if (filter.subscriptions.length && filter.disabled) | 106 if (filter.subscriptions.length && filter.disabled) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 window.clearTimeout(activateClickHide.timeout); | 141 window.clearTimeout(activateClickHide.timeout); |
| 139 activateClickHide.timeout = null; | 142 activateClickHide.timeout = null; |
| 140 } | 143 } |
| 141 document.body.classList.remove("clickhide-active"); | 144 document.body.classList.remove("clickhide-active"); |
| 142 page.sendMessage({type: "composer.content.finished"}); | 145 page.sendMessage({type: "composer.content.finished"}); |
| 143 } | 146 } |
| 144 | 147 |
| 145 function toggleCollapse(event) | 148 function toggleCollapse(event) |
| 146 { | 149 { |
| 147 let collapser = event.currentTarget; | 150 let collapser = event.currentTarget; |
| 148 Prefs[collapser.dataset.option] = !Prefs[collapser.dataset.option]; | 151 let collapsable = document.getElementById(collapser.dataset.collapsable); |
|
Thomas Greiner
2017/08/31 16:39:08
Typo: Replace "collapsable" with "collapsible"
| |
| 149 collapser.parentNode.classList.toggle("collapsed"); | 152 Prefs[collapser.dataset.option] = !collapsable.classList.toggle("collapsed"); |
|
Manish Jethani
2017/08/31 15:56:57
The pref value should follow the UI so they never
Thomas Greiner
2017/08/31 16:39:08
Usually we do it the other way around to ensure th
| |
| 150 } | 153 } |
| 151 | 154 |
| 152 document.addEventListener("DOMContentLoaded", onLoad, false); | 155 document.addEventListener("DOMContentLoaded", onLoad, false); |
| OLD | NEW |