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 3, 2015, 3:55 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 === document.body)
Sebastian Noack 2015/07/09 12:24:18 What if the click event occurs on the <html> eleme
Sebastian Noack 2015/07/09 12:24:19 Nit: We don't use the strict equality operator unl
Thomas Greiner 2015/07/09 13:55:06 I can't find that section in the Mozilla coding st
Thomas Greiner 2015/07/09 13:55:07 Done. Note that it doesn't make a difference in th
Sebastian Noack 2015/07/09 15:16:56 Yes, we are, however if the "click" is is triggere
Sebastian Noack 2015/07/09 15:16:57 You are right, I thought it were the other way aro
+ return;
+
+ if ("action" in element.dataset)
+ break;
+
+ element = element.parentNode;
Sebastian Noack 2015/07/09 15:16:56 This should be |element.parentElement| as mentione
Thomas Greiner 2015/07/10 14:19:15 Done.
+ }
+
+ switch (element.dataset.action)
Sebastian Noack 2015/07/09 12:24:18 Older Safari versions don't have dataset.
Thomas Greiner 2015/07/09 13:55:06 According to caniuse.com it has been supported sin
Sebastian Noack 2015/07/09 15:16:56 Officially, we support Safari 6+. That is mostly b
saroyanm 2015/07/09 17:14:19 I will suggest to make that kind of modification i
Sebastian Noack 2015/07/10 07:58:19 Well, by relying on flexbox, the new option page a
Thomas Greiner 2015/07/10 14:19:15 Done. I wouldn't consider IE support to be releva
+ {
+ 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