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

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

Issue 10860047: New toggle button on First-run page (Closed)
Patch Set: Created June 7, 2013, 12:19 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
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 featureSubscriptions.forEach(setToggleSubscriptionButton); 86 featureSubscriptions.forEach(setToggleSubscriptionButton);
87 var filterListener = function(action) 87 var filterListener = function(action)
88 { 88 {
89 if (/^subscription\.(added|removed|disabled)$/.test(action)) 89 if (/^subscription\.(added|removed|disabled)$/.test(action))
90 { 90 {
91 for (var i = 0; i < featureSubscriptions.length; i++) 91 for (var i = 0; i < featureSubscriptions.length; i++)
92 { 92 {
93 var featureSubscription = featureSubscriptions[i]; 93 var featureSubscription = featureSubscriptions[i];
94 updateToggleButton(featureSubscription.feature, isSubscriptionEnabled( featureSubscription)); 94 updateToggleButton(featureSubscription.feature, isSubscriptionEnabled( featureSubscription));
95 } 95 }
96
97 setSocialLinks();
96 } 98 }
97 } 99 }
98 FilterNotifier.addListener(filterListener); 100 FilterNotifier.addListener(filterListener);
99 window.addEventListener("unload", function(event) 101 window.addEventListener("unload", function(event)
100 { 102 {
101 FilterNotifier.removeListener(filterListener); 103 FilterNotifier.removeListener(filterListener);
102 }, false); 104 }, false);
103 105
104 window.addEventListener("resize", onWindowResize, false); 106 window.addEventListener("resize", onWindowResize, false);
105 document.addEventListener("scroll", onScroll, false); 107 document.addEventListener("scroll", onScroll, false);
106 108
107 onWindowResize(); 109 onWindowResize();
108 110
109 initSocialLinks(null); 111 setSocialLinks();
110 } 112 }
111 113
112 function onScroll() 114 function onScroll()
113 { 115 {
114 var currentHeight = document.documentElement.scrollTop + document.body.scrol lTop + document.documentElement.clientHeight; 116 var currentHeight = document.documentElement.scrollTop + document.body.scrol lTop + document.documentElement.clientHeight;
115 shade.style.opacity = (document.documentElement.scrollHeight == currentHeigh t) ? "0.0" : "0.5"; 117 shade.style.opacity = (document.documentElement.scrollHeight == currentHeigh t) ? "0.0" : "0.5";
116 } 118 }
117 119
118 function onWindowResize() 120 function onWindowResize()
119 { 121 {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 } 217 }
216 218
217 iframe.removeEventListener("load", popupLoadListener); 219 iframe.removeEventListener("load", popupLoadListener);
218 }; 220 };
219 iframe.addEventListener("load", popupLoadListener, false); 221 iframe.addEventListener("load", popupLoadListener, false);
220 222
221 iframe.src = url; 223 iframe.src = url;
222 glassPane.className = "visible"; 224 glassPane.className = "visible";
223 } 225 }
224 226
225 function initSocialLinks(variant) 227 function setSocialLinks()
226 { 228 {
229 var isSocialFeatureEnabled = false;
230 for (var i = 0; i < featureSubscriptions.length; i++)
231 {
232 if (featureSubscriptions[i].feature == "social")
233 {
234 isSocialFeatureEnabled = isSubscriptionEnabled(featureSubscriptions[i]);
235 break;
236 }
237 }
238
227 var networks = ["twitter", "facebook", "gplus"]; 239 var networks = ["twitter", "facebook", "gplus"];
228 networks.forEach(function(network) 240 networks.forEach(function(network)
229 { 241 {
230 var link = E("share-" + network); 242 var link = E("share-" + network);
231 link.addEventListener("click", function(e) 243 if (isSocialFeatureEnabled)
232 { 244 link.removeEventListener("click", onSocialLinkClick, false);
233 e.preventDefault(); 245 else
234 openSharePopup(Utils.getDocLink("share-" + network) + "&variant=" + vari ant); 246 link.addEventListener("click", onSocialLinkClick, false);
235 }, false);
236 }); 247 });
237 } 248 }
238 249
250 function onSocialLinkClick(e)
251 {
252 e.preventDefault();
253 openSharePopup(Utils.getDocLink(e.target.id));
254 }
255
239 function setLinks(id) 256 function setLinks(id)
240 { 257 {
241 var element = E(id); 258 var element = E(id);
242 if (!element) 259 if (!element)
243 return; 260 return;
244 261
245 var links = element.getElementsByTagName("a"); 262 var links = element.getElementsByTagName("a");
246 for (var i = 0; i < links.length; i++) 263 for (var i = 0; i < links.length; i++)
247 { 264 {
248 if (typeof arguments[i + 1] == "string") 265 if (typeof arguments[i + 1] == "string")
(...skipping 15 matching lines...) Expand all
264 UI.openFiltersDialog(); 281 UI.openFiltersDialog();
265 else 282 else
266 { 283 {
267 backgroundPage.openOptions(); 284 backgroundPage.openOptions();
268 } 285 }
269 } 286 }
270 287
271 function updateToggleButton(feature, isEnabled) 288 function updateToggleButton(feature, isEnabled)
272 { 289 {
273 var button = E("toggle-" + feature); 290 var button = E("toggle-" + feature);
274 button.className = isEnabled ? "disable" : "enable"; 291 if (isEnabled)
275 button.textContent = i18n.getMessage(isEnabled ? "firstRun_action_disable" : "firstRun_action_enable"); 292 button.className = button.className.replace("enable", "disable");
293 else
294 button.className = button.className.replace("disable", "enable");
Wladimir Palant 2013/06/07 14:00:04 Frankly, one class name should be sufficient here:
276 } 295 }
277 296
278 document.addEventListener("DOMContentLoaded", onDOMLoaded, false); 297 document.addEventListener("DOMContentLoaded", onDOMLoaded, false);
279 })(); 298 })();
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