diff options
author | Frédéric Guillot <fred@miniflux.net> | 2018-08-25 12:21:54 -0700 |
---|---|---|
committer | Frédéric Guillot <fred@miniflux.net> | 2018-08-25 12:21:54 -0700 |
commit | 551b73acfb6ed4620387c7345b117d32697deb77 (patch) | |
tree | 4c46ec045da34d03a3e8230e25e48e0237f0685c /ui/static/js | |
parent | febce4f2e3a86da4171783fcc593b25a807c3da8 (diff) |
Add remove button in feed edit page
Diffstat (limited to 'ui/static/js')
-rw-r--r-- | ui/static/js/bootstrap.js | 1 | ||||
-rw-r--r-- | ui/static/js/confirm_handler.js | 14 |
2 files changed, 12 insertions, 3 deletions
diff --git a/ui/static/js/bootstrap.js b/ui/static/js/bootstrap.js index bd3b09e..3e9004f 100644 --- a/ui/static/js/bootstrap.js +++ b/ui/static/js/bootstrap.js @@ -58,6 +58,7 @@ document.addEventListener("DOMContentLoaded", function() { }); mouseHandler.onClick("a[data-on-click=markPageAsRead]", () => navHandler.markPageAsRead()); + mouseHandler.onClick("a[data-confirm]", (event) => { (new ConfirmHandler()).handle(event); }); diff --git a/ui/static/js/confirm_handler.js b/ui/static/js/confirm_handler.js index 9fe9133..c0147cd 100644 --- a/ui/static/js/confirm_handler.js +++ b/ui/static/js/confirm_handler.js @@ -1,7 +1,15 @@ class ConfirmHandler { - remove(url) { + executeRequest(url, redirectURL) { let request = new RequestBuilder(url); - request.withCallback(() => window.location.reload()); + + request.withCallback(() => { + if (redirectURL) { + window.location.href = redirectURL; + } else { + window.location.reload(); + } + }); + request.execute(); } @@ -24,7 +32,7 @@ class ConfirmHandler { questionElement.remove(); containerElement.appendChild(loadingElement); - this.remove(linkElement.dataset.url); + this.executeRequest(linkElement.dataset.url, linkElement.dataset.redirectUrl); }; let noElement = document.createElement("a"); |