From 52758c01242cee40a603423b855f95ae7c20c8fa Mon Sep 17 00:00:00 2001 From: Simon Martens Date: Mon, 29 Sep 2025 18:29:17 +0200 Subject: [PATCH] +Startseite u. Suche Baic styling --- views/assets/scripts.js | 102 ++-- views/assets/style.css | 2 +- .../components/_newspaper_layout.gohtml | 16 +- views/routes/body.gohtml | 79 ++- .../components/_page_action_buttons.gohtml | 62 +++ views/routes/components/_page_modal.gohtml | 21 + .../components/_unified_piece_entry.gohtml | 4 + views/routes/kategorie/pieces/body.gohtml | 9 +- views/routes/ort/fragment/body.gohtml | 4 +- views/routes/piece/body.gohtml | 9 +- .../_piece_inhaltsverzeichnis.gohtml | 4 +- .../_piece_sequential_layout.gohtml | 34 +- views/routes/search/body.gohtml | 505 +++++++++++++----- .../transform/inhaltsverzeichnis-scrollspy.js | 49 +- views/transform/places.js | 53 +- views/transform/search.js | 77 +-- 16 files changed, 669 insertions(+), 361 deletions(-) create mode 100644 views/routes/components/_page_action_buttons.gohtml create mode 100644 views/routes/components/_page_modal.gohtml diff --git a/views/assets/scripts.js b/views/assets/scripts.js index d08ff49..ef316ae 100644 --- a/views/assets/scripts.js +++ b/views/assets/scripts.js @@ -194,7 +194,7 @@ class F extends HTMLElement { this.innerHTML = ` @@ -269,7 +269,7 @@ class j extends HTMLElement { month: "2-digit", year: "numeric" }); - return `${e} (${i})`; + return `${e} - ${i}`; } return e; } @@ -281,35 +281,35 @@ class j extends HTMLElement { } createMenu() { this.innerHTML = ` -
+
- @@ -77,8 +72,6 @@ {{- if .model.Pieces -}}
-

{{ .model.Year }}

- {{- /* Group pieces by title within the year */ -}} {{- $groupedPieces := dict -}} {{- range $_, $p := .model.Pieces -}} @@ -146,4 +139,4 @@
{{- end -}}
-
\ No newline at end of file + diff --git a/views/routes/ort/fragment/body.gohtml b/views/routes/ort/fragment/body.gohtml index 1eb39f4..8322af1 100644 --- a/views/routes/ort/fragment/body.gohtml +++ b/views/routes/ort/fragment/body.gohtml @@ -1,4 +1,4 @@ {{- /* Fragment with specific class for HTMX selection */ -}} -
+
{{ template "_place_pieces" .model.SelectedPlace }} -
\ No newline at end of file +
diff --git a/views/routes/piece/body.gohtml b/views/routes/piece/body.gohtml index c34e2bd..69041f8 100644 --- a/views/routes/piece/body.gohtml +++ b/views/routes/piece/body.gohtml @@ -5,10 +5,12 @@
- +
- {{ template "_piece_inhaltsverzeichnis" . }} + + {{ template "_piece_inhaltsverzeichnis" . }} +
@@ -18,6 +20,9 @@
+ + + {{ else }}
diff --git a/views/routes/piece/components/_piece_inhaltsverzeichnis.gohtml b/views/routes/piece/components/_piece_inhaltsverzeichnis.gohtml index e20cb1a..0645a34 100644 --- a/views/routes/piece/components/_piece_inhaltsverzeichnis.gohtml +++ b/views/routes/piece/components/_piece_inhaltsverzeichnis.gohtml @@ -19,7 +19,7 @@
- {{ template "_unified_piece_entry" (dict "Piece" $firstPiece.PieceByIssue "DisplayMode" "piece" "ShowPlaceTags" true "UseColonFormat" false "ShowContinuation" true) }} + {{ template "_unified_piece_entry" (dict "Piece" $firstPiece.PieceByIssue.Piece "DisplayMode" "piece" "ShowPlaceTags" true "UseColonFormat" false "ShowContinuation" true) }}
{{ end }} @@ -88,7 +88,7 @@ {{ range $otherPiece := $pageEntry.OtherPieces }}
- {{ template "_unified_piece_entry" (dict "Piece" $otherPiece.PieceByIssue "DisplayMode" "piece" "ShowPlaceTags" true "UseColonFormat" false "ShowContinuation" true) }} + {{ template "_unified_piece_entry" (dict "Piece" $otherPiece.PieceByIssue.Piece "DisplayMode" "piece" "ShowPlaceTags" true "UseColonFormat" false "ShowContinuation" true) }}
{{ end }} {{ else }} diff --git a/views/routes/piece/components/_piece_sequential_layout.gohtml b/views/routes/piece/components/_piece_sequential_layout.gohtml index 4f9e317..4119776 100644 --- a/views/routes/piece/components/_piece_sequential_layout.gohtml +++ b/views/routes/piece/components/_piece_sequential_layout.gohtml @@ -30,23 +30,7 @@ - - - - - + {{ template "_page_action_buttons" (dict "PageNumber" $page.PageNumber "IsBeilage" false "PartNumber" $pageEntry.PartNumber "ImageElement" (printf "#piece-page-%d .piece-page-image" $page.PageNumber) "ButtonSize" "small" "ShowZoom" true) }}
@@ -79,17 +63,5 @@ {{ end }} - - \ No newline at end of file + + {{ template "_page_modal" }} \ No newline at end of file diff --git a/views/routes/search/body.gohtml b/views/routes/search/body.gohtml index c18fe1b..6a7db9b 100644 --- a/views/routes/search/body.gohtml +++ b/views/routes/search/body.gohtml @@ -1,133 +1,400 @@ {{ $model := .model }} - -
-
-

Personen

- {{ if $model.Agents.Items }} - {{ range $i, $agent := $model.Agents.Items }} - {{ $gnd := GetGND $agent.GND }} -
- {{- index $agent.Names 0 -}} -
- {{ if $gnd }} -
- {{- if and $gnd.DateOfBirth $gnd.DateOfDeath -}} -
- {{- if $gnd.DateOfBirth -}} - {{- HRDateYear (index $gnd.DateOfBirth 0) -}} - {{- else -}} - [?] - {{- end -}} -  –  - {{- if $gnd.DateOfDeath -}} - {{- HRDateYear (index $gnd.DateOfDeath 0) -}} - {{- else -}} - [?] - {{- end -}} -
- {{- end -}} -
- {{ end }} - {{ end }} - {{ else }} -
Keine Personen gefunden.
- {{ end }} -
- -
-

Orte

- {{ if $model.Places.Items }} - {{ range $i, $place := $model.Places.Items }} -
- {{- index $place.Names 0 -}} -
- {{ end }} - {{ else }} -
Keine Orte gefunden.
- {{ end }} -
- -
-

Kategorien

- {{ if $model.Categories.Items }} - {{ range $i, $category := $model.Categories.Items }} -
- {{- index $category.Names 0 -}} -
- {{ end }} - {{ else }} -
Keine Kategorien gefunden.
- {{ end }} -
- -
-

Ausgaben

- {{ if $model.Issues.Items }} - {{ range $i, $issue := $model.Issues.Items }} -
- KGPZ - {{ $issue.Datum.When.Year }}/{{ $issue.Number.No }} - ({{ HRDateShort - $issue.Datum.When.String - }}) -
- {{ end }} - {{ else }} -
Keine Ausgaben gefunden.
- {{ end }} -
- -
-

Werke

- {{ if $model.Works.Items }} - {{ range $i, $w := $model.Works.Items }} -
- {{- if ne (len $w.Citation.InnerXML ) 0 -}} - - {{- end -}} - {{ range $_, $url := $w.URLs }} -
- {{ $url.Chardata }} -
- {{ end }} - - {{ $pieces := LookupPieces $w }} - {{ if len $pieces }} -
- {{ range $_, $p := $pieces }} - {{- range $_, $i := $p.Item.IssueRefs -}} -
- {{ template "_citation" $i }} +
+ +
+ +
+

+ + Personen + {{ if $model.Agents.Items }}{{ len $model.Agents.Items }}{{ end }} +

+ {{ if $model.Agents.Items }} +
+ {{ range $i, $agent := $model.Agents.Items }} + {{ $gnd := GetGND $agent.GND }} +
+ + {{- index $agent.Names 0 -}} + + {{ if $gnd }} + {{ if and $gnd.DateOfBirth $gnd.DateOfDeath }} +
+ {{- if $gnd.DateOfBirth -}} + {{- HRDateYear (index $gnd.DateOfBirth 0) -}} + {{- else -}} + [?] + {{- end -}} +  –  + {{- if $gnd.DateOfDeath -}} + {{- HRDateYear (index $gnd.DateOfDeath 0) -}} + {{- else -}} + [?] + {{- end -}}
- {{- end -}} + {{ end }} {{ end }}
{{ end }}
+ {{ else }} +

Keine Personen gefunden.

{{ end }} - {{ else }} -
Keine Werke gefunden.
- {{ end }} +
+ + +
+

+ + Orte + {{ if $model.Places.Items }}{{ len $model.Places.Items }}{{ end }} +

+ {{ if $model.Places.Items }} +
+ {{ range $i, $place := $model.Places.Items }} + + {{ end }} +
+ {{ else }} +

Keine Orte gefunden.

+ {{ end }} +
+ + +
+

+ + Kategorien + {{ if $model.Categories.Items }}{{ len $model.Categories.Items }}{{ end }} +

+ {{ if $model.Categories.Items }} +
+ {{ range $i, $category := $model.Categories.Items }} + + {{ end }} +
+ {{ else }} +

Keine Kategorien gefunden.

+ {{ end }} +
+ + +
+

+ + Ausgaben + {{ if $model.Issues.Items }}{{ len $model.Issues.Items }}{{ end }} +

+ {{ if $model.Issues.Items }} +
+ {{ range $i, $issue := $model.Issues.Items }} +
+ + KGPZ {{ $issue.Datum.When.Year }}/{{ $issue.Number.No }} + +
+ {{ HRDateShort $issue.Datum.When.String }} +
+
+ {{ end }} +
+ {{ else }} +

Keine Ausgaben gefunden.

+ {{ end }} +
-
-

Beiträge

- {{ if $model.Pieces.Items }} - {{ range $i, $piece := $model.Pieces.Items }} -
- {{ $piece.String }} + +
+ +
+

+ + Werke + {{ if $model.Works.Items }}{{ len $model.Works.Items }}{{ end }} +

+ {{ if $model.Works.Items }} +
+ {{ range $i, $w := $model.Works.Items }} +
+ {{- if ne (len $w.Citation.InnerXML ) 0 -}} +
+ {{- /* Show all work contributors with their roles */ -}} + {{- $workContributors := slice -}} + {{- range $workAgentRef := $w.AgentRefs -}} + {{- $agent := GetAgent $workAgentRef.Ref -}} + {{- if and $agent (gt (len $agent.Names) 0) -}} + {{- if eq $workAgentRef.Category "übersetzer" -}} + {{- $workContributors = append $workContributors (printf "%s (Übers.)" $workAgentRef.Ref (index $agent.Names 0)) -}} + {{- else if eq $workAgentRef.Category "herausgeber" -}} + {{- $workContributors = append $workContributors (printf "%s (Hrsg.)" $workAgentRef.Ref (index $agent.Names 0)) -}} + {{- else -}} + {{- $workContributors = append $workContributors (printf "%s" $workAgentRef.Ref (index $agent.Names 0)) -}} + {{- end -}} + {{- end -}} + {{- end -}} + {{- range $index, $contributor := $workContributors -}} + {{- if gt $index 0 }}, {{ end }}{{ Safe $contributor }} + {{- end -}} + {{- if gt (len $workContributors) 0 }}: {{ end }}{{- Safe $w.Citation.HTML -}} + {{- range $_, $url := $w.URLs -}} + + + {{ $url.Chardata }} + + + {{- end -}} +
+ {{- end -}} + + {{- /* Find all pieces that reference this work */ -}} + {{ $workPieces := LookupPieces $w }} + {{ if len $workPieces }} +
+ {{- /* Group pieces by category + author combination */ -}} + {{- $pieceGroups := dict -}} + {{- range $_, $p := $workPieces -}} + {{- /* Get categories for this piece */ -}} + {{- $categoryFlags := GetCategoryFlags $p.Item -}} + {{- $categories := slice -}} + {{- if $categoryFlags.Rezension -}} + {{- $categories = append $categories "Rezension" -}} + {{- end -}} + {{- if $categoryFlags.Auszug -}} + {{- $categories = append $categories "Auszug" -}} + {{- end -}} + {{- if $categoryFlags.Theaterkritik -}} + {{- $categories = append $categories "Theaterkritik" -}} + {{- end -}} + {{- if $categoryFlags.Uebersetzung -}} + {{- $categories = append $categories "Übersetzung" -}} + {{- end -}} + {{- if $categoryFlags.Kommentar -}} + {{- $categories = append $categories "Kommentar" -}} + {{- end -}} + {{- if $categoryFlags.Replik -}} + {{- $categories = append $categories "Replik" -}} + {{- end -}} + {{- if $categoryFlags.Anzeige -}} + {{- $categories = append $categories "Anzeige" -}} + {{- end -}} + {{- if $categoryFlags.Provinienz -}} + {{- $categories = append $categories "Provinienz" -}} + {{- end -}} + {{- if eq (len $categories) 0 -}} + {{- $categories = append $categories "Beitrag" -}} + {{- end -}} + + {{- /* Get authors, translators, and editors for this piece */ -}} + {{- $pieceAuthors := slice -}} + {{- $pieceTranslators := slice -}} + {{- $pieceEditors := slice -}} + {{- range $agentref := $p.Item.AgentRefs -}} + {{- if (or (eq $agentref.Category "") (eq $agentref.Category "autor")) -}} + {{- $pieceAuthors = append $pieceAuthors $agentref.Ref -}} + {{- else if eq $agentref.Category "übersetzer" -}} + {{- $pieceTranslators = append $pieceTranslators $agentref.Ref -}} + {{- else if eq $agentref.Category "herausgeber" -}} + {{- $pieceEditors = append $pieceEditors $agentref.Ref -}} + {{- end -}} + {{- end -}} + {{- $sortedAuthors := sortStrings $pieceAuthors -}} + {{- $sortedTranslators := sortStrings $pieceTranslators -}} + {{- $sortedEditors := sortStrings $pieceEditors -}} + + {{- /* Create group key: categories + authors + translators + editors */ -}} + {{- $sortedCategories := sortStrings $categories -}} + {{- $groupKey := printf "%s|%s|%s|%s" (joinWithUnd $sortedCategories) (joinWithUnd $sortedAuthors) (joinWithUnd $sortedTranslators) (joinWithUnd $sortedEditors) -}} + + {{- /* Add piece to group (check for duplicates by ID) */ -}} + {{- $existing := index $pieceGroups $groupKey -}} + {{- if $existing -}} + {{- /* Check if piece is already in group */ -}} + {{- $found := false -}} + {{- range $existingPiece := $existing -}} + {{- if eq $existingPiece.Item.ID $p.Item.ID -}} + {{- $found = true -}} + {{- end -}} + {{- end -}} + {{- if not $found -}} + {{- $pieceGroups = merge $pieceGroups (dict $groupKey (append $existing $p)) -}} + {{- end -}} + {{- else -}} + {{- $pieceGroups = merge $pieceGroups (dict $groupKey (slice $p)) -}} + {{- end -}} + {{- end -}} + + {{- /* Display each group */ -}} + {{- range $groupKey, $groupPieces := $pieceGroups -}} +
+ {{- /* Extract categories, authors, translators, and editors from group key */ -}} + {{- $keyParts := split $groupKey "|" -}} + {{- $categoryName := index $keyParts 0 -}} + {{- $authorPart := index $keyParts 1 -}} + {{- $translatorPart := "" -}} + {{- if gt (len $keyParts) 2 -}} + {{- $translatorPart = index $keyParts 2 -}} + {{- end -}} + {{- $editorPart := "" -}} + {{- if gt (len $keyParts) 3 -}} + {{- $editorPart = index $keyParts 3 -}} + {{- end -}} + + {{- /* Use plural if multiple pieces grouped together */ -}} + {{- $displayCategory := $categoryName -}} + {{- if gt (len $groupPieces) 1 -}} + {{- if eq $categoryName "Rezension" -}} + {{- $displayCategory = "Rezensionen" -}} + {{- else if eq $categoryName "Auszug" -}} + {{- $displayCategory = "Auszüge" -}} + {{- else if eq $categoryName "Theaterkritik" -}} + {{- $displayCategory = "Theaterkritiken" -}} + {{- else if eq $categoryName "Übersetzung" -}} + {{- $displayCategory = "Übersetzungen" -}} + {{- else if eq $categoryName "Kommentar" -}} + {{- $displayCategory = "Kommentare" -}} + {{- else if eq $categoryName "Replik" -}} + {{- $displayCategory = "Repliken" -}} + {{- else if eq $categoryName "Anzeige" -}} + {{- $displayCategory = "Anzeigen" -}} + {{- else if eq $categoryName "Beitrag" -}} + {{- $displayCategory = "Beiträge" -}} + {{- end -}} + {{- end -}} + {{ $displayCategory }}{{- if or (ne $authorPart "") (ne $translatorPart "") (ne $editorPart "") }} von {{ end }} + {{- /* Display authors */ -}} + {{- if ne $authorPart "" -}} + {{- range $i, $authorID := (split $authorPart " und ") -}} + {{- if gt $i 0 }} und {{ end }} + {{- $agent := GetAgent $authorID -}} + {{- if and $agent (gt (len $agent.Names) 0) -}} + {{ index $agent.Names 0 }} + {{- end -}} + {{- end -}} + {{- end -}} + {{- /* Display translators with (Übers.) suffix */ -}} + {{- if ne $translatorPart "" -}} + {{- if ne $authorPart "" }}, {{ end }} + {{- range $i, $translatorID := (split $translatorPart " und ") -}} + {{- if gt $i 0 }}, {{ end }} + {{- $agent := GetAgent $translatorID -}} + {{- if and $agent (gt (len $agent.Names) 0) -}} + {{ index $agent.Names 0 }} (Übers.) + {{- end -}} + {{- end -}} + {{- end -}} + {{- /* Display editors with (Hrsg.) suffix */ -}} + {{- if ne $editorPart "" -}} + {{- if or (ne $authorPart "") (ne $translatorPart "") }}, {{ end }} + {{- range $i, $editorID := (split $editorPart " und ") -}} + {{- if gt $i 0 }}, {{ end }} + {{- $agent := GetAgent $editorID -}} + {{- if and $agent (gt (len $agent.Names) 0) -}} + {{ index $agent.Names 0 }} (Hrsg.) + {{- end -}} + {{- end -}} + {{- end -}}: + {{- /* Show citations separated by commas */ -}} + {{ " " }}{{- range $pieceIndex, $p := $groupPieces -}} + {{- range $issueIndex, $issue := $p.Item.IssueRefs -}} + {{- if or (gt $pieceIndex 0) (gt $issueIndex 0) }}, {{ end -}} + {{- template "_citation" $issue -}} + {{- end -}} + {{- /* Add "Ganzer Beitrag" link if piece spans multiple issues */ -}} + {{- if gt (len $p.Item.IssueRefs) 1 -}} + {{ " " }} + {{- end -}} + {{- end -}} +
+ {{- end -}} +
+ {{ end }} +
+ {{ end }}
+ {{ else }} +

Keine Werke gefunden.

{{ end }} - {{ else }} -
Keine Beiträge gefunden.
- {{ end }} +
+ + +
+

+ + Beiträge + {{ if $model.Pieces.Items }}{{ len $model.Pieces.Items }}{{ end }} +

+ {{ if $model.Pieces.Items }} +
+ {{- /* Group pieces by their own title/incipit, not by work being reviewed */ -}} + {{- $groupedPieces := dict -}} + {{- range $_, $piece := $model.Pieces.Items -}} + {{- $groupKey := "" -}} + {{- if $piece.Title -}} + {{- $groupKey = index $piece.Title 0 -}} + {{- else if $piece.Incipit -}} + {{- $groupKey = index $piece.Incipit 0 -}} + {{- else -}} + {{- $groupKey = printf "untitled-%s" $piece.ID -}} + {{- end -}} + + {{- $existing := index $groupedPieces $groupKey -}} + {{- if $existing -}} + {{- $groupedPieces = merge $groupedPieces (dict $groupKey (append $existing $piece)) -}} + {{- else -}} + {{- $groupedPieces = merge $groupedPieces (dict $groupKey (slice $piece)) -}} + {{- end -}} + {{- end -}} + +
+ {{- /* Display grouped pieces */ -}} + {{- range $groupKey, $groupedItems := $groupedPieces -}} +
+
+ {{- /* Use first piece for display text */ -}} + {{ template "_unified_piece_entry" (dict "Piece" (index $groupedItems 0) "DisplayMode" "search" "ShowPlaceTags" true "UseColonFormat" false "ShowContinuation" false) }} + + {{- /* Show all citations from all pieces in this group inline with commas */ -}} + {{ " " }}{{- range $groupIndex, $groupItem := $groupedItems -}} + {{- range $issueIndex, $issue := $groupItem.IssueRefs -}} + {{- if or (gt $groupIndex 0) (gt $issueIndex 0) }}, {{ end -}} + {{- template "_citation" $issue -}}{{- end -}} + {{- end -}} + {{- /* Add "Ganzer Beitrag" link if piece spans multiple issues */ -}} + {{- $firstGroupItem := index $groupedItems 0 -}} + {{- if gt (len $firstGroupItem.IssueRefs) 1 -}} + {{ " " }} + {{- end }} +
+
+ {{- end -}} +
+
+ {{ else }} +

Keine Beiträge gefunden.

+ {{ end }} +
diff --git a/views/transform/inhaltsverzeichnis-scrollspy.js b/views/transform/inhaltsverzeichnis-scrollspy.js index 371548d..a789758 100644 --- a/views/transform/inhaltsverzeichnis-scrollspy.js +++ b/views/transform/inhaltsverzeichnis-scrollspy.js @@ -19,11 +19,15 @@ export class InhaltsverzeichnisScrollspy extends HTMLElement { this.singlePageViewerActive = false; this.singlePageViewerCurrentPage = null; // Track which page is currently viewed in single page mode this.boundHandleSinglePageViewer = this.handleSinglePageViewer.bind(this); + this.eventListenersAttached = false; // Track if global event listeners are attached } connectedCallback() { - this.setupScrollspy(); - this.setupSinglePageViewerDetection(); + // Use requestAnimationFrame to ensure DOM is fully settled after HTMX content swap + requestAnimationFrame(() => { + this.setupScrollspy(); + this.setupSinglePageViewerDetection(); + }); } disconnectedCallback() { @@ -35,9 +39,27 @@ export class InhaltsverzeichnisScrollspy extends HTMLElement { const newspaperPageContainers = document.querySelectorAll('.newspaper-page-container[data-page-container]'); if (newspaperPageContainers.length === 0) { - return; // No page containers found + // No page containers found initially - retry after a short delay for HTMX content + setTimeout(() => { + const retryContainers = document.querySelectorAll('.newspaper-page-container[data-page-container]'); + if (retryContainers.length > 0) { + this.initializeScrollspy(retryContainers); + } + }, 100); + return; } + this.initializeScrollspy(newspaperPageContainers); + } + + initializeScrollspy(newspaperPageContainers) { + + // Clear existing state to prevent conflicts during HTMX navigation + if (this.pageObserver) { + this.pageObserver.disconnect(); + } + this.pageContainers.clear(); + // Map page containers to their corresponding Inhaltsverzeichnis entries newspaperPageContainers.forEach(container => { const pageNumber = container.getAttribute('data-page-container'); @@ -236,10 +258,13 @@ export class InhaltsverzeichnisScrollspy extends HTMLElement { } setupSinglePageViewerDetection() { - // Listen for single page viewer events - document.addEventListener('singlepageviewer:opened', this.boundHandleSinglePageViewer); - document.addEventListener('singlepageviewer:closed', this.boundHandleSinglePageViewer); - document.addEventListener('singlepageviewer:pagechanged', this.boundHandleSinglePageViewer); + // Only attach event listeners if not already attached + if (!this.eventListenersAttached) { + document.addEventListener('singlepageviewer:opened', this.boundHandleSinglePageViewer); + document.addEventListener('singlepageviewer:closed', this.boundHandleSinglePageViewer); + document.addEventListener('singlepageviewer:pagechanged', this.boundHandleSinglePageViewer); + this.eventListenersAttached = true; + } // Check initial state this.checkSinglePageViewerState(); @@ -302,9 +327,13 @@ export class InhaltsverzeichnisScrollspy extends HTMLElement { this.pageObserver = null; } - document.removeEventListener('singlepageviewer:opened', this.boundHandleSinglePageViewer); - document.removeEventListener('singlepageviewer:closed', this.boundHandleSinglePageViewer); - document.removeEventListener('singlepageviewer:pagechanged', this.boundHandleSinglePageViewer); + // Only remove event listeners if they were attached + if (this.eventListenersAttached) { + document.removeEventListener('singlepageviewer:opened', this.boundHandleSinglePageViewer); + document.removeEventListener('singlepageviewer:closed', this.boundHandleSinglePageViewer); + document.removeEventListener('singlepageviewer:pagechanged', this.boundHandleSinglePageViewer); + this.eventListenersAttached = false; + } this.pageContainers.clear(); } diff --git a/views/transform/places.js b/views/transform/places.js index f22f852..23c0a44 100644 --- a/views/transform/places.js +++ b/views/transform/places.js @@ -140,7 +140,6 @@ export class PlaceAccordion extends HTMLElement { connectedCallback() { this.setupAccordion(); this.setupEventListeners(); - this.updateBorders(); this.setupMapEventListeners(); this.setupHoverEvents(); } @@ -160,26 +159,12 @@ export class PlaceAccordion extends HTMLElement { } setupAccordion() { - // Add chevron icon if not already present - if (!this.querySelector(".accordion-chevron")) { - const chevron = document.createElement("i"); - chevron.className = - "ri-chevron-down-line accordion-chevron transition-transform duration-200 text-slate-400"; - - // Find the badge and insert chevron before it - const badge = this.querySelector('[class*="bg-slate-100"]'); - if (badge) { - badge.parentNode.insertBefore(chevron, badge); - } - } - - // Create content container if not exists if (!this.querySelector("[data-content]")) { const placeId = this.getAttribute("data-place-id"); const contentContainer = document.createElement("div"); contentContainer.setAttribute("data-content", ""); contentContainer.className = - "accordion-content overflow-hidden transition-all duration-300 max-h-0"; + "accordion-content overflow-hidden transition-all duration-300 max-h-0 border-b border-slate-200"; // Add HTMX attributes to override body defaults contentContainer.setAttribute("hx-get", `/ort/fragment/${placeId}`); @@ -272,8 +257,6 @@ export class PlaceAccordion extends HTMLElement { if (this.isLoading) return; this.isExpanded = true; - this.updateChevron(); - this.updateBorders(); const contentContainer = this.querySelector("[data-content]"); if (!contentContainer) return; @@ -289,8 +272,6 @@ export class PlaceAccordion extends HTMLElement { collapse() { this.isExpanded = false; - this.updateChevron(); - this.updateBorders(); const contentContainer = this.querySelector("[data-content]"); if (contentContainer) { @@ -330,33 +311,6 @@ export class PlaceAccordion extends HTMLElement { // Trigger the HTMX request htmx.trigger(contentContainer, "load-content"); } - - updateChevron() { - const chevron = this.querySelector(".accordion-chevron"); - if (chevron) { - if (this.isExpanded) { - chevron.style.transform = "rotate(180deg)"; - } else { - chevron.style.transform = "rotate(0deg)"; - } - } - } - - updateBorders() { - if (this.isExpanded) { - // When expanded: remove border from header, add border to whole component - this.classList.add("border-b", "border-slate-100"); - } else { - // When collapsed: add border to component (for separation between items) - this.classList.add("border-b", "border-slate-100"); - } - - // Remove border from last item if it's the last child - const isLastChild = !this.nextElementSibling; - if (isLastChild) { - this.classList.remove("border-b"); - } - } } /** @@ -525,7 +479,8 @@ export class PlacesMap extends HTMLElement { circle.setAttribute("filter", "drop-shadow(0 0.05 0.08 rgba(0,0,0,0.15))"); circle.style.cursor = "pointer"; circle.style.pointerEvents = "all"; - circle.style.transition = "r 0.3s ease, fill 0.3s ease, stroke 0.3s ease, opacity 0.3s ease"; + circle.style.transition = + "r 0.3s ease, fill 0.3s ease, stroke 0.3s ease, opacity 0.3s ease"; // Add hover effects for white dots circle.addEventListener("mouseenter", () => { @@ -664,7 +619,6 @@ export class PlacesMap extends HTMLElement { placeContainers.forEach((container) => { this.intersectionObserver.observe(container); }); - } setPointActive(circle) { @@ -701,7 +655,6 @@ export class PlacesMap extends HTMLElement { return; } - if (this.tooltip && tooltipText) { // Set tooltip content and position this.tooltip.textContent = tooltipText; diff --git a/views/transform/search.js b/views/transform/search.js index 512cc72..46d235d 100644 --- a/views/transform/search.js +++ b/views/transform/search.js @@ -418,7 +418,7 @@ class SchnellauswahlButton extends HTMLElement { this.innerHTML = ` @@ -543,36 +543,36 @@ class NavigationMenu extends HTMLElement { } static get observedAttributes() { - return ['git-commit', 'git-date', 'git-url']; + return ["git-commit", "git-date", "git-url"]; } get gitCommit() { - return this.getAttribute('git-commit'); + return this.getAttribute("git-commit"); } get gitDate() { - return this.getAttribute('git-date'); + return this.getAttribute("git-date"); } get gitUrl() { - return this.getAttribute('git-url'); + return this.getAttribute("git-url"); } formatCommitInfo() { if (!this.gitCommit) { - return 'Keine Commit-Info'; + return "Keine Commit-Info"; } const shortCommit = this.gitCommit.substring(0, 7); if (this.gitDate) { const date = new Date(this.gitDate); - const formattedDate = date.toLocaleDateString('de-DE', { - day: '2-digit', - month: '2-digit', - year: 'numeric' + const formattedDate = date.toLocaleDateString("de-DE", { + day: "2-digit", + month: "2-digit", + year: "numeric", }); - return `${shortCommit} (${formattedDate})`; + return `${shortCommit} - ${formattedDate}`; } return shortCommit; @@ -590,35 +590,35 @@ class NavigationMenu extends HTMLElement { createMenu() { this.innerHTML = ` -
+
-