Files
fewo-stommer/resources/themes/seebad/theme.js
T
LarsandClaude Opus 5.5 f7cbc66451
Deploy / test (push) Failing after 2s
Deploy / deploy (push) Skipped
Section "Grundriss (interaktiv)": floor plan with rooms, admin editor, Seebad view
- Table floor_plans (tenant_id, one per apartment, picture = website photo, rooms as JSON with
  corners in percent of the picture), model FloorPlan with BelongsToTenant, Property::floorPlan()
- Admin › Webseite › Grundriss: room list with name, description, photos, equipment (from the
  equipment list), accessibility hint, visibility, and an area editor (click the corners on the picture)
- Section floor_plan: base view without JavaScript (areas jump to the room list), Seebad view with
  room buttons, highlighted area and a cartouche per room (theme.js initFloorPlans)
- Tests: tenant inheritance, point parsing, website output, admin create incl. validation; the
  render test for all themes now includes the floor plan
- Docs: THEMES §5, ZUSAMMENARBEIT §6, STATUS §6 (incl. note for tenancy phase 5)
- styles/grundriss: revised rendering, WebP renditions, room areas of the Stommer flat in percent

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 15:26:02 +02:00

100 lines
3.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Theme „Seebad“: übernimmt Lightbox, Verfügbarkeitssuche und rollierende Angebote vom Eltern-Theme.
* Eigene Verbesserungen darunter – alles muss auch ohne JavaScript funktionieren.
*/
import '../ostsee-licht/theme.js';
// Logo, favicon (resources/themes/seebad/img) – addressed in Blade via Vite::asset().
import.meta.glob(['./img/**'], { eager: true, query: '?url' });
/**
* Menu panels (partials/header): the arrow next to a menu item opens a panel with jump links into the page.
* Without JavaScript the arrows stay hidden and the menu items are plain links.
*/
function initMenuPanels() {
const header = document.querySelector('[data-menu]');
const toggles = [...document.querySelectorAll('[data-menu-toggle]')];
if (!header || toggles.length === 0) {
return;
}
const panelOf = (toggle) => document.getElementById(toggle.getAttribute('aria-controls'));
const close = (toggle) => {
toggle.setAttribute('aria-expanded', 'false');
panelOf(toggle).hidden = true;
};
toggles.forEach((toggle) => {
toggle.hidden = false;
toggle.addEventListener('click', () => {
const open = toggle.getAttribute('aria-expanded') === 'true';
toggles.filter((other) => other !== toggle).forEach(close);
toggle.setAttribute('aria-expanded', String(!open));
panelOf(toggle).hidden = open;
});
});
document.addEventListener('keydown', (event) => {
const open = toggles.find((toggle) => toggle.getAttribute('aria-expanded') === 'true');
if (event.key === 'Escape' && open) {
close(open);
open.focus();
}
});
document.addEventListener('click', (event) => {
if (!header.contains(event.target)) {
toggles.forEach(close);
}
});
window.matchMedia('(min-width: 80rem)').addEventListener('change', () => toggles.forEach(close));
}
initMenuPanels();
/**
* Floor plan (sections/floor_plan): one room at a time. Areas and room buttons select a room; on narrow
* screens the description below the plan is scrolled into view. Without JavaScript all rooms are listed.
*/
function initFloorPlans() {
const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
document.querySelectorAll('[data-floor-plan]').forEach((plan) => {
const rooms = [...plan.querySelectorAll('[data-floor-room]')];
const links = [...plan.querySelectorAll('[data-floor-room-link]')];
if (rooms.length === 0) {
return;
}
const select = (key, scroll) => {
rooms.forEach((room) => {
room.hidden = room.id !== key;
});
links.forEach((link) => {
const active = link.dataset.floorRoomLink === key;
link.toggleAttribute('data-active', active);
if (active) {
link.setAttribute('aria-current', 'true');
} else {
link.removeAttribute('aria-current');
}
});
const room = rooms.find((candidate) => candidate.id === key);
if (scroll && room && room.getBoundingClientRect().top > window.innerHeight) {
room.scrollIntoView({ behavior: reduceMotion ? 'auto' : 'smooth', block: 'nearest' });
}
};
links.forEach((link) => {
link.addEventListener('click', (event) => {
event.preventDefault();
select(link.dataset.floorRoomLink, true);
});
});
const fromHash = rooms.find((room) => `#${room.id}` === window.location.hash);
select((fromHash ?? rooms[0]).id, false);
});
}
initFloorPlans();