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

Side by Side Diff: new-options.js

Issue 29480624: Issue 5374 - Add filter list popup (Closed)
Patch Set: Created July 7, 2017, 6:12 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
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-2017 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 element.querySelector(".display").textContent = title; 212 element.querySelector(".display").textContent = title;
213 element.setAttribute("aria-label", title); 213 element.setAttribute("aria-label", title);
214 if (this.details[i].searchable) 214 if (this.details[i].searchable)
215 element.setAttribute("data-search", title.toLowerCase()); 215 element.setAttribute("data-search", title.toLowerCase());
216 let control = element.querySelector(".control[role='checkbox']"); 216 let control = element.querySelector(".control[role='checkbox']");
217 if (control) 217 if (control)
218 { 218 {
219 control.setAttribute("aria-checked", item.disabled == false); 219 control.setAttribute("aria-checked", item.disabled == false);
220 if (item.url == acceptableAdsUrl && this == collections.filterLists) 220 if (item.url == acceptableAdsUrl && this == collections.filterLists)
221 control.disabled = true; 221 control.disabled = true;
222
223 if (this.details[i].checkedDisabled)
224 {
225 control.disabled = item.disabled == false;
226 element.setAttribute("aria-disabled", true);
227 }
222 } 228 }
223 229
230 let descriptionElem = element.querySelector(".description");
231 if (descriptionElem)
232 descriptionElem.textContent = item.description;
233
224 let dateElement = element.querySelector(".date"); 234 let dateElement = element.querySelector(".date");
225 let timeElement = element.querySelector(".time"); 235 let timeElement = element.querySelector(".time");
226 if (dateElement && timeElement) 236 if (dateElement && timeElement)
227 { 237 {
228 let message = element.querySelector(".message"); 238 let message = element.querySelector(".message");
229 if (item.isDownloading) 239 if (item.isDownloading)
230 { 240 {
231 let text = getMessage("options_filterList_lastDownload_inProgress"); 241 let text = getMessage("options_filterList_lastDownload_inProgress");
232 message.textContent = text; 242 message.textContent = text;
233 element.classList.add("show-message"); 243 element.classList.add("show-message");
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 if (!nextElement) 308 if (!nextElement)
299 return false; 309 return false;
300 310
301 nextElement.focus(); 311 nextElement.focus();
302 return true; 312 return true;
303 } 313 }
304 314
305 collections.popular = new Collection([ 315 collections.popular = new Collection([
306 { 316 {
307 id: "recommend-list-table" 317 id: "recommend-list-table"
318 },
319 {
320 id: "recommend-general-list-table",
321 checkedDisabled: true
308 } 322 }
309 ]); 323 ]);
310 collections.langs = new Collection([ 324 collections.langs = new Collection([
311 { 325 {
312 id: "blocking-languages-table", 326 id: "blocking-languages-table",
313 emptyText: ["options_dialog_language_added_empty"] 327 emptyText: ["options_dialog_language_added_empty"]
314 }, 328 },
315 { 329 {
316 id: "blocking-languages-dialog-table", 330 id: "blocking-languages-dialog-table",
317 emptyText: ["options_dialog_language_added_empty"] 331 emptyText: ["options_dialog_language_added_empty"]
318 } 332 }
319 ]); 333 ]);
320 collections.allLangs = new Collection([ 334 collections.allLangs = new Collection([
321 { 335 {
322 id: "all-lang-table", 336 id: "all-lang-table",
323 emptyText: ["options_dialog_language_other_empty"], 337 emptyText: ["options_dialog_language_other_empty"],
324 searchable: true 338 searchable: true
339 },
340 {
341 id: "recommend-ads-list-table",
342 checkedDisabled: true
325 } 343 }
326 ]); 344 ]);
327 collections.acceptableAds = new Collection([ 345 collections.acceptableAds = new Collection([
328 { 346 {
329 id: "acceptableads-table" 347 id: "acceptableads-table"
330 } 348 }
331 ]); 349 ]);
332 collections.custom = new Collection([ 350 collections.custom = new Collection([
333 { 351 {
334 id: "custom-list-table" 352 id: "custom-list-table"
(...skipping 22 matching lines...) Expand all
357 { 375 {
358 if (subscription.recommended == "ads") 376 if (subscription.recommended == "ads")
359 { 377 {
360 if (subscription.disabled) 378 if (subscription.disabled)
361 { 379 {
362 collections.allLangs.addItem(subscription); 380 collections.allLangs.addItem(subscription);
363 collections.langs.removeItem(subscription); 381 collections.langs.removeItem(subscription);
364 } 382 }
365 else 383 else
366 { 384 {
367 collections.allLangs.removeItem(subscription);
368 collections.langs.addItem(subscription); 385 collections.langs.addItem(subscription);
369 } 386 }
370 } 387 }
371 } 388 }
372 389
373 function addSubscription(subscription) 390 function addSubscription(subscription)
374 { 391 {
375 let collection; 392 let collection;
376 if (subscription.recommended) 393 if (subscription.recommended)
377 { 394 {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 homepage: null, 452 homepage: null,
436 originalTitle: element.getAttribute("title"), 453 originalTitle: element.getAttribute("title"),
437 recommended: type, 454 recommended: type,
438 url: element.getAttribute("url") 455 url: element.getAttribute("url")
439 }; 456 };
440 457
441 let prefix = element.getAttribute("prefixes"); 458 let prefix = element.getAttribute("prefixes");
442 if (prefix) 459 if (prefix)
443 { 460 {
444 prefix = prefix.replace(/\W/g, "_"); 461 prefix = prefix.replace(/\W/g, "_");
445 subscription.title = getMessage("options_language_" + prefix); 462 subscription.title = element.getAttribute("specialization");
463 subscription.description = getMessage("options_language_" + prefix);
saroyanm 2017/07/07 18:22:11 The strings will need to be updated after the spec
saroyanm 2017/07/13 17:09:22 Updated the reference -> https://bitbucket.org/adb
446 } 464 }
447 else 465 else
448 { 466 {
449 type = type.replace(/\W/g, "_"); 467 type = type.replace(/\W/g, "_");
450 subscription.title = getMessage("common_feature_" + 468 subscription.title = getMessage("options_feature_" +
451 type + "_title"); 469 type + "_title");
470 subscription.description = getMessage("options_feature_" +
saroyanm 2017/07/07 18:22:11 I don't think that TYPE is a unique identifier for
saroyanm 2017/07/13 17:09:22 As discussed we can still use type, while we are p
471 type + "_description");
452 } 472 }
453 473
454 addSubscription(subscription); 474 addSubscription(subscription);
455 } 475 }
456 }); 476 });
457 } 477 }
458 478
459 function findParentData(element, dataName, returnElement) 479 function findParentData(element, dataName, returnElement)
460 { 480 {
461 while (element) 481 while (element)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 location.hash = id; 519 location.hash = id;
500 } 520 }
501 521
502 function execAction(action, element) 522 function execAction(action, element)
503 { 523 {
504 switch (action) 524 switch (action)
505 { 525 {
506 case "add-domain-exception": 526 case "add-domain-exception":
507 addWhitelistedDomain(); 527 addWhitelistedDomain();
508 break; 528 break;
509 case "add-language-subscription": 529 case "add-enable-subscription":
510 addEnableSubscription(findParentData(element, "access", false)); 530 addEnableSubscription(findParentData(element, "access", false));
511 break; 531 break;
512 case "add-predefined-subscription": { 532 case "add-predefined-subscription": {
513 let dialog = E("dialog-content-predefined"); 533 let dialog = E("dialog-content-predefined");
514 let title = dialog.querySelector("h3").textContent; 534 let title = dialog.querySelector("h3").textContent;
515 let url = dialog.querySelector(".url").textContent; 535 let url = dialog.querySelector(".url").textContent;
516 addEnableSubscription(url, title); 536 addEnableSubscription(url, title);
517 closeDialog(); 537 closeDialog();
518 break; 538 break;
519 } 539 }
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 }); 1336 });
1317 ext.backgroundPage.sendMessage({ 1337 ext.backgroundPage.sendMessage({
1318 type: "subscriptions.listen", 1338 type: "subscriptions.listen",
1319 filter: ["added", "disabled", "homepage", "lastDownload", "removed", 1339 filter: ["added", "disabled", "homepage", "lastDownload", "removed",
1320 "title", "downloadStatus", "downloading"] 1340 "title", "downloadStatus", "downloading"]
1321 }); 1341 });
1322 1342
1323 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 1343 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
1324 window.addEventListener("hashchange", onHashChange, false); 1344 window.addEventListener("hashchange", onHashChange, false);
1325 } 1345 }
OLDNEW

Powered by Google App Engine
This is Rietveld