| 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 var labelShowExpanded = E("label-show-expanded"); | 98 } |
| 93 var labelShowOverview = E("label-show-overview"); | 99 else if (canDoMore.classList.contains("expanded")) |
| 94 | 100 { |
| 95 if (activateFeatures.classList.contains("overview")) | 101 canDoMore.classList.remove("expanded"); |
| 96 { | |
| 97 canDoMoreOverview.classList.toggle("fade-out"); | |
| 98 activateFeatures.classList.remove("overview"); | |
| 99 activateFeatures.classList.add("expanded"); | |
|
Thomas Greiner
2013/08/26 11:33:50
Review comment not addressed.
| |
| 100 | |
| 101 labelShowExpanded.classList.toggle("hide"); | |
| 102 labelShowOverview.classList.toggle("hide"); | |
| 103 | |
| 104 activateFeatures.setAttribute("data-status","expanded"); | |
| 105 | |
| 106 setTimeout(function() | |
| 107 { | |
| 108 canDoMoreOverview.classList.add("hide"); | |
| 109 canDoMoreExpanded.classList.add("show"); | |
| 110 },500); | |
| 111 | |
| 112 /* Next timeout has to be done because of an js bug. | |
| 113 * If you set "display: block" and "opacity: 1" | |
| 114 * at the same time the content would be shown | |
| 115 * directly without any transition. | |
| 116 * With the following timeout the opacity | |
| 117 * transition works correctly | |
| 118 */ | |
| 119 setTimeout(function() | |
| 120 { | |
| 121 canDoMoreExpanded.classList.toggle("fade-out"); | |
| 122 },520); | |
| 123 } | |
| 124 else if (activateFeatures.classList.contains("expanded")) | |
| 125 { | |
| 126 canDoMoreExpanded.classList.toggle("fade-out"); | |
| 127 activateFeatures.classList.remove("expanded"); | |
| 128 activateFeatures.classList.add("overview"); | |
| 129 | |
| 130 labelShowExpanded.classList.toggle("hide"); | |
| 131 labelShowOverview.classList.toggle("hide"); | |
| 132 | |
| 133 activateFeatures.setAttribute("data-status","overview"); | |
| 134 | |
| 135 setTimeout(function() | |
| 136 { | |
| 137 canDoMoreExpanded.classList.remove("show"); | |
| 138 canDoMoreOverview.classList.remove("hide"); | |
| 139 },500); | |
| 140 | |
| 141 setTimeout(function() | |
| 142 { | |
| 143 canDoMoreOverview.classList.toggle("fade-out"); | |
| 144 },520); | |
| 145 } | 102 } |
|
Wladimir Palant
2013/10/05 09:15:59
Nit: One line of code is enough for the entire fun
| |
| 146 } | 103 } |
| 147 | 104 |
| 148 function isSubscriptionEnabled(featureSubscription) | 105 function isSubscriptionEnabled(featureSubscription) |
| 149 { | 106 { |
| 150 return featureSubscription.url in FilterStorage.knownSubscriptions | 107 return featureSubscription.url in FilterStorage.knownSubscriptions |
| 151 && !Subscription.fromURL(featureSubscription.url).disabled; | 108 && !Subscription.fromURL(featureSubscription.url).disabled; |
| 152 } | 109 } |
| 153 | 110 |
| 154 function setToggleSubscriptionButton(featureSubscription) | 111 function setToggleSubscriptionButton(featureSubscription) |
| 155 { | 112 { |
| 156 var feature = featureSubscription.feature; | 113 var feature = featureSubscription.feature; |
| 157 | 114 |
| 158 var element = E("toggle-" + feature); | 115 var element = E("toggle-" + feature); |
| 159 updateToggleButton(feature, isSubscriptionEnabled(featureSubscription)); | 116 updateToggleButton(feature, isSubscriptionEnabled(featureSubscription)); |
| 160 element.addEventListener("click", function(event) | 117 element.addEventListener("click", function(event) |
| 161 { | 118 { |
| 162 var subscription = Subscription.fromURL(featureSubscription.url); | 119 var subscription = Subscription.fromURL(featureSubscription.url); |
| 163 if (isSubscriptionEnabled(featureSubscription)) | 120 if (isSubscriptionEnabled(featureSubscription)) |
| 164 FilterStorage.removeSubscription(subscription); | 121 FilterStorage.removeSubscription(subscription); |
| 165 else | 122 else |
| 166 { | 123 { |
| 167 subscription.disabled = false; | 124 subscription.disabled = false; |
| 168 subscription.title = featureSubscription.title; | 125 subscription.title = featureSubscription.title; |
| 169 subscription.homepage = featureSubscription.homepage; | 126 subscription.homepage = featureSubscription.homepage; |
| 170 FilterStorage.addSubscription(subscription); | 127 FilterStorage.addSubscription(subscription); |
| 171 if (!subscription.lastDownload) | 128 if (!subscription.lastDownload) |
| 172 Synchronizer.execute(subscription); | 129 Synchronizer.execute(subscription); |
| 173 } | 130 } |
| 174 }, false); | 131 }, false); |
| 175 } | |
| 176 | |
| 177 function scrollPage() | |
| 178 { | |
| 179 if (scrollTimer) | |
| 180 stopScroll(); | |
| 181 | |
| 182 scrollTimer = setInterval(function() | |
| 183 { | |
| 184 window.scrollBy(0, 5); | |
| 185 }, 20); | |
| 186 } | |
| 187 | |
| 188 function stopScroll() | |
| 189 { | |
| 190 clearTimeout(scrollTimer); | |
| 191 scrollTimer = null; | |
| 192 } | 132 } |
| 193 | 133 |
| 194 function openSharePopup(url) | 134 function openSharePopup(url) |
| 195 { | 135 { |
| 196 var iframe = E("share-popup"); | 136 var iframe = E("share-popup"); |
| 197 var glassPane = E("glass-pane"); | 137 var glassPane = E("glass-pane"); |
| 198 var popupMessageReceived = false; | 138 var popupMessageReceived = false; |
| 199 | 139 |
| 200 var popupMessageListener = function(event) | 140 var popupMessageListener = function(event) |
| 201 { | 141 { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 302 { | 242 { |
| 303 var button = E("toggle-" + feature); | 243 var button = E("toggle-" + feature); |
| 304 if (isEnabled) | 244 if (isEnabled) |
| 305 button.classList.remove("off"); | 245 button.classList.remove("off"); |
| 306 else | 246 else |
| 307 button.classList.add("off"); | 247 button.classList.add("off"); |
| 308 } | 248 } |
| 309 | 249 |
| 310 document.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 250 document.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
| 311 })(); | 251 })(); |
| LEFT | RIGHT |