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

Delta Between Two Patch Sets: js/desktop-options.js

Issue 29733668: Handle disabled state of AA
Left Patch Set: Intuitive solution Created March 26, 2018, 9:02 p.m.
Right Patch Set: Created March 26, 2018, 9:23 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « background.js ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 displays[j].textContent = title; 230 displays[j].textContent = title;
231 } 231 }
232 232
233 element.setAttribute("aria-label", title); 233 element.setAttribute("aria-label", title);
234 if (this.details[i].searchable) 234 if (this.details[i].searchable)
235 element.setAttribute("data-search", title.toLowerCase()); 235 element.setAttribute("data-search", title.toLowerCase());
236 let controls = element.querySelectorAll(".control[role='checkbox']"); 236 let controls = element.querySelectorAll(".control[role='checkbox']");
237 for (let control of controls) 237 for (let control of controls)
238 { 238 {
239 control.setAttribute("aria-checked", item.disabled == false); 239 control.setAttribute("aria-checked", item.disabled == false);
240 if (isAcceptableAds(item.url) && this == collections.filterLists &&
241 !item.disabled)
242 {
243 control.disabled = true;
244 }
240 } 245 }
241 if (additionalSubscriptions.includes(item.url)) 246 if (additionalSubscriptions.includes(item.url))
242 { 247 {
243 element.classList.add("preconfigured"); 248 element.classList.add("preconfigured");
244 let disablePreconfigures = 249 let disablePreconfigures =
245 element.querySelectorAll("[data-disable~='preconfigured']"); 250 element.querySelectorAll("[data-disable~='preconfigured']");
246 for (let disablePreconfigure of disablePreconfigures) 251 for (let disablePreconfigure of disablePreconfigures)
247 disablePreconfigure.disabled = true; 252 disablePreconfigure.disabled = true;
248 } 253 }
249 254
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 1073
1069 function setAcceptableAds() 1074 function setAcceptableAds()
1070 { 1075 {
1071 let acceptableAdsForm = E("acceptable-ads"); 1076 let acceptableAdsForm = E("acceptable-ads");
1072 let acceptableAds = E("acceptable-ads-allow"); 1077 let acceptableAds = E("acceptable-ads-allow");
1073 let acceptableAdsPrivacy = E("acceptable-ads-privacy-allow"); 1078 let acceptableAdsPrivacy = E("acceptable-ads-privacy-allow");
1074 acceptableAdsForm.classList.remove("show-dnt-notification"); 1079 acceptableAdsForm.classList.remove("show-dnt-notification");
1075 acceptableAds.setAttribute("aria-checked", false); 1080 acceptableAds.setAttribute("aria-checked", false);
1076 acceptableAdsPrivacy.setAttribute("aria-checked", false); 1081 acceptableAdsPrivacy.setAttribute("aria-checked", false);
1077 acceptableAdsPrivacy.setAttribute("tabindex", 0); 1082 acceptableAdsPrivacy.setAttribute("tabindex", 0);
1078 if (acceptableAdsUrl in subscriptionsMap && !acceptableAdsUrl.disabled) 1083 if (acceptableAdsUrl in subscriptionsMap &&
1084 !subscriptionsMap[acceptableAdsUrl].disabled)
1079 { 1085 {
1080 acceptableAds.setAttribute("aria-checked", true); 1086 acceptableAds.setAttribute("aria-checked", true);
1081 acceptableAdsPrivacy.setAttribute("aria-disabled", false); 1087 acceptableAdsPrivacy.setAttribute("aria-disabled", false);
1082 } 1088 }
1083 else if (acceptableAdsPrivacyUrl in subscriptionsMap && 1089 else if (acceptableAdsPrivacyUrl in subscriptionsMap &&
1084 !acceptableAdsPrivacyUrl.disabled) 1090 !subscriptionsMap[acceptableAdsPrivacyUrl].disabled)
1085 { 1091 {
1086 acceptableAds.setAttribute("aria-checked", true); 1092 acceptableAds.setAttribute("aria-checked", true);
1087 acceptableAdsPrivacy.setAttribute("aria-checked", true); 1093 acceptableAdsPrivacy.setAttribute("aria-checked", true);
1088 acceptableAdsPrivacy.setAttribute("aria-disabled", false); 1094 acceptableAdsPrivacy.setAttribute("aria-disabled", false);
1089 1095
1090 // Edge uses window instead of navigator. 1096 // Edge uses window instead of navigator.
1091 // Prefer navigator first since it's the standard. 1097 // Prefer navigator first since it's the standard.
1092 if ((navigator.doNotTrack || window.doNotTrack) != 1) 1098 if ((navigator.doNotTrack || window.doNotTrack) != 1)
1093 acceptableAdsForm.classList.add("show-dnt-notification"); 1099 acceptableAdsForm.classList.add("show-dnt-notification");
1094 } 1100 }
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 knownSubscription.originalTitle = subscription.title; 1287 knownSubscription.originalTitle = subscription.title;
1282 else 1288 else
1283 knownSubscription[property] = subscription[property]; 1289 knownSubscription[property] = subscription[property];
1284 } 1290 }
1285 subscription = knownSubscription; 1291 subscription = knownSubscription;
1286 } 1292 }
1287 switch (action) 1293 switch (action)
1288 { 1294 {
1289 case "disabled": 1295 case "disabled":
1290 updateSubscription(subscription); 1296 updateSubscription(subscription);
1297 if (isAcceptableAds(subscription.url))
1298 setAcceptableAds();
1299
1291 setPrivacyConflict(); 1300 setPrivacyConflict();
1292 break; 1301 break;
1293 case "downloading": 1302 case "downloading":
1294 case "downloadStatus": 1303 case "downloadStatus":
1295 case "homepage": 1304 case "homepage":
1296 case "lastDownload": 1305 case "lastDownload":
1297 case "title": 1306 case "title":
1298 updateSubscription(subscription); 1307 updateSubscription(subscription);
1299 break; 1308 break;
1300 case "added": 1309 case "added":
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1494 "ui_warn_tracking"] 1503 "ui_warn_tracking"]
1495 }); 1504 });
1496 port.postMessage({ 1505 port.postMessage({
1497 type: "subscriptions.listen", 1506 type: "subscriptions.listen",
1498 filter: ["added", "disabled", "homepage", "lastDownload", "removed", 1507 filter: ["added", "disabled", "homepage", "lastDownload", "removed",
1499 "title", "downloadStatus", "downloading"] 1508 "title", "downloadStatus", "downloading"]
1500 }); 1509 });
1501 1510
1502 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 1511 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
1503 window.addEventListener("hashchange", onHashChange, false); 1512 window.addEventListener("hashchange", onHashChange, false);
LEFTRIGHT

Powered by Google App Engine
This is Rietveld