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

Side by Side Diff: firstRun.js

Issue 29565721: No Issue - Implemented first run page Base URL: https://hg.adblockplus.org/adblockplusui/
Patch Set: Addressed latest round of feedback Created Jan. 30, 2018, 2:06 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 <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present 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 /* globals checkShareResource, getDocLink, openSharePopup, setLinks, E */ 18 /* globals checkShareResource, getDocLink, openSharePopup, setLinks, E */
Thomas Greiner 2018/02/16 16:19:14 Detail: We no longer use `checkShareResource()` an
19 19
20 "use strict"; 20 "use strict";
21 21
22 (function() 22 (function()
23 { 23 {
24 function onDOMLoaded()
25 {
26 // Set up logo image
27 let logo = E("logo");
28 logo.src = "skin/abp-128.png";
29 let errorCallback = function()
30 {
31 logo.removeEventListener("error", errorCallback, false);
32 // We are probably in Chrome/Opera/Safari, the image has a different path.
33 logo.src = "icons/detailed/abp-128.png";
34 };
35 logo.addEventListener("error", errorCallback, false);
36
37 // Set up URLs
38 getDocLink("donate", (link) =>
39 {
40 E("donate").href = link;
41 });
42
43 getDocLink("contributors", (link) =>
44 {
45 E("contributors").href = link;
46 });
47
48 getDocLink("acceptable_ads_criteria", (link) =>
49 {
50 setLinks("acceptable-ads-explanation", link, openFilters);
51 });
52
53 getDocLink("contribute", (link) =>
54 {
55 setLinks("share-headline", link);
56 });
57
58 browser.runtime.sendMessage({
59 type: "app.get",
60 what: "issues"
61 }, (issues) =>
62 {
63 // Show warning if filterlists settings were reinitialized
64 if (issues.filterlistsReinitialized)
65 {
66 E("filterlistsReinitializedWarning").removeAttribute("hidden");
67 setLinks("filterlistsReinitializedWarning", openFilters);
68 }
69 });
70
71 updateSocialLinks();
72
73 ext.onMessage.addListener((message) =>
74 {
75 if (message.type == "subscriptions.respond")
76 {
77 updateSocialLinks();
78 }
79 });
80 browser.runtime.sendMessage({
81 type: "subscriptions.listen",
82 filter: ["added", "removed", "updated", "disabled"]
83 });
84 }
85
86 function updateSocialLinks()
87 {
88 for (let network of ["twitter", "facebook", "gplus"])
89 {
90 let link = E("share-" + network);
91 checkShareResource(link.getAttribute("data-script"), (isBlocked) =>
92 {
93 // Don't open the share page if the sharing script would be blocked
94 if (isBlocked)
95 link.removeEventListener("click", onSocialLinkClick, false);
96 else
97 link.addEventListener("click", onSocialLinkClick, false);
98 });
99 }
100 }
101
102 function onSocialLinkClick(event)
103 {
104 if (window.matchMedia("(max-width: 970px)").matches)
105 return;
106
107 event.preventDefault();
108
109 getDocLink(event.target.id, (link) =>
110 {
111 openSharePopup(link);
112 });
113 }
114
115 function openFilters() 24 function openFilters()
116 { 25 {
117 browser.runtime.sendMessage({type: "app.open", what: "options"}); 26 browser.runtime.sendMessage({type: "app.open", what: "options"});
118 } 27 }
119 28
29 function navigationClick(event)
30 {
31 document.getElementById("navbar-menu").classList.toggle("visible");
Thomas Greiner 2018/02/16 16:19:12 Detail: I don't mind using either `E()` or `docume
32 }
33
34 function initMenu()
35 {
36 document.getElementById("navbar-menu-toggle").addEventListener("click", navi gationClick, false);
Thomas Greiner 2018/02/16 16:19:11 Detail: The third function argument parameter is r
Thomas Greiner 2018/02/16 16:19:14 Coding style: "Line length: 80 characters or less"
37 }
38
39 function onDOMLoaded()
40 {
41 const optionsTrigger = E("options-trigger");
Thomas Greiner 2018/02/16 16:19:13 Coding style: "Use const for constant expressions
42
43 optionsTrigger.addEventListener("click", (e) =>
44 {
45 e.preventDefault();
46 openFilters();
47 });
48
49 setLinks("first-column-description", " https://adblockplus.org/terms");
Thomas Greiner 2018/02/16 16:19:13 As done with the Updates page, don't hardcode any
50 setLinks("third-column-description", "https://adblockplus.org/acceptable-ads #optout");
51 setLinks("copyright-notice", "https://eyeo.com");
52
53 initMenu();
54 }
55
120 document.addEventListener("DOMContentLoaded", onDOMLoaded, false); 56 document.addEventListener("DOMContentLoaded", onDOMLoaded, false);
121 }()); 57 }());
OLDNEW

Powered by Google App Engine
This is Rietveld