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: new share part, transition changed with own method Created Aug. 6, 2013, 3:57 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
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 setLinks("share-headline", Utils.getDocLink("contribute"));
Thomas Greiner 2013/08/07 14:17:54 Please move the setLinks call from lines 58-59 her
50
49 // Show warning if data corruption was detected 51 // Show warning if data corruption was detected
50 if (typeof backgroundPage != "undefined" && backgroundPage.seenDataCorruptio n) 52 if (typeof backgroundPage != "undefined" && backgroundPage.seenDataCorruptio n)
51 { 53 {
52 E("dataCorruptionWarning").removeAttribute("hidden"); 54 E("dataCorruptionWarning").removeAttribute("hidden");
53 setLinks("dataCorruptionWarning", Utils.getDocLink("knownIssuesChrome_filt erstorage")); 55 setLinks("dataCorruptionWarning", Utils.getDocLink("knownIssuesChrome_filt erstorage"));
54 } 56 }
55 57
56 // Set up URL 58 // Set up URL
57 setLinks("acceptableAdsExplanation", Utils.getDocLink("acceptable_ads_criter ia"), openFilters); 59 setLinks("acceptableAdsExplanation", Utils.getDocLink("acceptable_ads_criter ia"), openFilters);
58 60
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 61 // Set up feature buttons linked to subscriptions
64 featureSubscriptions.forEach(setToggleSubscriptionButton); 62 featureSubscriptions.forEach(setToggleSubscriptionButton);
65 var filterListener = function(action) 63 var filterListener = function(action)
66 { 64 {
67 if (/^subscription\.(added|removed|disabled)$/.test(action)) 65 if (/^subscription\.(added|removed|disabled)$/.test(action))
68 { 66 {
69 for (var i = 0; i < featureSubscriptions.length; i++) 67 for (var i = 0; i < featureSubscriptions.length; i++)
70 { 68 {
71 var featureSubscription = featureSubscriptions[i]; 69 var featureSubscription = featureSubscriptions[i];
72 updateToggleButton(featureSubscription.feature, isSubscriptionEnabled( featureSubscription)); 70 updateToggleButton(featureSubscription.feature, isSubscriptionEnabled( featureSubscription));
73 } 71 }
74 } 72 }
75 } 73 }
76 FilterNotifier.addListener(filterListener); 74 FilterNotifier.addListener(filterListener);
77 window.addEventListener("unload", function(event) 75 window.addEventListener("unload", function(event)
78 { 76 {
79 FilterNotifier.removeListener(filterListener); 77 FilterNotifier.removeListener(filterListener);
80 }, false); 78 }, false);
81 79
82 window.addEventListener("resize", onWindowResize, false); 80 // you can click activate-feature or one of the icons to toggle the features area
Thomas Greiner 2013/08/07 14:17:54 Start comment with a capital letter.
83 document.addEventListener("scroll", onScroll, false); 81 E("activate-features").addEventListener("click", showFeature, false);
84 82 E("can-do-more-overview").addEventListener("click", showFeature, false);
85 onWindowResize();
86 83
87 initSocialLinks(); 84 initSocialLinks();
88 } 85 }
89 86
90 function onScroll() 87 function showFeature()
91 { 88 {
92 var currentHeight = document.documentElement.scrollTop + document.body.scrol lTop + document.documentElement.clientHeight; 89 var activateFeatures = E("activate-features");
93 shade.style.opacity = (document.documentElement.scrollHeight == currentHeigh t) ? "0.0" : "0.5"; 90 var canDoMoreOverview = E("can-do-more-overview");
94 } 91 var canDoMoreExpanded = E("can-do-more-expanded");
95 92 var activateFeaturesLabel = E("activate-features-label");
96 function onWindowResize() 93 var arrowLeft = E("arrow-left");
97 { 94 var arrowRight = E("arrow-right");
Thomas Greiner 2013/08/07 14:17:54 Instead of changing classes of all those elements
98 onScroll(); 95
99 } 96 if (activateFeatures.getAttribute("data-status") == "overview")
Thomas Greiner 2013/08/07 14:17:54 You should be able to get rid of the data-status a
100 97 {
101 function toggleTypoCorrectionEnabled() 98 canDoMoreOverview.classList.remove("opacity-one");
102 { 99 canDoMoreOverview.classList.add("opacity-zero");
103 Prefs.correctTypos = !Prefs.correctTypos; 100 arrowLeft.classList.remove("arrow-down");
101 arrowLeft.classList.add("arrow-up");
102 arrowRight.classList.remove("arrow-down");
103 arrowRight.classList.add("arrow-up");
104 activateFeaturesLabel.innerHTML = "show overview again";
Thomas Greiner 2013/08/07 14:17:54 Don't use innerHTML. Instead you can use innerText
105 activateFeatures.setAttribute("data-status","expanded");
106 setTimeout(function()
107 {
108 canDoMoreOverview.classList.add("display-none");
109 canDoMoreExpanded.classList.add("display-block");
110 canDoMoreExpanded.classList.add("can-do-more-expanded-higher");
111 },500);
112
113 /* Next timeout has to be done because of an js bug.
Thomas Greiner 2013/08/07 14:17:54 If it's a bug you should also add the URL to the b
114 * If you set "display: block" and "opacity: 1"
115 * at the same time the content would be shown
116 * directly without any transition.
117 * With the following timeout the opacity
118 * transition works correctly
119 */
120 setTimeout(function()
121 {
122 canDoMoreExpanded.classList.add("opacity-one");
123 },520);
124 }
125 else if (activateFeatures.getAttribute("data-status") == "expanded")
126 {
127 canDoMoreExpanded.classList.remove("opacity-one");
128 arrowLeft.classList.remove("arrow-up");
129 arrowLeft.classList.add("arrow-down");
130 arrowRight.classList.remove("arrow-up");
131 arrowRight.classList.add("arrow-down");
132 activateFeaturesLabel.innerHTML = "activate features";
Thomas Greiner 2013/08/07 14:17:54 Don't use innerHTML.
133 activateFeatures.setAttribute("data-status","overview");
134 setTimeout(function()
135 {
136 canDoMoreExpanded.classList.remove("display-block");
137 canDoMoreOverview.classList.remove("display-none");
138 },500);
139
140 setTimeout(function()
141 {
142 canDoMoreOverview.classList.add("opacity-one");
143 canDoMoreOverview.classList.remove("opacity-zero");
144 },520);
145 }
104 } 146 }
105 147
106 function isSubscriptionEnabled(featureSubscription) 148 function isSubscriptionEnabled(featureSubscription)
107 { 149 {
108 return featureSubscription.url in FilterStorage.knownSubscriptions 150 return featureSubscription.url in FilterStorage.knownSubscriptions
109 && !Subscription.fromURL(featureSubscription.url).disabled; 151 && !Subscription.fromURL(featureSubscription.url).disabled;
110 } 152 }
111 153
112 function setToggleSubscriptionButton(featureSubscription) 154 function setToggleSubscriptionButton(featureSubscription)
113 { 155 {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 { 260 {
219 event.preventDefault(); 261 event.preventDefault();
220 openSharePopup(Utils.getDocLink(event.target.id)); 262 openSharePopup(Utils.getDocLink(event.target.id));
221 } 263 }
222 } 264 }
223 265
224 function setLinks(id) 266 function setLinks(id)
225 { 267 {
226 var element = E(id); 268 var element = E(id);
227 if (!element) 269 if (!element)
270 {
228 return; 271 return;
229 272 }
273
230 var links = element.getElementsByTagName("a"); 274 var links = element.getElementsByTagName("a");
275
231 for (var i = 0; i < links.length; i++) 276 for (var i = 0; i < links.length; i++)
232 { 277 {
233 if (typeof arguments[i + 1] == "string") 278 if (typeof arguments[i + 1] == "string")
234 { 279 {
235 links[i].href = arguments[i + 1]; 280 links[i].href = arguments[i + 1];
236 links[i].setAttribute("target", "_blank"); 281 links[i].setAttribute("target", "_blank");
237 } 282 }
238 else if (typeof arguments[i + 1] == "function") 283 else if (typeof arguments[i + 1] == "function")
239 { 284 {
240 links[i].href = "javascript:void(0);"; 285 links[i].href = "javascript:void(0);";
(...skipping 16 matching lines...) Expand all
257 { 302 {
258 var button = E("toggle-" + feature); 303 var button = E("toggle-" + feature);
259 if (isEnabled) 304 if (isEnabled)
260 button.classList.remove("off"); 305 button.classList.remove("off");
261 else 306 else
262 button.classList.add("off"); 307 button.classList.add("off");
263 } 308 }
264 309
265 document.addEventListener("DOMContentLoaded", onDOMLoaded, false); 310 document.addEventListener("DOMContentLoaded", onDOMLoaded, false);
266 })(); 311 })();
OLDNEW

Powered by Google App Engine
This is Rietveld