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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 featureSubscriptions.forEach(setToggleSubscriptionButton); | 86 featureSubscriptions.forEach(setToggleSubscriptionButton); |
87 var filterListener = function(action) | 87 var filterListener = function(action) |
88 { | 88 { |
89 if (/^subscription\.(added|removed|disabled)$/.test(action)) | 89 if (/^subscription\.(added|removed|disabled)$/.test(action)) |
90 { | 90 { |
91 for (var i = 0; i < featureSubscriptions.length; i++) | 91 for (var i = 0; i < featureSubscriptions.length; i++) |
92 { | 92 { |
93 var featureSubscription = featureSubscriptions[i]; | 93 var featureSubscription = featureSubscriptions[i]; |
94 updateToggleButton(featureSubscription.feature, isSubscriptionEnabled(
featureSubscription)); | 94 updateToggleButton(featureSubscription.feature, isSubscriptionEnabled(
featureSubscription)); |
95 } | 95 } |
96 | |
97 setSocialLinks(); | |
98 } | 96 } |
99 } | 97 } |
100 FilterNotifier.addListener(filterListener); | 98 FilterNotifier.addListener(filterListener); |
101 window.addEventListener("unload", function(event) | 99 window.addEventListener("unload", function(event) |
102 { | 100 { |
103 FilterNotifier.removeListener(filterListener); | 101 FilterNotifier.removeListener(filterListener); |
104 }, false); | 102 }, false); |
105 | 103 |
106 window.addEventListener("resize", onWindowResize, false); | 104 window.addEventListener("resize", onWindowResize, false); |
107 document.addEventListener("scroll", onScroll, false); | 105 document.addEventListener("scroll", onScroll, false); |
108 | 106 |
109 onWindowResize(); | 107 onWindowResize(); |
110 | 108 |
111 setSocialLinks(); | 109 initSocialLinks(null); |
112 } | 110 } |
113 | 111 |
114 function onScroll() | 112 function onScroll() |
115 { | 113 { |
116 var currentHeight = document.documentElement.scrollTop + document.body.scrol
lTop + document.documentElement.clientHeight; | 114 var currentHeight = document.documentElement.scrollTop + document.body.scrol
lTop + document.documentElement.clientHeight; |
117 shade.style.opacity = (document.documentElement.scrollHeight == currentHeigh
t) ? "0.0" : "0.5"; | 115 shade.style.opacity = (document.documentElement.scrollHeight == currentHeigh
t) ? "0.0" : "0.5"; |
118 } | 116 } |
119 | 117 |
120 function onWindowResize() | 118 function onWindowResize() |
121 { | 119 { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 } | 215 } |
218 | 216 |
219 iframe.removeEventListener("load", popupLoadListener); | 217 iframe.removeEventListener("load", popupLoadListener); |
220 }; | 218 }; |
221 iframe.addEventListener("load", popupLoadListener, false); | 219 iframe.addEventListener("load", popupLoadListener, false); |
222 | 220 |
223 iframe.src = url; | 221 iframe.src = url; |
224 glassPane.className = "visible"; | 222 glassPane.className = "visible"; |
225 } | 223 } |
226 | 224 |
227 function setSocialLinks() | 225 function initSocialLinks(variant) |
228 { | 226 { |
229 var isSocialFeatureEnabled = false; | |
230 for (var i = 0; i < featureSubscriptions.length; i++) | |
231 { | |
232 if (featureSubscriptions[i].feature == "social") | |
233 { | |
234 isSocialFeatureEnabled = isSubscriptionEnabled(featureSubscriptions[i]); | |
235 break; | |
236 } | |
237 } | |
238 | |
239 var networks = ["twitter", "facebook", "gplus"]; | 227 var networks = ["twitter", "facebook", "gplus"]; |
240 networks.forEach(function(network) | 228 networks.forEach(function(network) |
241 { | 229 { |
242 var link = E("share-" + network); | 230 var link = E("share-" + network); |
243 if (isSocialFeatureEnabled) | 231 link.addEventListener("click", function(e) |
244 link.removeEventListener("click", onSocialLinkClick, false); | 232 { |
245 else | 233 e.preventDefault(); |
246 link.addEventListener("click", onSocialLinkClick, false); | 234 openSharePopup(Utils.getDocLink("share-" + network) + "&variant=" + vari
ant); |
| 235 }, false); |
247 }); | 236 }); |
248 } | |
249 | |
250 function onSocialLinkClick(e) | |
251 { | |
252 e.preventDefault(); | |
253 openSharePopup(Utils.getDocLink(e.target.id)); | |
254 } | 237 } |
255 | 238 |
256 function setLinks(id) | 239 function setLinks(id) |
257 { | 240 { |
258 var element = E(id); | 241 var element = E(id); |
259 if (!element) | 242 if (!element) |
260 return; | 243 return; |
261 | 244 |
262 var links = element.getElementsByTagName("a"); | 245 var links = element.getElementsByTagName("a"); |
263 for (var i = 0; i < links.length; i++) | 246 for (var i = 0; i < links.length; i++) |
(...skipping 18 matching lines...) Expand all Loading... |
282 else | 265 else |
283 { | 266 { |
284 backgroundPage.openOptions(); | 267 backgroundPage.openOptions(); |
285 } | 268 } |
286 } | 269 } |
287 | 270 |
288 function updateToggleButton(feature, isEnabled) | 271 function updateToggleButton(feature, isEnabled) |
289 { | 272 { |
290 var button = E("toggle-" + feature); | 273 var button = E("toggle-" + feature); |
291 if (isEnabled) | 274 if (isEnabled) |
292 button.className = button.className.replace("enable", "disable"); | 275 button.classList.remove("off"); |
293 else | 276 else |
294 button.className = button.className.replace("disable", "enable"); | 277 button.classList.add("off"); |
295 } | 278 } |
296 | 279 |
297 document.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 280 document.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
298 })(); | 281 })(); |
LEFT | RIGHT |