40 lines
1.3 KiB
JavaScript
40 lines
1.3 KiB
JavaScript
|
|
/*
|
||
|
|
* OrganonTweaks -- the "Save & Close" button on the task edit form. It is a plain type=button (so it
|
||
|
|
* never becomes the Enter default -- Enter still triggers the core Save), and on click it repoints
|
||
|
|
* the form to the plugin's TaskSaveCloseController and lets Kanboard's own modal submit it. Kanboard
|
||
|
|
* keeps ownership of the POST, CSRF, error re-render, and the X-Ajax-Redirect navigation; we only
|
||
|
|
* change the destination, so the controller redirects to the board instead of the card view.
|
||
|
|
*/
|
||
|
|
(function () {
|
||
|
|
"use strict";
|
||
|
|
|
||
|
|
document.addEventListener("click", function (e) {
|
||
|
|
if (!e.target || !e.target.closest) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
var btn = e.target.closest("[data-organon-save-close]");
|
||
|
|
if (!btn) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
e.preventDefault();
|
||
|
|
|
||
|
|
var form = btn.closest("form");
|
||
|
|
var url = btn.getAttribute("data-url");
|
||
|
|
if (!form || !url) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
form.setAttribute("action", url);
|
||
|
|
|
||
|
|
if (window.KB && KB.modal && KB.modal.isOpen && KB.modal.isOpen() && KB.modal.submitForm) {
|
||
|
|
KB.modal.submitForm();
|
||
|
|
} else if (form.requestSubmit) {
|
||
|
|
form.requestSubmit();
|
||
|
|
} else {
|
||
|
|
form.submit();
|
||
|
|
}
|
||
|
|
}, false);
|
||
|
|
})();
|