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 25 matching lines...) Expand all Loading... | |
36 { | 36 { |
37 feature: "tracking", | 37 feature: "tracking", |
38 homepage: "https://easylist.adblockplus.org/", | 38 homepage: "https://easylist.adblockplus.org/", |
39 title: "EasyPrivacy", | 39 title: "EasyPrivacy", |
40 url: "https://easylist-downloads.adblockplus.org/easyprivacy.txt" | 40 url: "https://easylist-downloads.adblockplus.org/easyprivacy.txt" |
41 } | 41 } |
42 ]; | 42 ]; |
43 | 43 |
44 function onDOMLoaded() | 44 function onDOMLoaded() |
45 { | 45 { |
46 var locale = require("utils").Utils.appLocale; | |
47 document.documentElement.setAttribute("lang", locale); | |
48 | |
49 // Set up URLs | |
46 var donateLink = E("donate"); | 50 var donateLink = E("donate"); |
47 donateLink.href = Utils.getDocLink("donate"); | 51 donateLink.href = Utils.getDocLink("donate"); |
48 | 52 |
49 // Set up URL | 53 var contributors = E("contributors"); |
54 contributors.href = Utils.getDocLink("contributors"); | |
55 | |
50 setLinks("acceptableAdsExplanation", Utils.getDocLink("acceptable_ads_criter ia"), openFilters); | 56 setLinks("acceptableAdsExplanation", Utils.getDocLink("acceptable_ads_criter ia"), openFilters); |
51 setLinks("share-headline", Utils.getDocLink("contribute")); | 57 setLinks("share-headline", Utils.getDocLink("contribute")); |
52 | 58 |
53 // Show warning if data corruption was detected | 59 // Show warning if data corruption was detected |
54 if (typeof backgroundPage != "undefined" && backgroundPage.seenDataCorruptio n) | 60 if (typeof backgroundPage != "undefined" && backgroundPage.seenDataCorruptio n) |
55 { | 61 { |
56 E("dataCorruptionWarning").removeAttribute("hidden"); | 62 E("dataCorruptionWarning").removeAttribute("hidden"); |
57 setLinks("dataCorruptionWarning", Utils.getDocLink("knownIssuesChrome_filt erstorage")); | 63 setLinks("dataCorruptionWarning", Utils.getDocLink("knownIssuesChrome_filt erstorage")); |
58 } | 64 } |
59 | 65 |
(...skipping 10 matching lines...) Expand all Loading... | |
70 } | 76 } |
71 } | 77 } |
72 } | 78 } |
73 FilterNotifier.addListener(filterListener); | 79 FilterNotifier.addListener(filterListener); |
74 window.addEventListener("unload", function(event) | 80 window.addEventListener("unload", function(event) |
75 { | 81 { |
76 FilterNotifier.removeListener(filterListener); | 82 FilterNotifier.removeListener(filterListener); |
77 }, false); | 83 }, false); |
78 | 84 |
79 // You can click activate-feature or one of the icons to toggle the features area | 85 // You can click activate-feature or one of the icons to toggle the features area |
80 E("activate-features").addEventListener("click", showFeature, false); | 86 E("activate-features").addEventListener("click", toggleFeature, false); |
81 E("can-do-more-overview").addEventListener("click", showFeature, false); | 87 E("can-do-more-overview").addEventListener("click", toggleFeature, false); |
82 | 88 |
83 initSocialLinks(); | 89 initSocialLinks(); |
84 } | 90 } |
85 | 91 |
86 function showFeature() | 92 function toggleFeature() |
87 { | 93 { |
88 var activateFeatures = E("activate-features"); | 94 var canDoMore = E("can-do-more"); |
89 var canDoMoreOverview = E("can-do-more-overview"); | 95 if (!canDoMore.classList.contains("expanded")) |
90 var canDoMoreExpanded = E("can-do-more-expanded"); | 96 { |
91 var activateFeaturesLabel = E("activate-features-label"); | 97 canDoMore.classList.add("expanded"); |
92 | 98 } |
93 if (activateFeatures.getAttribute("class") == "overview") | 99 else if (canDoMore.classList.contains("expanded")) |
Thomas Greiner
2013/08/22 10:42:12
You can use classList.contains instead.
| |
94 { | 100 { |
95 canDoMoreOverview.classList.remove("fade-in"); | 101 canDoMore.classList.remove("expanded"); |
96 canDoMoreOverview.classList.add("fade-out"); | |
97 activateFeatures.classList.remove("overview"); | |
98 activateFeatures.classList.add("expanded"); | |
Thomas Greiner
2013/08/22 10:42:12
Why don't you simply add the class "expanded" to #
| |
99 | |
100 | |
101 /* Cross Browser Text change */ | |
102 if ((activateFeaturesLabel.textContent) && (typeof (activateFeaturesLabel. textContent) != "undefined")) | |
Thomas Greiner
2013/08/22 10:42:12
No need for checking it twice. Checking
if ("textC
| |
103 { | |
104 activateFeaturesLabel.textContent = "show overview again"; | |
Thomas Greiner
2013/08/22 10:42:12
Should be translatable.
| |
105 } else | |
106 { | |
107 activateFeaturesLabel.innerText = "show overview again"; | |
Thomas Greiner
2013/08/22 10:42:12
Should be translatable.
| |
108 } | |
109 activateFeatures.setAttribute("data-status","expanded"); | |
110 | |
111 setTimeout(function() | |
112 { | |
113 canDoMoreOverview.classList.add("hide"); | |
114 canDoMoreExpanded.classList.add("show"); | |
115 canDoMoreExpanded.classList.add("can-do-more-expanded-higher"); | |
116 },500); | |
117 | |
118 /* Next timeout has to be done because of an js bug. | |
119 * If you set "display: block" and "opacity: 1" | |
120 * at the same time the content would be shown | |
121 * directly without any transition. | |
122 * With the following timeout the opacity | |
123 * transition works correctly | |
124 */ | |
125 setTimeout(function() | |
126 { | |
127 canDoMoreExpanded.classList.add("fade-in"); | |
128 },520); | |
129 } | |
130 else if (activateFeatures.getAttribute("class") == "expanded") | |
131 { | |
132 canDoMoreExpanded.classList.remove("fade-in"); | |
133 activateFeatures.classList.remove("expanded"); | |
134 activateFeatures.classList.add("overview"); | |
135 | |
136 /* Cross Browser Text change */ | |
137 if ((activateFeaturesLabel.textContent) && (typeof (activateFeaturesLabel. textContent) != "undefined")) | |
Thomas Greiner
2013/08/22 10:42:12
No need for checking it twice. Checking
if ("textC
| |
138 { | |
139 activateFeaturesLabel.textContent = "activate features"; | |
Thomas Greiner
2013/08/22 10:42:12
Should be translatable.
| |
140 } else | |
141 { | |
142 activateFeaturesLabel.innerText = "activate features"; | |
Thomas Greiner
2013/08/22 10:42:12
Should be translatable.
| |
143 } | |
144 activateFeatures.setAttribute("data-status","overview"); | |
145 | |
146 setTimeout(function() | |
147 { | |
148 canDoMoreExpanded.classList.remove("show"); | |
149 canDoMoreOverview.classList.remove("hide"); | |
150 },500); | |
151 | |
152 setTimeout(function() | |
153 { | |
154 canDoMoreOverview.classList.add("fade-in"); | |
155 canDoMoreOverview.classList.remove("fade-out"); | |
156 },520); | |
157 } | 102 } |
Wladimir Palant
2013/10/05 09:15:59
Nit: One line of code is enough for the entire fun
| |
158 } | 103 } |
159 | 104 |
160 function isSubscriptionEnabled(featureSubscription) | 105 function isSubscriptionEnabled(featureSubscription) |
161 { | 106 { |
162 return featureSubscription.url in FilterStorage.knownSubscriptions | 107 return featureSubscription.url in FilterStorage.knownSubscriptions |
163 && !Subscription.fromURL(featureSubscription.url).disabled; | 108 && !Subscription.fromURL(featureSubscription.url).disabled; |
164 } | 109 } |
165 | 110 |
166 function setToggleSubscriptionButton(featureSubscription) | 111 function setToggleSubscriptionButton(featureSubscription) |
167 { | 112 { |
168 var feature = featureSubscription.feature; | 113 var feature = featureSubscription.feature; |
169 | 114 |
170 var element = E("toggle-" + feature); | 115 var element = E("toggle-" + feature); |
171 updateToggleButton(feature, isSubscriptionEnabled(featureSubscription)); | 116 updateToggleButton(feature, isSubscriptionEnabled(featureSubscription)); |
172 element.addEventListener("click", function(event) | 117 element.addEventListener("click", function(event) |
173 { | 118 { |
174 var subscription = Subscription.fromURL(featureSubscription.url); | 119 var subscription = Subscription.fromURL(featureSubscription.url); |
175 if (isSubscriptionEnabled(featureSubscription)) | 120 if (isSubscriptionEnabled(featureSubscription)) |
176 FilterStorage.removeSubscription(subscription); | 121 FilterStorage.removeSubscription(subscription); |
177 else | 122 else |
178 { | 123 { |
179 subscription.disabled = false; | 124 subscription.disabled = false; |
180 subscription.title = featureSubscription.title; | 125 subscription.title = featureSubscription.title; |
181 subscription.homepage = featureSubscription.homepage; | 126 subscription.homepage = featureSubscription.homepage; |
182 FilterStorage.addSubscription(subscription); | 127 FilterStorage.addSubscription(subscription); |
183 if (!subscription.lastDownload) | 128 if (!subscription.lastDownload) |
184 Synchronizer.execute(subscription); | 129 Synchronizer.execute(subscription); |
185 } | 130 } |
186 }, false); | 131 }, false); |
187 } | |
188 | |
189 function scrollPage() | |
190 { | |
191 if (scrollTimer) | |
192 stopScroll(); | |
193 | |
194 scrollTimer = setInterval(function() | |
195 { | |
196 window.scrollBy(0, 5); | |
197 }, 20); | |
198 } | |
199 | |
200 function stopScroll() | |
201 { | |
202 clearTimeout(scrollTimer); | |
203 scrollTimer = null; | |
204 } | 132 } |
205 | 133 |
206 function openSharePopup(url) | 134 function openSharePopup(url) |
207 { | 135 { |
208 var iframe = E("share-popup"); | 136 var iframe = E("share-popup"); |
209 var glassPane = E("glass-pane"); | 137 var glassPane = E("glass-pane"); |
210 var popupMessageReceived = false; | 138 var popupMessageReceived = false; |
211 | 139 |
212 var popupMessageListener = function(event) | 140 var popupMessageListener = function(event) |
213 { | 141 { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
314 { | 242 { |
315 var button = E("toggle-" + feature); | 243 var button = E("toggle-" + feature); |
316 if (isEnabled) | 244 if (isEnabled) |
317 button.classList.remove("off"); | 245 button.classList.remove("off"); |
318 else | 246 else |
319 button.classList.add("off"); | 247 button.classList.add("off"); |
320 } | 248 } |
321 | 249 |
322 document.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 250 document.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
323 })(); | 251 })(); |
LEFT | RIGHT |