Left: | ||
Right: |
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") | |
Thomas Greiner
2017/10/20 15:35:03
Detail: No need to check for "true" or "false" whe
saroyanm
2017/10/20 16:42:06
In our code in some places we do set attribute lik
Thomas Greiner
2017/10/20 17:59:57
I'm fine with working on this in a separate ticket
saroyanm
2017/10/20 19:06:46
Ticket: https://issues.adblockplus.org/ticket/5900
| |
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 isRegularAcceptableAds = value == "ads"; | |
662 | |
657 browser.runtime.sendMessage({ | 663 browser.runtime.sendMessage({ |
658 type: value == "privacy" ? "subscriptions.add" : | 664 type: isRegularAcceptableAds != isChecked ? "subscriptions.add" : |
659 "subscriptions.remove", | 665 "subscriptions.remove", |
660 url: acceptableAdsPrivacyUrl | 666 url: acceptableAdsUrl |
661 }); | 667 }); |
662 browser.runtime.sendMessage({ | 668 browser.runtime.sendMessage({ |
663 type: value == "ads" ? "subscriptions.add" : "subscriptions.remove", | 669 type: isRegularAcceptableAds || isChecked ? "subscriptions.remove" : |
664 url: acceptableAdsUrl | 670 "subscriptions.add", |
671 url: acceptableAdsPrivacyUrl | |
665 }); | 672 }); |
Thomas Greiner
2017/10/20 15:35:03
This is very hard to read so for the sake of maint
saroyanm
2017/10/20 16:42:06
I agree with you, I made it hopefully simpler now.
Thomas Greiner
2017/10/20 17:59:57
It's better. As mentioned in person, I'd avoid dup
saroyanm
2017/10/20 19:06:46
Done.
| |
666 break; | 673 break; |
667 case "switch-tab": | 674 case "switch-tab": |
668 switchTab(element.getAttribute("href").substr(1)); | 675 switchTab(element.getAttribute("href").substr(1)); |
669 break; | 676 break; |
670 case "toggle-disable-subscription": | 677 case "toggle-disable-subscription": |
671 browser.runtime.sendMessage({ | 678 browser.runtime.sendMessage({ |
672 type: "subscriptions.toggle", | 679 type: "subscriptions.toggle", |
673 keepInstalled: true, | 680 keepInstalled: true, |
674 url: findParentData(element, "access", false) | 681 url: findParentData(element, "access", false) |
675 }); | 682 }); |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
882 { | 889 { |
883 E("whitelisting-add-button").disabled = !e.target.value; | 890 E("whitelisting-add-button").disabled = !e.target.value; |
884 }, false); | 891 }, false); |
885 | 892 |
886 getDocLink("contribute", (link) => | 893 getDocLink("contribute", (link) => |
887 { | 894 { |
888 E("contribute").href = link; | 895 E("contribute").href = link; |
889 }); | 896 }); |
890 getDocLink("acceptable_ads_criteria", (link) => | 897 getDocLink("acceptable_ads_criteria", (link) => |
891 { | 898 { |
892 setLinks("enable-aa-description", link); | 899 setLinks("enable-acceptable-ads-description", link); |
900 }); | |
901 getDocLink("privacy_friendly_ads", (link) => | |
902 { | |
903 E("enable-acceptable-ads-privacy-description").href = link; | |
893 }); | 904 }); |
894 getDocLink("adblock_plus_{browser}_dnt", url => | 905 getDocLink("adblock_plus_{browser}_dnt", url => |
895 { | 906 { |
896 setLinks("dnt", url); | 907 setLinks("dnt", url); |
897 }); | 908 }); |
898 | 909 |
899 // Advanced tab | 910 // Advanced tab |
900 let customize = document.querySelectorAll("#customize li[data-pref]"); | 911 let customize = document.querySelectorAll("#customize li[data-pref]"); |
901 customize = Array.prototype.map.call(customize, (checkbox) => | 912 customize = Array.prototype.map.call(customize, (checkbox) => |
902 { | 913 { |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1027 } | 1038 } |
1028 | 1039 |
1029 function hideNotification() | 1040 function hideNotification() |
1030 { | 1041 { |
1031 E("notification").setAttribute("aria-hidden", true); | 1042 E("notification").setAttribute("aria-hidden", true); |
1032 E("notification-text").textContent = ""; | 1043 E("notification-text").textContent = ""; |
1033 } | 1044 } |
1034 | 1045 |
1035 function setAcceptableAds() | 1046 function setAcceptableAds() |
1036 { | 1047 { |
1037 let option = "none"; | 1048 let acceptableAdsForm = E("acceptable-ads"); |
1038 document.forms["acceptable-ads"].classList.remove("show-dnt-notification"); | 1049 let acceptableAds = E("acceptable-ads-allow"); |
1050 let acceptableAdsPrivacy = E("acceptable-ads-privacy-allow"); | |
1051 acceptableAdsForm.classList.remove("show-dnt-notification"); | |
1052 acceptableAds.setAttribute("aria-checked", false); | |
1053 acceptableAdsPrivacy.setAttribute("aria-checked", false); | |
1054 acceptableAdsPrivacy.setAttribute("tabindex", 0); | |
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 acceptableAdsPrivacy.setAttribute("tabindex", -1); | |
1074 } | |
1051 } | 1075 } |
1052 | 1076 |
1053 function isAcceptableAds(url) | 1077 function isAcceptableAds(url) |
1054 { | 1078 { |
1055 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl; | 1079 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl; |
1056 } | 1080 } |
1057 | 1081 |
1058 function populateLists() | 1082 function populateLists() |
1059 { | 1083 { |
1060 subscriptionsMap = Object.create(null); | 1084 subscriptionsMap = Object.create(null); |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1380 }); | 1404 }); |
1381 browser.runtime.sendMessage({ | 1405 browser.runtime.sendMessage({ |
1382 type: "subscriptions.listen", | 1406 type: "subscriptions.listen", |
1383 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1407 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
1384 "title", "downloadStatus", "downloading"] | 1408 "title", "downloadStatus", "downloading"] |
1385 }); | 1409 }); |
1386 | 1410 |
1387 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1411 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
1388 window.addEventListener("hashchange", onHashChange, false); | 1412 window.addEventListener("hashchange", onHashChange, false); |
1389 } | 1413 } |
OLD | NEW |