Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: desktop-options.js

Issue 29578574: Issue 5632 - Use checkboxes for toggling acceptable ads (Closed)
Patch Set: Addressed Thomas Comments Created Oct. 20, 2017, 4:39 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « desktop-options.html ('k') | skin/desktop-options.css » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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")
+ return;
+
switch (action)
{
case "add-domain-exception":
@@ -654,15 +657,35 @@
break;
case "switch-acceptable-ads":
let value = element.value || element.dataset.value;
- browser.runtime.sendMessage({
- type: value == "privacy" ? "subscriptions.add" :
- "subscriptions.remove",
- url: acceptableAdsPrivacyUrl
- });
- browser.runtime.sendMessage({
- type: value == "ads" ? "subscriptions.add" : "subscriptions.remove",
- url: acceptableAdsUrl
- });
+ // User check the checkbox
+ let isCheck = element.getAttribute("aria-checked") != "true";
+
+ // Acceptable Ads checkbox clicked
+ if (value == "ads")
+ {
+ browser.runtime.sendMessage({
+ type: isCheck ? "subscriptions.add" :
+ "subscriptions.remove",
+ url: acceptableAdsUrl
+ });
+ browser.runtime.sendMessage({
+ type: "subscriptions.remove",
+ url: acceptableAdsPrivacyUrl
+ });
+ }
+ else // Privacy Friendly Acceptable Ads checkbox clicked
+ {
+ browser.runtime.sendMessage({
+ type: isCheck ? "subscriptions.add" :
+ "subscriptions.remove",
+ url: acceptableAdsPrivacyUrl
+ });
+ browser.runtime.sendMessage({
+ type: isCheck ? "subscriptions.remove" :
+ "subscriptions.add",
+ url: acceptableAdsUrl
+ });
+ }
break;
case "switch-tab":
switchTab(element.getAttribute("href").substr(1));
@@ -889,7 +912,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 +1061,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)
« no previous file with comments | « desktop-options.html ('k') | skin/desktop-options.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld