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

Delta Between Two Patch Sets: options.js

Issue 29321417: Issue 2357 - Added "predefined list" dialog to options page (Closed)
Left Patch Set: post-review: rebased Created July 16, 2015, 10:49 a.m.
Right Patch Set: Post-review: Merged Created July 16, 2015, 11:36 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 | « options.html ('k') | skin/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-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 { 338 {
339 if (!element) 339 if (!element)
340 return; 340 return;
341 341
342 if (element.hasAttribute("data-action")) 342 if (element.hasAttribute("data-action"))
343 break; 343 break;
344 344
345 element = element.parentElement; 345 element = element.parentElement;
346 } 346 }
347 347
348 switch (element.getAttribute("data-action")) 348 var actions = element.getAttribute("data-action").split(",");
349 { 349 for (var i = 0; i < actions.length; i++)
350 case "add-domain-exception": 350 {
351 addWhitelistedDomain(); 351 switch (actions[i])
352 break; 352 {
353 case "add-predefined-subscription": 353 case "add-domain-exception":
354 var dialog = E("dialog-content-predefined"); 354 addWhitelistedDomain();
355 var title = dialog.querySelector("h3").textContent; 355 break;
356 var url = dialog.querySelector(".url").textContent; 356 case "add-predefined-subscription":
357 addEnableSubscription(url, title); 357 var dialog = E("dialog-content-predefined");
358 document.body.removeAttribute("data-dialog"); 358 var title = dialog.querySelector("h3").textContent;
359 break; 359 var url = dialog.querySelector(".url").textContent;
360 case "cancel-domain-exception": 360 addEnableSubscription(url, title);
361 E("whitelisting-textbox").value = ""; 361 document.body.removeAttribute("data-dialog");
362 break; 362 break;
363 case "close-dialog": 363 case "cancel-custom-filters":
364 document.body.removeAttribute("data-dialog"); 364 E("custom-filters").classList.remove("mode-edit");
saroyanm 2015/07/16 12:32:27 Strange, classList according to MDN is supported s
Sebastian Noack 2015/07/16 12:36:50 As I already told you in a different comment, it's
saroyanm 2015/07/16 12:41:01 Ahh right your reference to caniuse went out of my
365 break; 365 break;
366 case "edit-custom-filters": 366 case "cancel-domain-exception":
367 editCustomFilters(); 367 E("whitelisting-textbox").value = "";
368 break; 368 break;
369 case "import-subscription": 369 case "close-dialog":
370 var url = E("blockingList-textbox").value; 370 document.body.removeAttribute("data-dialog");
371 addEnableSubscription(url); 371 break;
372 document.body.removeAttribute("data-dialog"); 372 case "edit-custom-filters":
373 break; 373 E("custom-filters").classList.add("mode-edit");
374 case "open-dialog": 374 editCustomFilters();
375 openDialog(element.getAttribute("data-dialog")); 375 break;
376 break; 376 case "import-subscription":
377 case "switch-tab": 377 var url = E("blockingList-textbox").value;
378 document.body.setAttribute("data-tab", 378 addEnableSubscription(url);
379 element.getAttribute("data-tab")); 379 document.body.removeAttribute("data-dialog");
380 break; 380 break;
381 case "open-dialog":
382 openDialog(element.getAttribute("data-dialog"));
383 break;
384 case "save-custom-filters":
385 ext.backgroundPage.sendMessage(
386 {
387 type: "filters.importRaw",
388 text: E("custom-filters-raw").value
389 });
390 E("custom-filters").classList.remove("mode-edit");
391 break;
392 case "switch-tab":
393 document.body.setAttribute("data-tab",
394 element.getAttribute("data-tab"));
395 break;
396 }
381 } 397 }
382 } 398 }
383 399
384 function onDOMLoaded() 400 function onDOMLoaded()
385 { 401 {
386 var recommendationTemplate = document.querySelector("#recommend-list-table t emplate"); 402 var recommendationTemplate = document.querySelector("#recommend-list-table t emplate");
387 var popularText = ext.i18n.getMessage("options_popular"); 403 var popularText = ext.i18n.getMessage("options_popular");
388 recommendationTemplate.content.querySelector(".popular").textContent = popul arText; 404 recommendationTemplate.content.querySelector(".popular").textContent = popul arText;
389 var languagesTemplate = document.querySelector("#all-lang-table template"); 405 var languagesTemplate = document.querySelector("#all-lang-table template");
390 var buttonText = ext.i18n.getMessage("options_button_add"); 406 var buttonText = ext.i18n.getMessage("options_button_add");
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 text: filterText 471 text: filterText
456 }); 472 });
457 filterTextbox.value = ""; 473 filterTextbox.value = "";
458 } 474 }
459 E("custom-filters-add").addEventListener("submit", function(e) 475 E("custom-filters-add").addEventListener("submit", function(e)
460 { 476 {
461 e.preventDefault(); 477 e.preventDefault();
462 addCustomFilters(); 478 addCustomFilters();
463 }, false); 479 }, false);
464 var customFilterEditButtons = document.querySelectorAll("#custom-filters-edi t-wrapper button"); 480 var customFilterEditButtons = document.querySelectorAll("#custom-filters-edi t-wrapper button");
465 E("custom-filters-edit-wrapper").addEventListener("click", function(e)
466 {
467 var target = null;
468 if (e.target.localName == "button")
469 target = e.target;
470 else if (e.target.parentElement.localName == "button")
471 target = e.target.parentElement;
472 else
473 return;
474
475 var id = target.id;
476 E("custom-filters").classList.toggle("mode-edit");
477 if (id == "custom-filters-show-edit")
478 editCustomFilters();
479 else if (id == "custom-filters-raw-save")
480 {
481 ext.backgroundPage.sendMessage(
482 {
483 type: "filters.importRaw",
484 text: E("custom-filters-raw").value
485 });
486 }
487 }, false);
488 } 481 }
489 482
490 function openDialog(name) 483 function openDialog(name)
491 { 484 {
492 document.body.setAttribute("data-dialog", name); 485 document.body.setAttribute("data-dialog", name);
493 } 486 }
494 487
495 function populateLists() 488 function populateLists()
496 { 489 {
497 subscriptionsMap = Object.create(null); 490 subscriptionsMap = Object.create(null);
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 filter: ["added", "loaded", "removed"] 732 filter: ["added", "loaded", "removed"]
740 }); 733 });
741 ext.backgroundPage.sendMessage( 734 ext.backgroundPage.sendMessage(
742 { 735 {
743 type: "subscriptions.listen", 736 type: "subscriptions.listen",
744 filter: ["added", "disabled", "homepage", "removed", "title"] 737 filter: ["added", "disabled", "homepage", "removed", "title"]
745 }); 738 });
746 739
747 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 740 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
748 })(); 741 })();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld