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); this.handleDeleteClick = this.handleDeleteClick.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 = ""; // 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; } } // 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; // Build half-open menu content let halfOpenContent = ""; if (hasReihe) { const deleteButton = hasCsrf ? ` ` : ""; halfOpenContent = `