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

Unified Diff: options.js

Issue 29321417: Issue 2357 - Added "predefined list" dialog to options page (Closed)
Patch Set: Created July 9, 2015, 1:50 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « options.html ('k') | skin/options.css » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: options.js
===================================================================
--- a/options.js
+++ b/options.js
@@ -316,6 +316,55 @@
request.send(null);
}
+ function onClick(e)
+ {
+ var element = e.target;
+ while (true)
+ {
+ if (!element)
+ return;
+
+ if ("action" in element.dataset)
+ break;
+
+ element = element.parentNode;
+ }
+
+ switch (element.dataset.action)
+ {
+ case "add-domain-exception":
+ addWhitelistedDomain();
+ break;
+ case "add-subscription":
+ var dialog = E("dialog-content-addSubscription");
+ var title = dialog.querySelector("h3").textContent;
+ var url = dialog.querySelector(".url").textContent;
+ addEnableSubscription(url, title);
+ delete document.body.dataset.dialog;
+ break;
+ case "cancel-domain-exception":
+ E("whitelisting-textbox").value = "";
+ break;
+ case "close-dialog":
+ delete document.body.dataset.dialog;
+ break;
+ case "edit-custom-filters":
+ editCustomFilters();
+ break;
+ case "import-subscription":
+ var url = E("blockingList-textbox").value;
+ addEnableSubscription(url);
+ delete document.body.dataset.dialog;
+ break;
+ case "open-language-dialog":
+ openDialog("language");
+ break;
+ case "open-subscription-dialog":
+ openDialog("customlist");
+ break;
+ }
+ }
+
function onDOMLoaded()
{
var recommendationTemplate = document.querySelector("#recommend-list-table template");
@@ -368,31 +417,10 @@
updateShareLink();
// Initialize interactive UI elements
+ document.body.addEventListener("click", onClick, false);
var placeholderValue = ext.i18n.getMessage("options_dialog_language_find");
E("find-language").setAttribute("placeholder", placeholderValue);
- E("add-blocking-list").addEventListener("click", function()
- {
- openDialog("customlist");
- }, false);
- E("add-website-language").addEventListener("click", function()
- {
- openDialog("language");
- }, false);
- E("dialog-close").addEventListener("click", function()
- {
- delete document.body.dataset.dialog;
- }, false);
- E("edit-ownBlockingList-button").addEventListener("click", editCustomFilters, false);
E("find-language").addEventListener("keyup", onFindLanguageKeyUp, false);
- E("whitelisting").addEventListener("click", function(e)
- {
- var id = e.target.id;
- if (id == "whitelisting-add-icon" || id == "whitelisting-enter-icon")
- addWhitelistedDomain();
- else if (id == "whitelisting-cancel-button")
- E("whitelisting-textbox").value = "";
- }, false);
- E("whitelisting-add-button").addEventListener("click", addWhitelistedDomain, false);
E("whitelisting-textbox").addEventListener("keypress", function(e)
{
// e.keyCode has been deprecated so we attempt to use e.key
@@ -400,12 +428,6 @@
if ((e.key && e.key == "Enter") || (!e.key && e.keyCode == 13))
addWhitelistedDomain();
}, false);
- E("import-blockingList-button").addEventListener("click", function()
- {
- var url = E("blockingList-textbox").value;
- addEnableSubscription(url);
- delete document.body.dataset.dialog;
- }, false);
}
function openDialog(name)
@@ -606,8 +628,10 @@
function showAddSubscriptionDialog(subscription)
{
- E("blockingList-textbox").value = subscription.url;
- openDialog("customlist");
+ var dialog = E("dialog-content-addSubscription");
+ dialog.querySelector("h3").textContent = subscription.title || "";
+ dialog.querySelector(".url").textContent = subscription.url;
+ openDialog("addSubscription");
}
function updateShareLink()
« no previous file with comments | « options.html ('k') | skin/options.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld