| OLD | NEW |
| 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 "use strict"; | 18 "use strict"; |
| 19 | 19 |
| 20 |
| 20 (function() | 21 (function() |
| 21 { | 22 { |
| 22 var shade; | |
| 23 var scrollTimer; | |
| 24 | |
| 25 // Load subscriptions for features | 23 // Load subscriptions for features |
| 26 var featureSubscriptions = [ | 24 var featureSubscriptions = [ |
| 27 { | 25 { |
| 28 feature: "malware", | 26 feature: "malware", |
| 29 homepage: "http://malwaredomains.com/", | 27 homepage: "http://malwaredomains.com/", |
| 30 title: "Malware Domains", | 28 title: "Malware Domains", |
| 31 url: "https://easylist-downloads.adblockplus.org/malwaredomains_full.txt" | 29 url: "https://easylist-downloads.adblockplus.org/malwaredomains_full.txt" |
| 32 }, | 30 }, |
| 33 { | 31 { |
| 34 feature: "social", | 32 feature: "social", |
| 35 homepage: "https://www.fanboy.co.nz/", | 33 homepage: "https://www.fanboy.co.nz/", |
| 36 title: "Fanboy's Social Blocking List", | 34 title: "Fanboy's Social Blocking List", |
| 37 url: "https://easylist-downloads.adblockplus.org/fanboy-social.txt" | 35 url: "https://easylist-downloads.adblockplus.org/fanboy-social.txt" |
| 38 }, | 36 }, |
| 39 { | 37 { |
| 40 feature: "tracking", | 38 feature: "tracking", |
| 41 homepage: "https://easylist.adblockplus.org/", | 39 homepage: "https://easylist.adblockplus.org/", |
| 42 title: "EasyPrivacy", | 40 title: "EasyPrivacy", |
| 43 url: "https://easylist-downloads.adblockplus.org/easyprivacy.txt" | 41 url: "https://easylist-downloads.adblockplus.org/easyprivacy.txt" |
| 44 } | 42 } |
| 45 ]; | 43 ]; |
| 46 | 44 |
| 45 |
| 46 function showFeature() |
| 47 { |
| 48 var toggleButton = E("activate-features"); |
| 49 var overView = E("can-do-more-overview"); |
| 50 var expandedView = E("can-do-more-expanded"); |
| 51 |
| 52 if(toggleButton.getAttribute("data-status") == "overview") |
| 53 { |
| 54 fade("out", overView, 750, true); |
| 55 setTimeout(function() |
| 56 { |
| 57 fade("in", expandedView, 750, true) |
| 58 },750); |
| 59 |
| 60 toggleButton.innerHTML = "show overview again"; |
| 61 toggleButton.setAttribute("data-status","expanded"); |
| 62 |
| 63 } |
| 64 else if (toggleButton.getAttribute("data-status") == "expanded") |
| 65 { |
| 66 fade("out", expandedView, 750, true); |
| 67 setTimeout(function() |
| 68 { |
| 69 fade("in", overView, 750, true) |
| 70 },750); |
| 71 |
| 72 toggleButton.innerHTML = "activate features"; |
| 73 toggleButton.setAttribute("data-status", "overview"); |
| 74 } |
| 75 |
| 76 // jQuery-style fading |
| 77 function fade(type, el, duration, IEsupport) |
| 78 { |
| 79 var isIn = (type == "in"), |
| 80 IE = (IEsupport) ? IEsupport : false, |
| 81 opacity = isIn ? 0 : 1, |
| 82 interval = 50, |
| 83 gap = interval / duration; |
| 84 |
| 85 if(isIn) |
| 86 { |
| 87 el.style.display = "block"; |
| 88 el.style.opacity = opacity; |
| 89 if(IE) |
| 90 { |
| 91 el.style.filter = "alpha(opacity=" + opacity + ")"; |
| 92 el.style.filter = "progid:DXImageTransform.Microsoft.Alpha(Opacity=" +
opacity + ")"; |
| 93 } |
| 94 } |
| 95 |
| 96 function func() |
| 97 { |
| 98 opacity = isIn ? opacity + gap : opacity - gap; |
| 99 el.style.opacity = opacity; |
| 100 if(IE) |
| 101 { |
| 102 el.style.filter = "alpha(opacity=" + opacity * 100 + ")"; |
| 103 el.style.filter = "progid:DXImageTransform.Microsoft.Alpha(Opacity=" +
opacity * 100 + ")"; |
| 104 } |
| 105 if(opacity <= 0 || opacity >= 1) |
| 106 { |
| 107 window.clearInterval(fading); |
| 108 } |
| 109 if(opacity <= 0) |
| 110 { |
| 111 el.style.display = "none"; |
| 112 } |
| 113 } |
| 114 var fading = window.setInterval(func, interval); |
| 115 } |
| 116 } |
| 117 |
| 47 function onDOMLoaded() | 118 function onDOMLoaded() |
| 48 { | 119 { |
| 120 var donateLink = E("donate"); |
| 121 donateLink.href = Utils.getDocLink("donate"); |
| 122 |
| 49 // Show warning if data corruption was detected | 123 // Show warning if data corruption was detected |
| 50 if (typeof backgroundPage != "undefined" && backgroundPage.seenDataCorruptio
n) | 124 if (typeof backgroundPage != "undefined" && backgroundPage.seenDataCorruptio
n) |
| 51 { | 125 { |
| 52 E("dataCorruptionWarning").removeAttribute("hidden"); | 126 E("dataCorruptionWarning").removeAttribute("hidden"); |
| 53 setLinks("dataCorruptionWarning", Utils.getDocLink("knownIssuesChrome_filt
erstorage")); | 127 setLinks("dataCorruptionWarning", Utils.getDocLink("knownIssuesChrome_filt
erstorage")); |
| 54 } | 128 } |
| 55 | 129 |
| 56 // Set up URL | 130 // Set up URL |
| 57 setLinks("acceptableAdsExplanation", Utils.getDocLink("acceptable_ads_criter
ia"), openFilters); | 131 setLinks("acceptableAdsExplanation", Utils.getDocLink("acceptable_ads_criter
ia"), openFilters); |
| 58 | 132 |
| 59 shade = E("shade"); | |
| 60 shade.addEventListener("mouseover", scrollPage, false); | |
| 61 shade.addEventListener("mouseout", stopScroll, false); | |
| 62 | |
| 63 // Set up feature buttons linked to subscriptions | 133 // Set up feature buttons linked to subscriptions |
| 64 featureSubscriptions.forEach(setToggleSubscriptionButton); | 134 featureSubscriptions.forEach(setToggleSubscriptionButton); |
| 65 var filterListener = function(action) | 135 var filterListener = function(action) |
| 66 { | 136 { |
| 67 if (/^subscription\.(added|removed|disabled)$/.test(action)) | 137 if (/^subscription\.(added|removed|disabled)$/.test(action)) |
| 68 { | 138 { |
| 69 for (var i = 0; i < featureSubscriptions.length; i++) | 139 for (var i = 0; i < featureSubscriptions.length; i++) |
| 70 { | 140 { |
| 71 var featureSubscription = featureSubscriptions[i]; | 141 var featureSubscription = featureSubscriptions[i]; |
| 72 updateToggleButton(featureSubscription.feature, isSubscriptionEnabled(
featureSubscription)); | 142 updateToggleButton(featureSubscription.feature, isSubscriptionEnabled(
featureSubscription)); |
| 73 } | 143 } |
| 74 } | 144 } |
| 75 } | 145 } |
| 76 FilterNotifier.addListener(filterListener); | 146 FilterNotifier.addListener(filterListener); |
| 77 window.addEventListener("unload", function(event) | 147 window.addEventListener("unload", function(event) |
| 78 { | 148 { |
| 79 FilterNotifier.removeListener(filterListener); | 149 FilterNotifier.removeListener(filterListener); |
| 80 }, false); | 150 }, false); |
| 81 | 151 |
| 82 window.addEventListener("resize", onWindowResize, false); | 152 // you can click activate-feature or one of the icons to toggle the features
area |
| 83 document.addEventListener("scroll", onScroll, false); | 153 E("activate-features").addEventListener("click", showFeature, false); |
| 84 | 154 E("can-do-more-overview").addEventListener("click", showFeature, false); |
| 85 onWindowResize(); | |
| 86 | 155 |
| 87 initSocialLinks(); | 156 initSocialLinks(); |
| 88 } | 157 } |
| 89 | 158 |
| 90 function onScroll() | |
| 91 { | |
| 92 var currentHeight = document.documentElement.scrollTop + document.body.scrol
lTop + document.documentElement.clientHeight; | |
| 93 shade.style.opacity = (document.documentElement.scrollHeight == currentHeigh
t) ? "0.0" : "0.5"; | |
| 94 } | |
| 95 | |
| 96 function onWindowResize() | |
| 97 { | |
| 98 onScroll(); | |
| 99 } | |
| 100 | |
| 101 function toggleTypoCorrectionEnabled() | |
| 102 { | |
| 103 Prefs.correctTypos = !Prefs.correctTypos; | |
| 104 } | |
| 105 | |
| 106 function isSubscriptionEnabled(featureSubscription) | 159 function isSubscriptionEnabled(featureSubscription) |
| 107 { | 160 { |
| 108 return featureSubscription.url in FilterStorage.knownSubscriptions | 161 return featureSubscription.url in FilterStorage.knownSubscriptions |
| 109 && !Subscription.fromURL(featureSubscription.url).disabled; | 162 && !Subscription.fromURL(featureSubscription.url).disabled; |
| 110 } | 163 } |
| 111 | 164 |
| 112 function setToggleSubscriptionButton(featureSubscription) | 165 function setToggleSubscriptionButton(featureSubscription) |
| 113 { | 166 { |
| 114 var feature = featureSubscription.feature; | 167 var feature = featureSubscription.feature; |
| 115 | 168 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 { | 310 { |
| 258 var button = E("toggle-" + feature); | 311 var button = E("toggle-" + feature); |
| 259 if (isEnabled) | 312 if (isEnabled) |
| 260 button.classList.remove("off"); | 313 button.classList.remove("off"); |
| 261 else | 314 else |
| 262 button.classList.add("off"); | 315 button.classList.add("off"); |
| 263 } | 316 } |
| 264 | 317 |
| 265 document.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 318 document.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
| 266 })(); | 319 })(); |
| OLD | NEW |