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

Delta Between Two Patch Sets: desktop-options.js

Issue 29683678: Issue 5542: Implement tooltips for new options page (Closed)
Left Patch Set: Created Feb. 5, 2018, 12:32 p.m.
Right Patch Set: cleaning up the patch Created Feb. 5, 2018, 12:35 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
« no previous file with change/comment | « desktop-options.html ('k') | skin/desktop-options.css » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 type + "_title"); 526 type + "_title");
527 } 527 }
528 528
529 addSubscription(subscription); 529 addSubscription(subscription);
530 } 530 }
531 }); 531 });
532 } 532 }
533 533
534 function findParentData(element, dataName, returnElement) 534 function findParentData(element, dataName, returnElement)
535 { 535 {
536 element = element.closest(`[data-${dataName}]`); 536 while (element)
537 if (!element) 537 {
538 return null; 538 if (element.hasAttribute("data-" + dataName))
539 if (returnElement) 539 {
540 return element; 540 if (returnElement)
541 return element.getAttribute(`data-${dataName}`); 541 return element;
542 return element.getAttribute("data-" + dataName);
543 }
544
545 element = element.parentElement;
546 }
547 return null;
542 } 548 }
543 549
544 function sendMessageHandleErrors(message, onSuccess) 550 function sendMessageHandleErrors(message, onSuccess)
545 { 551 {
546 browser.runtime.sendMessage(message, (errors) => 552 browser.runtime.sendMessage(message, (errors) =>
547 { 553 {
548 if (errors.length > 0) 554 if (errors.length > 0)
549 alert(errors.join("\n")); 555 alert(errors.join("\n"));
550 else if (onSuccess) 556 else if (onSuccess)
551 onSuccess(); 557 onSuccess();
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after
1388 1394
1389 let checkbox = document.querySelector( 1395 let checkbox = document.querySelector(
1390 "[data-pref='" + key + "'] button[role='checkbox']" 1396 "[data-pref='" + key + "'] button[role='checkbox']"
1391 ); 1397 );
1392 if (checkbox) 1398 if (checkbox)
1393 checkbox.setAttribute("aria-checked", value); 1399 checkbox.setAttribute("aria-checked", value);
1394 } 1400 }
1395 1401
1396 function updateTooltips() 1402 function updateTooltips()
1397 { 1403 {
1398 const anchors = document.querySelectorAll("[data-tooltip]"); 1404 const anchors = document.querySelectorAll("[data-tooltip]");
sergei 2018/02/19 10:18:42 I thought we don't use `const` in such cases, do w
a.giammarchi 2018/02/19 10:26:38 why not, if I might ask? `const` is used to guard
sergei 2018/02/19 10:44:45 Yep, I know what it is for but I got several times
a.giammarchi 2018/02/19 10:53:05 that's the second point though, the first one says
1399 for (const anchor of anchors) 1405 for (const anchor of anchors)
1400 { 1406 {
1401 let id = anchor.getAttribute("data-tooltip"); 1407 let id = anchor.getAttribute("data-tooltip");
1402 1408
1403 // instead of replacing the whole node 1409 // instead of replacing the whole node
1404 // just make it non discoverable for 1410 // just make it non discoverable for
1405 // the next updateTooltips call 1411 // the next updateTooltips call
1406 anchor.removeAttribute("data-tooltip"); 1412 anchor.removeAttribute("data-tooltip");
1407 anchor.classList.add("icon", "tooltip"); 1413 anchor.classList.add("icon", "tooltip");
1408 1414
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 }); 1484 });
1479 browser.runtime.sendMessage({ 1485 browser.runtime.sendMessage({
1480 type: "subscriptions.listen", 1486 type: "subscriptions.listen",
1481 filter: ["added", "disabled", "homepage", "lastDownload", "removed", 1487 filter: ["added", "disabled", "homepage", "lastDownload", "removed",
1482 "title", "downloadStatus", "downloading"] 1488 "title", "downloadStatus", "downloading"]
1483 }); 1489 });
1484 1490
1485 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 1491 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
1486 window.addEventListener("hashchange", onHashChange, false); 1492 window.addEventListener("hashchange", onHashChange, false);
1487 } 1493 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld