Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 shade = E("shade"); | 59 shade = E("shade"); |
60 shade.addEventListener("mouseover", scrollPage, false); | 60 shade.addEventListener("mouseover", scrollPage, false); |
61 shade.addEventListener("mouseout", stopScroll, false); | 61 shade.addEventListener("mouseout", stopScroll, false); |
62 | 62 |
63 // Set up typo feature | 63 // Set up typo feature |
64 if (require("typoBootstrap")) | 64 if (require("typoBootstrap")) |
65 { | 65 { |
66 var featureTypo = E("feature-typo"); | 66 var featureTypo = E("feature-typo"); |
67 featureTypo.removeAttribute("hidden"); | 67 featureTypo.removeAttribute("hidden"); |
68 | 68 |
69 var toggleTypo = E("toggle-typo"); | |
70 updateToggleButton("typo", Prefs.correctTypos); | 69 updateToggleButton("typo", Prefs.correctTypos); |
71 | 70 |
72 var listener = function(name) | 71 var listener = function(name) |
73 { | 72 { |
74 if (name == "correctTypos") | 73 if (name == "correctTypos") |
75 updateToggleButton("typo", Prefs.correctTypos); | 74 updateToggleButton("typo", Prefs.correctTypos); |
76 } | 75 } |
77 Prefs.addListener(listener); | 76 Prefs.addListener(listener); |
78 window.addEventListener("unload", function(event) | 77 window.addEventListener("unload", function(event) |
79 { | 78 { |
80 Prefs.removeListener(listener); | 79 Prefs.removeListener(listener); |
81 }, false); | 80 }, false); |
82 | 81 |
83 toggleTypo.addEventListener("click", function(event) | 82 E("toggle-typo").addEventListener("click", toggleTypoCorrectionEnabled, fa lse); |
84 { | |
85 toggleTypoCorrectionEnabled(); | |
86 }, false); | |
Wladimir Palant
2013/05/28 13:39:01
If you want a function then please don't wrap it i
| |
87 } | 83 } |
88 | 84 |
89 // Set up feature buttons linked to subscriptions | 85 // Set up feature buttons linked to subscriptions |
90 featureSubscriptions.forEach(setToggleSubscriptionButton); | 86 featureSubscriptions.forEach(setToggleSubscriptionButton); |
91 var filterListener = function(action) | 87 var filterListener = function(action) |
92 { | 88 { |
93 for (var i = 0; i < featureSubscriptions.length; i++) | 89 if (/^subscription\.(added|removed|disabled)$/.test(action)) |
94 { | 90 { |
95 if (/^(filter|subscription)\.(added|removed|disabled)$/.test(action)) | 91 for (var i = 0; i < featureSubscriptions.length; i++) |
Wladimir Palant
2013/05/28 13:39:01
This regexp should be: /^subscription\.(added|remo
| |
96 { | 92 { |
97 var featureSubscription = featureSubscriptions[i]; | 93 var featureSubscription = featureSubscriptions[i]; |
98 updateToggleButton(featureSubscription.feature, isSubscriptionEnabled( featureSubscription)); | 94 updateToggleButton(featureSubscription.feature, isSubscriptionEnabled( featureSubscription)); |
99 } | 95 } |
100 } | 96 } |
101 } | 97 } |
102 FilterNotifier.addListener(filterListener); | 98 FilterNotifier.addListener(filterListener); |
103 window.addEventListener("unload", function(event) | 99 window.addEventListener("unload", function(event) |
104 { | 100 { |
105 FilterNotifier.removeListener(filterListener); | 101 FilterNotifier.removeListener(filterListener); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
274 | 270 |
275 function updateToggleButton(feature, isEnabled) | 271 function updateToggleButton(feature, isEnabled) |
276 { | 272 { |
277 var button = E("toggle-" + feature); | 273 var button = E("toggle-" + feature); |
278 button.className = isEnabled ? "disable" : "enable"; | 274 button.className = isEnabled ? "disable" : "enable"; |
279 button.textContent = i18n.getMessage(isEnabled ? "firstRun_action_disable" : "firstRun_action_enable"); | 275 button.textContent = i18n.getMessage(isEnabled ? "firstRun_action_disable" : "firstRun_action_enable"); |
280 } | 276 } |
281 | 277 |
282 document.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 278 document.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
283 })(); | 279 })(); |
LEFT | RIGHT |