Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
648 removeExisting: true | 648 removeExisting: true |
649 }, | 649 }, |
650 () => | 650 () => |
651 { | 651 { |
652 setCustomFiltersView("read"); | 652 setCustomFiltersView("read"); |
653 }); | 653 }); |
654 break; | 654 break; |
655 case "show-more-filters-section": | 655 case "show-more-filters-section": |
656 E("more-filters").setAttribute("aria-hidden", false); | 656 E("more-filters").setAttribute("aria-hidden", false); |
657 break; | 657 break; |
658 case "switch-acceptable-ads": { | 658 case "switch-acceptable-ads": |
659 let isChecked = element.getAttribute("aria-checked") == "true"; | |
660 let value = element.value || element.dataset.value; | 659 let value = element.value || element.dataset.value; |
661 let isAcceptableAds = value == "ads"; | 660 // User check the checkbox |
661 let shouldCheck = element.getAttribute("aria-checked") != "true"; | |
662 let installAcceptableAds = false; | |
663 let installAcceptableAdsPrivacy = false; | |
664 // Acceptable Ads checkbox clicked | |
665 if (value == "ads") | |
666 { | |
667 installAcceptableAds = shouldCheck; | |
668 } | |
669 // Privacy Friendly Acceptable Ads checkbox clicked | |
670 else | |
671 { | |
672 installAcceptableAdsPrivacy = shouldCheck; | |
673 installAcceptableAds = !shouldCheck; | |
674 } | |
662 | 675 |
663 browser.runtime.sendMessage({ | 676 browser.runtime.sendMessage({ |
664 type: isAcceptableAds != isChecked ? "subscriptions.add" : | 677 type: installAcceptableAds ? "subscriptions.add" : |
665 "subscriptions.remove", | 678 "subscriptions.remove", |
666 url: acceptableAdsUrl | 679 url: acceptableAdsUrl |
667 }); | 680 }); |
668 browser.runtime.sendMessage({ | 681 browser.runtime.sendMessage({ |
669 type: isAcceptableAds || isChecked ? "subscriptions.remove" : | 682 type: installAcceptableAdsPrivacy ? "subscriptions.add" : |
670 "subscriptions.add", | 683 "subscriptions.remove", |
671 url: acceptableAdsPrivacyUrl | 684 url: acceptableAdsPrivacyUrl |
672 }); | 685 }); |
673 break; | 686 break; |
674 } | |
675 case "switch-tab": | 687 case "switch-tab": |
676 switchTab(element.getAttribute("href").substr(1)); | 688 switchTab(element.getAttribute("href").substr(1)); |
677 break; | 689 break; |
678 case "toggle-disable-subscription": | 690 case "toggle-disable-subscription": |
679 browser.runtime.sendMessage({ | 691 browser.runtime.sendMessage({ |
680 type: "subscriptions.toggle", | 692 type: "subscriptions.toggle", |
681 keepInstalled: true, | 693 keepInstalled: true, |
682 url: findParentData(element, "access", false) | 694 url: findParentData(element, "access", false) |
683 }); | 695 }); |
684 break; | 696 break; |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1045 } | 1057 } |
1046 | 1058 |
1047 function setAcceptableAds() | 1059 function setAcceptableAds() |
1048 { | 1060 { |
1049 let acceptableAdsForm = E("acceptable-ads"); | 1061 let acceptableAdsForm = E("acceptable-ads"); |
1050 let acceptableAds = E("acceptable-ads-allow"); | 1062 let acceptableAds = E("acceptable-ads-allow"); |
1051 let acceptableAdsPrivacy = E("acceptable-ads-privacy-allow"); | 1063 let acceptableAdsPrivacy = E("acceptable-ads-privacy-allow"); |
1052 acceptableAdsForm.classList.remove("show-dnt-notification"); | 1064 acceptableAdsForm.classList.remove("show-dnt-notification"); |
1053 acceptableAds.setAttribute("aria-checked", false); | 1065 acceptableAds.setAttribute("aria-checked", false); |
1054 acceptableAdsPrivacy.setAttribute("aria-checked", false); | 1066 acceptableAdsPrivacy.setAttribute("aria-checked", false); |
1067 acceptableAdsPrivacy.setAttribute("tabindex", 0); | |
1055 if (acceptableAdsUrl in subscriptionsMap) | 1068 if (acceptableAdsUrl in subscriptionsMap) |
1056 { | 1069 { |
1057 acceptableAds.setAttribute("aria-checked", true); | 1070 acceptableAds.setAttribute("aria-checked", true); |
1058 acceptableAdsPrivacy.setAttribute("aria-disabled", false); | 1071 acceptableAdsPrivacy.setAttribute("aria-disabled", false); |
1059 } | 1072 } |
1060 else if (acceptableAdsPrivacyUrl in subscriptionsMap) | 1073 else if (acceptableAdsPrivacyUrl in subscriptionsMap) |
1061 { | 1074 { |
1062 acceptableAds.setAttribute("aria-checked", true); | 1075 acceptableAds.setAttribute("aria-checked", true); |
1063 acceptableAdsPrivacy.setAttribute("aria-checked", true); | 1076 acceptableAdsPrivacy.setAttribute("aria-checked", true); |
1064 acceptableAdsPrivacy.setAttribute("aria-disabled", false); | 1077 acceptableAdsPrivacy.setAttribute("aria-disabled", false); |
1065 | 1078 |
1066 if (navigator.doNotTrack != 1) | 1079 if (navigator.doNotTrack != 1) |
1067 acceptableAdsForm.classList.add("show-dnt-notification"); | 1080 acceptableAdsForm.classList.add("show-dnt-notification"); |
1068 } | 1081 } |
1069 else | 1082 else |
1070 { | 1083 { |
1071 // Using aria-disabled in order to keep the focus | 1084 // Using aria-disabled in order to keep the focus |
1072 acceptableAdsPrivacy.setAttribute("aria-disabled", true); | 1085 acceptableAdsPrivacy.setAttribute("aria-disabled", true); |
ire
2017/10/18 17:48:45
This is a fine compromise. We should also set the
saroyanm
2017/10/19 20:41:56
Good point, done.
| |
1086 acceptableAdsPrivacy.setAttribute("tabindex", -1); | |
1073 } | 1087 } |
1074 } | 1088 } |
1075 | 1089 |
1076 function isAcceptableAds(url) | 1090 function isAcceptableAds(url) |
1077 { | 1091 { |
1078 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl; | 1092 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl; |
1079 } | 1093 } |
1080 | 1094 |
1081 function populateLists() | 1095 function populateLists() |
1082 { | 1096 { |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1403 }); | 1417 }); |
1404 browser.runtime.sendMessage({ | 1418 browser.runtime.sendMessage({ |
1405 type: "subscriptions.listen", | 1419 type: "subscriptions.listen", |
1406 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1420 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
1407 "title", "downloadStatus", "downloading"] | 1421 "title", "downloadStatus", "downloading"] |
1408 }); | 1422 }); |
1409 | 1423 |
1410 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1424 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
1411 window.addEventListener("hashchange", onHashChange, false); | 1425 window.addEventListener("hashchange", onHashChange, false); |
1412 } | 1426 } |
LEFT | RIGHT |