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

Unified 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.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: firstRun.js
===================================================================
--- a/firstRun.js
+++ b/firstRun.js
@@ -16,106 +16,42 @@
*/
/* globals checkShareResource, getDocLink, openSharePopup, setLinks, E */
Thomas Greiner 2018/02/16 16:19:14 Detail: We no longer use `checkShareResource()` an
"use strict";
(function()
{
- function onDOMLoaded()
- {
- // Set up logo image
- let logo = E("logo");
- logo.src = "skin/abp-128.png";
- let errorCallback = function()
- {
- logo.removeEventListener("error", errorCallback, false);
- // We are probably in Chrome/Opera/Safari, the image has a different path.
- logo.src = "icons/detailed/abp-128.png";
- };
- logo.addEventListener("error", errorCallback, false);
-
- // Set up URLs
- getDocLink("donate", (link) =>
- {
- E("donate").href = link;
- });
-
- getDocLink("contributors", (link) =>
- {
- E("contributors").href = link;
- });
-
- getDocLink("acceptable_ads_criteria", (link) =>
- {
- setLinks("acceptable-ads-explanation", link, openFilters);
- });
-
- getDocLink("contribute", (link) =>
- {
- setLinks("share-headline", link);
- });
-
- browser.runtime.sendMessage({
- type: "app.get",
- what: "issues"
- }, (issues) =>
- {
- // Show warning if filterlists settings were reinitialized
- if (issues.filterlistsReinitialized)
- {
- E("filterlistsReinitializedWarning").removeAttribute("hidden");
- setLinks("filterlistsReinitializedWarning", openFilters);
- }
- });
-
- updateSocialLinks();
-
- ext.onMessage.addListener((message) =>
- {
- if (message.type == "subscriptions.respond")
- {
- updateSocialLinks();
- }
- });
- browser.runtime.sendMessage({
- type: "subscriptions.listen",
- filter: ["added", "removed", "updated", "disabled"]
- });
- }
-
- function updateSocialLinks()
- {
- for (let network of ["twitter", "facebook", "gplus"])
- {
- let link = E("share-" + network);
- checkShareResource(link.getAttribute("data-script"), (isBlocked) =>
- {
- // Don't open the share page if the sharing script would be blocked
- if (isBlocked)
- link.removeEventListener("click", onSocialLinkClick, false);
- else
- link.addEventListener("click", onSocialLinkClick, false);
- });
- }
- }
-
- function onSocialLinkClick(event)
- {
- if (window.matchMedia("(max-width: 970px)").matches)
- return;
-
- event.preventDefault();
-
- getDocLink(event.target.id, (link) =>
- {
- openSharePopup(link);
- });
- }
-
function openFilters()
{
browser.runtime.sendMessage({type: "app.open", what: "options"});
}
+ function navigationClick(event)
+ {
+ 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
+ }
+
+ function initMenu()
+ {
+ document.getElementById("navbar-menu-toggle").addEventListener("click", navigationClick, 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"
+ }
+
+ function onDOMLoaded()
+ {
+ const optionsTrigger = E("options-trigger");
Thomas Greiner 2018/02/16 16:19:13 Coding style: "Use const for constant expressions
+
+ optionsTrigger.addEventListener("click", (e) =>
+ {
+ e.preventDefault();
+ openFilters();
+ });
+
+ 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
+ setLinks("third-column-description", "https://adblockplus.org/acceptable-ads#optout");
+ setLinks("copyright-notice", "https://eyeo.com");
+
+ initMenu();
+ }
+
document.addEventListener("DOMContentLoaded", onDOMLoaded, false);
}());

Powered by Google App Engine
This is Rietveld