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

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

Issue 11075001: Added fallback to first-run page for when social media buttons are blocked by filters (Closed)
Patch Set: Created June 27, 2013, 10:18 a.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') | no next file » | 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 window.addEventListener("unload", function(event) 99 window.addEventListener("unload", function(event)
100 { 100 {
101 FilterNotifier.removeListener(filterListener); 101 FilterNotifier.removeListener(filterListener);
102 }, false); 102 }, false);
103 103
104 window.addEventListener("resize", onWindowResize, false); 104 window.addEventListener("resize", onWindowResize, false);
105 document.addEventListener("scroll", onScroll, false); 105 document.addEventListener("scroll", onScroll, false);
106 106
107 onWindowResize(); 107 onWindowResize();
108 108
109 initSocialLinks(null); 109 initSocialLinks();
110 } 110 }
111 111
112 function onScroll() 112 function onScroll()
113 { 113 {
114 var currentHeight = document.documentElement.scrollTop + document.body.scrol lTop + document.documentElement.clientHeight; 114 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"; 115 shade.style.opacity = (document.documentElement.scrollHeight == currentHeigh t) ? "0.0" : "0.5";
116 } 116 }
117 117
118 function onWindowResize() 118 function onWindowResize()
119 { 119 {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 } 215 }
216 216
217 iframe.removeEventListener("load", popupLoadListener); 217 iframe.removeEventListener("load", popupLoadListener);
218 }; 218 };
219 iframe.addEventListener("load", popupLoadListener, false); 219 iframe.addEventListener("load", popupLoadListener, false);
220 220
221 iframe.src = url; 221 iframe.src = url;
222 glassPane.className = "visible"; 222 glassPane.className = "visible";
223 } 223 }
224 224
225 function initSocialLinks(variant) 225 function initSocialLinks()
226 { 226 {
227 var networks = ["twitter", "facebook", "gplus"]; 227 var networks = ["twitter", "facebook", "gplus"];
228 networks.forEach(function(network) 228 networks.forEach(function(network)
229 { 229 {
230 var link = E("share-" + network); 230 var link = E("share-" + network);
231 link.addEventListener("click", function(e) 231 link.addEventListener("click", onSocialLinkClick, false);
232 {
233 e.preventDefault();
234 openSharePopup(Utils.getDocLink("share-" + network) + "&variant=" + vari ant);
235 }, false);
236 }); 232 });
237 } 233 }
238 234
235 function onSocialLinkClick(event)
236 {
237 var filter = defaultMatcher.matchesAny("https://platform.twitter.com/widgets .js", "SCRIPT", "adblockplus.org", true);
238 if (!(filter instanceof BlockingFilter))
239 {
240 event.preventDefault();
241 openSharePopup(Utils.getDocLink(event.target.id));
242 }
243 }
244
239 function setLinks(id) 245 function setLinks(id)
240 { 246 {
241 var element = E(id); 247 var element = E(id);
242 if (!element) 248 if (!element)
243 return; 249 return;
244 250
245 var links = element.getElementsByTagName("a"); 251 var links = element.getElementsByTagName("a");
246 for (var i = 0; i < links.length; i++) 252 for (var i = 0; i < links.length; i++)
247 { 253 {
248 if (typeof arguments[i + 1] == "string") 254 if (typeof arguments[i + 1] == "string")
(...skipping 23 matching lines...) Expand all
272 { 278 {
273 var button = E("toggle-" + feature); 279 var button = E("toggle-" + feature);
274 if (isEnabled && button.classList.contains("off")) 280 if (isEnabled && button.classList.contains("off"))
275 button.classList.remove("off"); 281 button.classList.remove("off");
276 else if (!isEnabled && !button.classList.contains("off")) 282 else if (!isEnabled && !button.classList.contains("off"))
277 button.classList.add("off"); 283 button.classList.add("off");
278 } 284 }
279 285
280 document.addEventListener("DOMContentLoaded", onDOMLoaded, false); 286 document.addEventListener("DOMContentLoaded", onDOMLoaded, false);
281 })(); 287 })();
OLDNEW
« no previous file with comments | « chrome/content/ui/firstRun.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld