| 1 | (function () { |
| 2 | var open = document.querySelector("[data-transfer-open]"); |
| 3 | var dialog = document.querySelector("[data-transfer-dialog]"); |
| 4 | if (!open || !dialog) { |
| 5 | return; |
| 6 | } |
| 7 | var copy = dialog.querySelector("[data-transfer-copy]"); |
| 8 | var user = dialog.querySelector("[data-transfer-user]"); |
| 9 | var input = dialog.querySelector("[data-transfer-confirm]"); |
| 10 | var button = dialog.querySelector("[data-transfer-submit]"); |
| 11 | var cancel = dialog.querySelector("[data-transfer-cancel]"); |
| 12 | var pattern = copy ? copy.getAttribute("data-pattern") : ""; |
| 13 | |
| 14 | function sync() { |
| 15 | var name = user ? user.value : ""; |
| 16 | if (copy) { |
| 17 | copy.textContent = pattern.replace("%s", name); |
| 18 | } |
| 19 | if (button) { |
| 20 | button.disabled = !input || input.value !== name; |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | open.addEventListener("click", function () { |
| 25 | if (input) { |
| 26 | input.value = ""; |
| 27 | } |
| 28 | sync(); |
| 29 | dialog.showModal(); |
| 30 | }); |
| 31 | if (user) { |
| 32 | user.addEventListener("change", sync); |
| 33 | } |
| 34 | if (input) { |
| 35 | input.addEventListener("input", sync); |
| 36 | } |
| 37 | if (cancel) { |
| 38 | cancel.addEventListener("click", function () { |
| 39 | dialog.close(); |
| 40 | }); |
| 41 | } |
| 42 | sync(); |
| 43 | })(); |
| 44 | |
| 45 | // Groep verwijderen: eigen modal, knop pas actief na de groepsnaam. |
| 46 | (function () { |
| 47 | var open = document.querySelector("[data-gdel-open]"); |
| 48 | var dialog = document.querySelector("[data-gdel-dialog]"); |
| 49 | if (!open || !dialog) { |
| 50 | return; |
| 51 | } |
| 52 | var input = dialog.querySelector("[data-gdel-confirm]"); |
| 53 | var button = dialog.querySelector("[data-gdel-submit]"); |
| 54 | function sync() { |
| 55 | var v = input.value.trim(); |
| 56 | button.disabled = v !== input.getAttribute("data-name") && v !== input.getAttribute("data-path"); |
| 57 | } |
| 58 | open.addEventListener("click", function () { |
| 59 | input.value = ""; |
| 60 | sync(); |
| 61 | dialog.showModal(); |
| 62 | input.focus(); |
| 63 | }); |
| 64 | input.addEventListener("input", sync); |
| 65 | dialog.querySelector("[data-gdel-cancel]").addEventListener("click", function () { |
| 66 | dialog.close(); |
| 67 | }); |
| 68 | })(); |
| 69 | |
| 70 | // Fork: eigen modal om doel en naam te kiezen. |
| 71 | (function () { |
| 72 | var open = document.querySelector("[data-fork-open]"); |
| 73 | var dialog = document.querySelector("[data-fork-dialog]"); |
| 74 | if (!open || !dialog) { |
| 75 | return; |
| 76 | } |
| 77 | open.addEventListener("click", function () { |
| 78 | dialog.showModal(); |
| 79 | }); |
| 80 | dialog.querySelector("[data-fork-cancel]").addEventListener("click", function () { |
| 81 | dialog.close(); |
| 82 | }); |
| 83 | })(); |