37 lines
1.3 KiB
JavaScript
37 lines
1.3 KiB
JavaScript
/*
|
|
* OrganonTweaks -- clicking a task title opens the edit modal instead of the read-only card view,
|
|
* reusing Kanboard's own modal opener (KB.modal.open). Board part: the title is a link, and a hidden
|
|
* marker rendered next to it (only when the user may edit) carries the server-generated edit URL.
|
|
*
|
|
* A capture-phase delegated click is used so it (a) runs before Kanboard's own bubble-phase handlers,
|
|
* (b) survives the board's AJAX re-renders without re-binding, and (c) stops both the link navigation
|
|
* and the card's own click.
|
|
*/
|
|
(function () {
|
|
"use strict";
|
|
|
|
function openEdit(url) {
|
|
if (url && window.KB && KB.modal) {
|
|
KB.modal.open(url, "large", false);
|
|
}
|
|
}
|
|
|
|
document.addEventListener("click", function (e) {
|
|
if (!e.target || !e.target.closest) {
|
|
return;
|
|
}
|
|
|
|
// Board card title -> open the edit modal via the per-card marker URL.
|
|
var link = e.target.closest(".task-board-title a");
|
|
if (link) {
|
|
var card = link.closest(".task-board");
|
|
var marker = card ? card.querySelector(".organon-edit-url") : null;
|
|
if (marker) {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
openEdit(marker.getAttribute("data-url"));
|
|
}
|
|
}
|
|
}, true);
|
|
})();
|