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

Side by Side Diff: desktop-options.js

Issue 29578574: Issue 5632 - Use checkboxes for toggling acceptable ads (Closed)
Patch Set: Rebased Created Oct. 17, 2017, 3:59 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
« no previous file with comments | « desktop-options.html ('k') | locale/en_US/desktop-options.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 }, 646 },
647 () => 647 () =>
648 { 648 {
649 setCustomFiltersView("read"); 649 setCustomFiltersView("read");
650 }); 650 });
651 break; 651 break;
652 case "show-more-filters-section": 652 case "show-more-filters-section":
653 E("more-filters").setAttribute("aria-hidden", false); 653 E("more-filters").setAttribute("aria-hidden", false);
654 break; 654 break;
655 case "switch-acceptable-ads": 655 case "switch-acceptable-ads":
656 let isChecked = element.getAttribute("aria-checked") == "true";
656 let value = element.value || element.dataset.value; 657 let value = element.value || element.dataset.value;
658 let isAcceptableAds = value == "ads";
659
657 browser.runtime.sendMessage({ 660 browser.runtime.sendMessage({
658 type: value == "privacy" ? "subscriptions.add" : 661 type: isAcceptableAds != isChecked ? "subscriptions.add" :
659 "subscriptions.remove", 662 "subscriptions.remove",
660 url: acceptableAdsPrivacyUrl 663 url: acceptableAdsUrl
661 }); 664 });
662 browser.runtime.sendMessage({ 665 browser.runtime.sendMessage({
663 type: value == "ads" ? "subscriptions.add" : "subscriptions.remove", 666 type: isAcceptableAds || isChecked ? "subscriptions.remove" :
664 url: acceptableAdsUrl 667 "subscriptions.add",
668 url: acceptableAdsPrivacyUrl
665 }); 669 });
666 break; 670 break;
667 case "switch-tab": 671 case "switch-tab":
668 switchTab(element.getAttribute("href").substr(1)); 672 switchTab(element.getAttribute("href").substr(1));
669 break; 673 break;
670 case "toggle-disable-subscription": 674 case "toggle-disable-subscription":
671 browser.runtime.sendMessage({ 675 browser.runtime.sendMessage({
672 type: "subscriptions.toggle", 676 type: "subscriptions.toggle",
673 keepInstalled: true, 677 keepInstalled: true,
674 url: findParentData(element, "access", false) 678 url: findParentData(element, "access", false)
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 { 886 {
883 E("whitelisting-add-button").disabled = !e.target.value; 887 E("whitelisting-add-button").disabled = !e.target.value;
884 }, false); 888 }, false);
885 889
886 getDocLink("contribute", (link) => 890 getDocLink("contribute", (link) =>
887 { 891 {
888 E("contribute").href = link; 892 E("contribute").href = link;
889 }); 893 });
890 getDocLink("acceptable_ads_criteria", (link) => 894 getDocLink("acceptable_ads_criteria", (link) =>
891 { 895 {
892 setLinks("enable-aa-description", link); 896 setLinks("enable-acceptable-ads-description", link);
897 });
898 getDocLink("privacy_friendly_ads", (link) =>
899 {
900 setLinks("enable-acceptable-ads-privacy-description", link);
893 }); 901 });
894 getDocLink("adblock_plus_{browser}_dnt", url => 902 getDocLink("adblock_plus_{browser}_dnt", url =>
895 { 903 {
896 setLinks("dnt", url); 904 setLinks("dnt", url);
897 }); 905 });
898 906
899 // Advanced tab 907 // Advanced tab
900 let customize = document.querySelectorAll("#customize li[data-pref]"); 908 let customize = document.querySelectorAll("#customize li[data-pref]");
901 customize = Array.prototype.map.call(customize, (checkbox) => 909 customize = Array.prototype.map.call(customize, (checkbox) =>
902 { 910 {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 } 1035 }
1028 1036
1029 function hideNotification() 1037 function hideNotification()
1030 { 1038 {
1031 E("notification").setAttribute("aria-hidden", true); 1039 E("notification").setAttribute("aria-hidden", true);
1032 E("notification-text").textContent = ""; 1040 E("notification-text").textContent = "";
1033 } 1041 }
1034 1042
1035 function setAcceptableAds() 1043 function setAcceptableAds()
1036 { 1044 {
1037 let option = "none"; 1045 let acceptableAdsForm = E("acceptable-ads");
1038 document.forms["acceptable-ads"].classList.remove("show-dnt-notification"); 1046 let acceptableAds = E("acceptable-ads-allow");
1047 let acceptableAdsPrivacy = E("acceptable-ads-privacy-allow");
1048 acceptableAdsForm.classList.remove("show-dnt-notification");
1049 acceptableAds.setAttribute("aria-checked", false);
1050 acceptableAdsPrivacy.setAttribute("aria-checked", false);
1051 acceptableAdsPrivacy.disabled = true;
1039 if (acceptableAdsUrl in subscriptionsMap) 1052 if (acceptableAdsUrl in subscriptionsMap)
1040 { 1053 {
1041 option = "ads"; 1054 acceptableAds.setAttribute("aria-checked", true);
1055 acceptableAdsPrivacy.disabled = false;
1042 } 1056 }
1043 else if (acceptableAdsPrivacyUrl in subscriptionsMap) 1057 else if (acceptableAdsPrivacyUrl in subscriptionsMap)
1044 { 1058 {
1045 option = "privacy"; 1059 acceptableAds.setAttribute("aria-checked", true);
1060 acceptableAdsPrivacy.setAttribute("aria-checked", true);
1061 acceptableAdsPrivacy.disabled = false;
1046 1062
1047 if (!navigator.doNotTrack) 1063 if (navigator.doNotTrack != 1)
1048 document.forms["acceptable-ads"].classList.add("show-dnt-notification"); 1064 acceptableAdsForm.classList.add("show-dnt-notification");
1049 } 1065 }
1050 document.forms["acceptable-ads"]["acceptable-ads"].value = option;
1051 } 1066 }
1052 1067
1053 function isAcceptableAds(url) 1068 function isAcceptableAds(url)
1054 { 1069 {
1055 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl; 1070 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl;
1056 } 1071 }
1057 1072
1058 function populateLists() 1073 function populateLists()
1059 { 1074 {
1060 subscriptionsMap = Object.create(null); 1075 subscriptionsMap = Object.create(null);
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 }); 1395 });
1381 browser.runtime.sendMessage({ 1396 browser.runtime.sendMessage({
1382 type: "subscriptions.listen", 1397 type: "subscriptions.listen",
1383 filter: ["added", "disabled", "homepage", "lastDownload", "removed", 1398 filter: ["added", "disabled", "homepage", "lastDownload", "removed",
1384 "title", "downloadStatus", "downloading"] 1399 "title", "downloadStatus", "downloading"]
1385 }); 1400 });
1386 1401
1387 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 1402 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
1388 window.addEventListener("hashchange", onHashChange, false); 1403 window.addEventListener("hashchange", onHashChange, false);
1389 } 1404 }
OLDNEW
« no previous file with comments | « desktop-options.html ('k') | locale/en_US/desktop-options.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld