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 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 }); | 552 }); |
553 } | 553 } |
554 | 554 |
555 function switchTab(id) | 555 function switchTab(id) |
556 { | 556 { |
557 location.hash = id; | 557 location.hash = id; |
558 } | 558 } |
559 | 559 |
560 function execAction(action, element) | 560 function execAction(action, element) |
561 { | 561 { |
| 562 if (element.getAttribute("aria-disabled") == "true") |
| 563 return; |
| 564 |
562 switch (action) | 565 switch (action) |
563 { | 566 { |
564 case "add-domain-exception": | 567 case "add-domain-exception": |
565 addWhitelistedDomain(); | 568 addWhitelistedDomain(); |
566 break; | 569 break; |
567 case "add-language-subscription": | 570 case "add-language-subscription": |
568 addEnableSubscription(findParentData(element, "access", false)); | 571 addEnableSubscription(findParentData(element, "access", false)); |
569 break; | 572 break; |
570 case "add-predefined-subscription": { | 573 case "add-predefined-subscription": { |
571 let dialog = E("dialog-content-predefined"); | 574 let dialog = E("dialog-content-predefined"); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 removeExisting: true | 648 removeExisting: true |
646 }, | 649 }, |
647 () => | 650 () => |
648 { | 651 { |
649 setCustomFiltersView("read"); | 652 setCustomFiltersView("read"); |
650 }); | 653 }); |
651 break; | 654 break; |
652 case "show-more-filters-section": | 655 case "show-more-filters-section": |
653 E("more-filters").setAttribute("aria-hidden", false); | 656 E("more-filters").setAttribute("aria-hidden", false); |
654 break; | 657 break; |
655 case "switch-acceptable-ads": { | 658 case "switch-acceptable-ads": |
656 let isChecked = element.getAttribute("aria-checked") == "true"; | |
657 let value = element.value || element.dataset.value; | 659 let value = element.value || element.dataset.value; |
658 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 } |
659 | 675 |
660 browser.runtime.sendMessage({ | 676 browser.runtime.sendMessage({ |
661 type: isAcceptableAds != isChecked ? "subscriptions.add" : | 677 type: installAcceptableAds ? "subscriptions.add" : |
662 "subscriptions.remove", | 678 "subscriptions.remove", |
663 url: acceptableAdsUrl | 679 url: acceptableAdsUrl |
664 }); | 680 }); |
665 browser.runtime.sendMessage({ | 681 browser.runtime.sendMessage({ |
666 type: isAcceptableAds || isChecked ? "subscriptions.remove" : | 682 type: installAcceptableAdsPrivacy ? "subscriptions.add" : |
667 "subscriptions.add", | 683 "subscriptions.remove", |
668 url: acceptableAdsPrivacyUrl | 684 url: acceptableAdsPrivacyUrl |
669 }); | 685 }); |
670 break; | 686 break; |
671 } | |
672 case "switch-tab": | 687 case "switch-tab": |
673 switchTab(element.getAttribute("href").substr(1)); | 688 switchTab(element.getAttribute("href").substr(1)); |
674 break; | 689 break; |
675 case "toggle-disable-subscription": | 690 case "toggle-disable-subscription": |
676 browser.runtime.sendMessage({ | 691 browser.runtime.sendMessage({ |
677 type: "subscriptions.toggle", | 692 type: "subscriptions.toggle", |
678 keepInstalled: true, | 693 keepInstalled: true, |
679 url: findParentData(element, "access", false) | 694 url: findParentData(element, "access", false) |
680 }); | 695 }); |
681 break; | 696 break; |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 getDocLink("contribute", (link) => | 906 getDocLink("contribute", (link) => |
892 { | 907 { |
893 E("contribute").href = link; | 908 E("contribute").href = link; |
894 }); | 909 }); |
895 getDocLink("acceptable_ads_criteria", (link) => | 910 getDocLink("acceptable_ads_criteria", (link) => |
896 { | 911 { |
897 setLinks("enable-acceptable-ads-description", link); | 912 setLinks("enable-acceptable-ads-description", link); |
898 }); | 913 }); |
899 getDocLink("privacy_friendly_ads", (link) => | 914 getDocLink("privacy_friendly_ads", (link) => |
900 { | 915 { |
901 setLinks("enable-acceptable-ads-privacy-description", link); | 916 E("enable-acceptable-ads-privacy-description").href = link; |
902 }); | 917 }); |
903 getDocLink("adblock_plus_{browser}_dnt", url => | 918 getDocLink("adblock_plus_{browser}_dnt", url => |
904 { | 919 { |
905 setLinks("dnt", url); | 920 setLinks("dnt", url); |
906 }); | 921 }); |
907 | 922 |
908 // Advanced tab | 923 // Advanced tab |
909 let customize = document.querySelectorAll("#customize li[data-pref]"); | 924 let customize = document.querySelectorAll("#customize li[data-pref]"); |
910 customize = Array.prototype.map.call(customize, (checkbox) => | 925 customize = Array.prototype.map.call(customize, (checkbox) => |
911 { | 926 { |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1042 } | 1057 } |
1043 | 1058 |
1044 function setAcceptableAds() | 1059 function setAcceptableAds() |
1045 { | 1060 { |
1046 let acceptableAdsForm = E("acceptable-ads"); | 1061 let acceptableAdsForm = E("acceptable-ads"); |
1047 let acceptableAds = E("acceptable-ads-allow"); | 1062 let acceptableAds = E("acceptable-ads-allow"); |
1048 let acceptableAdsPrivacy = E("acceptable-ads-privacy-allow"); | 1063 let acceptableAdsPrivacy = E("acceptable-ads-privacy-allow"); |
1049 acceptableAdsForm.classList.remove("show-dnt-notification"); | 1064 acceptableAdsForm.classList.remove("show-dnt-notification"); |
1050 acceptableAds.setAttribute("aria-checked", false); | 1065 acceptableAds.setAttribute("aria-checked", false); |
1051 acceptableAdsPrivacy.setAttribute("aria-checked", false); | 1066 acceptableAdsPrivacy.setAttribute("aria-checked", false); |
| 1067 acceptableAdsPrivacy.setAttribute("tabindex", 0); |
1052 if (acceptableAdsUrl in subscriptionsMap) | 1068 if (acceptableAdsUrl in subscriptionsMap) |
1053 { | 1069 { |
1054 acceptableAds.setAttribute("aria-checked", true); | 1070 acceptableAds.setAttribute("aria-checked", true); |
1055 acceptableAdsPrivacy.disabled = false; | 1071 acceptableAdsPrivacy.setAttribute("aria-disabled", false); |
1056 } | 1072 } |
1057 else if (acceptableAdsPrivacyUrl in subscriptionsMap) | 1073 else if (acceptableAdsPrivacyUrl in subscriptionsMap) |
1058 { | 1074 { |
1059 acceptableAds.setAttribute("aria-checked", true); | 1075 acceptableAds.setAttribute("aria-checked", true); |
1060 acceptableAdsPrivacy.setAttribute("aria-checked", true); | 1076 acceptableAdsPrivacy.setAttribute("aria-checked", true); |
1061 acceptableAdsPrivacy.disabled = false; | 1077 acceptableAdsPrivacy.setAttribute("aria-disabled", false); |
1062 | 1078 |
1063 if (navigator.doNotTrack != 1) | 1079 if (navigator.doNotTrack != 1) |
1064 acceptableAdsForm.classList.add("show-dnt-notification"); | 1080 acceptableAdsForm.classList.add("show-dnt-notification"); |
1065 } | 1081 } |
1066 else | 1082 else |
1067 { | 1083 { |
1068 acceptableAdsPrivacy.disabled = true; | 1084 // Using aria-disabled in order to keep the focus |
| 1085 acceptableAdsPrivacy.setAttribute("aria-disabled", true); |
| 1086 acceptableAdsPrivacy.setAttribute("tabindex", -1); |
1069 } | 1087 } |
1070 } | 1088 } |
1071 | 1089 |
1072 function isAcceptableAds(url) | 1090 function isAcceptableAds(url) |
1073 { | 1091 { |
1074 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl; | 1092 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl; |
1075 } | 1093 } |
1076 | 1094 |
1077 function populateLists() | 1095 function populateLists() |
1078 { | 1096 { |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1399 }); | 1417 }); |
1400 browser.runtime.sendMessage({ | 1418 browser.runtime.sendMessage({ |
1401 type: "subscriptions.listen", | 1419 type: "subscriptions.listen", |
1402 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1420 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
1403 "title", "downloadStatus", "downloading"] | 1421 "title", "downloadStatus", "downloading"] |
1404 }); | 1422 }); |
1405 | 1423 |
1406 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1424 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
1407 window.addEventListener("hashchange", onHashChange, false); | 1425 window.addEventListener("hashchange", onHashChange, false); |
1408 } | 1426 } |
LEFT | RIGHT |