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: Addressed Jeen's suggestion in the ticket Created March 2, 2018, 4:31 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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 } 244 }
244 getPref("additional_subscriptions", (additionalSubscriptions) => 245 if (additionalSubscriptions.includes(item.url))
245 { 246 {
246 if (additionalSubscriptions.includes(item.url)) 247 element.classList.add("preconfigured");
247 element.classList.add("preconfigured"); 248 let disablePreconfigures =
248 }); 249 element.querySelectorAll("[data-disable~='preconfigured']");
250 for (let disablePreconfigure of disablePreconfigures)
251 disablePreconfigure.disabled = true;
252 }
249 253
250 let lastUpdateElement = element.querySelector(".last-update"); 254 let lastUpdateElement = element.querySelector(".last-update");
251 if (lastUpdateElement) 255 if (lastUpdateElement)
252 { 256 {
253 let message = element.querySelector(".message"); 257 let message = element.querySelector(".message");
254 if (item.isDownloading) 258 if (item.isDownloading)
255 { 259 {
256 let text = getMessage("options_filterList_lastDownload_inProgress"); 260 let text = getMessage("options_filterList_lastDownload_inProgress");
257 message.textContent = text; 261 message.textContent = text;
258 element.classList.add("show-message"); 262 element.classList.add("show-message");
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 472
469 filtersMap[filter.text] = filter; 473 filtersMap[filter.text] = filter;
470 } 474 }
471 475
472 function loadCustomFilters(filters) 476 function loadCustomFilters(filters)
473 { 477 {
474 for (let filter of filters) 478 for (let filter of filters)
475 updateFilter(filter); 479 updateFilter(filter);
476 480
477 setCustomFiltersView("read"); 481 setCustomFiltersView("read");
478 isCustomFiltersLoaded = true;
479 } 482 }
480 483
481 function removeCustomFilter(text) 484 function removeCustomFilter(text)
482 { 485 {
483 let index = customFilters.indexOf(text); 486 let index = customFilters.indexOf(text);
484 if (index >= 0) 487 if (index >= 0)
485 customFilters.splice(index, 1); 488 customFilters.splice(index, 1);
486 489
487 updateCustomFiltersUi(); 490 updateCustomFiltersUi();
488 } 491 }
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 for (let property in collections) 1150 for (let property in collections)
1148 collections[property].clearAll(); 1151 collections[property].clearAll();
1149 1152
1150 setCustomFiltersView("empty"); 1153 setCustomFiltersView("empty");
1151 browser.runtime.sendMessage({ 1154 browser.runtime.sendMessage({
1152 type: "subscriptions.get", 1155 type: "subscriptions.get",
1153 special: true 1156 special: true
1154 }, 1157 },
1155 (subscriptions) => 1158 (subscriptions) =>
1156 { 1159 {
1157 // Load filters 1160 let customFilterPromises = subscriptions.map(getSubscriptionFilters);
1158 for (let subscription of subscriptions) 1161 Promise.all(customFilterPromises).then((filters) =>
1159 { 1162 {
1160 browser.runtime.sendMessage({ 1163 loadCustomFilters([].concat(...filters));
1161 type: "filters.get", 1164 isCustomFiltersLoaded = true;
1162 subscriptionUrl: subscription.url 1165 });
1163 },
1164 (filters) =>
1165 {
1166 loadCustomFilters(filters);
1167 });
1168 }
1169 }); 1166 });
1170 loadRecommendations(); 1167 loadRecommendations();
1171 browser.runtime.sendMessage({ 1168 browser.runtime.sendMessage({
1172 type: "prefs.get", 1169 type: "prefs.get",
1173 key: "subscriptions_exceptionsurl" 1170 key: "subscriptions_exceptionsurl"
1174 }, 1171 },
1175 (url) => 1172 (url) =>
1176 { 1173 {
1177 acceptableAdsUrl = url; 1174 acceptableAdsUrl = url;
1178 1175
1179 browser.runtime.sendMessage({ 1176 browser.runtime.sendMessage({
1180 type: "prefs.get", 1177 type: "prefs.get",
1181 key: "subscriptions_exceptionsurl_privacy" 1178 key: "subscriptions_exceptionsurl_privacy"
1182 }, 1179 },
1183 (urlPrivacy) => 1180 (urlPrivacy) =>
1184 { 1181 {
1185 acceptableAdsPrivacyUrl = urlPrivacy; 1182 acceptableAdsPrivacyUrl = urlPrivacy;
1186 1183
1187 // Load user subscriptions 1184 getPref("additional_subscriptions", (subscriptionUrls) =>
1188 browser.runtime.sendMessage({ 1185 {
1189 type: "subscriptions.get", 1186 additionalSubscriptions = subscriptionUrls;
1190 downloadable: true 1187
1191 }, 1188 // Load user subscriptions
1192 (subscriptions) => 1189 browser.runtime.sendMessage({
1193 { 1190 type: "subscriptions.get",
1194 for (let subscription of subscriptions) 1191 downloadable: true
1195 onSubscriptionMessage("added", subscription); 1192 },
1196 1193 (subscriptions) =>
1197 setAcceptableAds(); 1194 {
1195 for (let subscription of subscriptions)
1196 onSubscriptionMessage("added", subscription);
1197
1198 setAcceptableAds();
1199 });
1198 }); 1200 });
1199 }); 1201 });
1200 }); 1202 });
1201 } 1203 }
1202 1204
1203 function addWhitelistedDomain() 1205 function addWhitelistedDomain()
1204 { 1206 {
1205 let domain = E("whitelisting-textbox"); 1207 let domain = E("whitelisting-textbox");
1206 for (let whitelistItem of collections.whitelist.items) 1208 for (let whitelistItem of collections.whitelist.items)
1207 { 1209 {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 else 1335 else
1334 { 1336 {
1335 collections.more.removeItem(subscription); 1337 collections.more.removeItem(subscription);
1336 } 1338 }
1337 } 1339 }
1338 1340
1339 collections.filterLists.removeItem(subscription); 1341 collections.filterLists.removeItem(subscription);
1340 setPrivacyConflict(); 1342 setPrivacyConflict();
1341 break; 1343 break;
1342 } 1344 }
1345 }
1346
1347 function getSubscriptionFilters(subscription)
1348 {
1349 return browser.runtime.sendMessage({
1350 type: "filters.get",
1351 subscriptionUrl: subscription.url});
1343 } 1352 }
1344 1353
1345 function hidePref(key, value) 1354 function hidePref(key, value)
1346 { 1355 {
1347 let element = document.querySelector("[data-pref='" + key + "']"); 1356 let element = document.querySelector("[data-pref='" + key + "']");
1348 if (element) 1357 if (element)
1349 element.setAttribute("aria-hidden", value); 1358 element.setAttribute("aria-hidden", value);
1350 } 1359 }
1351 1360
1352 function getPref(key, callback) 1361 function getPref(key, callback)
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1472 "ui_warn_tracking"] 1481 "ui_warn_tracking"]
1473 }); 1482 });
1474 browser.runtime.sendMessage({ 1483 browser.runtime.sendMessage({
1475 type: "subscriptions.listen", 1484 type: "subscriptions.listen",
1476 filter: ["added", "disabled", "homepage", "lastDownload", "removed", 1485 filter: ["added", "disabled", "homepage", "lastDownload", "removed",
1477 "title", "downloadStatus", "downloading"] 1486 "title", "downloadStatus", "downloading"]
1478 }); 1487 });
1479 1488
1480 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 1489 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
1481 window.addEventListener("hashchange", onHashChange, false); 1490 window.addEventListener("hashchange", onHashChange, false);
LEFTRIGHT

Powered by Google App Engine
This is Rietveld