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: Addressed Ire's comments Created Oct. 17, 2017, 7:20 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 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 removeExisting: true 645 removeExisting: true
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",
663 url: acceptableAdsUrl
664 });
665 browser.runtime.sendMessage({
666 type: isAcceptableAds || isChecked ? "subscriptions.remove" :
667 "subscriptions.add",
660 url: acceptableAdsPrivacyUrl 668 url: acceptableAdsPrivacyUrl
661 }); 669 });
662 browser.runtime.sendMessage({
663 type: value == "ads" ? "subscriptions.add" : "subscriptions.remove",
664 url: acceptableAdsUrl
665 });
666 break; 670 break;
671 }
667 case "switch-tab": 672 case "switch-tab":
668 switchTab(element.getAttribute("href").substr(1)); 673 switchTab(element.getAttribute("href").substr(1));
669 break; 674 break;
670 case "toggle-disable-subscription": 675 case "toggle-disable-subscription":
671 browser.runtime.sendMessage({ 676 browser.runtime.sendMessage({
672 type: "subscriptions.toggle", 677 type: "subscriptions.toggle",
673 keepInstalled: true, 678 keepInstalled: true,
674 url: findParentData(element, "access", false) 679 url: findParentData(element, "access", false)
675 }); 680 });
676 break; 681 break;
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 { 887 {
883 E("whitelisting-add-button").disabled = !e.target.value; 888 E("whitelisting-add-button").disabled = !e.target.value;
884 }, false); 889 }, false);
885 890
886 getDocLink("contribute", (link) => 891 getDocLink("contribute", (link) =>
887 { 892 {
888 E("contribute").href = link; 893 E("contribute").href = link;
889 }); 894 });
890 getDocLink("acceptable_ads_criteria", (link) => 895 getDocLink("acceptable_ads_criteria", (link) =>
891 { 896 {
892 setLinks("enable-aa-description", link); 897 setLinks("enable-acceptable-ads-description", link);
898 });
899 getDocLink("privacy_friendly_ads", (link) =>
900 {
901 setLinks("enable-acceptable-ads-privacy-description", link);
893 }); 902 });
894 getDocLink("adblock_plus_{browser}_dnt", url => 903 getDocLink("adblock_plus_{browser}_dnt", url =>
895 { 904 {
896 setLinks("dnt", url); 905 setLinks("dnt", url);
897 }); 906 });
898 907
899 // Advanced tab 908 // Advanced tab
900 let customize = document.querySelectorAll("#customize li[data-pref]"); 909 let customize = document.querySelectorAll("#customize li[data-pref]");
901 customize = Array.prototype.map.call(customize, (checkbox) => 910 customize = Array.prototype.map.call(customize, (checkbox) =>
902 { 911 {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 } 1036 }
1028 1037
1029 function hideNotification() 1038 function hideNotification()
1030 { 1039 {
1031 E("notification").setAttribute("aria-hidden", true); 1040 E("notification").setAttribute("aria-hidden", true);
1032 E("notification-text").textContent = ""; 1041 E("notification-text").textContent = "";
1033 } 1042 }
1034 1043
1035 function setAcceptableAds() 1044 function setAcceptableAds()
1036 { 1045 {
1037 let option = "none"; 1046 let acceptableAdsForm = E("acceptable-ads");
1038 document.forms["acceptable-ads"].classList.remove("show-dnt-notification"); 1047 let acceptableAds = E("acceptable-ads-allow");
1048 let acceptableAdsPrivacy = E("acceptable-ads-privacy-allow");
1049 acceptableAdsForm.classList.remove("show-dnt-notification");
1050 acceptableAds.setAttribute("aria-checked", false);
1051 acceptableAdsPrivacy.setAttribute("aria-checked", false);
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; 1066 else
1067 {
1068 acceptableAdsPrivacy.disabled = true;
1069 }
1051 } 1070 }
1052 1071
1053 function isAcceptableAds(url) 1072 function isAcceptableAds(url)
1054 { 1073 {
1055 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl; 1074 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl;
1056 } 1075 }
1057 1076
1058 function populateLists() 1077 function populateLists()
1059 { 1078 {
1060 subscriptionsMap = Object.create(null); 1079 subscriptionsMap = Object.create(null);
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 }); 1399 });
1381 browser.runtime.sendMessage({ 1400 browser.runtime.sendMessage({
1382 type: "subscriptions.listen", 1401 type: "subscriptions.listen",
1383 filter: ["added", "disabled", "homepage", "lastDownload", "removed", 1402 filter: ["added", "disabled", "homepage", "lastDownload", "removed",
1384 "title", "downloadStatus", "downloading"] 1403 "title", "downloadStatus", "downloading"]
1385 }); 1404 });
1386 1405
1387 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 1406 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
1388 window.addEventListener("hashchange", onHashChange, false); 1407 window.addEventListener("hashchange", onHashChange, false);
1389 } 1408 }
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