| 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() |