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 |
| 53 var contributors = E("contributors"); |
| 54 contributors.href = Utils.getDocLink("contributors"); |
| 55 |
| 56 setLinks("acceptableAdsExplanation", Utils.getDocLink("acceptable_ads_criter
ia"), openFilters); |
| 57 setLinks("share-headline", Utils.getDocLink("contribute")); |
| 58 |
49 // Show warning if data corruption was detected | 59 // Show warning if data corruption was detected |
50 if (typeof backgroundPage != "undefined" && backgroundPage.seenDataCorruptio
n) | 60 if (typeof backgroundPage != "undefined" && backgroundPage.seenDataCorruptio
n) |
51 { | 61 { |
52 E("dataCorruptionWarning").removeAttribute("hidden"); | 62 E("dataCorruptionWarning").removeAttribute("hidden"); |
53 setLinks("dataCorruptionWarning", Utils.getDocLink("knownIssuesChrome_filt
erstorage")); | 63 setLinks("dataCorruptionWarning", Utils.getDocLink("knownIssuesChrome_filt
erstorage")); |
54 } | 64 } |
55 | |
56 // Set up URL | |
57 setLinks("acceptableAdsExplanation", Utils.getDocLink("acceptable_ads_criter
ia"), openFilters); | |
58 | 65 |
59 // Set up feature buttons linked to subscriptions | 66 // Set up feature buttons linked to subscriptions |
60 featureSubscriptions.forEach(setToggleSubscriptionButton); | 67 featureSubscriptions.forEach(setToggleSubscriptionButton); |
61 var filterListener = function(action) | 68 var filterListener = function(action) |
62 { | 69 { |
63 if (/^subscription\.(added|removed|disabled)$/.test(action)) | 70 if (/^subscription\.(added|removed|disabled)$/.test(action)) |
64 { | 71 { |
65 for (var i = 0; i < featureSubscriptions.length; i++) | 72 for (var i = 0; i < featureSubscriptions.length; i++) |
66 { | 73 { |
67 var featureSubscription = featureSubscriptions[i]; | 74 var featureSubscription = featureSubscriptions[i]; |
68 updateToggleButton(featureSubscription.feature, isSubscriptionEnabled(
featureSubscription)); | 75 updateToggleButton(featureSubscription.feature, isSubscriptionEnabled(
featureSubscription)); |
69 } | 76 } |
70 } | 77 } |
71 } | 78 } |
72 FilterNotifier.addListener(filterListener); | 79 FilterNotifier.addListener(filterListener); |
73 window.addEventListener("unload", function(event) | 80 window.addEventListener("unload", function(event) |
74 { | 81 { |
75 FilterNotifier.removeListener(filterListener); | 82 FilterNotifier.removeListener(filterListener); |
76 }, false); | 83 }, false); |
77 | 84 |
78 // 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 |
79 E("activate-features").addEventListener("click", showFeature, false); | 86 E("activate-features").addEventListener("click", toggleFeature, false); |
80 E("can-do-more-overview").addEventListener("click", showFeature, false); | 87 E("can-do-more-overview").addEventListener("click", toggleFeature, false); |
81 | 88 |
82 initSocialLinks(); | 89 initSocialLinks(); |
83 } | 90 } |
84 | 91 |
85 function showFeature() | 92 function toggleFeature() |
86 { | 93 { |
87 if(!E("can-do-more-overview").classList.contains("opacity-zero")) | 94 var canDoMore = E("can-do-more"); |
88 { | 95 if (!canDoMore.classList.contains("expanded")) |
89 E("can-do-more-overview").classList.remove("opacity-one") | 96 { |
90 E("can-do-more-overview").classList.add("opacity-zero"); | 97 canDoMore.classList.add("expanded"); |
91 setTimeout(function() | 98 } |
92 { | 99 else if (canDoMore.classList.contains("expanded")) |
93 E("can-do-more-overview").classList.add("display-none"); | 100 { |
94 E("can-do-more-expanded").classList.add("display-block"); | 101 canDoMore.classList.remove("expanded"); |
95 E("can-do-more-expanded").classList.add("can-do-more-expanded-higher"); | |
96 },1000); | |
97 | |
98 /* Next timeout has to be done because of an js bug. | |
99 * If you set "display: block" and "opacity: 1" | |
100 * at the same time the content would be shown | |
101 * directly without any transition. | |
102 * With the following timeout the opacity | |
103 * transition works correctly | |
104 */ | |
105 setTimeout(function() | |
106 { | |
107 E("can-do-more-expanded").classList.add("opacity-one"); | |
108 },1020); | |
109 } | |
110 else if (E("can-do-more-overview").classList.contains("opacity-zero")) | |
111 { | |
112 E("can-do-more-expanded").classList.remove("opacity-one"); | |
113 setTimeout(function() | |
114 { | |
115 E("can-do-more-expanded").classList.remove("display-block"); | |
116 E("can-do-more-overview").classList.remove("display-none"); | |
117 },1000); | |
118 | |
119 setTimeout(function() | |
120 { | |
121 E("can-do-more-overview").classList.add("opacity-one"); | |
122 E("can-do-more-overview").classList.remove("opacity-zero"); | |
123 },1020); | |
124 } | 102 } |
125 } | 103 } |
126 | 104 |
127 function isSubscriptionEnabled(featureSubscription) | 105 function isSubscriptionEnabled(featureSubscription) |
128 { | 106 { |
129 return featureSubscription.url in FilterStorage.knownSubscriptions | 107 return featureSubscription.url in FilterStorage.knownSubscriptions |
130 && !Subscription.fromURL(featureSubscription.url).disabled; | 108 && !Subscription.fromURL(featureSubscription.url).disabled; |
131 } | 109 } |
132 | 110 |
133 function setToggleSubscriptionButton(featureSubscription) | 111 function setToggleSubscriptionButton(featureSubscription) |
134 { | 112 { |
135 var feature = featureSubscription.feature; | 113 var feature = featureSubscription.feature; |
136 | 114 |
137 var element = E("toggle-" + feature); | 115 var element = E("toggle-" + feature); |
138 updateToggleButton(feature, isSubscriptionEnabled(featureSubscription)); | 116 updateToggleButton(feature, isSubscriptionEnabled(featureSubscription)); |
139 element.addEventListener("click", function(event) | 117 element.addEventListener("click", function(event) |
140 { | 118 { |
141 var subscription = Subscription.fromURL(featureSubscription.url); | 119 var subscription = Subscription.fromURL(featureSubscription.url); |
142 if (isSubscriptionEnabled(featureSubscription)) | 120 if (isSubscriptionEnabled(featureSubscription)) |
143 FilterStorage.removeSubscription(subscription); | 121 FilterStorage.removeSubscription(subscription); |
144 else | 122 else |
145 { | 123 { |
146 subscription.disabled = false; | 124 subscription.disabled = false; |
147 subscription.title = featureSubscription.title; | 125 subscription.title = featureSubscription.title; |
148 subscription.homepage = featureSubscription.homepage; | 126 subscription.homepage = featureSubscription.homepage; |
149 FilterStorage.addSubscription(subscription); | 127 FilterStorage.addSubscription(subscription); |
150 if (!subscription.lastDownload) | 128 if (!subscription.lastDownload) |
151 Synchronizer.execute(subscription); | 129 Synchronizer.execute(subscription); |
152 } | 130 } |
153 }, false); | 131 }, false); |
154 } | |
155 | |
156 function scrollPage() | |
157 { | |
158 if (scrollTimer) | |
159 stopScroll(); | |
160 | |
161 scrollTimer = setInterval(function() | |
162 { | |
163 window.scrollBy(0, 5); | |
164 }, 20); | |
165 } | |
166 | |
167 function stopScroll() | |
168 { | |
169 clearTimeout(scrollTimer); | |
170 scrollTimer = null; | |
171 } | 132 } |
172 | 133 |
173 function openSharePopup(url) | 134 function openSharePopup(url) |
174 { | 135 { |
175 var iframe = E("share-popup"); | 136 var iframe = E("share-popup"); |
176 var glassPane = E("glass-pane"); | 137 var glassPane = E("glass-pane"); |
177 var popupMessageReceived = false; | 138 var popupMessageReceived = false; |
178 | 139 |
179 var popupMessageListener = function(event) | 140 var popupMessageListener = function(event) |
180 { | 141 { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 { | 242 { |
282 var button = E("toggle-" + feature); | 243 var button = E("toggle-" + feature); |
283 if (isEnabled) | 244 if (isEnabled) |
284 button.classList.remove("off"); | 245 button.classList.remove("off"); |
285 else | 246 else |
286 button.classList.add("off"); | 247 button.classList.add("off"); |
287 } | 248 } |
288 | 249 |
289 document.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 250 document.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
290 })(); | 251 })(); |
LEFT | RIGHT |