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: Created Oct. 5, 2017, 1:47 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 */
19 19
20 "use strict"; 20 "use strict";
21 21
22 (function() 22 (function()
23 { 23 {
24 function onDOMLoaded() 24 function onDOMLoaded()
25 { 25 {
26 // Set up logo image 26
27 let logo = E("logo"); 27 const optionsTrigger = E("options-trigger");
28 logo.src = "skin/abp-128.png"; 28
29 let errorCallback = function() 29 optionsTrigger.addEventListener("click", (e) =>
30 { 30 {
31 logo.removeEventListener("error", errorCallback, false); 31 e.preventDefault();
32 // We are probably in Chrome/Opera/Safari, the image has a different path. 32 openFilters();
33 logo.src = "icons/detailed/abp-128.png"; 33 })
34 };
35 logo.addEventListener("error", errorCallback, false);
36 34
37 // Set up URLs 35 setLinks("first-column-description", " https://adblockplus.org/terms");
38 getDocLink("donate", (link) => 36 setLinks("third-column-description", "https://adblockplus.org/acceptable-ads #optout");
39 {
40 E("donate").href = link;
41 });
42 37
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 ext.backgroundPage.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 ext.backgroundPage.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 } 38 }
114 39
115 function openFilters() 40 function openFilters()
116 { 41 {
117 ext.backgroundPage.sendMessage({type: "app.open", what: "options"}); 42 ext.backgroundPage.sendMessage({type: "app.open", what: "options"});
118 } 43 }
119 44
120 document.addEventListener("DOMContentLoaded", onDOMLoaded, false); 45 document.addEventListener("DOMContentLoaded", onDOMLoaded, false);
121 }()); 46 }());
OLDNEW

Powered by Google App Engine
This is Rietveld