BlueGit

timfa bluegit

Files

bluegit / internal / server / static / hookcopy.js

hookcopy.js

hookcopy.js 1.2 KiB Download Raw
1// Kopieervenster voor webhooks (eigen modal, geen browser-popup).
2(function () {
3 var dlg = document.querySelector("[data-hookcopy-dialog]");
4 if (!dlg) { return; }
5 var id = dlg.querySelector("[data-hookcopy-id]");
6 var name = dlg.querySelector("[data-hookcopy-name-input]");
7 document.querySelectorAll("[data-hookcopy-open]").forEach(function (b) {
8 b.addEventListener("click", function () {
9 id.value = b.getAttribute("data-hookcopy-open");
10 name.value = "";
11 name.placeholder = b.getAttribute("data-hookcopy-name") || "";
12 document.documentElement.classList.add("bgmodal-open");
13 if (dlg.showModal) { dlg.showModal(); } else { dlg.setAttribute("open", ""); }
14 var sel = dlg.querySelector("select");
15 if (sel) { sel.focus(); }
16 });
17 });
18 function close() {
19 document.documentElement.classList.remove("bgmodal-open");
20 if (dlg.open) { dlg.close(); }
21 }
22 dlg.querySelector("[data-hookcopy-cancel]").addEventListener("click", close);
23 dlg.addEventListener("close", function () { document.documentElement.classList.remove("bgmodal-open"); });
24 dlg.addEventListener("click", function (e) { if (e.target === dlg) { close(); } });
25})();