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

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

Issue 29712664: Issue 6432 - Hide remove button for additional filter lists (Closed)
Left Patch Set: Created March 1, 2018, 9:43 p.m.
Right Patch Set: Reverted the colors back Created March 9, 2018, 11:25 a.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 | « desktop-options.html ('k') | skin/icons/checkbox.svg » ('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-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
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 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 /* globals checkShareResource, getDocLink, i18nFormatDateTime, openSharePopup, 18 /* globals checkShareResource, getDocLink, i18nFormatDateTime, openSharePopup,
19 setLinks, E */ 19 setLinks, E */
20 20
21 "use strict"; 21 "use strict";
22 22
23 let subscriptionsMap = Object.create(null); 23 let subscriptionsMap = Object.create(null);
24 let filtersMap = Object.create(null); 24 let filtersMap = Object.create(null);
25 let collections = Object.create(null); 25 let collections = Object.create(null);
26 let acceptableAdsUrl = null; 26 let acceptableAdsUrl = null;
27 let acceptableAdsPrivacyUrl = null; 27 let acceptableAdsPrivacyUrl = null;
28 let isCustomFiltersLoaded = false; 28 let isCustomFiltersLoaded = false;
29 let additionalSubscriptions = [];
29 let {getMessage} = browser.i18n; 30 let {getMessage} = browser.i18n;
30 let {setElementText} = ext.i18n; 31 let {setElementText} = ext.i18n;
31 let customFilters = []; 32 let customFilters = [];
32 let filterErrors = new Map([ 33 let filterErrors = new Map([
33 ["synchronize_invalid_url", 34 ["synchronize_invalid_url",
34 "options_filterList_lastDownload_invalidURL"], 35 "options_filterList_lastDownload_invalidURL"],
35 ["synchronize_connection_error", 36 ["synchronize_connection_error",
36 "options_filterList_lastDownload_connectionError"], 37 "options_filterList_lastDownload_connectionError"],
37 ["synchronize_invalid_data", 38 ["synchronize_invalid_data",
38 "options_filterList_lastDownload_invalidData"], 39 "options_filterList_lastDownload_invalidData"],
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 if (this.details[i].searchable) 234 if (this.details[i].searchable)
234 element.setAttribute("data-search", title.toLowerCase()); 235 element.setAttribute("data-search", title.toLowerCase());
235 let controls = element.querySelectorAll(".control[role='checkbox']"); 236 let controls = element.querySelectorAll(".control[role='checkbox']");
236 for (let control of controls) 237 for (let control of controls)
237 { 238 {
238 control.setAttribute("aria-checked", item.disabled == false); 239 control.setAttribute("aria-checked", item.disabled == false);
239 if (isAcceptableAds(item.url) && this == collections.filterLists) 240 if (isAcceptableAds(item.url) && this == collections.filterLists)
240 { 241 {
241 control.disabled = true; 242 control.disabled = true;
242 } 243 }
243 else if (this == collections.filterLists) 244 }
saroyanm 2018/03/01 21:52:34 I wonder if I also should consider the case of rem
Thomas Greiner 2018/03/02 11:33:35 This if-statement is redundant because in the CSS
Thomas Greiner 2018/03/02 11:33:36 You're right that we should also consider other pl
saroyanm 2018/03/02 13:50:29 Done.
saroyanm 2018/03/02 13:50:29 Done. I moved implementation out of the for loop,
244 { 245 if (additionalSubscriptions.includes(item.url))
245 // List preinstalled by administrators 246 {
Thomas Greiner 2018/03/02 11:33:35 Detail: This is already documented under https://h
saroyanm 2018/03/02 13:50:29 Done.
246 getPref("additional_subscriptions", (additionalSubscriptions) => 247 element.classList.add("preconfigured");
247 { 248 let disablePreconfigures =
248 if (additionalSubscriptions.includes(item.url)) 249 element.querySelectorAll("[data-disable~='preconfigured']");
249 element.classList.add("non-removable"); 250 for (let disablePreconfigure of disablePreconfigures)
Thomas Greiner 2018/03/02 11:33:35 Detail: What about keeping the name more objective
saroyanm 2018/03/02 13:50:29 Done.
250 }); 251 disablePreconfigure.disabled = true;
251 }
252 } 252 }
253 253
254 let lastUpdateElement = element.querySelector(".last-update"); 254 let lastUpdateElement = element.querySelector(".last-update");
255 if (lastUpdateElement) 255 if (lastUpdateElement)
256 { 256 {
257 let message = element.querySelector(".message"); 257 let message = element.querySelector(".message");
258 if (item.isDownloading) 258 if (item.isDownloading)
259 { 259 {
260 let text = getMessage("options_filterList_lastDownload_inProgress"); 260 let text = getMessage("options_filterList_lastDownload_inProgress");
261 message.textContent = text; 261 message.textContent = text;
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 472
473 filtersMap[filter.text] = filter; 473 filtersMap[filter.text] = filter;
474 } 474 }
475 475
476 function loadCustomFilters(filters) 476 function loadCustomFilters(filters)
477 { 477 {
478 for (let filter of filters) 478 for (let filter of filters)
479 updateFilter(filter); 479 updateFilter(filter);
480 480
481 setCustomFiltersView("read"); 481 setCustomFiltersView("read");
482 isCustomFiltersLoaded = true;
483 } 482 }
484 483
485 function removeCustomFilter(text) 484 function removeCustomFilter(text)
486 { 485 {
487 let index = customFilters.indexOf(text); 486 let index = customFilters.indexOf(text);
488 if (index >= 0) 487 if (index >= 0)
489 customFilters.splice(index, 1); 488 customFilters.splice(index, 1);
490 489
491 updateCustomFiltersUi(); 490 updateCustomFiltersUi();
492 } 491 }
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 for (let property in collections) 1150 for (let property in collections)
1152 collections[property].clearAll(); 1151 collections[property].clearAll();
1153 1152
1154 setCustomFiltersView("empty"); 1153 setCustomFiltersView("empty");
1155 browser.runtime.sendMessage({ 1154 browser.runtime.sendMessage({
1156 type: "subscriptions.get", 1155 type: "subscriptions.get",
1157 special: true 1156 special: true
1158 }, 1157 },
1159 (subscriptions) => 1158 (subscriptions) =>
1160 { 1159 {
1161 // Load filters 1160 let customFilterPromises = subscriptions.map(getSubscriptionFilters);
1162 for (let subscription of subscriptions) 1161 Promise.all(customFilterPromises).then((filters) =>
1163 { 1162 {
1164 browser.runtime.sendMessage({ 1163 loadCustomFilters([].concat(...filters));
1165 type: "filters.get", 1164 isCustomFiltersLoaded = true;
1166 subscriptionUrl: subscription.url 1165 });
1167 },
1168 (filters) =>
1169 {
1170 loadCustomFilters(filters);
1171 });
1172 }
1173 }); 1166 });
1174 loadRecommendations(); 1167 loadRecommendations();
1175 browser.runtime.sendMessage({ 1168 browser.runtime.sendMessage({
1176 type: "prefs.get", 1169 type: "prefs.get",
1177 key: "subscriptions_exceptionsurl" 1170 key: "subscriptions_exceptionsurl"
1178 }, 1171 },
1179 (url) => 1172 (url) =>
1180 { 1173 {
1181 acceptableAdsUrl = url; 1174 acceptableAdsUrl = url;
1182 1175
1183 browser.runtime.sendMessage({ 1176 browser.runtime.sendMessage({
1184 type: "prefs.get", 1177 type: "prefs.get",
1185 key: "subscriptions_exceptionsurl_privacy" 1178 key: "subscriptions_exceptionsurl_privacy"
1186 }, 1179 },
1187 (urlPrivacy) => 1180 (urlPrivacy) =>
1188 { 1181 {
1189 acceptableAdsPrivacyUrl = urlPrivacy; 1182 acceptableAdsPrivacyUrl = urlPrivacy;
1190 1183
1191 // Load user subscriptions 1184 getPref("additional_subscriptions", (subscriptionUrls) =>
1192 browser.runtime.sendMessage({ 1185 {
1193 type: "subscriptions.get", 1186 additionalSubscriptions = subscriptionUrls;
1194 downloadable: true 1187
1195 }, 1188 // Load user subscriptions
1196 (subscriptions) => 1189 browser.runtime.sendMessage({
1197 { 1190 type: "subscriptions.get",
1198 for (let subscription of subscriptions) 1191 downloadable: true
1199 onSubscriptionMessage("added", subscription); 1192 },
1200 1193 (subscriptions) =>
1201 setAcceptableAds(); 1194 {
1195 for (let subscription of subscriptions)
1196 onSubscriptionMessage("added", subscription);
1197
1198 setAcceptableAds();
1199 });
1202 }); 1200 });
1203 }); 1201 });
1204 }); 1202 });
1205 } 1203 }
1206 1204
1207 function addWhitelistedDomain() 1205 function addWhitelistedDomain()
1208 { 1206 {
1209 let domain = E("whitelisting-textbox"); 1207 let domain = E("whitelisting-textbox");
1210 for (let whitelistItem of collections.whitelist.items) 1208 for (let whitelistItem of collections.whitelist.items)
1211 { 1209 {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1337 else 1335 else
1338 { 1336 {
1339 collections.more.removeItem(subscription); 1337 collections.more.removeItem(subscription);
1340 } 1338 }
1341 } 1339 }
1342 1340
1343 collections.filterLists.removeItem(subscription); 1341 collections.filterLists.removeItem(subscription);
1344 setPrivacyConflict(); 1342 setPrivacyConflict();
1345 break; 1343 break;
1346 } 1344 }
1345 }
1346
1347 function getSubscriptionFilters(subscription)
1348 {
1349 return browser.runtime.sendMessage({
1350 type: "filters.get",
1351 subscriptionUrl: subscription.url});
1347 } 1352 }
1348 1353
1349 function hidePref(key, value) 1354 function hidePref(key, value)
1350 { 1355 {
1351 let element = document.querySelector("[data-pref='" + key + "']"); 1356 let element = document.querySelector("[data-pref='" + key + "']");
1352 if (element) 1357 if (element)
1353 element.setAttribute("aria-hidden", value); 1358 element.setAttribute("aria-hidden", value);
1354 } 1359 }
1355 1360
1356 function getPref(key, callback) 1361 function getPref(key, callback)
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1476 "ui_warn_tracking"] 1481 "ui_warn_tracking"]
1477 }); 1482 });
1478 browser.runtime.sendMessage({ 1483 browser.runtime.sendMessage({
1479 type: "subscriptions.listen", 1484 type: "subscriptions.listen",
1480 filter: ["added", "disabled", "homepage", "lastDownload", "removed", 1485 filter: ["added", "disabled", "homepage", "lastDownload", "removed",
1481 "title", "downloadStatus", "downloading"] 1486 "title", "downloadStatus", "downloading"]
1482 }); 1487 });
1483 1488
1484 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 1489 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
1485 window.addEventListener("hashchange", onHashChange, false); 1490 window.addEventListener("hashchange", onHashChange, false);
LEFTRIGHT

Powered by Google App Engine
This is Rietveld