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

Delta Between Two Patch Sets: chrome/content/ui/firstRun.js

Issue 11039060: first run page redesign (Closed)
Left Patch Set: new share part, transition changed with own method Created Aug. 6, 2013, 3:57 p.m.
Right Patch Set: improve after wladimirs code review Created Oct. 4, 2013, 4:50 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
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
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
53 var contributors = E("contributors");
54 contributors.href = Utils.getDocLink("contributors");
55
56 setLinks("acceptableAdsExplanation", Utils.getDocLink("acceptable_ads_criter ia"), openFilters);
49 setLinks("share-headline", Utils.getDocLink("contribute")); 57 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 58
51 // Show warning if data corruption was detected 59 // Show warning if data corruption was detected
52 if (typeof backgroundPage != "undefined" && backgroundPage.seenDataCorruptio n) 60 if (typeof backgroundPage != "undefined" && backgroundPage.seenDataCorruptio n)
53 { 61 {
54 E("dataCorruptionWarning").removeAttribute("hidden"); 62 E("dataCorruptionWarning").removeAttribute("hidden");
55 setLinks("dataCorruptionWarning", Utils.getDocLink("knownIssuesChrome_filt erstorage")); 63 setLinks("dataCorruptionWarning", Utils.getDocLink("knownIssuesChrome_filt erstorage"));
56 } 64 }
57
58 // Set up URL
59 setLinks("acceptableAdsExplanation", Utils.getDocLink("acceptable_ads_criter ia"), openFilters);
60 65
61 // Set up feature buttons linked to subscriptions 66 // Set up feature buttons linked to subscriptions
62 featureSubscriptions.forEach(setToggleSubscriptionButton); 67 featureSubscriptions.forEach(setToggleSubscriptionButton);
63 var filterListener = function(action) 68 var filterListener = function(action)
64 { 69 {
65 if (/^subscription\.(added|removed|disabled)$/.test(action)) 70 if (/^subscription\.(added|removed|disabled)$/.test(action))
66 { 71 {
67 for (var i = 0; i < featureSubscriptions.length; i++) 72 for (var i = 0; i < featureSubscriptions.length; i++)
68 { 73 {
69 var featureSubscription = featureSubscriptions[i]; 74 var featureSubscription = featureSubscriptions[i];
70 updateToggleButton(featureSubscription.feature, isSubscriptionEnabled( featureSubscription)); 75 updateToggleButton(featureSubscription.feature, isSubscriptionEnabled( featureSubscription));
71 } 76 }
72 } 77 }
73 } 78 }
74 FilterNotifier.addListener(filterListener); 79 FilterNotifier.addListener(filterListener);
75 window.addEventListener("unload", function(event) 80 window.addEventListener("unload", function(event)
76 { 81 {
77 FilterNotifier.removeListener(filterListener); 82 FilterNotifier.removeListener(filterListener);
78 }, false); 83 }, false);
79 84
80 // 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
Thomas Greiner 2013/08/07 14:17:54 Start comment with a capital letter.
81 E("activate-features").addEventListener("click", showFeature, false); 86 E("activate-features").addEventListener("click", toggleFeature, false);
82 E("can-do-more-overview").addEventListener("click", showFeature, false); 87 E("can-do-more-overview").addEventListener("click", toggleFeature, false);
83 88
84 initSocialLinks(); 89 initSocialLinks();
85 } 90 }
86 91
87 function showFeature() 92 function toggleFeature()
88 { 93 {
89 var activateFeatures = E("activate-features"); 94 var canDoMore = E("can-do-more");
90 var canDoMoreOverview = E("can-do-more-overview"); 95 if (!canDoMore.classList.contains("expanded"))
91 var canDoMoreExpanded = E("can-do-more-expanded"); 96 {
92 var activateFeaturesLabel = E("activate-features-label"); 97 canDoMore.classList.add("expanded");
93 var arrowLeft = E("arrow-left"); 98 }
94 var arrowRight = E("arrow-right"); 99 else if (canDoMore.classList.contains("expanded"))
Thomas Greiner 2013/08/07 14:17:54 Instead of changing classes of all those elements
95 100 {
96 if (activateFeatures.getAttribute("data-status") == "overview") 101 canDoMore.classList.remove("expanded");
Thomas Greiner 2013/08/07 14:17:54 You should be able to get rid of the data-status a
97 {
98 canDoMoreOverview.classList.remove("opacity-one");
99 canDoMoreOverview.classList.add("opacity-zero");
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 } 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
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 })();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld