/*
* BulkMoveTasks -- place the "Move tasks in bulk" entry inside the native column menu.
*
* Kanboard only exposes the template:board:column:dropdown hook AFTER the column menu
*
, and its dropdown JS clones just that when the menu opens. So the hook item
* cannot reach the menu on its own. The column_dropdown.php template renders the item
* hidden next to the menu; this script moves each such item into that column's real
* so it appears alongside "Hide this column", "Create tasks in bulk", etc.
*
* It re-runs when the board is redrawn (AJAX polling / drag-and-drop refresh).
*/
(function () {
"use strict";
function relocate() {
var items = document.querySelectorAll(".bulkmovetasks-menu-item");
for (var i = 0; i < items.length; i++) {
var li = items[i];
// Already moved into a menu list: just make sure it is visible.
if (li.closest("ul")) {
li.style.display = "";
continue;
}
// The hook renders the item as a child of the column's dropdown wrapper;
// its first is the native menu.
var menu = li.parentNode ? li.parentNode.querySelector("ul") : null;
if (menu) {
menu.appendChild(li);
li.style.display = "";
}
}
}
function init() {
if (!document.getElementById("board")) {
return;
}
relocate();
var container = document.getElementById("board-container");
if (container && window.MutationObserver) {
new MutationObserver(relocate).observe(container, { childList: true, subtree: true });
}
}
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", init);
} else {
init();
}
})();