export class FabMenu extends HTMLElement { constructor() { super(); this.state = null; // Will be set in connectedCallback: 'closed', 'half', 'full' this.handleClick = this.handleClick.bind(this); this.handleClickAway = this.handleClickAway.bind(this); } connectedCallback() { // Get data attributes passed from template const userName = this.getAttribute("data-user-name") || "Benutzer"; const userEmail = this.getAttribute("data-user-email") || ""; const userId = this.getAttribute("data-user-id") || ""; const isAdminOrEditor = this.getAttribute("data-is-admin-or-editor") === "true"; const isAdmin = this.getAttribute("data-is-admin") === "true"; const redirectPath = this.getAttribute("data-redirect-path") || ""; // Detect context from URL const path = window.location.pathname; let hasReihe = false, reiheId = "", reiheUpdated = ""; let hasPerson = false, personId = ""; let hasEntry = false, entryId = "", entryUpdated = ""; let hasPage = false, pageKey = ""; // Reihe detail page: /reihe/{id} (but not /reihe/new or /reihe/{id}/edit) const reiheMatch = path.match(/^\/reihe\/([^\/]+)\/?$/); if (reiheMatch && reiheMatch[1] !== "new") { hasReihe = true; reiheId = reiheMatch[1]; // Try to get updated timestamp from page const updatedMeta = document.querySelector('meta[name="entity-updated"]'); if (updatedMeta) { reiheUpdated = updatedMeta.content; } } // Person detail page: /person/{id} (but not /person/new or /person/{id}/edit) const personMatch = path.match(/^\/person\/([^\/]+)\/?$/); if (personMatch && personMatch[1] !== "new") { hasPerson = true; personId = personMatch[1]; } // Almanach detail page: /almanach/{id} (but not /almanach-new or /almanach/{id}/edit) const almanachMatch = path.match(/^\/almanach\/([^\/]+)\/?$/); if (almanachMatch && almanachMatch[1] !== "new") { hasEntry = true; entryId = almanachMatch[1]; // Try to get updated timestamp from page const updatedMeta = document.querySelector('meta[name="entity-updated"]'); if (updatedMeta) { entryUpdated = updatedMeta.content; } } // Page views use page editor keys via meta tag or URL mapping const pageKeyMeta = document.querySelector('meta[name="page-key"]'); if (pageKeyMeta && pageKeyMeta.content) { hasPage = true; pageKey = pageKeyMeta.content; } else { const textPageMatch = path.match(/^\/redaktion\/([^\/]+)\/?$/); const textPageKey = textPageMatch ? textPageMatch[1] : ""; const knownPageKeys = new Set([ "kontakt", "danksagungen", "literatur", "einleitung", "benutzerhinweise", "lesekabinett", ]); if (textPageKey && knownPageKeys.has(textPageKey)) { hasPage = true; pageKey = textPageKey; } else if (path === "/" || path === "/index/") { hasPage = true; pageKey = "index"; } else if (path === "/reihen" || path === "/reihen/") { hasPage = true; pageKey = "reihen"; } } // Try to find CSRF token from page forms let csrfToken = ""; const csrfInput = document.querySelector('input[name="csrf_token"]'); if (csrfInput) { csrfToken = csrfInput.value; } const hasCsrf = csrfToken !== ""; this.hasContext = hasReihe || hasPerson || hasEntry || hasPage; // Build half-open menu content let halfOpenContent = ""; if (hasReihe) { halfOpenContent = `