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