feat: lightbox gallery, event create UX improvements, cancel modal, footer consistency, Swiss German fixes
This commit is contained in:
1 parent
4b54c48311
commit
e805abbf12
16 files changed
+307
-77
No files matched your search
+21
-10
@@ -8,7 +8,6 @@ const steps = Array.from(document.querySelectorAll(".step"));
|
||||
const backButton = document.getElementById("backButton");
|
||||
const nextButton = document.getElementById("nextButton");
|
||||
const progressBar = document.getElementById("progressBar");
|
||||
const progressMarker = document.getElementById("progressMarker");
|
||||
const progressMarkerLabel = document.getElementById("progressMarkerLabel");
|
||||
const errorMessage = document.getElementById("errorMessage");
|
||||
const usernameElement = document.getElementById("username");
|
||||
@@ -121,7 +120,7 @@ function markRadioGroupInvalid(group) {
|
||||
* Zeigt den gewünschten Schritt an.
|
||||
* Dabei werden auch Buttons, Progress Bar und Review aktualisiert.
|
||||
*/
|
||||
function showStep(index) {
|
||||
function showStep(index, pushHistory = true) {
|
||||
currentStep = index;
|
||||
submissionSuccess.hidden = true;
|
||||
clearStepInvalidState(index);
|
||||
@@ -136,6 +135,11 @@ function showStep(index) {
|
||||
updateProgressBar(index, lastStep);
|
||||
setErrorMessage("");
|
||||
|
||||
// Browser-History aktualisieren, damit Zurück-Taste funktioniert
|
||||
if (pushHistory) {
|
||||
history.pushState({ step: index }, "");
|
||||
}
|
||||
|
||||
// Für bessere UX: bei jedem Schritt wieder nach oben scrollen
|
||||
window.scrollTo({ top: 0, behavior: "smooth" });
|
||||
}
|
||||
@@ -168,22 +172,17 @@ function updateFlowVisibility(stepIndex) {
|
||||
* - letzter Schritt = 100%
|
||||
*/
|
||||
function updateProgressBar(stepIndex, totalStepIndex) {
|
||||
const totalFormSteps = totalStepIndex;
|
||||
let progress = 0;
|
||||
let markerPosition = 0;
|
||||
let markerStep = 1;
|
||||
let markerTransform = "translateX(-50%)";
|
||||
|
||||
if (stepIndex > 0) {
|
||||
progress = ((stepIndex - 1) / (totalStepIndex - 1)) * 100;
|
||||
markerPosition = ((stepIndex - 1) / (totalStepIndex - 1)) * 100;
|
||||
progress = ((stepIndex) / totalFormSteps) * 100;
|
||||
markerStep = stepIndex;
|
||||
}
|
||||
|
||||
progressBar.style.width = `${progress}%`;
|
||||
progressMarker.style.left = `${markerPosition}%`;
|
||||
progressMarker.style.transform = markerTransform;
|
||||
progressMarker.hidden = stepIndex === 0;
|
||||
progressMarkerLabel.textContent = String(markerStep);
|
||||
progressMarkerLabel.textContent = `Schritt ${markerStep} von ${totalFormSteps}`;
|
||||
}
|
||||
|
||||
|
||||
@@ -767,9 +766,21 @@ function initEventCreationFlow() {
|
||||
registerValidationFeedbackHandlers();
|
||||
registerReviewEditHandlers();
|
||||
|
||||
// Browser-Zurück-Taste: vorherigen Schritt wiederherstellen
|
||||
window.addEventListener("popstate", (e) => {
|
||||
if (e.state && typeof e.state.step === "number") {
|
||||
showStep(e.state.step, false);
|
||||
} else {
|
||||
showStep(0, false);
|
||||
}
|
||||
});
|
||||
|
||||
// Startzustand: Intro anzeigen
|
||||
submissionSuccess.hidden = true;
|
||||
showStep(0);
|
||||
|
||||
// Initialen History-Eintrag ersetzen, damit Step 0 im Verlauf ist
|
||||
history.replaceState({ step: 0 }, "");
|
||||
}
|
||||
|
||||
// Startpunkt des Skripts
|
||||
|
||||
+45
-4
@@ -6,7 +6,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||
// DOM entry point and shared asset path.
|
||||
// -------------------------------------------------------------
|
||||
const detailContainer = document.getElementById('detail-view');
|
||||
const locationIconPath = 'assets/location-pin.svg';
|
||||
const locationIconPath = 'assets/icon_location-pin.svg';
|
||||
const currentUser = getCurrentUser();
|
||||
|
||||
// Read event id from query string (detail page deep-link support).
|
||||
@@ -358,12 +358,20 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||
<article class="detail-panel detail-panel-compact">
|
||||
<div class="detail-participants-head">
|
||||
<h2 class="detail-section-title">Teilnehmer</h2>
|
||||
<a href="#" class="detail-participants-link">Alle ansehen</a>
|
||||
<button type="button" class="detail-participants-link" data-show-all-participants>Alle ansehen</button>
|
||||
</div>
|
||||
<div class="detail-avatar-row">
|
||||
<div class="detail-avatar-row" data-participants-row>
|
||||
${visibleParticipants.map(name => `<span class="participant-avatar">${name.charAt(0).toUpperCase()}</span>`).join('')}
|
||||
${remainingParticipants > 0 ? `<span class="participant-more">+${remainingParticipants}</span>` : ''}
|
||||
</div>
|
||||
<div class="detail-participants-full hidden" data-participants-full>
|
||||
${participants.map(name => `
|
||||
<div class="detail-participant-item">
|
||||
<span class="participant-avatar">${name.charAt(0).toUpperCase()}</span>
|
||||
<span class="participant-name">${name}</span>
|
||||
</div>
|
||||
`).join('')}
|
||||
</div>
|
||||
</article>
|
||||
|
||||
${addressPanelMarkup}
|
||||
@@ -392,7 +400,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||
|
||||
<div class="detail-action-buttons">
|
||||
<span class="detail-spots-pill${isFull ? ' detail-spots-pill-full' : ''}">
|
||||
${isFull ? 'AUSGEBUCHT' : `${freePlaces} Plaetze frei`}
|
||||
${isFull ? 'AUSGEBUCHT' : `${freePlaces} Plätze frei`}
|
||||
</span>
|
||||
<button class="detail-primary-btn${actionButtonVariantClass}" type="button" data-register-button ${actionButtonDisabled ? 'disabled' : ''}>
|
||||
${actionButtonLabel}
|
||||
@@ -447,8 +455,27 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||
|
||||
if (registrationSet.has(Number(event.id))) {
|
||||
registrationSet.delete(Number(event.id));
|
||||
|
||||
// Snackbar: Feedback bei Abmeldung.
|
||||
const snackbar = document.getElementById('snackbar');
|
||||
if (snackbar) {
|
||||
snackbar.textContent = 'Du wurdest erfolgreich abgemeldet.';
|
||||
snackbar.classList.add('snackbar--danger', 'snackbar--visible');
|
||||
setTimeout(() => {
|
||||
snackbar.classList.remove('snackbar--visible');
|
||||
setTimeout(() => snackbar.classList.remove('snackbar--danger'), 400);
|
||||
}, 3000);
|
||||
}
|
||||
} else if (!isFull && !isRegistrationClosed) {
|
||||
registrationSet.add(Number(event.id));
|
||||
|
||||
// Snackbar: Feedback bei Anmeldung.
|
||||
const snackbar = document.getElementById('snackbar');
|
||||
if (snackbar) {
|
||||
snackbar.textContent = 'Du wurdest erfolgreich angemeldet.';
|
||||
snackbar.classList.add('snackbar--visible');
|
||||
setTimeout(() => snackbar.classList.remove('snackbar--visible'), 3000);
|
||||
}
|
||||
}
|
||||
|
||||
nextRegistrationMap[currentUser.email] = Array.from(registrationSet);
|
||||
@@ -459,6 +486,20 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||
});
|
||||
}
|
||||
|
||||
// "Alle ansehen": Teilnehmerliste aufklappen / zuklappen.
|
||||
const showAllBtn = detailContainer.querySelector('[data-show-all-participants]');
|
||||
const avatarRow = detailContainer.querySelector('[data-participants-row]');
|
||||
const fullList = detailContainer.querySelector('[data-participants-full]');
|
||||
|
||||
if (showAllBtn && avatarRow && fullList) {
|
||||
showAllBtn.addEventListener('click', () => {
|
||||
const isExpanded = !fullList.classList.contains('hidden');
|
||||
fullList.classList.toggle('hidden');
|
||||
avatarRow.classList.toggle('hidden');
|
||||
showAllBtn.textContent = isExpanded ? 'Alle ansehen' : 'Weniger anzeigen';
|
||||
});
|
||||
}
|
||||
|
||||
// Central close helper to keep all close paths consistent.
|
||||
function closeLightbox() {
|
||||
if (!lightbox) {
|
||||
|
||||
@@ -294,11 +294,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
});
|
||||
|
||||
const filtered = allEvents.filter(event => {
|
||||
// Lokal erstellte Events werden nicht in der allgemeinen Event-Uebersicht angezeigt.
|
||||
if (event.source === 'local') {
|
||||
return false;
|
||||
}
|
||||
|
||||
const categoryMatch = activeCategory === 'ALLE' || event.category === activeCategory;
|
||||
const locationMatch = selectedLocation === 'ALLE_ORTE' || event.location === selectedLocation;
|
||||
const eventDateIso = parseEventDateToIso(event.date);
|
||||
|
||||
@@ -97,4 +97,47 @@ if (carouselTrack) {
|
||||
buildDots();
|
||||
updateTrack();
|
||||
});
|
||||
|
||||
// =============================================
|
||||
// Lightbox: Bild vergroessern bei Klick
|
||||
// =============================================
|
||||
const lightbox = document.getElementById('gallery-lightbox');
|
||||
const lightboxImage = lightbox ? lightbox.querySelector('.lightbox__image') : null;
|
||||
|
||||
function openLightbox(src, alt) {
|
||||
if (!lightbox || !lightboxImage) return;
|
||||
lightboxImage.src = src;
|
||||
lightboxImage.alt = alt || 'Grossansicht';
|
||||
lightbox.classList.add('is-open');
|
||||
lightbox.setAttribute('aria-hidden', 'false');
|
||||
}
|
||||
|
||||
function closeLightbox() {
|
||||
if (!lightbox) return;
|
||||
lightbox.classList.remove('is-open');
|
||||
lightbox.setAttribute('aria-hidden', 'true');
|
||||
lightboxImage.src = '';
|
||||
}
|
||||
|
||||
// Klick auf Galerie-Bild oeffnet die Lightbox.
|
||||
items.forEach(function(item) {
|
||||
var img = item.querySelector('img');
|
||||
if (img) {
|
||||
item.addEventListener('click', function() {
|
||||
openLightbox(img.src, img.alt);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Lightbox schliessen: Backdrop, Close-Button oder ESC-Taste.
|
||||
if (lightbox) {
|
||||
lightbox.querySelector('.lightbox__close').addEventListener('click', closeLightbox);
|
||||
lightbox.querySelector('[data-close-lightbox]').addEventListener('click', closeLightbox);
|
||||
|
||||
document.addEventListener('keydown', function(e) {
|
||||
if (e.key === 'Escape' && lightbox.classList.contains('is-open')) {
|
||||
closeLightbox();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+29
-1
@@ -177,7 +177,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
if (cancelButton && currentUser?.email) {
|
||||
const eventId = Number(cancelButton.getAttribute('data-cancel-event-id'));
|
||||
if (Number.isFinite(eventId)) {
|
||||
cancelHostedEvent(eventId, currentUser.email);
|
||||
openCancelEventModal(eventId);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -265,6 +265,34 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
|
||||
|
||||
// Sagt ein gehostetes Event ab (aus eigener Profilansicht entfernen).
|
||||
let pendingCancelEventId = null;
|
||||
|
||||
function openCancelEventModal(eventId) {
|
||||
pendingCancelEventId = eventId;
|
||||
const modal = document.getElementById('cancelEventModal');
|
||||
modal.classList.add('show');
|
||||
}
|
||||
|
||||
window.closeCancelEventModal = function() {
|
||||
pendingCancelEventId = null;
|
||||
const modal = document.getElementById('cancelEventModal');
|
||||
modal.classList.remove('show');
|
||||
};
|
||||
|
||||
document.getElementById('confirmCancelEventBtn').addEventListener('click', function() {
|
||||
if (pendingCancelEventId !== null && currentUser?.email) {
|
||||
cancelHostedEvent(pendingCancelEventId, currentUser.email);
|
||||
}
|
||||
closeCancelEventModal();
|
||||
});
|
||||
|
||||
// Schliesst das Modal bei Klick ausserhalb des Inhalts.
|
||||
document.getElementById('cancelEventModal').addEventListener('click', function(e) {
|
||||
if (e.target === this) {
|
||||
closeCancelEventModal();
|
||||
}
|
||||
});
|
||||
|
||||
function cancelHostedEvent(eventId, userEmail) {
|
||||
// Lokal erstellte, eigene Events werden direkt aus dem Storage geloescht.
|
||||
const storedEvents = getStoredEvents();
|
||||
|
||||
+2
-2
@@ -42,7 +42,7 @@ function openWelcomeModal() {
|
||||
document.body.style.overflow = 'hidden';
|
||||
}
|
||||
|
||||
// Funktion zum Schließen des Welcome Modals
|
||||
// Funktion zum Schliessen des Welcome Modals
|
||||
function closeWelcomeModal() {
|
||||
welcomeModal.classList.remove('show');
|
||||
document.body.style.overflow = 'auto';
|
||||
@@ -172,7 +172,7 @@ passwortInput.addEventListener('input', function() {
|
||||
}
|
||||
});
|
||||
|
||||
// Modal schließen wenn außerhalb geklickt wird
|
||||
// Modal schliessen wenn ausserhalb geklickt wird
|
||||
welcomeModal.addEventListener('click', function(event) {
|
||||
if (event.target === welcomeModal) {
|
||||
closeWelcomeModal();
|
||||
|
||||
Reference in new issue
Block a user