Invite now opens a member-list popup instead of an inline auto-submit select, and class selection reuses the raid-signup modal's class-picker grid, triggered via a "Klasse festlegen/ändern" button. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
74 lines
2.7 KiB
JavaScript
74 lines
2.7 KiB
JavaScript
(function () {
|
|
'use strict';
|
|
|
|
function openModal(modal) {
|
|
if (modal) modal.hidden = false;
|
|
}
|
|
|
|
function closeModal(modal) {
|
|
if (modal) modal.hidden = true;
|
|
}
|
|
|
|
function wireModal(modal) {
|
|
if (!modal) return;
|
|
var closeBtn = modal.querySelector('.modal-close');
|
|
if (closeBtn) closeBtn.addEventListener('click', function () { closeModal(modal); });
|
|
modal.addEventListener('click', function (e) {
|
|
if (e.target === modal) closeModal(modal);
|
|
});
|
|
}
|
|
|
|
// ---- Mitglied einladen ----
|
|
var inviteModal = document.getElementById('premade-invite-modal');
|
|
var inviteForm = document.getElementById('premade-invite-form');
|
|
var invitePremadeIdField = document.getElementById('premade-invite-premade-id');
|
|
var inviteUserIdField = document.getElementById('premade-invite-user-id');
|
|
|
|
wireModal(inviteModal);
|
|
|
|
document.querySelectorAll('.premade-slot-invite-btn').forEach(function (btn) {
|
|
btn.addEventListener('click', function () {
|
|
invitePremadeIdField.value = btn.getAttribute('data-premade-id') || '';
|
|
openModal(inviteModal);
|
|
});
|
|
});
|
|
|
|
if (inviteModal) {
|
|
inviteModal.querySelectorAll('.premade-invite-option').forEach(function (btn) {
|
|
btn.addEventListener('click', function () {
|
|
inviteUserIdField.value = btn.getAttribute('data-user-id') || '';
|
|
inviteForm.submit();
|
|
});
|
|
});
|
|
}
|
|
|
|
// ---- Klasse festlegen/aendern ----
|
|
var classModal = document.getElementById('premade-class-modal');
|
|
var classForm = document.getElementById('premade-class-form');
|
|
var classPremadeIdField = document.getElementById('premade-class-premade-id');
|
|
var classValueField = document.getElementById('premade-class-value');
|
|
|
|
wireModal(classModal);
|
|
|
|
document.querySelectorAll('.premade-class-btn').forEach(function (btn) {
|
|
btn.addEventListener('click', function () {
|
|
classPremadeIdField.value = btn.getAttribute('data-premade-id') || '';
|
|
var currentClass = btn.getAttribute('data-current-class') || '';
|
|
if (classModal) {
|
|
classModal.querySelectorAll('.class-picker-option').forEach(function (option) {
|
|
option.classList.toggle('selected', option.getAttribute('data-class') === currentClass);
|
|
});
|
|
}
|
|
openModal(classModal);
|
|
});
|
|
});
|
|
|
|
if (classModal) {
|
|
classModal.querySelectorAll('.class-picker-option').forEach(function (btn) {
|
|
btn.addEventListener('click', function () {
|
|
classValueField.value = btn.getAttribute('data-class') || '';
|
|
classForm.submit();
|
|
});
|
|
});
|
|
}
|
|
})();
|