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

Delta Between Two Patch Sets: firstRun.js

Issue 29565721: No Issue - Implemented first run page Base URL: https://hg.adblockplus.org/adblockplusui/
Left Patch Set: Addressed newest round of feedback Created Oct. 20, 2017, 2:43 p.m.
Right 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
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 */
juliandoucette 2017/10/21 16:18:43 @greiner, @saroyanm "[Deprecation] Synchronous XM
Thomas Greiner 2017/10/23 12:01:55 No, this issue only applies to the development env
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 openFilters()
25 {
26 browser.runtime.sendMessage({type: "app.open", what: "options"});
27 }
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
24 function onDOMLoaded() 39 function onDOMLoaded()
25 { 40 {
26 function initLanguageSelection()
27 {
28 const locale = document.getElementById("navbar-locale-selected");
29 // skip if page does not have language selection (EG: blog)
30 if (!locale)
31 return;
32
33 locale.onclick = function()
34 {
35 toggleClass(document.getElementById("navbar-locale-menu"), "visible");
36 };
37 }
38
39 function navigationClick(event)
40 {
41 toggleClass(document.getElementById("navbar-menu"), "visible");
42 }
43
44 function initMenu()
45 {
46 document.getElementById("navbar-menu-toggle").onclick = navigationClick;
47 }
48
49 function toggleClass(element, className)
Thomas Greiner 2017/10/23 13:17:43 We've already been using `Element.classList` in ot
juliandoucette 2017/10/23 13:27:35 He copied this from abp.org main.js. It's unclear
juliandoucette 2017/10/23 13:29:58 (On that note, we could polyfill classList and ref
Thomas Greiner 2017/10/23 16:45:49 From what I see, if we remove the language selecti
juliandoucette 2017/10/24 14:22:18 See https://codereview.adblockplus.org/29587659
martin 2017/10/26 10:33:16 Done.
50 {
51 if (hasClass(element, className))
52 removeClass(element, className);
53 else
54 addClass(element, className);
55 }
56
57 function hasClass(element, className)
58 {
59 return !!element.className.match("\\b" + escapeRegExp(className) + "\\b");
60 }
61
62 function addClass(element, className)
63 {
64 if (hasClass(element, className))
65 return;
66
67 if (element.className.length)
68 element.className += " ";
69 element.className += className;
70 }
71
72 function removeClass(element, className)
73 {
74 const regExp = new RegExp("\\s*\\b" + escapeRegExp(className) + "\\b\\s*") ;
75 element.className = element.className.replace(regExp, "");
76 }
77
78 function escapeRegExp(string)
79 {
80 return string.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
81 }
82
83 initLanguageSelection();
84 initMenu();
85
86 const optionsTrigger = E("options-trigger"); 41 const optionsTrigger = E("options-trigger");
Thomas Greiner 2018/02/16 16:19:13 Coding style: "Use const for constant expressions
87 42
88 optionsTrigger.addEventListener("click", (e) => 43 optionsTrigger.addEventListener("click", (e) =>
89 { 44 {
90 e.preventDefault(); 45 e.preventDefault();
91 openFilters(); 46 openFilters();
92 }); 47 });
93 48
94 setLinks("first-column-description", " https://adblockplus.org/terms"); 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
95 setLinks("third-column-description", "https://adblockplus.org/acceptable-ads #optout"); 50 setLinks("third-column-description", "https://adblockplus.org/acceptable-ads #optout");
96 setLinks("copyright-notice", "https://eyeo.com"); 51 setLinks("copyright-notice", "https://eyeo.com");
97 }
98 52
99 function openFilters() 53 initMenu();
100 {
101 browser.runtime.sendMessage({type: "app.open", what: "options"});
102 } 54 }
103 55
104 document.addEventListener("DOMContentLoaded", onDOMLoaded, false); 56 document.addEventListener("DOMContentLoaded", onDOMLoaded, false);
105 }()); 57 }());
LEFTRIGHT

Powered by Google App Engine
This is Rietveld