Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: chrome/content/ui/firstRun.js

Issue 11039060: first run page redesign (Closed)
Patch Set: tansition changed, set Links fixed Created July 31, 2013, 12:47 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/content/ui/firstRun.html ('k') | chrome/locale/en-US/firstRun.properties » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 (function() 20 (function()
21 { 21 {
22 var shade;
23 var scrollTimer;
24
25 // Load subscriptions for features 22 // Load subscriptions for features
26 var featureSubscriptions = [ 23 var featureSubscriptions = [
27 { 24 {
28 feature: "malware", 25 feature: "malware",
29 homepage: "http://malwaredomains.com/", 26 homepage: "http://malwaredomains.com/",
30 title: "Malware Domains", 27 title: "Malware Domains",
31 url: "https://easylist-downloads.adblockplus.org/malwaredomains_full.txt" 28 url: "https://easylist-downloads.adblockplus.org/malwaredomains_full.txt"
32 }, 29 },
33 { 30 {
34 feature: "social", 31 feature: "social",
35 homepage: "https://www.fanboy.co.nz/", 32 homepage: "https://www.fanboy.co.nz/",
36 title: "Fanboy's Social Blocking List", 33 title: "Fanboy's Social Blocking List",
37 url: "https://easylist-downloads.adblockplus.org/fanboy-social.txt" 34 url: "https://easylist-downloads.adblockplus.org/fanboy-social.txt"
38 }, 35 },
39 { 36 {
40 feature: "tracking", 37 feature: "tracking",
41 homepage: "https://easylist.adblockplus.org/", 38 homepage: "https://easylist.adblockplus.org/",
42 title: "EasyPrivacy", 39 title: "EasyPrivacy",
43 url: "https://easylist-downloads.adblockplus.org/easyprivacy.txt" 40 url: "https://easylist-downloads.adblockplus.org/easyprivacy.txt"
44 } 41 }
45 ]; 42 ];
46 43
47 function onDOMLoaded() 44 function onDOMLoaded()
48 { 45 {
46 var donateLink = E("donate");
47 donateLink.href = Utils.getDocLink("donate");
48
49 // Show warning if data corruption was detected 49 // Show warning if data corruption was detected
50 if (typeof backgroundPage != "undefined" && backgroundPage.seenDataCorruptio n) 50 if (typeof backgroundPage != "undefined" && backgroundPage.seenDataCorruptio n)
51 { 51 {
52 E("dataCorruptionWarning").removeAttribute("hidden"); 52 E("dataCorruptionWarning").removeAttribute("hidden");
53 setLinks("dataCorruptionWarning", Utils.getDocLink("knownIssuesChrome_filt erstorage")); 53 setLinks("dataCorruptionWarning", Utils.getDocLink("knownIssuesChrome_filt erstorage"));
54 } 54 }
55 55
56 // Set up URL 56 // Set up URL
57 setLinks("acceptableAdsExplanation", Utils.getDocLink("acceptable_ads_criter ia"), openFilters); 57 setLinks("acceptableAdsExplanation", Utils.getDocLink("acceptable_ads_criter ia"), openFilters);
58 58
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 59 // Set up feature buttons linked to subscriptions
64 featureSubscriptions.forEach(setToggleSubscriptionButton); 60 featureSubscriptions.forEach(setToggleSubscriptionButton);
65 var filterListener = function(action) 61 var filterListener = function(action)
66 { 62 {
67 if (/^subscription\.(added|removed|disabled)$/.test(action)) 63 if (/^subscription\.(added|removed|disabled)$/.test(action))
68 { 64 {
69 for (var i = 0; i < featureSubscriptions.length; i++) 65 for (var i = 0; i < featureSubscriptions.length; i++)
70 { 66 {
71 var featureSubscription = featureSubscriptions[i]; 67 var featureSubscription = featureSubscriptions[i];
72 updateToggleButton(featureSubscription.feature, isSubscriptionEnabled( featureSubscription)); 68 updateToggleButton(featureSubscription.feature, isSubscriptionEnabled( featureSubscription));
73 } 69 }
74 } 70 }
75 } 71 }
76 FilterNotifier.addListener(filterListener); 72 FilterNotifier.addListener(filterListener);
77 window.addEventListener("unload", function(event) 73 window.addEventListener("unload", function(event)
78 { 74 {
79 FilterNotifier.removeListener(filterListener); 75 FilterNotifier.removeListener(filterListener);
80 }, false); 76 }, false);
81 77
82 window.addEventListener("resize", onWindowResize, false); 78 // you can click activate-feature or one of the icons to toggle the features area
83 document.addEventListener("scroll", onScroll, false); 79 E("activate-features").addEventListener("click", showFeature, false);
84 80 E("can-do-more-overview").addEventListener("click", showFeature, false);
85 onWindowResize();
86 81
87 initSocialLinks(); 82 initSocialLinks();
88 } 83 }
89 84
90 function onScroll() 85 function showFeature()
91 { 86 {
92 var currentHeight = document.documentElement.scrollTop + document.body.scrol lTop + document.documentElement.clientHeight; 87 if(!E("can-do-more-overview").classList.contains("opacity-zero"))
93 shade.style.opacity = (document.documentElement.scrollHeight == currentHeigh t) ? "0.0" : "0.5"; 88 {
94 } 89 E("can-do-more-overview").classList.remove("opacity-one")
95 90 E("can-do-more-overview").classList.add("opacity-zero");
96 function onWindowResize() 91 setTimeout(function()
97 { 92 {
98 onScroll(); 93 E("can-do-more-overview").classList.add("display-none");
99 } 94 E("can-do-more-expanded").classList.add("display-block");
100 95 E("can-do-more-expanded").classList.add("can-do-more-expanded-higher");
101 function toggleTypoCorrectionEnabled() 96 },1000);
102 { 97
103 Prefs.correctTypos = !Prefs.correctTypos; 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 }
104 } 125 }
105 126
106 function isSubscriptionEnabled(featureSubscription) 127 function isSubscriptionEnabled(featureSubscription)
107 { 128 {
108 return featureSubscription.url in FilterStorage.knownSubscriptions 129 return featureSubscription.url in FilterStorage.knownSubscriptions
109 && !Subscription.fromURL(featureSubscription.url).disabled; 130 && !Subscription.fromURL(featureSubscription.url).disabled;
110 } 131 }
111 132
112 function setToggleSubscriptionButton(featureSubscription) 133 function setToggleSubscriptionButton(featureSubscription)
113 { 134 {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 { 239 {
219 event.preventDefault(); 240 event.preventDefault();
220 openSharePopup(Utils.getDocLink(event.target.id)); 241 openSharePopup(Utils.getDocLink(event.target.id));
221 } 242 }
222 } 243 }
223 244
224 function setLinks(id) 245 function setLinks(id)
225 { 246 {
226 var element = E(id); 247 var element = E(id);
227 if (!element) 248 if (!element)
249 {
228 return; 250 return;
229 251 }
252
230 var links = element.getElementsByTagName("a"); 253 var links = element.getElementsByTagName("a");
254
231 for (var i = 0; i < links.length; i++) 255 for (var i = 0; i < links.length; i++)
232 { 256 {
233 if (typeof arguments[i + 1] == "string") 257 if (typeof arguments[i + 1] == "string")
234 { 258 {
235 links[i].href = arguments[i + 1]; 259 links[i].href = arguments[i + 1];
236 links[i].setAttribute("target", "_blank"); 260 links[i].setAttribute("target", "_blank");
237 } 261 }
238 else if (typeof arguments[i + 1] == "function") 262 else if (typeof arguments[i + 1] == "function")
239 { 263 {
240 links[i].href = "javascript:void(0);"; 264 links[i].href = "javascript:void(0);";
(...skipping 16 matching lines...) Expand all
257 { 281 {
258 var button = E("toggle-" + feature); 282 var button = E("toggle-" + feature);
259 if (isEnabled) 283 if (isEnabled)
260 button.classList.remove("off"); 284 button.classList.remove("off");
261 else 285 else
262 button.classList.add("off"); 286 button.classList.add("off");
263 } 287 }
264 288
265 document.addEventListener("DOMContentLoaded", onDOMLoaded, false); 289 document.addEventListener("DOMContentLoaded", onDOMLoaded, false);
266 })(); 290 })();
OLDNEW
« no previous file with comments | « chrome/content/ui/firstRun.html ('k') | chrome/locale/en-US/firstRun.properties » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld