Index: desktop-options.js |
=================================================================== |
--- a/desktop-options.js |
+++ b/desktop-options.js |
@@ -559,6 +559,9 @@ |
function execAction(action, element) |
{ |
+ 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
|
+ return; |
+ |
switch (action) |
{ |
case "add-domain-exception": |
@@ -653,15 +656,19 @@ |
E("more-filters").setAttribute("aria-hidden", false); |
break; |
case "switch-acceptable-ads": |
+ let isChecked = element.getAttribute("aria-checked") == "true"; |
let value = element.value || element.dataset.value; |
+ let isRegularAcceptableAds = value == "ads"; |
+ |
browser.runtime.sendMessage({ |
- type: value == "privacy" ? "subscriptions.add" : |
+ type: isRegularAcceptableAds != isChecked ? "subscriptions.add" : |
"subscriptions.remove", |
- url: acceptableAdsPrivacyUrl |
+ url: acceptableAdsUrl |
}); |
browser.runtime.sendMessage({ |
- type: value == "ads" ? "subscriptions.add" : "subscriptions.remove", |
- url: acceptableAdsUrl |
+ type: isRegularAcceptableAds || isChecked ? "subscriptions.remove" : |
+ "subscriptions.add", |
+ url: acceptableAdsPrivacyUrl |
}); |
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.
|
break; |
case "switch-tab": |
@@ -889,7 +896,11 @@ |
}); |
getDocLink("acceptable_ads_criteria", (link) => |
{ |
- setLinks("enable-aa-description", link); |
+ setLinks("enable-acceptable-ads-description", link); |
+ }); |
+ getDocLink("privacy_friendly_ads", (link) => |
+ { |
+ E("enable-acceptable-ads-privacy-description").href = link; |
}); |
getDocLink("adblock_plus_{browser}_dnt", url => |
{ |
@@ -1034,20 +1045,33 @@ |
function setAcceptableAds() |
{ |
- let option = "none"; |
- document.forms["acceptable-ads"].classList.remove("show-dnt-notification"); |
+ let acceptableAdsForm = E("acceptable-ads"); |
+ let acceptableAds = E("acceptable-ads-allow"); |
+ let acceptableAdsPrivacy = E("acceptable-ads-privacy-allow"); |
+ acceptableAdsForm.classList.remove("show-dnt-notification"); |
+ acceptableAds.setAttribute("aria-checked", false); |
+ acceptableAdsPrivacy.setAttribute("aria-checked", false); |
+ acceptableAdsPrivacy.setAttribute("tabindex", 0); |
if (acceptableAdsUrl in subscriptionsMap) |
{ |
- option = "ads"; |
+ acceptableAds.setAttribute("aria-checked", true); |
+ acceptableAdsPrivacy.setAttribute("aria-disabled", false); |
} |
else if (acceptableAdsPrivacyUrl in subscriptionsMap) |
{ |
- option = "privacy"; |
+ acceptableAds.setAttribute("aria-checked", true); |
+ acceptableAdsPrivacy.setAttribute("aria-checked", true); |
+ acceptableAdsPrivacy.setAttribute("aria-disabled", false); |
- if (!navigator.doNotTrack) |
- document.forms["acceptable-ads"].classList.add("show-dnt-notification"); |
+ if (navigator.doNotTrack != 1) |
+ acceptableAdsForm.classList.add("show-dnt-notification"); |
} |
- document.forms["acceptable-ads"]["acceptable-ads"].value = option; |
+ else |
+ { |
+ // Using aria-disabled in order to keep the focus |
+ acceptableAdsPrivacy.setAttribute("aria-disabled", true); |
+ acceptableAdsPrivacy.setAttribute("tabindex", -1); |
+ } |
} |
function isAcceptableAds(url) |