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: Created Oct. 16, 2017, 5:36 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
Index: desktop-options.js
===================================================================
--- a/desktop-options.js
+++ b/desktop-options.js
@@ -653,15 +653,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 isAcceptableAds = value == "ads";
ire 2017/10/17 08:16:34 I'm getting the eslint error: isAcceptableAds is a
saroyanm 2017/10/17 19:23:07 Thanks, I isolated scope with the braces. Let me k
ire 2017/10/18 17:48:45 I'm still getting the same error, I don't think th
saroyanm 2017/10/19 20:41:55 Right, my bad, I thought it was a variable in the
ire 2017/10/20 08:14:41 I don't have a strong preference about the name. I
+
chrome.runtime.sendMessage({
- type: value == "privacy" ? "subscriptions.add" :
+ type: isAcceptableAds != isChecked ? "subscriptions.add" :
"subscriptions.remove",
- url: acceptableAdsPrivacyUrl
+ url: acceptableAdsUrl
});
chrome.runtime.sendMessage({
- type: value == "ads" ? "subscriptions.add" : "subscriptions.remove",
- url: acceptableAdsUrl
+ type: isAcceptableAds || isChecked ? "subscriptions.remove" :
+ "subscriptions.add",
+ url: acceptableAdsPrivacyUrl
});
break;
case "switch-tab":
@@ -889,7 +893,11 @@
});
getDocLink("acceptable_ads_criteria", (link) =>
{
- setLinks("enable-aa-description", link);
+ setLinks("enable-acceptable-ads-description", link);
+ });
+ getDocLink("privacy_friendly_ads", (link) =>
saroyanm 2017/10/16 17:45:51 We still missing this redirection link, I'll reach
ire 2017/10/17 08:16:34 Acknowledged.
+ {
+ setLinks("enable-acceptable-ads-privacy-description", link);
});
getDocLink("adblock_plus_{browser}_dnt", url =>
{
@@ -1034,20 +1042,27 @@
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.disabled = true;
ire 2017/10/17 08:16:34 When you toggle the acceptableAdsPrivacy checkbox
saroyanm 2017/10/17 19:23:07 yes this is trickier than it appears. I'll try to
saroyanm 2017/10/17 19:54:29 Done.
ire 2017/10/18 17:48:45 Ah I see, very tricky!
if (acceptableAdsUrl in subscriptionsMap)
{
- option = "ads";
+ acceptableAds.setAttribute("aria-checked", true);
+ acceptableAdsPrivacy.disabled = false;
}
else if (acceptableAdsPrivacyUrl in subscriptionsMap)
{
- option = "privacy";
+ acceptableAds.setAttribute("aria-checked", true);
+ acceptableAdsPrivacy.setAttribute("aria-checked", true);
+ acceptableAdsPrivacy.disabled = false;
- if (!navigator.doNotTrack)
- document.forms["acceptable-ads"].classList.add("show-dnt-notification");
+ if (navigator.doNotTrack != 1)
saroyanm 2017/10/16 17:45:52 See -> https://issues.adblockplus.org/ticket/5866
ire 2017/10/17 08:16:34 Seen. I agree with you.
ire 2017/10/17 08:16:34 I don't know if support for Edge/Safari is relevan
saroyanm 2017/10/17 19:23:07 We don't consider Safari, but it make sense for th
ire 2017/10/18 17:48:45 Acknowledged.
+ acceptableAdsForm.classList.add("show-dnt-notification");
}
- document.forms["acceptable-ads"]["acceptable-ads"].value = option;
}
function isAcceptableAds(url)

Powered by Google App Engine
This is Rietveld