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 // Set up URL | 46 var locale = require("utils").Utils.appLocale; |
47 document.documentElement.setAttribute("lang", locale); | |
48 | |
49 // Set up URLs | |
47 var donateLink = E("donate"); | 50 var donateLink = E("donate"); |
48 donateLink.href = Utils.getDocLink("donate"); | 51 donateLink.href = Utils.getDocLink("donate"); |
49 | 52 |
50 var contributors = E("contributors"); | 53 var contributors = E("contributors"); |
51 contributors.href = Utils.getDocLink("contributors"); | 54 contributors.href = Utils.getDocLink("contributors"); |
52 | 55 |
53 setLinks("acceptableAdsExplanation", Utils.getDocLink("acceptable_ads_criter ia"), openFilters); | 56 setLinks("acceptableAdsExplanation", Utils.getDocLink("acceptable_ads_criter ia"), openFilters); |
54 setLinks("share-headline", Utils.getDocLink("contribute")); | 57 setLinks("share-headline", Utils.getDocLink("contribute")); |
55 | 58 |
56 // Show warning if data corruption was detected | 59 // Show warning if data corruption was detected |
(...skipping 16 matching lines...) Expand all Loading... | |
73 } | 76 } |
74 } | 77 } |
75 } | 78 } |
76 FilterNotifier.addListener(filterListener); | 79 FilterNotifier.addListener(filterListener); |
77 window.addEventListener("unload", function(event) | 80 window.addEventListener("unload", function(event) |
78 { | 81 { |
79 FilterNotifier.removeListener(filterListener); | 82 FilterNotifier.removeListener(filterListener); |
80 }, false); | 83 }, false); |
81 | 84 |
82 // 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 |
83 E("activate-features").addEventListener("click", showFeature, false); | 86 E("activate-features").addEventListener("click", toggleFeature, false); |
84 E("can-do-more-overview").addEventListener("click", showFeature, false); | 87 E("can-do-more-overview").addEventListener("click", toggleFeature, false); |
85 | 88 |
86 initSocialLinks(); | 89 initSocialLinks(); |
87 } | 90 } |
88 | 91 |
89 function showFeature() | 92 function toggleFeature() |
90 { | 93 { |
91 var canDoMore = E("can-do-more"); | 94 var canDoMore = E("can-do-more"); |
92 var canDoMoreOverview = E("can-do-more-overview"); | |
93 var canDoMoreExpanded = E("can-do-more-expanded"); | |
94 | |
95 if (!canDoMore.classList.contains("expanded")) | 95 if (!canDoMore.classList.contains("expanded")) |
96 { | 96 { |
97 canDoMore.classList.add("expanded"); | 97 canDoMore.classList.add("expanded"); |
98 canDoMoreOverview.classList.add("fade-out"); | |
99 | |
100 setTimeout(function() | |
101 { | |
102 canDoMoreOverview.classList.add("hide"); | |
103 canDoMoreExpanded.classList.remove("hide"); | |
104 },500); | |
105 | |
106 /* Next timeout has to be done because of an js bug. | |
107 * If you set "display: block" and "opacity: 1" | |
108 * at the same time the content would be shown | |
109 * directly without any transition. | |
110 * With the following timeout the opacity | |
111 * transition works correctly | |
112 */ | |
113 setTimeout(function() | |
114 { | |
115 canDoMoreExpanded.classList.remove("fade-out"); | |
116 },520); | |
117 } | 98 } |
118 else if (canDoMore.classList.contains("expanded")) | 99 else if (canDoMore.classList.contains("expanded")) |
119 { | 100 { |
120 canDoMore.classList.remove("expanded"); | 101 canDoMore.classList.remove("expanded"); |
121 canDoMoreExpanded.classList.add("fade-out"); | |
122 | |
123 setTimeout(function() | |
124 { | |
125 canDoMoreExpanded.classList.add("hide"); | |
126 canDoMoreOverview.classList.remove("hide"); | |
127 },500); | |
128 | |
129 setTimeout(function() | |
130 { | |
131 canDoMoreOverview.classList.remove("fade-out"); | |
132 },520); | |
133 } | 102 } |
Wladimir Palant
2013/10/05 09:15:59
Nit: One line of code is enough for the entire fun
| |
134 } | 103 } |
135 | 104 |
136 function isSubscriptionEnabled(featureSubscription) | 105 function isSubscriptionEnabled(featureSubscription) |
137 { | 106 { |
138 return featureSubscription.url in FilterStorage.knownSubscriptions | 107 return featureSubscription.url in FilterStorage.knownSubscriptions |
139 && !Subscription.fromURL(featureSubscription.url).disabled; | 108 && !Subscription.fromURL(featureSubscription.url).disabled; |
140 } | 109 } |
141 | 110 |
142 function setToggleSubscriptionButton(featureSubscription) | 111 function setToggleSubscriptionButton(featureSubscription) |
143 { | 112 { |
144 var feature = featureSubscription.feature; | 113 var feature = featureSubscription.feature; |
145 | 114 |
146 var element = E("toggle-" + feature); | 115 var element = E("toggle-" + feature); |
147 updateToggleButton(feature, isSubscriptionEnabled(featureSubscription)); | 116 updateToggleButton(feature, isSubscriptionEnabled(featureSubscription)); |
148 element.addEventListener("click", function(event) | 117 element.addEventListener("click", function(event) |
149 { | 118 { |
150 var subscription = Subscription.fromURL(featureSubscription.url); | 119 var subscription = Subscription.fromURL(featureSubscription.url); |
151 if (isSubscriptionEnabled(featureSubscription)) | 120 if (isSubscriptionEnabled(featureSubscription)) |
152 FilterStorage.removeSubscription(subscription); | 121 FilterStorage.removeSubscription(subscription); |
153 else | 122 else |
154 { | 123 { |
155 subscription.disabled = false; | 124 subscription.disabled = false; |
156 subscription.title = featureSubscription.title; | 125 subscription.title = featureSubscription.title; |
157 subscription.homepage = featureSubscription.homepage; | 126 subscription.homepage = featureSubscription.homepage; |
158 FilterStorage.addSubscription(subscription); | 127 FilterStorage.addSubscription(subscription); |
159 if (!subscription.lastDownload) | 128 if (!subscription.lastDownload) |
160 Synchronizer.execute(subscription); | 129 Synchronizer.execute(subscription); |
161 } | 130 } |
162 }, false); | 131 }, false); |
163 } | |
164 | |
165 function scrollPage() | |
Thomas Greiner
2013/08/26 16:25:04
Doesn't seem to be used anywhere.
| |
166 { | |
167 if (scrollTimer) | |
168 stopScroll(); | |
169 | |
170 scrollTimer = setInterval(function() | |
171 { | |
172 window.scrollBy(0, 5); | |
173 }, 20); | |
174 } | |
175 | |
176 function stopScroll() | |
Thomas Greiner
2013/08/26 16:25:04
Doesn't seem to be used anywhere.
| |
177 { | |
178 clearTimeout(scrollTimer); | |
179 scrollTimer = null; | |
180 } | 132 } |
181 | 133 |
182 function openSharePopup(url) | 134 function openSharePopup(url) |
183 { | 135 { |
184 var iframe = E("share-popup"); | 136 var iframe = E("share-popup"); |
185 var glassPane = E("glass-pane"); | 137 var glassPane = E("glass-pane"); |
186 var popupMessageReceived = false; | 138 var popupMessageReceived = false; |
187 | 139 |
188 var popupMessageListener = function(event) | 140 var popupMessageListener = function(event) |
189 { | 141 { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
290 { | 242 { |
291 var button = E("toggle-" + feature); | 243 var button = E("toggle-" + feature); |
292 if (isEnabled) | 244 if (isEnabled) |
293 button.classList.remove("off"); | 245 button.classList.remove("off"); |
294 else | 246 else |
295 button.classList.add("off"); | 247 button.classList.add("off"); |
296 } | 248 } |
297 | 249 |
298 document.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 250 document.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
299 })(); | 251 })(); |
LEFT | RIGHT |