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

Delta Between Two Patch Sets: new-options.js

Issue 29478597: Issue 5326 - General tab (HTML, strings and functionality) (Closed)
Left Patch Set: Created Aug. 17, 2017, 8:33 p.m.
Right Patch Set: rebase Created Aug. 23, 2017, 12:36 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 | « new-options.html ('k') | skin/new-options.css » ('j') | 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-2017 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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 listItem.setAttribute("role", "section"); 134 listItem.setAttribute("role", "section");
135 135
136 let tooltip = listItem.querySelector("[data-tooltip]"); 136 let tooltip = listItem.querySelector("[data-tooltip]");
137 if (tooltip) 137 if (tooltip)
138 { 138 {
139 let tooltipId = tooltip.getAttribute("data-tooltip"); 139 let tooltipId = tooltip.getAttribute("data-tooltip");
140 tooltipId = tooltipId.replace("%value%", item.recommended); 140 tooltipId = tooltipId.replace("%value%", item.recommended);
141 if (getMessage(tooltipId)) 141 if (getMessage(tooltipId))
142 { 142 {
143 tooltip.setAttribute("data-tooltip", tooltipId); 143 tooltip.setAttribute("data-tooltip", tooltipId);
144 }
145 else
146 {
147 tooltip.parentNode.removeChild(tooltip);
148 } 144 }
149 } 145 }
150 146
151 for (let control of listItem.querySelectorAll(".control")) 147 for (let control of listItem.querySelectorAll(".control"))
152 { 148 {
153 if (control.hasAttribute("title")) 149 if (control.hasAttribute("title"))
154 { 150 {
155 let titleValue = getMessage(control.getAttribute("title")); 151 let titleValue = getMessage(control.getAttribute("title"));
156 control.setAttribute("title", titleValue); 152 control.setAttribute("title", titleValue);
157 } 153 }
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 let nextElement = focusables[index]; 330 let nextElement = focusables[index];
335 if (!nextElement) 331 if (!nextElement)
336 return false; 332 return false;
337 333
338 nextElement.focus(); 334 nextElement.focus();
339 return true; 335 return true;
340 } 336 }
341 337
342 collections.protection = new Collection([ 338 collections.protection = new Collection([
343 { 339 {
344 id: "recommend-security-list-table" 340 id: "recommend-protection-list-table"
345 } 341 }
346 ]); 342 ]);
347 collections.langs = new Collection([ 343 collections.langs = new Collection([
348 { 344 {
349 id: "blocking-languages-table", 345 id: "blocking-languages-table",
350 emptyText: ["options_language_empty"] 346 emptyText: ["options_language_empty"]
351 } 347 }
352 ]); 348 ]);
353 collections.allLangs = new Collection([ 349 collections.allLangs = new Collection([
354 { 350 {
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 type: "filters.importRaw", 627 type: "filters.importRaw",
632 text: E("custom-filters-raw").value, 628 text: E("custom-filters-raw").value,
633 removeExisting: true 629 removeExisting: true
634 }, 630 },
635 () => 631 () =>
636 { 632 {
637 setCustomFiltersView("read"); 633 setCustomFiltersView("read");
638 }); 634 });
639 break; 635 break;
640 case "switch-acceptable-ads": 636 case "switch-acceptable-ads":
641 let value = element.value; 637 let {value} = element;
642 ext.backgroundPage.sendMessage({ 638 ext.backgroundPage.sendMessage({
643 type: value == "privacy" ? "subscriptions.add" : 639 type: value == "privacy" ? "subscriptions.add" :
644 "subscriptions.remove", 640 "subscriptions.remove",
645 url: acceptableAdsPrivacyUrl 641 url: acceptableAdsPrivacyUrl
646 }); 642 });
647 ext.backgroundPage.sendMessage({ 643 ext.backgroundPage.sendMessage({
648 type: value == "ads" ? "subscriptions.add" : "subscriptions.remove", 644 type: value == "ads" ? "subscriptions.add" : "subscriptions.remove",
649 url: acceptableAdsUrl 645 url: acceptableAdsUrl
650 }); 646 });
651 break; 647 break;
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 986
991 function closeDialog() 987 function closeDialog()
992 { 988 {
993 let dialog = E("dialog"); 989 let dialog = E("dialog");
994 dialog.setAttribute("aria-hidden", true); 990 dialog.setAttribute("aria-hidden", true);
995 dialog.removeAttribute("aria-labelledby"); 991 dialog.removeAttribute("aria-labelledby");
996 document.body.removeAttribute("data-dialog"); 992 document.body.removeAttribute("data-dialog");
997 focusedBeforeDialog.focus(); 993 focusedBeforeDialog.focus();
998 } 994 }
999 995
1000 function setDntNotification(state)
Thomas Greiner 2017/08/22 16:08:57 Let's move this into `setAcceptableAds()` as well
saroyanm 2017/08/22 17:00:07 Done.
1001 {
1002 if (state)
1003 E("acceptable-ads").classList.add("show-dnt-notification");
1004 else
1005 E("acceptable-ads").classList.remove("show-dnt-notification");
1006 }
1007
1008 function setAcceptableAds() 996 function setAcceptableAds()
1009 { 997 {
1010 let optionsContainer = E("acceptable-ads"); 998 let option = "none";
1011 optionsContainer.querySelector("[value='none']").checked = true; 999 document.forms["acceptable-ads"].classList.remove("show-dnt-notification");
1012 for (let url in subscriptionsMap) 1000 if (acceptableAdsUrl in subscriptionsMap)
1013 { 1001 {
1014 if (url == acceptableAdsPrivacyUrl) 1002 option = "ads";
1015 { 1003 }
1016 optionsContainer.querySelector("[value='privacy']").checked = true; 1004 else if (acceptableAdsPrivacyUrl in subscriptionsMap)
1017 } 1005 {
1018 if (url == acceptableAdsUrl) 1006 option = "privacy";
1019 { 1007
1020 optionsContainer.querySelector("[value='ads']").checked = true; 1008 if (!navigator.doNotTrack)
1021 break; 1009 document.forms["acceptable-ads"].classList.add("show-dnt-notification");
1022 } 1010 }
1023 } 1011 document.forms["acceptable-ads"]["acceptable-ads"].value = option;
Thomas Greiner 2017/08/22 16:08:58 No need to loop through `subscriptionsMap` or tick
saroyanm 2017/08/22 17:00:09 Done.
1024 } 1012 }
1025 1013
1026 function isAcceptableAds(url) 1014 function isAcceptableAds(url)
1027 { 1015 {
1028 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl; 1016 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl;
1029 } 1017 }
1030 1018
1031 function populateLists() 1019 function populateLists()
1032 { 1020 {
1033 subscriptionsMap = Object.create(null); 1021 subscriptionsMap = Object.create(null);
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 break; 1182 break;
1195 case "added": 1183 case "added":
1196 if (subscription.url in subscriptionsMap) 1184 if (subscription.url in subscriptionsMap)
1197 updateSubscription(subscription); 1185 updateSubscription(subscription);
1198 else 1186 else
1199 addSubscription(subscription); 1187 addSubscription(subscription);
1200 1188
1201 if (isAcceptableAds(subscription.url)) 1189 if (isAcceptableAds(subscription.url))
1202 setAcceptableAds(); 1190 setAcceptableAds();
1203 1191
1204 if (subscription.url == acceptableAdsPrivacyUrl)
1205 {
1206 if (!navigator.doNotTrack)
1207 setDntNotification(true);
1208 }
1209
1210 collections.filterLists.addItem(subscription); 1192 collections.filterLists.addItem(subscription);
1211 break; 1193 break;
1212 case "removed": 1194 case "removed":
1213 if (subscription.recommended) 1195 if (subscription.recommended)
1214 { 1196 {
1215 subscription.disabled = true; 1197 subscription.disabled = true;
1216 onSubscriptionMessage("disabled", subscription); 1198 onSubscriptionMessage("disabled", subscription);
1217 } 1199 }
1218 else if (isAcceptableAds(subscription.url)) 1200 else
1219 { 1201 {
1220 if (subscription.url == acceptableAdsPrivacyUrl) 1202 delete subscriptionsMap[subscription.url];
1203 if (isAcceptableAds(subscription.url))
1221 { 1204 {
1222 setDntNotification(false); 1205 setAcceptableAds();
1223 } 1206 }
1224 1207 else
1225 delete subscriptionsMap[subscription.url]; 1208 {
Thomas Greiner 2017/08/22 16:08:58 Detail: This happens whenever a non-recommended su
saroyanm 2017/08/22 17:00:09 Done.
1226 setAcceptableAds(); 1209 collections.custom.removeItem(subscription);
1227 } 1210 }
1228 else
1229 {
1230 collections.custom.removeItem(subscription);
1231 delete subscriptionsMap[subscription.url];
1232 } 1211 }
1233 collections.filterLists.removeItem(subscription); 1212 collections.filterLists.removeItem(subscription);
1234 break; 1213 break;
1235 } 1214 }
1236 1215
1237 updateShareLink(); 1216 updateShareLink();
1238 } 1217 }
1239 1218
1240 function hidePref(key, value) 1219 function hidePref(key, value)
1241 { 1220 {
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1388 }); 1367 });
1389 ext.backgroundPage.sendMessage({ 1368 ext.backgroundPage.sendMessage({
1390 type: "subscriptions.listen", 1369 type: "subscriptions.listen",
1391 filter: ["added", "disabled", "homepage", "lastDownload", "removed", 1370 filter: ["added", "disabled", "homepage", "lastDownload", "removed",
1392 "title", "downloadStatus", "downloading"] 1371 "title", "downloadStatus", "downloading"]
1393 }); 1372 });
1394 1373
1395 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 1374 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
1396 window.addEventListener("hashchange", onHashChange, false); 1375 window.addEventListener("hashchange", onHashChange, false);
1397 } 1376 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld