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

Side by Side Diff: new-options.js

Issue 29519650: Issue 5540 - implement notification (Closed)
Patch Set: Created Aug. 25, 2017, 1:20 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
« no previous file with comments | « new-options.html ('k') | skin/delete.svg » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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-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
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 } 425 }
426 } 426 }
427 427
428 function updateFilter(filter) 428 function updateFilter(filter)
429 { 429 {
430 let match = filter.text.match(whitelistedDomainRegexp); 430 let match = filter.text.match(whitelistedDomainRegexp);
431 if (match && !filtersMap[filter.text]) 431 if (match && !filtersMap[filter.text])
432 { 432 {
433 filter.title = match[1]; 433 filter.title = match[1];
434 collections.whitelist.addItem(filter); 434 collections.whitelist.addItem(filter);
435 if (isCustomFiltersLoaded)
436 {
437 let text = getMessage("options_whitelist_notification", [filter.title]);
438 showNotification(text);
439 }
435 } 440 }
436 else 441 else
437 { 442 {
438 customFilters.push(filter.text); 443 customFilters.push(filter.text);
439 if (isCustomFiltersLoaded) 444 if (isCustomFiltersLoaded)
440 updateCustomFiltersUi(); 445 updateCustomFiltersUi();
441 } 446 }
442 447
443 filtersMap[filter.text] = filter; 448 filtersMap[filter.text] = filter;
444 } 449 }
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 break; 586 break;
582 } 587 }
583 } 588 }
584 break; 589 break;
585 case "close-dialog": 590 case "close-dialog":
586 closeDialog(); 591 closeDialog();
587 break; 592 break;
588 case "edit-custom-filters": 593 case "edit-custom-filters":
589 setCustomFiltersView("write"); 594 setCustomFiltersView("write");
590 break; 595 break;
596 case "hide-notification":
597 hideNotification();
598 break;
591 case "import-subscription": { 599 case "import-subscription": {
592 let url = E("blockingList-textbox").value; 600 let url = E("blockingList-textbox").value;
593 addEnableSubscription(url); 601 addEnableSubscription(url);
594 closeDialog(); 602 closeDialog();
595 break; 603 break;
596 } 604 }
597 case "open-context-menu": { 605 case "open-context-menu": {
598 let listItem = findParentData(element, "access", true); 606 let listItem = findParentData(element, "access", true);
599 if (listItem && !listItem.classList.contains("show-context-menu")) 607 if (listItem && !listItem.classList.contains("show-context-menu"))
600 listItem.classList.add("show-context-menu"); 608 listItem.classList.add("show-context-menu");
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 994
987 function closeDialog() 995 function closeDialog()
988 { 996 {
989 let dialog = E("dialog"); 997 let dialog = E("dialog");
990 dialog.setAttribute("aria-hidden", true); 998 dialog.setAttribute("aria-hidden", true);
991 dialog.removeAttribute("aria-labelledby"); 999 dialog.removeAttribute("aria-labelledby");
992 document.body.removeAttribute("data-dialog"); 1000 document.body.removeAttribute("data-dialog");
993 focusedBeforeDialog.focus(); 1001 focusedBeforeDialog.focus();
994 } 1002 }
995 1003
1004 function showNotification(text)
1005 {
1006 E("notification").setAttribute("aria-hidden", false);
1007 E("notification-text").textContent = text;
1008 setTimeout(hideNotification, 3000);
1009 }
1010
1011 function hideNotification()
1012 {
1013 E("notification").setAttribute("aria-hidden", true);
1014 E("notification-text").textContent = "";
1015 }
1016
996 function setAcceptableAds() 1017 function setAcceptableAds()
997 { 1018 {
998 let option = "none"; 1019 let option = "none";
999 document.forms["acceptable-ads"].classList.remove("show-dnt-notification"); 1020 document.forms["acceptable-ads"].classList.remove("show-dnt-notification");
1000 if (acceptableAdsUrl in subscriptionsMap) 1021 if (acceptableAdsUrl in subscriptionsMap)
1001 { 1022 {
1002 option = "ads"; 1023 option = "ads";
1003 } 1024 }
1004 else if (acceptableAdsPrivacyUrl in subscriptionsMap) 1025 else if (acceptableAdsPrivacyUrl in subscriptionsMap)
1005 { 1026 {
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 }); 1388 });
1368 ext.backgroundPage.sendMessage({ 1389 ext.backgroundPage.sendMessage({
1369 type: "subscriptions.listen", 1390 type: "subscriptions.listen",
1370 filter: ["added", "disabled", "homepage", "lastDownload", "removed", 1391 filter: ["added", "disabled", "homepage", "lastDownload", "removed",
1371 "title", "downloadStatus", "downloading"] 1392 "title", "downloadStatus", "downloading"]
1372 }); 1393 });
1373 1394
1374 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 1395 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
1375 window.addEventListener("hashchange", onHashChange, false); 1396 window.addEventListener("hashchange", onHashChange, false);
1376 } 1397 }
OLDNEW
« no previous file with comments | « new-options.html ('k') | skin/delete.svg » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld