Vieweradvanced start impl

This commit is contained in:
Simon Martens
2025-09-23 02:05:26 +02:00
parent fc5e8ae8a4
commit c8e56bbfc0
3 changed files with 480 additions and 138 deletions

View File

@@ -27,8 +27,8 @@ class E extends HTMLElement {
}, window.addEventListener("scroll", this.scrollHandler), this.navLinks.forEach((e) => { }, window.addEventListener("scroll", this.scrollHandler), this.navLinks.forEach((e) => {
const t = (i) => { const t = (i) => {
i.preventDefault(); i.preventDefault();
const n = e.getAttribute("data-target"), r = document.getElementById(n); const n = e.getAttribute("data-target"), s = document.getElementById(n);
r && (this.updateActiveLinkImmediate(n), this.manualNavigation = !0, r.scrollIntoView({ s && (this.updateActiveLinkImmediate(n), this.manualNavigation = !0, s.scrollIntoView({
behavior: "smooth", behavior: "smooth",
block: "start" block: "start"
}), setTimeout(() => { }), setTimeout(() => {
@@ -42,9 +42,9 @@ class E extends HTMLElement {
const e = document.getElementById("scrollspy-slider"), t = document.getElementById("scrollspy-nav"); const e = document.getElementById("scrollspy-slider"), t = document.getElementById("scrollspy-nav");
if (!e || !t || e.style.opacity === "0") if (!e || !t || e.style.opacity === "0")
return; return;
const i = t.getBoundingClientRect(), n = parseFloat(e.style.top), r = parseFloat(e.style.height), s = n + r, a = t.scrollTop, l = a + i.height; const i = t.getBoundingClientRect(), n = parseFloat(e.style.top), s = parseFloat(e.style.height), r = n + s, a = t.scrollTop, l = a + i.height;
if (s > l) { if (r > l) {
const c = s - i.height + 20; const c = r - i.height + 20;
t.scrollTo({ t.scrollTo({
top: c, top: c,
behavior: "smooth" behavior: "smooth"
@@ -64,24 +64,24 @@ class E extends HTMLElement {
try { try {
this.sections.forEach((n) => { this.sections.forEach((n) => {
if (!n || !n.getAttribute) return; if (!n || !n.getAttribute) return;
const r = n.getAttribute("id"), s = n.querySelector(".akteur-werke-section"), a = n.querySelector(".akteur-beitraege-section"); const s = n.getAttribute("id"), r = n.querySelector(".akteur-werke-section"), a = n.querySelector(".akteur-beitraege-section");
let l = !1; let l = !1;
if (s) { if (r) {
const c = s.getBoundingClientRect(), d = c.top < window.innerHeight, u = c.bottom > 0; const c = r.getBoundingClientRect(), d = c.top < window.innerHeight, u = c.bottom > 0;
d && u && (l = !0); d && u && (l = !0);
} }
if (a && !l) { if (a && !l) {
const c = a.getBoundingClientRect(), d = c.top < window.innerHeight, u = c.bottom > 0; const c = a.getBoundingClientRect(), d = c.top < window.innerHeight, u = c.bottom > 0;
d && u && (l = !0); d && u && (l = !0);
} }
if (!s && !a) { if (!r && !a) {
const c = n.querySelector("div:first-child"); const c = n.querySelector("div:first-child");
if (c) { if (c) {
const d = c.getBoundingClientRect(), u = d.top >= 0, g = d.bottom <= window.innerHeight; const d = c.getBoundingClientRect(), u = d.top >= 0, g = d.bottom <= window.innerHeight;
u && g && (l = !0); u && g && (l = !0);
} }
} }
l && e.push(r); l && e.push(s);
}); });
} catch { } catch {
return; return;
@@ -89,17 +89,17 @@ class E extends HTMLElement {
const t = [], i = document.getElementById("scrollspy-slider"); const t = [], i = document.getElementById("scrollspy-slider");
if (this.navLinks.forEach((n) => { if (this.navLinks.forEach((n) => {
n.classList.remove("font-medium"); n.classList.remove("font-medium");
const r = n.getAttribute("data-target"); const s = n.getAttribute("data-target");
e.includes(r) && (n.classList.add("font-medium"), t.push(n)); e.includes(s) && (n.classList.add("font-medium"), t.push(n));
}), t.length > 0 && i) { }), t.length > 0 && i) {
const n = document.getElementById("scrollspy-nav"), r = n.getBoundingClientRect(); const n = document.getElementById("scrollspy-nav"), s = n.getBoundingClientRect();
let s = 1 / 0, a = -1 / 0; let r = 1 / 0, a = -1 / 0;
t.forEach((c) => { t.forEach((c) => {
const d = c.getBoundingClientRect(), u = d.top - r.top + n.scrollTop, g = u + d.height; const d = c.getBoundingClientRect(), u = d.top - s.top + n.scrollTop, g = u + d.height;
s = Math.min(s, u), a = Math.max(a, g); r = Math.min(r, u), a = Math.max(a, g);
}); });
let l = a - s; let l = a - r;
i.style.top = `${s}px`, i.style.height = `${l}px`, i.style.opacity = "1", setTimeout(() => this.ensureMarkerVisibility(), 100); i.style.top = `${r}px`, i.style.height = `${l}px`, i.style.opacity = "1", setTimeout(() => this.ensureMarkerVisibility(), 100);
} else i && (i.style.opacity = "0"); } else i && (i.style.opacity = "0");
t.length > 0 && this.updateSidebarScroll(t); t.length > 0 && this.updateSidebarScroll(t);
} }
@@ -117,8 +117,8 @@ class E extends HTMLElement {
if (i && (i.classList.add("font-medium"), t)) { if (i && (i.classList.add("font-medium"), t)) {
const n = document.getElementById("scrollspy-nav"); const n = document.getElementById("scrollspy-nav");
if (n) { if (n) {
const r = n.getBoundingClientRect(), s = i.getBoundingClientRect(), a = s.top - r.top + n.scrollTop; const s = n.getBoundingClientRect(), r = i.getBoundingClientRect(), a = r.top - s.top + n.scrollTop;
t.style.top = `${a}px`, t.style.height = `${s.height}px`, t.style.opacity = "1"; t.style.top = `${a}px`, t.style.height = `${r.height}px`, t.style.opacity = "1";
} }
} }
} }
@@ -132,10 +132,10 @@ class E extends HTMLElement {
document.documentElement.clientHeight, document.documentElement.clientHeight,
document.documentElement.scrollHeight, document.documentElement.scrollHeight,
document.documentElement.offsetHeight document.documentElement.offsetHeight
), r = window.innerHeight, s = n - r, a = s > 0 ? window.scrollY / s : 0, l = t.clientHeight, d = t.scrollHeight - l; ), s = window.innerHeight, r = n - s, a = r > 0 ? window.scrollY / r : 0, l = t.clientHeight, d = t.scrollHeight - l;
if (d > 0) { if (d > 0) {
const u = a * d, g = i.getBoundingClientRect(), h = t.getBoundingClientRect(), m = g.top - h.top + t.scrollTop, f = l / 2, I = m - f, v = 0.7, L = v * u + (1 - v) * I, x = Math.max(0, Math.min(d, L)), H = t.scrollTop; const u = a * d, g = i.getBoundingClientRect(), p = t.getBoundingClientRect(), f = g.top - p.top + t.scrollTop, m = l / 2, H = f - m, v = 0.7, I = v * u + (1 - v) * H, x = Math.max(0, Math.min(d, I)), T = t.scrollTop;
Math.abs(x - H) > 10 && t.scrollTo({ Math.abs(x - T) > 10 && t.scrollTo({
top: x, top: x,
behavior: "smooth" behavior: "smooth"
}); });
@@ -158,7 +158,7 @@ class E extends HTMLElement {
customElements.define("akteure-scrollspy", E); customElements.define("akteure-scrollspy", E);
class B extends HTMLElement { class B extends HTMLElement {
constructor() { constructor() {
super(), this.resizeObserver = null; super(), this.resizeObserver = null, this.zoomLevel = 1, this.minZoom = 1, this.maxZoom = 3, this.zoomStep = 0.1, this.isPanning = !1, this.panStart = { x: 0, y: 0 }, this.panOffset = { x: 0, y: 0 }, this.dragDistance = 0;
} }
// Dynamically detect sidebar width in pixels // Dynamically detect sidebar width in pixels
detectSidebarWidth() { detectSidebarWidth() {
@@ -181,7 +181,7 @@ class B extends HTMLElement {
<div class="flex-1 bg-slate-50 overflow-auto pointer-events-auto"> <div class="flex-1 bg-slate-50 overflow-auto pointer-events-auto">
<div class="relative min-h-full flex flex-col"> <div class="relative min-h-full flex flex-col">
<!-- Header with page info and buttons --> <!-- Header with page info and buttons -->
<div class="flex items-center justify-between p-4"> <div class="flex items-center justify-between p-4 bg-slate-50 relative z-10 border-b border-slate-200">
<!-- Left: Sidebar toggle and page indicator --> <!-- Left: Sidebar toggle and page indicator -->
<div class="flex items-center gap-3"> <div class="flex items-center gap-3">
<!-- Sidebar toggle button --> <!-- Sidebar toggle button -->
@@ -198,6 +198,18 @@ class B extends HTMLElement {
<span id="page-icon" class="text-lg"></span> <span id="page-icon" class="text-lg"></span>
<span id="page-number" class="text-lg font-bold bg-blue-50 px-2 py-1 rounded flex items-center gap-1"></span> <span id="page-number" class="text-lg font-bold bg-blue-50 px-2 py-1 rounded flex items-center gap-1"></span>
</div> </div>
<!-- Zoom indicator and reset -->
<div class="flex items-center gap-2">
<span id="zoom-indicator" class="text-sm font-medium text-slate-600 bg-slate-100 px-2 py-1 rounded">100%</span>
<button
id="zoom-reset-btn"
onclick="this.closest('single-page-viewer').resetZoom()"
class="w-8 h-8 bg-slate-100 hover:bg-slate-200 text-slate-700 border border-slate-300 rounded flex items-center justify-center transition-colors duration-200 cursor-pointer text-xs"
title="Zoom zurücksetzen (1:1)">
<i class="ri-zoom-out-line text-sm"></i>
</button>
</div>
</div> </div>
<!-- Right: Action buttons --> <!-- Right: Action buttons -->
@@ -257,15 +269,15 @@ class B extends HTMLElement {
id="single-page-image" id="single-page-image"
src="" src=""
alt="" alt=""
class="w-full h-auto rounded-lg shadow-2xl cursor-zoom-out" class="w-full h-auto rounded-lg shadow-2xl cursor-zoom-in"
onclick="this.closest('single-page-viewer').close()" onclick="this.closest('single-page-viewer').handleImageClick()"
title="Klicken zum Schließen" title="Klicken zum Vergrößern oder Schließen"
/> />
</div> </div>
</div> </div>
</div> </div>
</div> </div>
`, this.setupResizeObserver(), this.setupKeyboardNavigation(); `, this.setupResizeObserver(), this.setupKeyboardNavigation(), this.setupZoomAndPan();
} }
// Set up resize observer to dynamically update sidebar width // Set up resize observer to dynamically update sidebar width
setupResizeObserver() { setupResizeObserver() {
@@ -281,32 +293,34 @@ class B extends HTMLElement {
e.style.width = t, console.log("Updated sidebar width to:", t); e.style.width = t, console.log("Updated sidebar width to:", t);
} }
} }
show(e, t, i, n = !1, r = 0, s = null, a = null, l = null) { show(e, t, i, n = !1, s = 0, r = null, a = null, l = null) {
const c = this.querySelector("#single-page-image"), d = this.querySelector("#page-number"), u = this.querySelector("#page-icon"); const c = this.querySelector("#single-page-image"), d = this.querySelector("#page-number"), u = this.querySelector("#page-icon");
this.querySelector("#page-indicator"), c.src = e, c.alt = t, this.currentPageNumber = i, this.currentIsBeilage = n, this.currentPartNumber = s; this.querySelector("#page-indicator"), c.src = e, c.alt = t, this.currentPageNumber = i, this.currentIsBeilage = n, this.currentPartNumber = r;
let g; let g;
if (l) if (l)
g = l; g = l;
else { else {
const m = this.getIssueContext(i); const f = this.getIssueContext(i);
g = m ? `${m}, ${i}` : `${i}`; g = f ? `${f}, ${i}` : `${i}`;
} }
if (d.innerHTML = g, r && i === r) { if (d.innerHTML = g, s && i === s) {
d.style.position = "relative"; d.style.position = "relative";
const m = d.querySelector(".target-page-dot"); const f = d.querySelector(".target-page-dot");
m && m.remove(); f && f.remove();
const f = document.createElement("span"); const m = document.createElement("span");
f.className = "target-page-dot absolute -top-1 -right-1 w-3 h-3 bg-red-500 rounded-full z-10", f.title = "verlinkte Seite", d.appendChild(f); m.className = "target-page-dot absolute -top-1 -right-1 w-3 h-3 bg-red-500 rounded-full z-10", m.title = "verlinkte Seite", d.appendChild(m);
} }
a ? a === "part-number" && s !== null ? u.innerHTML = `<span class="part-number bg-slate-100 text-slate-800 font-bold px-1.5 py-0.5 rounded border border-slate-400 flex items-center justify-center">${s}. Teil</span>` : u.innerHTML = this.generateIconFromType(a) : u.innerHTML = this.generateFallbackIcon(i, n, s), this.updateNavigationButtons(), this.style.display = "block"; a ? a === "part-number" && r !== null ? u.innerHTML = `<span class="part-number bg-slate-100 text-slate-800 font-bold px-1.5 py-0.5 rounded border border-slate-400 flex items-center justify-center">${r}. Teil</span>` : u.innerHTML = this.generateIconFromType(a) : u.innerHTML = this.generateFallbackIcon(i, n, r), this.updateNavigationButtons(), this.style.display = "block", this.resetZoom();
const h = this.querySelector(".flex-1.overflow-auto"); const p = this.querySelector(".flex-1.overflow-auto");
h && (h.scrollTop = 0), document.body.style.overflow = "hidden"; p && (p.scrollTop = 0), document.body.style.overflow = "hidden";
} }
close() { close() {
this.style.display = "none", document.body.style.overflow = ""; this.style.display = "none", document.body.style.overflow = "";
} }
disconnectedCallback() { disconnectedCallback() {
this.resizeObserver && (this.resizeObserver.disconnect(), this.resizeObserver = null), this.keyboardHandler && (document.removeEventListener("keydown", this.keyboardHandler), this.keyboardHandler = null), document.body.style.overflow = ""; this.resizeObserver && (this.resizeObserver.disconnect(), this.resizeObserver = null), this.keyboardHandler && (document.removeEventListener("keydown", this.keyboardHandler), this.keyboardHandler = null);
const e = this.querySelector(".flex-1.flex.items-center.justify-center"), t = this.querySelector("#single-page-image");
e && this.wheelHandler && e.removeEventListener("wheel", this.wheelHandler), t && (this.mouseDownHandler && t.removeEventListener("mousedown", this.mouseDownHandler), this.doubleClickHandler && t.removeEventListener("dblclick", this.doubleClickHandler)), this.mouseMoveHandler && document.removeEventListener("mousemove", this.mouseMoveHandler), this.mouseUpHandler && document.removeEventListener("mouseup", this.mouseUpHandler), document.body.style.overflow = "";
} }
// Generate icon HTML from Go icon type - matches templating/engine.go PageIcon function // Generate icon HTML from Go icon type - matches templating/engine.go PageIcon function
generateIconFromType(e) { generateIconFromType(e) {
@@ -339,9 +353,87 @@ class B extends HTMLElement {
case "Escape": case "Escape":
e.preventDefault(), this.close(); e.preventDefault(), this.close();
break; break;
case "+":
case "=":
e.preventDefault(), this.adjustZoom(this.zoomStep, { clientX: window.innerWidth / 2, clientY: window.innerHeight / 2 });
break;
case "-":
e.preventDefault(), this.adjustZoom(-this.zoomStep, { clientX: window.innerWidth / 2, clientY: window.innerHeight / 2 });
break;
case "0":
e.preventDefault(), this.resetZoom();
break;
} }
}, document.addEventListener("keydown", this.keyboardHandler); }, document.addEventListener("keydown", this.keyboardHandler);
} }
// Set up zoom and pan functionality
setupZoomAndPan() {
const e = this.querySelector(".flex-1.flex.items-center.justify-center"), t = this.querySelector("#single-page-image");
!e || !t || (this.wheelHandler = (i) => {
if (!i.ctrlKey) return;
i.preventDefault();
const n = i.deltaY > 0 ? -this.zoomStep : this.zoomStep;
this.adjustZoom(n, i);
}, this.mouseDownHandler = (i) => {
this.zoomLevel <= 1 || (i.preventDefault(), this.isPanning = !0, this.dragDistance = 0, this.panStart.x = i.clientX - this.panOffset.x, this.panStart.y = i.clientY - this.panOffset.y, t.style.cursor = "grabbing");
}, this.mouseMoveHandler = (i) => {
if (!this.isPanning || this.zoomLevel <= 1) return;
i.preventDefault();
const n = i.clientX - this.panStart.x, s = i.clientY - this.panStart.y, r = n - this.panOffset.x, a = s - this.panOffset.y;
this.dragDistance += Math.sqrt(r * r + a * a), this.panOffset.x = n, this.panOffset.y = s, this.updateImageTransform();
}, this.mouseUpHandler = (i) => {
this.isPanning && (this.isPanning = !1, this.updateImageCursor());
}, this.doubleClickHandler = (i) => {
i.preventDefault(), this.resetZoom();
}, e.addEventListener("wheel", this.wheelHandler, { passive: !1 }), t.addEventListener("mousedown", this.mouseDownHandler), document.addEventListener("mousemove", this.mouseMoveHandler), document.addEventListener("mouseup", this.mouseUpHandler), t.addEventListener("dblclick", this.doubleClickHandler));
}
// Adjust zoom level
adjustZoom(e, t) {
const i = Math.max(this.minZoom, Math.min(this.maxZoom, this.zoomLevel + e));
if (i === this.zoomLevel) return;
const s = this.querySelector("#single-page-image").getBoundingClientRect(), r = (t.clientX - s.left) / s.width, a = (t.clientY - s.top) / s.height, l = i / this.zoomLevel;
this.panOffset.x = r * s.width * (1 - l) + this.panOffset.x * l, this.panOffset.y = a * s.height * (1 - l) + this.panOffset.y * l, this.zoomLevel = i, this.updateImageTransform(), this.updateImageCursor(), this.updateZoomIndicator();
}
// Reset zoom to fit
resetZoom() {
this.zoomLevel = 1, this.panOffset.x = 0, this.panOffset.y = 0, this.updateImageTransform(), this.updateImageCursor(), this.updateZoomIndicator();
}
// Update image transform with boundaries
updateImageTransform() {
const e = this.querySelector("#single-page-image");
e && (this.constrainPanOffset(), this.zoomLevel === 1 && this.panOffset.x === 0 && this.panOffset.y === 0 ? e.style.transform = "" : e.style.transform = `scale(${this.zoomLevel}) translate(${this.panOffset.x / this.zoomLevel}px, ${this.panOffset.y / this.zoomLevel}px)`, e.style.transformOrigin = "center center");
}
// Constrain pan offset to keep image within container bounds
constrainPanOffset() {
const e = this.querySelector("#single-page-image"), t = this.querySelector(".flex-1.flex.items-center.justify-center");
if (!e || !t) return;
const i = e.getBoundingClientRect(), n = t.getBoundingClientRect(), s = i.width * this.zoomLevel, r = i.height * this.zoomLevel, a = Math.max(0, (s - n.width) / 2), l = Math.max(0, (r - n.height) / 2);
this.panOffset.x = Math.max(-a, Math.min(a, this.panOffset.x)), this.panOffset.y = Math.max(-l, Math.min(l, this.panOffset.y));
}
// Update cursor based on zoom state
updateImageCursor() {
const e = this.querySelector("#single-page-image");
e && (this.zoomLevel > 1 ? (e.className = e.className.replace("cursor-zoom-in", "cursor-grab"), e.title = "Ziehen zum Verschieben") : (e.className = e.className.replace("cursor-grab", "cursor-zoom-in"), e.title = "Klicken zum Vergrößern oder Schließen"));
}
// Update zoom level indicator
updateZoomIndicator() {
const e = this.querySelector("#zoom-indicator"), t = this.querySelector("#zoom-reset-btn");
if (!(!e || !t))
if (this.zoomLevel === 1)
e.textContent = "Strg + Mausrad oder +/- für Zoom", e.className = "text-xs font-medium text-slate-500 bg-slate-100 px-2 py-1 rounded", t.style.display = "none";
else {
const i = Math.round(this.zoomLevel * 100);
e.textContent = `${i}%`, e.className = "text-sm font-medium text-blue-700 bg-blue-100 px-2 py-1 rounded", t.style.display = "flex";
}
}
// Handle image click (always close viewer)
handleImageClick(e) {
if (this.dragDistance >= 5) {
this.dragDistance = 0;
return;
}
this.close(), this.dragDistance = 0;
}
// Share current page // Share current page
shareCurrentPage() { shareCurrentPage() {
if (typeof copyPagePermalink == "function") { if (typeof copyPagePermalink == "function") {
@@ -391,8 +483,8 @@ class B extends HTMLElement {
console.log("All pages found:", i), console.log("Current page:", this.currentPageNumber); console.log("All pages found:", i), console.log("Current page:", this.currentPageNumber);
const n = i.indexOf(this.currentPageNumber); const n = i.indexOf(this.currentPageNumber);
console.log("Current index:", n); console.log("Current index:", n);
let r = null, s = null; let s = null, r = null;
return n > 0 && (r = i[n - 1]), n < i.length - 1 && (s = i[n + 1]), console.log("Adjacent pages - prev:", r, "next:", s), { prevPage: r, nextPage: s }; return n > 0 && (s = i[n - 1]), n < i.length - 1 && (r = i[n + 1]), console.log("Adjacent pages - prev:", s, "next:", r), { prevPage: s, nextPage: r };
} }
// Navigate to previous page // Navigate to previous page
goToPreviousPage() { goToPreviousPage() {
@@ -412,16 +504,16 @@ class B extends HTMLElement {
if (i) { if (i) {
const n = i.querySelector(".newspaper-page-image, .piece-page-image"); const n = i.querySelector(".newspaper-page-image, .piece-page-image");
if (n) { if (n) {
let r = null; let s = null;
this.currentPartNumber !== null && (r = this.getPartNumberForPage(e)); this.currentPartNumber !== null && (s = this.getPartNumberForPage(e));
let s = null, a = null; let r = null, a = null;
s = i.getAttribute("data-page-icon-type"), i.querySelector(".part-number") && (s = "part-number"); r = i.getAttribute("data-page-icon-type"), i.querySelector(".part-number") && (r = "part-number");
const c = i.querySelector(".page-indicator"); const c = i.querySelector(".page-indicator");
if (c) { if (c) {
const d = c.cloneNode(!0); const d = c.cloneNode(!0);
d.querySelectorAll("i").forEach((h) => h.remove()), d.querySelectorAll( d.querySelectorAll("i").forEach((p) => p.remove()), d.querySelectorAll(
'[class*="target-page-dot"], .target-page-indicator' '[class*="target-page-dot"], .target-page-indicator'
).forEach((h) => h.remove()), a = d.textContent.trim(); ).forEach((p) => p.remove()), a = d.textContent.trim();
} }
this.show( this.show(
n.src, n.src,
@@ -429,8 +521,8 @@ class B extends HTMLElement {
e, e,
this.currentIsBeilage, this.currentIsBeilage,
0, 0,
r,
s, s,
r,
a a
); );
} }
@@ -455,10 +547,10 @@ class B extends HTMLElement {
} }
// Toggle sidebar visibility // Toggle sidebar visibility
toggleSidebar() { toggleSidebar() {
const e = this.querySelector("#sidebar-spacer"), t = this.querySelector("#sidebar-toggle-btn"), i = t.querySelector("i"), n = e.style.width, r = n === "0px" || n === "0"; const e = this.querySelector("#sidebar-spacer"), t = this.querySelector("#sidebar-toggle-btn"), i = t.querySelector("i"), n = e.style.width, s = n === "0px" || n === "0";
if (console.log("Current state - isCollapsed:", r), console.log("Current width:", n), r) { if (console.log("Current state - isCollapsed:", s), console.log("Current width:", n), s) {
const s = this.detectSidebarWidth(); const r = this.detectSidebarWidth();
e.style.width = s, t.className = "w-10 h-10 bg-slate-100 hover:bg-slate-200 text-slate-700 border border-slate-300 rounded flex items-center justify-center transition-colors duration-200 cursor-pointer", i.className = "ri-sidebar-fold-line text-lg font-bold", t.title = "Inhaltsverzeichnis ausblenden", console.log("Expanding sidebar to:", s); e.style.width = r, t.className = "w-10 h-10 bg-slate-100 hover:bg-slate-200 text-slate-700 border border-slate-300 rounded flex items-center justify-center transition-colors duration-200 cursor-pointer", i.className = "ri-sidebar-fold-line text-lg font-bold", t.title = "Inhaltsverzeichnis ausblenden", console.log("Expanding sidebar to:", r);
} else } else
e.style.width = "0px", t.className = "w-10 h-10 bg-orange-100 hover:bg-orange-200 text-orange-700 border border-orange-300 rounded flex items-center justify-center transition-colors duration-200 cursor-pointer", i.className = "ri-sidebar-unfold-line text-lg font-bold", t.title = "Inhaltsverzeichnis einblenden", console.log("Collapsing sidebar"); e.style.width = "0px", t.className = "w-10 h-10 bg-orange-100 hover:bg-orange-200 text-orange-700 border border-orange-300 rounded flex items-center justify-center transition-colors duration-200 cursor-pointer", i.className = "ri-sidebar-unfold-line text-lg font-bold", t.title = "Inhaltsverzeichnis einblenden", console.log("Collapsing sidebar");
console.log("New width:", e.style.width); console.log("New width:", e.style.width);
@@ -467,9 +559,9 @@ class B extends HTMLElement {
getIssueContext(e) { getIssueContext(e) {
const t = window.location.pathname, i = t.includes("/beitrag/"); const t = window.location.pathname, i = t.includes("/beitrag/");
if (i) { if (i) {
const s = document.querySelector(`[data-page-container="${e}"]`); const r = document.querySelector(`[data-page-container="${e}"]`);
if (s) { if (r) {
const c = s.querySelector(".page-indicator"); const c = r.querySelector(".page-indicator");
if (c) { if (c) {
const d = c.textContent.trim(), u = d.match(/(\d{1,2}\.\d{1,2}\.\d{4}\s+Nr\.\s+\d+)/); const d = c.textContent.trim(), u = d.match(/(\d{1,2}\.\d{1,2}\.\d{4}\s+Nr\.\s+\d+)/);
if (u) if (u)
@@ -487,9 +579,9 @@ class B extends HTMLElement {
const n = t.match(/\/(\d{4})\/(\d+)/); const n = t.match(/\/(\d{4})\/(\d+)/);
if (n) if (n)
return i ? `${n[1]} Nr. ${n[2]}` : ""; return i ? `${n[1]} Nr. ${n[2]}` : "";
const r = document.querySelector(".page-indicator"); const s = document.querySelector(".page-indicator");
if (r) { if (s) {
const a = r.textContent.trim().match(/(\d{4})\s+Nr\.\s+(\d+)/); const a = s.textContent.trim().match(/(\d{4})\s+Nr\.\s+(\d+)/);
if (a) if (a)
return `${a[1]} Nr. ${a[2]}`; return `${a[1]} Nr. ${a[2]}`;
} }
@@ -550,25 +642,25 @@ customElements.define("scroll-to-top-button", A);
window.currentPageContainers = window.currentPageContainers || []; window.currentPageContainers = window.currentPageContainers || [];
window.currentActiveIndex = window.currentActiveIndex || 0; window.currentActiveIndex = window.currentActiveIndex || 0;
window.pageObserver = window.pageObserver || null; window.pageObserver = window.pageObserver || null;
function N(o, e, t, i = null) { function q(o, e, t, i = null) {
let n = document.querySelector("single-page-viewer"); let n = document.querySelector("single-page-viewer");
n || (n = document.createElement("single-page-viewer"), document.body.appendChild(n)); n || (n = document.createElement("single-page-viewer"), document.body.appendChild(n));
const r = o.closest('[data-beilage="true"]') !== null, s = window.templateData && window.templateData.targetPage ? window.templateData.targetPage : 0, a = o.closest(".newspaper-page-container, .piece-page-container"); const s = o.closest('[data-beilage="true"]') !== null, r = window.templateData && window.templateData.targetPage ? window.templateData.targetPage : 0, a = o.closest(".newspaper-page-container, .piece-page-container");
let l = null, c = null; let l = null, c = null;
if (a) { if (a) {
l = a.getAttribute("data-page-icon-type"), a.querySelector(".part-number") && (l = "part-number"); l = a.getAttribute("data-page-icon-type"), a.querySelector(".part-number") && (l = "part-number");
const u = a.querySelector(".page-indicator"); const u = a.querySelector(".page-indicator");
if (u) { if (u) {
const g = u.cloneNode(!0); const g = u.cloneNode(!0);
g.querySelectorAll("i").forEach((f) => f.remove()), g.querySelectorAll('[class*="target-page-dot"], .target-page-indicator').forEach((f) => f.remove()), c = g.textContent.trim(); g.querySelectorAll("i").forEach((m) => m.remove()), g.querySelectorAll('[class*="target-page-dot"], .target-page-indicator').forEach((m) => m.remove()), c = g.textContent.trim();
} }
} }
n.show(o.src, o.alt, e, r, s, i, l, c); n.show(o.src, o.alt, e, s, r, i, l, c);
} }
function C() { function P() {
document.getElementById("pageModal").classList.add("hidden"); document.getElementById("pageModal").classList.add("hidden");
} }
function q() { function N() {
if (window.pageObserver && (window.pageObserver.disconnect(), window.pageObserver = null), window.currentPageContainers = Array.from(document.querySelectorAll(".newspaper-page-container")), window.currentActiveIndex = 0, b(), document.querySelector(".newspaper-page-container")) { if (window.pageObserver && (window.pageObserver.disconnect(), window.pageObserver = null), window.currentPageContainers = Array.from(document.querySelectorAll(".newspaper-page-container")), window.currentActiveIndex = 0, b(), document.querySelector(".newspaper-page-container")) {
let e = /* @__PURE__ */ new Set(); let e = /* @__PURE__ */ new Set();
window.pageObserver = new IntersectionObserver( window.pageObserver = new IntersectionObserver(
@@ -577,7 +669,7 @@ function q() {
const n = window.currentPageContainers.indexOf(i.target); const n = window.currentPageContainers.indexOf(i.target);
n !== -1 && (i.isIntersecting ? e.add(n) : e.delete(n)); n !== -1 && (i.isIntersecting ? e.add(n) : e.delete(n));
}), e.size > 0) { }), e.size > 0) {
const n = Array.from(e).sort((r, s) => r - s)[0]; const n = Array.from(e).sort((s, r) => s - r)[0];
n !== window.currentActiveIndex && (window.currentActiveIndex = n, b()); n !== window.currentActiveIndex && (window.currentActiveIndex = n, b());
} }
}, },
@@ -589,12 +681,12 @@ function q() {
}); });
} }
} }
function $() { function z() {
if (window.currentActiveIndex > 0) { if (window.currentActiveIndex > 0) {
let o = -1; let o = -1;
const e = []; const e = [];
window.currentPageContainers.forEach((i, n) => { window.currentPageContainers.forEach((i, n) => {
const r = i.getBoundingClientRect(), s = window.innerHeight, a = Math.max(r.top, 0), l = Math.min(r.bottom, s), c = Math.max(0, l - a), d = r.height; const s = i.getBoundingClientRect(), r = window.innerHeight, a = Math.max(s.top, 0), l = Math.min(s.bottom, r), c = Math.max(0, l - a), d = s.height;
c / d >= 0.3 && e.push(n); c / d >= 0.3 && e.push(n);
}); });
const t = Math.min(...e); const t = Math.min(...e);
@@ -615,7 +707,7 @@ function M() {
let o = -1; let o = -1;
const e = []; const e = [];
window.currentPageContainers.forEach((i, n) => { window.currentPageContainers.forEach((i, n) => {
const r = i.getBoundingClientRect(), s = window.innerHeight, a = Math.max(r.top, 0), l = Math.min(r.bottom, s), c = Math.max(0, l - a), d = r.height; const s = i.getBoundingClientRect(), r = window.innerHeight, a = Math.max(s.top, 0), l = Math.min(s.bottom, r), c = Math.max(0, l - a), d = s.height;
c / d >= 0.3 && e.push(n); c / d >= 0.3 && e.push(n);
}); });
const t = Math.max(...e); const t = Math.max(...e);
@@ -631,8 +723,8 @@ function M() {
}, 100)); }, 100));
} }
} }
function R() { function $() {
if (T()) { if (L()) {
const e = document.querySelector("#newspaper-content .newspaper-page-container"); const e = document.querySelector("#newspaper-content .newspaper-page-container");
e && e.scrollIntoView({ e && e.scrollIntoView({
block: "start" block: "start"
@@ -644,10 +736,10 @@ function R() {
}); });
} }
} }
function T() { function L() {
const o = []; const o = [];
window.currentPageContainers.forEach((e, t) => { window.currentPageContainers.forEach((e, t) => {
const i = e.getBoundingClientRect(), n = window.innerHeight, r = Math.max(i.top, 0), s = Math.min(i.bottom, n), a = Math.max(0, s - r), l = i.height; const i = e.getBoundingClientRect(), n = window.innerHeight, s = Math.max(i.top, 0), r = Math.min(i.bottom, n), a = Math.max(0, r - s), l = i.height;
a / l >= 0.3 && o.push(t); a / l >= 0.3 && o.push(t);
}); });
for (const e of o) { for (const e of o) {
@@ -660,11 +752,11 @@ function T() {
function b() { function b() {
const o = document.getElementById("prevPageBtn"), e = document.getElementById("nextPageBtn"), t = document.getElementById("beilageBtn"); const o = document.getElementById("prevPageBtn"), e = document.getElementById("nextPageBtn"), t = document.getElementById("beilageBtn");
if (o && (o.style.display = "flex", window.currentActiveIndex <= 0 ? (o.disabled = !0, o.classList.add("opacity-50", "cursor-not-allowed"), o.classList.remove("hover:bg-gray-200")) : (o.disabled = !1, o.classList.remove("opacity-50", "cursor-not-allowed"), o.classList.add("hover:bg-gray-200"))), e && (e.style.display = "flex", window.currentActiveIndex >= window.currentPageContainers.length - 1 ? (e.disabled = !0, e.classList.add("opacity-50", "cursor-not-allowed"), e.classList.remove("hover:bg-gray-200")) : (e.disabled = !1, e.classList.remove("opacity-50", "cursor-not-allowed"), e.classList.add("hover:bg-gray-200"))), t) { if (o && (o.style.display = "flex", window.currentActiveIndex <= 0 ? (o.disabled = !0, o.classList.add("opacity-50", "cursor-not-allowed"), o.classList.remove("hover:bg-gray-200")) : (o.disabled = !1, o.classList.remove("opacity-50", "cursor-not-allowed"), o.classList.add("hover:bg-gray-200"))), e && (e.style.display = "flex", window.currentActiveIndex >= window.currentPageContainers.length - 1 ? (e.disabled = !0, e.classList.add("opacity-50", "cursor-not-allowed"), e.classList.remove("hover:bg-gray-200")) : (e.disabled = !1, e.classList.remove("opacity-50", "cursor-not-allowed"), e.classList.add("hover:bg-gray-200"))), t) {
const i = T(), n = t.querySelector("i"); const i = L(), n = t.querySelector("i");
i ? (t.title = "Zur Hauptausgabe", t.className = "w-14 h-10 lg:w-16 lg:h-12 px-2 py-1 bg-gray-100 hover:bg-gray-200 text-gray-700 hover:text-gray-800 border border-gray-300 transition-colors duration-200 flex items-center justify-center cursor-pointer", n && (n.className = "ri-file-text-line text-lg lg:text-xl")) : (t.title = "Zu Beilage", t.className = "w-14 h-10 lg:w-16 lg:h-12 px-2 py-1 bg-amber-100 hover:bg-amber-200 text-amber-700 hover:text-amber-800 border border-amber-300 transition-colors duration-200 flex items-center justify-center cursor-pointer", n && (n.className = "ri-attachment-line text-lg lg:text-xl")); i ? (t.title = "Zur Hauptausgabe", t.className = "w-14 h-10 lg:w-16 lg:h-12 px-2 py-1 bg-gray-100 hover:bg-gray-200 text-gray-700 hover:text-gray-800 border border-gray-300 transition-colors duration-200 flex items-center justify-center cursor-pointer", n && (n.className = "ri-file-text-line text-lg lg:text-xl")) : (t.title = "Zu Beilage", t.className = "w-14 h-10 lg:w-16 lg:h-12 px-2 py-1 bg-amber-100 hover:bg-amber-200 text-amber-700 hover:text-amber-800 border border-amber-300 transition-colors duration-200 flex items-center justify-center cursor-pointer", n && (n.className = "ri-attachment-line text-lg lg:text-xl"));
} }
} }
function z() { function R() {
const o = document.getElementById("shareLinkBtn"); const o = document.getElementById("shareLinkBtn");
let e = ""; let e = "";
if (window.currentActiveIndex !== void 0 && window.currentPageContainers && window.currentPageContainers[window.currentActiveIndex]) { if (window.currentActiveIndex !== void 0 && window.currentPageContainers && window.currentPageContainers[window.currentActiveIndex]) {
@@ -682,48 +774,48 @@ function z() {
function S(o, e) { function S(o, e) {
if (navigator.clipboard) if (navigator.clipboard)
navigator.clipboard.writeText(o).then(() => { navigator.clipboard.writeText(o).then(() => {
p(e, "Link kopiert!"); h(e, "Link kopiert!");
}).catch((t) => { }).catch((t) => {
p(e, "Kopieren fehlgeschlagen"); h(e, "Kopieren fehlgeschlagen");
}); });
else { else {
const t = document.createElement("textarea"); const t = document.createElement("textarea");
t.value = o, document.body.appendChild(t), t.select(); t.value = o, document.body.appendChild(t), t.select();
try { try {
const i = document.execCommand("copy"); const i = document.execCommand("copy");
p(e, i ? "Link kopiert!" : "Kopieren fehlgeschlagen"); h(e, i ? "Link kopiert!" : "Kopieren fehlgeschlagen");
} catch { } catch {
p(e, "Kopieren fehlgeschlagen"); h(e, "Kopieren fehlgeschlagen");
} finally { } finally {
document.body.removeChild(t); document.body.removeChild(t);
} }
} }
} }
function V() { function O() {
const o = document.getElementById("citationBtn"), e = document.title || "KGPZ"; const o = document.getElementById("citationBtn"), e = document.title || "KGPZ";
let t = window.location.origin + window.location.pathname; let t = window.location.origin + window.location.pathname;
t.includes("#") && (t = t.split("#")[0]); t.includes("#") && (t = t.split("#")[0]);
const i = (/* @__PURE__ */ new Date()).toLocaleDateString("de-DE"), n = `Königsberger Gelehrte und Politische Zeitung (KGPZ). ${e}. Digital verfügbar unter: ${t} (Zugriff: ${i}).`; const i = (/* @__PURE__ */ new Date()).toLocaleDateString("de-DE"), n = `Königsberger Gelehrte und Politische Zeitung (KGPZ). ${e}. Digital verfügbar unter: ${t} (Zugriff: ${i}).`;
if (navigator.clipboard) if (navigator.clipboard)
navigator.clipboard.writeText(n).then(() => { navigator.clipboard.writeText(n).then(() => {
p(o, "Zitation kopiert!"); h(o, "Zitation kopiert!");
}).catch((r) => { }).catch((s) => {
p(o, "Kopieren fehlgeschlagen"); h(o, "Kopieren fehlgeschlagen");
}); });
else { else {
const r = document.createElement("textarea"); const s = document.createElement("textarea");
r.value = n, document.body.appendChild(r), r.select(); s.value = n, document.body.appendChild(s), s.select();
try { try {
const s = document.execCommand("copy"); const r = document.execCommand("copy");
p(o, s ? "Zitation kopiert!" : "Kopieren fehlgeschlagen"); h(o, r ? "Zitation kopiert!" : "Kopieren fehlgeschlagen");
} catch { } catch {
p(o, "Kopieren fehlgeschlagen"); h(o, "Kopieren fehlgeschlagen");
} finally { } finally {
document.body.removeChild(r); document.body.removeChild(s);
} }
} }
} }
function p(o, e) { function h(o, e) {
const t = document.querySelector(".simple-popup"); const t = document.querySelector(".simple-popup");
t && t.remove(); t && t.remove();
const i = document.createElement("div"); const i = document.createElement("div");
@@ -741,10 +833,10 @@ function p(o, e) {
transition: opacity 0.2s ease; transition: opacity 0.2s ease;
white-space: nowrap; white-space: nowrap;
`; `;
const n = o.getBoundingClientRect(), r = window.innerHeight, s = window.innerWidth; const n = o.getBoundingClientRect(), s = window.innerHeight, r = window.innerWidth;
let a = n.left - 10, l = n.bottom + 8; let a = n.left - 10, l = n.bottom + 8;
const c = 120, d = 32; const c = 120, d = 32;
a + c > s && (a = n.right - c + 10), l + d > r && (l = n.top - d - 8), i.style.left = Math.max(5, a) + "px", i.style.top = Math.max(5, l) + "px", document.body.appendChild(i), setTimeout(() => { a + c > r && (a = n.right - c + 10), l + d > s && (l = n.top - d - 8), i.style.left = Math.max(5, a) + "px", i.style.top = Math.max(5, l) + "px", document.body.appendChild(i), setTimeout(() => {
i.style.opacity = "1"; i.style.opacity = "1";
}, 10), setTimeout(() => { }, 10), setTimeout(() => {
i.style.opacity = "0", setTimeout(() => { i.style.opacity = "0", setTimeout(() => {
@@ -752,39 +844,39 @@ function p(o, e) {
}, 200); }, 200);
}, 2e3); }, 2e3);
} }
function O(o, e, t = !1) { function D(o, e, t = !1) {
let i = ""; let i = "";
if (t) if (t)
i = window.location.origin + window.location.pathname + `#beilage-1-page-${o}`; i = window.location.origin + window.location.pathname + `#beilage-1-page-${o}`;
else { else {
const r = window.location.pathname.split("/"); const s = window.location.pathname.split("/");
if (r.length >= 3) { if (s.length >= 3) {
const s = r[1], a = r[2]; const r = s[1], a = s[2];
i = `${window.location.origin}/${s}/${a}/${o}`; i = `${window.location.origin}/${r}/${a}/${o}`;
} else } else
i = window.location.origin + window.location.pathname + `/${o}`; i = window.location.origin + window.location.pathname + `/${o}`;
} }
const n = i; const n = i;
if (navigator.clipboard) if (navigator.clipboard)
navigator.clipboard.writeText(n).then(() => { navigator.clipboard.writeText(n).then(() => {
p(e, "Link kopiert!"); h(e, "Link kopiert!");
}).catch((r) => { }).catch((s) => {
p(e, "Kopieren fehlgeschlagen"); h(e, "Kopieren fehlgeschlagen");
}); });
else { else {
const r = document.createElement("textarea"); const s = document.createElement("textarea");
r.value = n, document.body.appendChild(r), r.select(); s.value = n, document.body.appendChild(s), s.select();
try { try {
const s = document.execCommand("copy"); const r = document.execCommand("copy");
p(e, s ? "Link kopiert!" : "Kopieren fehlgeschlagen"); h(e, r ? "Link kopiert!" : "Kopieren fehlgeschlagen");
} catch { } catch {
p(e, "Kopieren fehlgeschlagen"); h(e, "Kopieren fehlgeschlagen");
} finally { } finally {
document.body.removeChild(r); document.body.removeChild(s);
} }
} }
} }
function D(o, e) { function Z(o, e) {
const t = document.title || "KGPZ", i = window.location.pathname.split("/"); const t = document.title || "KGPZ", i = window.location.pathname.split("/");
let n; let n;
if (i.length >= 3) { if (i.length >= 3) {
@@ -792,33 +884,33 @@ function D(o, e) {
n = `${window.location.origin}/${l}/${c}/${o}`; n = `${window.location.origin}/${l}/${c}/${o}`;
} else } else
n = `${window.location.origin}${window.location.pathname}/${o}`; n = `${window.location.origin}${window.location.pathname}/${o}`;
const r = n, s = (/* @__PURE__ */ new Date()).toLocaleDateString("de-DE"), a = `Königsberger Gelehrte und Politische Zeitung (KGPZ). ${t}, Seite ${o}. Digital verfügbar unter: ${r} (Zugriff: ${s}).`; const s = n, r = (/* @__PURE__ */ new Date()).toLocaleDateString("de-DE"), a = `Königsberger Gelehrte und Politische Zeitung (KGPZ). ${t}, Seite ${o}. Digital verfügbar unter: ${s} (Zugriff: ${r}).`;
if (navigator.clipboard) if (navigator.clipboard)
navigator.clipboard.writeText(a).then(() => { navigator.clipboard.writeText(a).then(() => {
p(e, "Zitation kopiert!"); h(e, "Zitation kopiert!");
}).catch((l) => { }).catch((l) => {
p(e, "Kopieren fehlgeschlagen"); h(e, "Kopieren fehlgeschlagen");
}); });
else { else {
const l = document.createElement("textarea"); const l = document.createElement("textarea");
l.value = a, document.body.appendChild(l), l.select(); l.value = a, document.body.appendChild(l), l.select();
try { try {
const c = document.execCommand("copy"); const c = document.execCommand("copy");
p(e, c ? "Zitation kopiert!" : "Kopieren fehlgeschlagen"); h(e, c ? "Zitation kopiert!" : "Kopieren fehlgeschlagen");
} catch { } catch {
p(e, "Kopieren fehlgeschlagen"); h(e, "Kopieren fehlgeschlagen");
} finally { } finally {
document.body.removeChild(l); document.body.removeChild(l);
} }
} }
} }
function k() { function k() {
q(), window.addEventListener("scroll", function() { N(), window.addEventListener("scroll", function() {
clearTimeout(window.scrollTimeout), window.scrollTimeout = setTimeout(() => { clearTimeout(window.scrollTimeout), window.scrollTimeout = setTimeout(() => {
b(); b();
}, 50); }, 50);
}), document.addEventListener("keydown", function(o) { }), document.addEventListener("keydown", function(o) {
o.key === "Escape" && C(); o.key === "Escape" && P();
}); });
} }
function w() { function w() {
@@ -829,16 +921,16 @@ function w() {
if (i === o) if (i === o)
n = !0; n = !0;
else { else {
const r = o.match(/^\/(\d{4})\/(\d+)(?:\/(\d+))?$/), s = i.match(/^\/(\d{4})\/(\d+)$/); const s = o.match(/^\/(\d{4})\/(\d+)(?:\/(\d+))?$/), r = i.match(/^\/(\d{4})\/(\d+)$/);
if (r && s) { if (s && r) {
const [, a, l, c] = r, [, d, u] = s; const [, a, l, c] = s, [, d, u] = r;
a === d && l === u && (n = !0); a === d && l === u && (n = !0);
} }
} }
n ? (t.classList.add("text-red-700", "pointer-events-none"), t.setAttribute("aria-current", "page")) : (t.classList.remove("text-red-700", "pointer-events-none"), t.removeAttribute("aria-current")); n ? (t.classList.add("text-red-700", "pointer-events-none"), t.setAttribute("aria-current", "page")) : (t.classList.remove("text-red-700", "pointer-events-none"), t.removeAttribute("aria-current"));
}); });
} }
function P() { function C() {
const o = window.location.pathname, e = document.body; const o = window.location.pathname, e = document.body;
e.classList.remove( e.classList.remove(
"page-akteure", "page-akteure",
@@ -854,7 +946,7 @@ let y = [];
window.ExecuteNextSettle = function(o) { window.ExecuteNextSettle = function(o) {
typeof o == "function" && y.push(o); typeof o == "function" && y.push(o);
}; };
function K() { function V() {
for (; y.length > 0; ) { for (; y.length > 0; ) {
const o = y.shift(); const o = y.shift();
try { try {
@@ -864,19 +956,19 @@ function K() {
} }
} }
} }
window.enlargePage = N; window.enlargePage = q;
window.closeModal = C; window.closeModal = P;
window.scrollToPreviousPage = $; window.scrollToPreviousPage = z;
window.scrollToNextPage = M; window.scrollToNextPage = M;
window.scrollToBeilage = R; window.scrollToBeilage = $;
window.shareCurrentPage = z; window.shareCurrentPage = R;
window.generateCitation = V; window.generateCitation = O;
window.copyPagePermalink = O; window.copyPagePermalink = D;
window.generatePageCitation = D; window.generatePageCitation = Z;
function W() { function K() {
P(), w(), document.querySelector(".newspaper-page-container") && k(); C(), w(), document.querySelector(".newspaper-page-container") && k();
let o = function(t) { let o = function(t) {
P(), w(), K(), setTimeout(() => { C(), w(), V(), setTimeout(() => {
document.querySelector(".newspaper-page-container") && k(); document.querySelector(".newspaper-page-container") && k();
}, 50); }, 50);
}, e = function(t) { }, e = function(t) {
@@ -884,5 +976,5 @@ function W() {
document.body.addEventListener("htmx:afterSettle", o), document.body.addEventListener("htmx:afterSettle", w), document.body.addEventListener("htmx:beforeRequest", e); document.body.addEventListener("htmx:afterSettle", o), document.body.addEventListener("htmx:afterSettle", w), document.body.addEventListener("htmx:beforeRequest", e);
} }
export { export {
W as setup K as setup
}; };

File diff suppressed because one or more lines are too long

View File

@@ -8,6 +8,16 @@ export class SinglePageViewer extends HTMLElement {
super(); super();
// No shadow DOM - use regular DOM to allow Tailwind CSS // No shadow DOM - use regular DOM to allow Tailwind CSS
this.resizeObserver = null; this.resizeObserver = null;
// Zoom and pan state
this.zoomLevel = 1;
this.minZoom = 1; // No zoom below 100%
this.maxZoom = 3;
this.zoomStep = 0.1;
this.isPanning = false;
this.panStart = { x: 0, y: 0 };
this.panOffset = { x: 0, y: 0 };
this.dragDistance = 0;
} }
// Dynamically detect sidebar width in pixels // Dynamically detect sidebar width in pixels
@@ -50,7 +60,7 @@ export class SinglePageViewer extends HTMLElement {
<div class="flex-1 bg-slate-50 overflow-auto pointer-events-auto"> <div class="flex-1 bg-slate-50 overflow-auto pointer-events-auto">
<div class="relative min-h-full flex flex-col"> <div class="relative min-h-full flex flex-col">
<!-- Header with page info and buttons --> <!-- Header with page info and buttons -->
<div class="flex items-center justify-between p-4"> <div class="flex items-center justify-between p-4 bg-slate-50 relative z-10 border-b border-slate-200">
<!-- Left: Sidebar toggle and page indicator --> <!-- Left: Sidebar toggle and page indicator -->
<div class="flex items-center gap-3"> <div class="flex items-center gap-3">
<!-- Sidebar toggle button --> <!-- Sidebar toggle button -->
@@ -67,6 +77,18 @@ export class SinglePageViewer extends HTMLElement {
<span id="page-icon" class="text-lg"></span> <span id="page-icon" class="text-lg"></span>
<span id="page-number" class="text-lg font-bold bg-blue-50 px-2 py-1 rounded flex items-center gap-1"></span> <span id="page-number" class="text-lg font-bold bg-blue-50 px-2 py-1 rounded flex items-center gap-1"></span>
</div> </div>
<!-- Zoom indicator and reset -->
<div class="flex items-center gap-2">
<span id="zoom-indicator" class="text-sm font-medium text-slate-600 bg-slate-100 px-2 py-1 rounded">100%</span>
<button
id="zoom-reset-btn"
onclick="this.closest('single-page-viewer').resetZoom()"
class="w-8 h-8 bg-slate-100 hover:bg-slate-200 text-slate-700 border border-slate-300 rounded flex items-center justify-center transition-colors duration-200 cursor-pointer text-xs"
title="Zoom zurücksetzen (1:1)">
<i class="ri-zoom-out-line text-sm"></i>
</button>
</div>
</div> </div>
<!-- Right: Action buttons --> <!-- Right: Action buttons -->
@@ -126,9 +148,9 @@ export class SinglePageViewer extends HTMLElement {
id="single-page-image" id="single-page-image"
src="" src=""
alt="" alt=""
class="w-full h-auto rounded-lg shadow-2xl cursor-zoom-out" class="w-full h-auto rounded-lg shadow-2xl cursor-zoom-in"
onclick="this.closest('single-page-viewer').close()" onclick="this.closest('single-page-viewer').handleImageClick()"
title="Klicken zum Schließen" title="Klicken zum Vergrößern oder Schließen"
/> />
</div> </div>
</div> </div>
@@ -141,6 +163,9 @@ export class SinglePageViewer extends HTMLElement {
// Set up keyboard navigation // Set up keyboard navigation
this.setupKeyboardNavigation(); this.setupKeyboardNavigation();
// Set up zoom and pan functionality
this.setupZoomAndPan();
} }
// Set up resize observer to dynamically update sidebar width // Set up resize observer to dynamically update sidebar width
@@ -243,6 +268,9 @@ export class SinglePageViewer extends HTMLElement {
this.style.display = "block"; this.style.display = "block";
// Reset zoom and pan state for new page
this.resetZoom();
// Scroll to top of the single page viewer (no smooth scrolling) // Scroll to top of the single page viewer (no smooth scrolling)
const scrollContainer = this.querySelector(".flex-1.overflow-auto"); const scrollContainer = this.querySelector(".flex-1.overflow-auto");
if (scrollContainer) { if (scrollContainer) {
@@ -273,6 +301,20 @@ export class SinglePageViewer extends HTMLElement {
this.keyboardHandler = null; this.keyboardHandler = null;
} }
// Clean up zoom and pan event listeners
const imageContainer = this.querySelector('.flex-1.flex.items-center.justify-center');
const image = this.querySelector('#single-page-image');
if (imageContainer && this.wheelHandler) {
imageContainer.removeEventListener('wheel', this.wheelHandler);
}
if (image) {
if (this.mouseDownHandler) image.removeEventListener('mousedown', this.mouseDownHandler);
if (this.doubleClickHandler) image.removeEventListener('dblclick', this.doubleClickHandler);
}
if (this.mouseMoveHandler) document.removeEventListener('mousemove', this.mouseMoveHandler);
if (this.mouseUpHandler) document.removeEventListener('mouseup', this.mouseUpHandler);
// Restore background scrolling // Restore background scrolling
document.body.style.overflow = ""; document.body.style.overflow = "";
} }
@@ -320,6 +362,19 @@ export class SinglePageViewer extends HTMLElement {
event.preventDefault(); event.preventDefault();
this.close(); this.close();
break; break;
case '+':
case '=':
event.preventDefault();
this.adjustZoom(this.zoomStep, { clientX: window.innerWidth / 2, clientY: window.innerHeight / 2 });
break;
case '-':
event.preventDefault();
this.adjustZoom(-this.zoomStep, { clientX: window.innerWidth / 2, clientY: window.innerHeight / 2 });
break;
case '0':
event.preventDefault();
this.resetZoom();
break;
} }
}; };
@@ -327,6 +382,201 @@ export class SinglePageViewer extends HTMLElement {
document.addEventListener('keydown', this.keyboardHandler); document.addEventListener('keydown', this.keyboardHandler);
} }
// Set up zoom and pan functionality
setupZoomAndPan() {
const imageContainer = this.querySelector('.flex-1.flex.items-center.justify-center');
const image = this.querySelector('#single-page-image');
if (!imageContainer || !image) return;
// Mouse wheel zoom
this.wheelHandler = (event) => {
// Only zoom with Ctrl+scroll for better UX
if (!event.ctrlKey) return;
event.preventDefault();
const delta = event.deltaY > 0 ? -this.zoomStep : this.zoomStep;
this.adjustZoom(delta, event);
};
// Pan functionality
this.mouseDownHandler = (event) => {
if (this.zoomLevel <= 1) return; // Only pan when zoomed in
event.preventDefault();
this.isPanning = true;
this.dragDistance = 0;
this.panStart.x = event.clientX - this.panOffset.x;
this.panStart.y = event.clientY - this.panOffset.y;
image.style.cursor = 'grabbing';
};
this.mouseMoveHandler = (event) => {
if (!this.isPanning || this.zoomLevel <= 1) return;
event.preventDefault();
const newX = event.clientX - this.panStart.x;
const newY = event.clientY - this.panStart.y;
// Track drag distance to determine if it was a real drag
const deltaX = newX - this.panOffset.x;
const deltaY = newY - this.panOffset.y;
this.dragDistance += Math.sqrt(deltaX * deltaX + deltaY * deltaY);
this.panOffset.x = newX;
this.panOffset.y = newY;
this.updateImageTransform();
};
this.mouseUpHandler = (event) => {
if (this.isPanning) {
this.isPanning = false;
this.updateImageCursor();
}
};
// Double click to reset zoom
this.doubleClickHandler = (event) => {
event.preventDefault();
this.resetZoom();
};
// Add event listeners
imageContainer.addEventListener('wheel', this.wheelHandler, { passive: false });
image.addEventListener('mousedown', this.mouseDownHandler);
document.addEventListener('mousemove', this.mouseMoveHandler);
document.addEventListener('mouseup', this.mouseUpHandler);
image.addEventListener('dblclick', this.doubleClickHandler);
}
// Adjust zoom level
adjustZoom(delta, event) {
const newZoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.zoomLevel + delta));
if (newZoom === this.zoomLevel) return;
// Calculate zoom center point relative to image
const image = this.querySelector('#single-page-image');
const rect = image.getBoundingClientRect();
const centerX = (event.clientX - rect.left) / rect.width;
const centerY = (event.clientY - rect.top) / rect.height;
// Adjust pan offset to zoom around mouse position
const zoomRatio = newZoom / this.zoomLevel;
this.panOffset.x = centerX * rect.width * (1 - zoomRatio) + this.panOffset.x * zoomRatio;
this.panOffset.y = centerY * rect.height * (1 - zoomRatio) + this.panOffset.y * zoomRatio;
this.zoomLevel = newZoom;
this.updateImageTransform();
this.updateImageCursor();
this.updateZoomIndicator();
}
// Reset zoom to fit
resetZoom() {
this.zoomLevel = 1;
this.panOffset.x = 0;
this.panOffset.y = 0;
this.updateImageTransform();
this.updateImageCursor();
this.updateZoomIndicator();
}
// Update image transform with boundaries
updateImageTransform() {
const image = this.querySelector('#single-page-image');
if (!image) return;
// Apply pan boundaries to keep image within view
this.constrainPanOffset();
if (this.zoomLevel === 1 && this.panOffset.x === 0 && this.panOffset.y === 0) {
image.style.transform = '';
} else {
image.style.transform = `scale(${this.zoomLevel}) translate(${this.panOffset.x / this.zoomLevel}px, ${this.panOffset.y / this.zoomLevel}px)`;
}
// Update transform origin for better zoom behavior
image.style.transformOrigin = 'center center';
}
// Constrain pan offset to keep image within container bounds
constrainPanOffset() {
const image = this.querySelector('#single-page-image');
const container = this.querySelector('.flex-1.flex.items-center.justify-center');
if (!image || !container) return;
const imageRect = image.getBoundingClientRect();
const containerRect = container.getBoundingClientRect();
// Calculate the scaled image dimensions
const scaledWidth = imageRect.width * this.zoomLevel;
const scaledHeight = imageRect.height * this.zoomLevel;
// Calculate maximum allowed pan offsets
const maxPanX = Math.max(0, (scaledWidth - containerRect.width) / 2);
const maxPanY = Math.max(0, (scaledHeight - containerRect.height) / 2);
// Constrain pan offsets
this.panOffset.x = Math.max(-maxPanX, Math.min(maxPanX, this.panOffset.x));
this.panOffset.y = Math.max(-maxPanY, Math.min(maxPanY, this.panOffset.y));
}
// Update cursor based on zoom state
updateImageCursor() {
const image = this.querySelector('#single-page-image');
if (!image) return;
if (this.zoomLevel > 1) {
// When zoomed in: show grab cursor for panning
image.className = image.className.replace('cursor-zoom-in', 'cursor-grab');
image.title = 'Ziehen zum Verschieben';
} else {
// At 100%: show zoom-in cursor for zooming in
image.className = image.className.replace('cursor-grab', 'cursor-zoom-in');
image.title = 'Klicken zum Vergrößern oder Schließen';
}
}
// Update zoom level indicator
updateZoomIndicator() {
const indicator = this.querySelector('#zoom-indicator');
const resetBtn = this.querySelector('#zoom-reset-btn');
if (!indicator || !resetBtn) return;
if (this.zoomLevel === 1) {
// At 100%: Show helpful text and hide reset button
indicator.textContent = 'Strg + Mausrad oder +/- für Zoom';
indicator.className = 'text-xs font-medium text-slate-500 bg-slate-100 px-2 py-1 rounded';
resetBtn.style.display = 'none';
} else {
// Zoomed: Show percentage and reset button
const percentage = Math.round(this.zoomLevel * 100);
indicator.textContent = `${percentage}%`;
indicator.className = 'text-sm font-medium text-blue-700 bg-blue-100 px-2 py-1 rounded';
resetBtn.style.display = 'flex';
}
}
// Handle image click (always close viewer)
handleImageClick(event) {
// If it was a drag, don't do anything
if (this.dragDistance >= 5) {
this.dragDistance = 0;
return;
}
// Always close the viewer when clicking
this.close();
// Reset drag distance for next interaction
this.dragDistance = 0;
}
// Share current page // Share current page
shareCurrentPage() { shareCurrentPage() {
if (typeof copyPagePermalink === "function") { if (typeof copyPagePermalink === "function") {