reintro scrollspy

This commit is contained in:
Simon Martens
2025-09-23 04:12:29 +02:00
parent f2bcb771a4
commit db7844ed6f
11 changed files with 579 additions and 209 deletions

View File

@@ -1,4 +1,4 @@
class E extends HTMLElement { class H extends HTMLElement {
constructor() { constructor() {
super(), this.scrollHandler = null, this.scrollTimeout = null, this.clickHandlers = [], this.manualNavigation = !1; super(), this.scrollHandler = null, this.scrollTimeout = null, this.clickHandlers = [], this.manualNavigation = !1;
} }
@@ -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"), o = document.getElementById(n);
r && (this.updateActiveLinkImmediate(n), this.manualNavigation = !0, r.scrollIntoView({ o && (this.updateActiveLinkImmediate(n), this.manualNavigation = !0, o.scrollIntoView({
behavior: "smooth", behavior: "smooth",
block: "start" block: "start"
}), setTimeout(() => { }), setTimeout(() => {
@@ -42,7 +42,7 @@ 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), o = parseFloat(e.style.height), s = n + o, a = t.scrollTop, l = a + i.height;
if (s > l) { if (s > l) {
const c = s - i.height + 20; const c = s - i.height + 20;
t.scrollTo({ t.scrollTo({
@@ -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 o = n.getAttribute("id"), s = n.querySelector(".akteur-werke-section"), a = n.querySelector(".akteur-beitraege-section");
let l = !1; let l = !1;
if (s) { if (s) {
const c = s.getBoundingClientRect(), d = c.top < window.innerHeight, u = c.bottom > 0; const c = s.getBoundingClientRect(), d = c.top < window.innerHeight, g = c.bottom > 0;
d && u && (l = !0); d && g && (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, g = c.bottom > 0;
d && u && (l = !0); d && g && (l = !0);
} }
if (!s && !a) { if (!s && !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(), g = d.top >= 0, u = d.bottom <= window.innerHeight;
u && g && (l = !0); g && u && (l = !0);
} }
} }
l && e.push(r); l && e.push(o);
}); });
} catch { } catch {
return; return;
@@ -89,14 +89,14 @@ 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 o = n.getAttribute("data-target");
e.includes(r) && (n.classList.add("font-medium"), t.push(n)); e.includes(o) && (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"), o = n.getBoundingClientRect();
let s = 1 / 0, a = -1 / 0; let s = 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(), g = d.top - o.top + n.scrollTop, u = g + d.height;
s = Math.min(s, u), a = Math.max(a, g); s = Math.min(s, g), a = Math.max(a, u);
}); });
let l = a - s; let l = a - s;
i.style.top = `${s}px`, i.style.height = `${l}px`, i.style.opacity = "1", setTimeout(() => this.ensureMarkerVisibility(), 100); i.style.top = `${s}px`, i.style.height = `${l}px`, i.style.opacity = "1", setTimeout(() => this.ensureMarkerVisibility(), 100);
@@ -117,7 +117,7 @@ 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 o = n.getBoundingClientRect(), s = i.getBoundingClientRect(), a = s.top - o.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 = `${s.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; ), o = window.innerHeight, s = n - o, a = s > 0 ? window.scrollY / s : 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 g = a * d, u = i.getBoundingClientRect(), p = t.getBoundingClientRect(), f = u.top - p.top + t.scrollTop, m = l / 2, L = f - m, y = 0.7, I = y * g + (1 - y) * L, 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"
}); });
@@ -155,8 +155,8 @@ class E extends HTMLElement {
e && (e.style.opacity = "0", e.style.height = "0"), this.sections = null, this.navLinks = null, this.clickHandlers = [], this.manualNavigation = !1; e && (e.style.opacity = "0", e.style.height = "0"), this.sections = null, this.navLinks = null, this.clickHandlers = [], this.manualNavigation = !1;
} }
} }
customElements.define("akteure-scrollspy", E); customElements.define("akteure-scrollspy", H);
class B extends HTMLElement { class A extends HTMLElement {
constructor() { constructor() {
super(), this.resizeObserver = null; super(), this.resizeObserver = null;
} }
@@ -281,29 +281,33 @@ 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, o = 0, s = 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"), g = 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 = s;
let g; let u;
if (l) if (l)
g = l; u = l;
else { else {
const m = this.getIssueContext(i); const f = this.getIssueContext(i);
g = m ? `${m}, ${i}` : `${i}`; u = f ? `${f}, ${i}` : `${i}`;
} }
if (d.innerHTML = g, r && i === r) { if (d.innerHTML = u, o && i === o) {
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" && s !== null ? g.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>` : g.innerHTML = this.generateIconFromType(a) : g.innerHTML = this.generateFallbackIcon(i, n, s), this.updateNavigationButtons(), this.style.display = "block", this.setAttribute("active", "true");
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", document.dispatchEvent(new CustomEvent("singlepageviewer:opened", {
detail: { pageNumber: this.currentPageNumber, isBeilage: this.currentIsBeilage }
}));
} }
close() { close() {
this.style.display = "none", document.body.style.overflow = ""; this.style.display = "none", this.removeAttribute("active"), document.body.style.overflow = "", document.dispatchEvent(new CustomEvent("singlepageviewer:closed", {
detail: { pageNumber: this.currentPageNumber, isBeilage: this.currentIsBeilage }
}));
} }
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), document.body.style.overflow = "";
@@ -391,8 +395,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 o = null, s = 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 && (o = i[n - 1]), n < i.length - 1 && (s = i[n + 1]), console.log("Adjacent pages - prev:", o, "next:", s), { prevPage: o, nextPage: s };
} }
// Navigate to previous page // Navigate to previous page
goToPreviousPage() { goToPreviousPage() {
@@ -412,16 +416,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 o = null;
this.currentPartNumber !== null && (r = this.getPartNumberForPage(e)); this.currentPartNumber !== null && (o = this.getPartNumberForPage(e));
let s = null, a = null; let s = null, a = null;
s = i.getAttribute("data-page-icon-type"), i.querySelector(".part-number") && (s = "part-number"); s = i.getAttribute("data-page-icon-type"), i.querySelector(".part-number") && (s = "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,10 +433,12 @@ class B extends HTMLElement {
e, e,
this.currentIsBeilage, this.currentIsBeilage,
0, 0,
r, o,
s, s,
a a
); ), document.dispatchEvent(new CustomEvent("singlepageviewer:pagechanged", {
detail: { pageNumber: this.currentPageNumber, isBeilage: this.currentIsBeilage }
}));
} }
} }
} }
@@ -455,8 +461,8 @@ 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, o = n === "0px" || n === "0";
if (console.log("Current state - isCollapsed:", r), console.log("Current width:", n), r) { if (console.log("Current state - isCollapsed:", o), console.log("Current width:", n), o) {
const s = this.detectSidebarWidth(); const s = 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 = 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);
} else } else
@@ -471,12 +477,12 @@ class B extends HTMLElement {
if (s) { if (s) {
const c = s.querySelector(".page-indicator"); const c = s.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(), g = d.match(/(\d{1,2}\.\d{1,2}\.\d{4}\s+Nr\.\s+\d+)/);
if (u)
return u[1];
const g = d.match(/(\d{4})\s+Nr\.\s+(\d+)/);
if (g) if (g)
return `${g[1]} Nr. ${g[2]}`; return g[1];
const u = d.match(/(\d{4})\s+Nr\.\s+(\d+)/);
if (u)
return `${u[1]} Nr. ${u[2]}`;
} }
} }
const l = document.title.match(/(\d{4}).*Nr\.\s*(\d+)/); const l = document.title.match(/(\d{4}).*Nr\.\s*(\d+)/);
@@ -487,25 +493,25 @@ 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 o = document.querySelector(".page-indicator");
if (r) { if (o) {
const a = r.textContent.trim().match(/(\d{4})\s+Nr\.\s+(\d+)/); const a = o.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]}`;
} }
return "KGPZ"; return "KGPZ";
} }
} }
customElements.define("single-page-viewer", B); customElements.define("single-page-viewer", A);
document.body.addEventListener("htmx:beforeRequest", function(o) { document.body.addEventListener("htmx:beforeRequest", function(r) {
const e = document.querySelector("single-page-viewer"); const e = document.querySelector("single-page-viewer");
e && e.style.display !== "none" && (console.log("Cleaning up single page viewer before HTMX navigation"), e.close()); e && e.style.display !== "none" && (console.log("Cleaning up single page viewer before HTMX navigation"), e.close());
}); });
window.addEventListener("beforeunload", function() { window.addEventListener("beforeunload", function() {
const o = document.querySelector("single-page-viewer"); const r = document.querySelector("single-page-viewer");
o && o.close(); r && r.close();
}); });
class A extends HTMLElement { class B extends HTMLElement {
constructor() { constructor() {
super(), this.isVisible = !1, this.scrollHandler = null, this.htmxAfterSwapHandler = null; super(), this.isVisible = !1, this.scrollHandler = null, this.htmxAfterSwapHandler = null;
} }
@@ -546,29 +552,117 @@ class A extends HTMLElement {
}); });
} }
} }
customElements.define("scroll-to-top-button", A); customElements.define("scroll-to-top-button", B);
class N extends HTMLElement {
constructor() {
super(), this.pageObserver = null, this.pageContainers = /* @__PURE__ */ new Map(), this.singlePageViewerActive = !1, this.singlePageViewerCurrentPage = null, this.boundHandleSinglePageViewer = this.handleSinglePageViewer.bind(this);
}
connectedCallback() {
this.setupScrollspy(), this.setupSinglePageViewerDetection();
}
disconnectedCallback() {
this.cleanup();
}
setupScrollspy() {
const e = document.querySelectorAll(".newspaper-page-container[data-page-container]");
e.length !== 0 && (e.forEach((t) => {
const i = t.getAttribute("data-page-container"), n = t.hasAttribute("data-beilage"), o = this.findInhaltsEntriesForPage(i, n);
o.length > 0 && this.pageContainers.set(i, {
container: t,
entries: o,
state: "short",
// Default state
isBeilage: n
});
}), this.pageObserver = new IntersectionObserver((t) => {
t.forEach((i) => {
const n = i.target.getAttribute("data-page-container"), o = this.pageContainers.get(n);
if (o) {
const a = i.isIntersecting && i.intersectionRatio >= 0.5 || this.singlePageViewerActive ? "full" : "short";
o.state !== a && (o.state = a, this.updateEntriesState(o));
}
});
}, {
threshold: [0, 0.5, 1],
// Watch for 50% threshold
rootMargin: "0px"
}), this.pageContainers.forEach(({ container: t }) => {
this.pageObserver.observe(t);
}), this.pageContainers.forEach((t) => {
this.updateEntriesState(t);
}));
}
findInhaltsEntriesForPage(e, t = !1) {
const i = t ? `[data-page-container="${e}"][data-beilage="true"]` : `[data-page-container="${e}"]:not([data-beilage])`, n = this.querySelector(i);
return n ? Array.from(n.querySelectorAll(".inhalts-entry")) : [];
}
updateEntriesState(e) {
const { entries: t, state: i } = e;
i === "full" ? (t.forEach((n) => {
n.style.display = "";
}), this.highlightPageElements(e, !0)) : (t.forEach((n) => {
const o = n.hasAttribute("data-is-continuation");
n.style.display = o ? "none" : "";
}), this.highlightPageElements(e, !1));
}
highlightPageElements(e, t) {
var a;
const i = e.container.getAttribute("data-page-container"), n = this.querySelector(`[data-page-number="${i}"]`);
(a = n == null ? void 0 : n.closest(".page-entry")) == null || a.querySelector(".icon-container");
const o = n == null ? void 0 : n.closest(".page-entry");
o && (t ? (o.classList.add("!border-l-red-500"), o.classList.remove("border-slate-300")) : (o.classList.remove("!border-l-red-500"), o.classList.add("border-slate-300")));
const s = document.querySelector(`[data-page="${i}"].page-indicator`);
if (s) {
const l = s.querySelectorAll("i:not(.text-slate-400)");
t ? (s.classList.add("!bg-red-50", "!text-red-600"), l.forEach((c) => c.classList.add("!text-red-600"))) : (s.classList.remove("!bg-red-50", "!text-red-600"), l.forEach((c) => c.classList.remove("!text-red-600")));
}
}
setupSinglePageViewerDetection() {
document.addEventListener("singlepageviewer:opened", this.boundHandleSinglePageViewer), document.addEventListener("singlepageviewer:closed", this.boundHandleSinglePageViewer), document.addEventListener("singlepageviewer:pagechanged", this.boundHandleSinglePageViewer), this.checkSinglePageViewerState();
}
handleSinglePageViewer(e) {
var t;
this.singlePageViewerActive, this.singlePageViewerActive = e.type === "singlepageviewer:opened" || e.type === "singlepageviewer:pagechanged" && this.singlePageViewerActive, (this.singlePageViewerActive || e.type === "singlepageviewer:pagechanged") && ((t = e.detail) != null && t.pageNumber) ? this.singlePageViewerCurrentPage = e.detail.pageNumber.toString() : e.type === "singlepageviewer:closed" && (this.singlePageViewerCurrentPage = null, this.singlePageViewerActive = !1), this.pageContainers.forEach((i) => {
const n = i.container.getAttribute("data-page-container");
let o;
this.singlePageViewerActive ? o = n === this.singlePageViewerCurrentPage ? "full" : "short" : o = this.isPageContainerVisible(i.container) ? "full" : "short", i.state !== o && (i.state = o, this.updateEntriesState(i));
});
}
checkSinglePageViewerState() {
const e = document.querySelector("single-page-viewer[active]");
this.singlePageViewerActive = e !== null;
}
isPageContainerVisible(e) {
const t = e.getBoundingClientRect(), i = window.innerHeight, n = Math.max(t.top, 0), o = Math.min(t.bottom, i), s = Math.max(0, o - n), a = t.height;
return s / a >= 0.5;
}
cleanup() {
this.pageObserver && (this.pageObserver.disconnect(), this.pageObserver = null), document.removeEventListener("singlepageviewer:opened", this.boundHandleSinglePageViewer), document.removeEventListener("singlepageviewer:closed", this.boundHandleSinglePageViewer), document.removeEventListener("singlepageviewer:pagechanged", this.boundHandleSinglePageViewer), this.pageContainers.clear();
}
}
customElements.define("inhaltsverzeichnis-scrollspy", N);
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(r, 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 o = r.closest('[data-beilage="true"]') !== null, s = window.templateData && window.templateData.targetPage ? window.templateData.targetPage : 0, a = r.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 g = a.querySelector(".page-indicator");
if (u) { if (g) {
const g = u.cloneNode(!0); const u = g.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(); u.querySelectorAll("i").forEach((m) => m.remove()), u.querySelectorAll('[class*="target-page-dot"], .target-page-indicator').forEach((m) => m.remove()), c = u.textContent.trim();
} }
} }
n.show(o.src, o.alt, e, r, s, i, l, c); n.show(r.src, r.alt, e, o, s, i, l, c);
} }
function C() { function k() {
document.getElementById("pageModal").classList.add("hidden"); document.getElementById("pageModal").classList.add("hidden");
} }
function q() { function V() {
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 +671,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((o, s) => o - s)[0];
n !== window.currentActiveIndex && (window.currentActiveIndex = n, b()); n !== window.currentActiveIndex && (window.currentActiveIndex = n, b());
} }
}, },
@@ -591,19 +685,19 @@ function q() {
} }
function $() { function $() {
if (window.currentActiveIndex > 0) { if (window.currentActiveIndex > 0) {
let o = -1; let r = -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 o = i.getBoundingClientRect(), s = window.innerHeight, a = Math.max(o.top, 0), l = Math.min(o.bottom, s), c = Math.max(0, l - a), d = o.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);
for (let i = t - 1; i >= 0; i--) for (let i = t - 1; i >= 0; i--)
if (!e.includes(i)) { if (!e.includes(i)) {
o = i; r = i;
break; break;
} }
o === -1 && t > 0 && (o = t - 1), o >= 0 && (window.currentActiveIndex = o, window.currentPageContainers[window.currentActiveIndex].scrollIntoView({ r === -1 && t > 0 && (r = t - 1), r >= 0 && (window.currentActiveIndex = r, window.currentPageContainers[window.currentActiveIndex].scrollIntoView({
block: "start" block: "start"
}), setTimeout(() => { }), setTimeout(() => {
b(); b();
@@ -612,19 +706,19 @@ function $() {
} }
function M() { function M() {
if (window.currentActiveIndex < window.currentPageContainers.length - 1) { if (window.currentActiveIndex < window.currentPageContainers.length - 1) {
let o = -1; let r = -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 o = i.getBoundingClientRect(), s = window.innerHeight, a = Math.max(o.top, 0), l = Math.min(o.bottom, s), c = Math.max(0, l - a), d = o.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);
for (let i = t + 1; i < window.currentPageContainers.length; i++) for (let i = t + 1; i < window.currentPageContainers.length; i++)
if (!e.includes(i)) { if (!e.includes(i)) {
o = i; r = i;
break; break;
} }
o === -1 && t < window.currentPageContainers.length - 1 && (o = t + 1), o >= 0 && o < window.currentPageContainers.length && (window.currentActiveIndex = o, window.currentPageContainers[window.currentActiveIndex].scrollIntoView({ r === -1 && t < window.currentPageContainers.length - 1 && (r = t + 1), r >= 0 && r < window.currentPageContainers.length && (window.currentActiveIndex = r, window.currentPageContainers[window.currentActiveIndex].scrollIntoView({
block: "start" block: "start"
}), setTimeout(() => { }), setTimeout(() => {
b(); b();
@@ -632,7 +726,7 @@ function M() {
} }
} }
function R() { function R() {
if (T()) { if (E()) {
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,13 +738,13 @@ function R() {
}); });
} }
} }
function T() { function E() {
const o = []; const r = [];
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, o = Math.max(i.top, 0), s = Math.min(i.bottom, n), a = Math.max(0, s - o), l = i.height;
a / l >= 0.3 && o.push(t); a / l >= 0.3 && r.push(t);
}); });
for (const e of o) { for (const e of r) {
const t = window.currentPageContainers[e]; const t = window.currentPageContainers[e];
if (t && t.id && t.id.includes("beilage-")) if (t && t.id && t.id.includes("beilage-"))
return !0; return !0;
@@ -658,14 +752,14 @@ function T() {
return !1; return !1;
} }
function b() { function b() {
const o = document.getElementById("prevPageBtn"), e = document.getElementById("nextPageBtn"), t = document.getElementById("beilageBtn"); const r = 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 (r && (r.style.display = "flex", window.currentActiveIndex <= 0 ? (r.disabled = !0, r.classList.add("opacity-50", "cursor-not-allowed"), r.classList.remove("hover:bg-gray-200")) : (r.disabled = !1, r.classList.remove("opacity-50", "cursor-not-allowed"), r.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 = E(), 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 z() {
const o = document.getElementById("shareLinkBtn"); const r = 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]) {
const n = window.currentPageContainers[window.currentActiveIndex].querySelector("[data-page]"); const n = window.currentPageContainers[window.currentActiveIndex].querySelector("[data-page]");
@@ -676,54 +770,54 @@ function z() {
title: document.title, title: document.title,
url: t url: t
}).catch((i) => { }).catch((i) => {
S(t, o); S(t, r);
}) : S(t, o); }) : S(t, r);
} }
function S(o, e) { function S(r, e) {
if (navigator.clipboard) if (navigator.clipboard)
navigator.clipboard.writeText(o).then(() => { navigator.clipboard.writeText(r).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 = r, 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 r = 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(r, "Zitation kopiert!");
}).catch((r) => { }).catch((o) => {
p(o, "Kopieren fehlgeschlagen"); h(r, "Kopieren fehlgeschlagen");
}); });
else { else {
const r = document.createElement("textarea"); const o = document.createElement("textarea");
r.value = n, document.body.appendChild(r), r.select(); o.value = n, document.body.appendChild(o), o.select();
try { try {
const s = document.execCommand("copy"); const s = document.execCommand("copy");
p(o, s ? "Zitation kopiert!" : "Kopieren fehlgeschlagen"); h(r, s ? "Zitation kopiert!" : "Kopieren fehlgeschlagen");
} catch { } catch {
p(o, "Kopieren fehlgeschlagen"); h(r, "Kopieren fehlgeschlagen");
} finally { } finally {
document.body.removeChild(r); document.body.removeChild(o);
} }
} }
} }
function p(o, e) { function h(r, 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 +835,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 = r.getBoundingClientRect(), o = window.innerHeight, s = 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 > s && (a = n.right - c + 10), l + d > o && (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,94 +846,94 @@ function p(o, e) {
}, 200); }, 200);
}, 2e3); }, 2e3);
} }
function O(o, e, t = !1) { function K(r, 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-${r}`;
else { else {
const r = window.location.pathname.split("/"); const o = window.location.pathname.split("/");
if (r.length >= 3) { if (o.length >= 3) {
const s = r[1], a = r[2]; const s = o[1], a = o[2];
i = `${window.location.origin}/${s}/${a}/${o}`; i = `${window.location.origin}/${s}/${a}/${r}`;
} else } else
i = window.location.origin + window.location.pathname + `/${o}`; i = window.location.origin + window.location.pathname + `/${r}`;
} }
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((o) => {
p(e, "Kopieren fehlgeschlagen"); h(e, "Kopieren fehlgeschlagen");
}); });
else { else {
const r = document.createElement("textarea"); const o = document.createElement("textarea");
r.value = n, document.body.appendChild(r), r.select(); o.value = n, document.body.appendChild(o), o.select();
try { try {
const s = document.execCommand("copy"); const s = document.execCommand("copy");
p(e, s ? "Link kopiert!" : "Kopieren fehlgeschlagen"); h(e, s ? "Link kopiert!" : "Kopieren fehlgeschlagen");
} catch { } catch {
p(e, "Kopieren fehlgeschlagen"); h(e, "Kopieren fehlgeschlagen");
} finally { } finally {
document.body.removeChild(r); document.body.removeChild(o);
} }
} }
} }
function D(o, e) { function D(r, 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) {
const l = i[1], c = i[2]; const l = i[1], c = i[2];
n = `${window.location.origin}/${l}/${c}/${o}`; n = `${window.location.origin}/${l}/${c}/${r}`;
} else } else
n = `${window.location.origin}${window.location.pathname}/${o}`; n = `${window.location.origin}${window.location.pathname}/${r}`;
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 o = n, s = (/* @__PURE__ */ new Date()).toLocaleDateString("de-DE"), a = `Königsberger Gelehrte und Politische Zeitung (KGPZ). ${t}, Seite ${r}. Digital verfügbar unter: ${o} (Zugriff: ${s}).`;
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 P() {
q(), window.addEventListener("scroll", function() { V(), 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(r) {
o.key === "Escape" && C(); r.key === "Escape" && k();
}); });
} }
function w() { function w() {
const o = window.location.pathname; const r = window.location.pathname;
document.querySelectorAll(".citation-link[data-citation-url]").forEach((t) => { document.querySelectorAll(".citation-link[data-citation-url]").forEach((t) => {
const i = t.getAttribute("data-citation-url"); const i = t.getAttribute("data-citation-url");
let n = !1; let n = !1;
if (i === o) if (i === r)
n = !0; n = !0;
else { else {
const r = o.match(/^\/(\d{4})\/(\d+)(?:\/(\d+))?$/), s = i.match(/^\/(\d{4})\/(\d+)$/); const o = r.match(/^\/(\d{4})\/(\d+)(?:\/(\d+))?$/), s = i.match(/^\/(\d{4})\/(\d+)$/);
if (r && s) { if (o && s) {
const [, a, l, c] = r, [, d, u] = s; const [, a, l, c] = o, [, d, g] = s;
a === d && l === u && (n = !0); a === d && l === g && (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 r = window.location.pathname, e = document.body;
e.classList.remove( e.classList.remove(
"page-akteure", "page-akteure",
"page-ausgabe", "page-ausgabe",
@@ -848,41 +942,41 @@ function P() {
"page-kategorie", "page-kategorie",
"page-piece", "page-piece",
"page-edition" "page-edition"
), o.includes("/akteure/") || o.includes("/autoren") ? e.classList.add("page-akteure") : o.match(/\/\d{4}\/\d+/) ? e.classList.add("page-ausgabe") : o.includes("/search") || o.includes("/suche") ? e.classList.add("page-search") : o.includes("/ort/") ? e.classList.add("page-ort") : o.includes("/kategorie/") ? e.classList.add("page-kategorie") : o.includes("/beitrag/") ? e.classList.add("page-piece") : o.includes("/edition") && e.classList.add("page-edition"); ), r.includes("/akteure/") || r.includes("/autoren") ? e.classList.add("page-akteure") : r.match(/\/\d{4}\/\d+/) ? e.classList.add("page-ausgabe") : r.includes("/search") || r.includes("/suche") ? e.classList.add("page-search") : r.includes("/ort/") ? e.classList.add("page-ort") : r.includes("/kategorie/") ? e.classList.add("page-kategorie") : r.includes("/beitrag/") ? e.classList.add("page-piece") : r.includes("/edition") && e.classList.add("page-edition");
} }
let y = []; let v = [];
window.ExecuteNextSettle = function(o) { window.ExecuteNextSettle = function(r) {
typeof o == "function" && y.push(o); typeof r == "function" && v.push(r);
}; };
function K() { function j() {
for (; y.length > 0; ) { for (; v.length > 0; ) {
const o = y.shift(); const r = v.shift();
try { try {
o(); r();
} catch (e) { } catch (e) {
console.error("Error executing settle queue function:", e); console.error("Error executing settle queue function:", e);
} }
} }
} }
window.enlargePage = N; window.enlargePage = q;
window.closeModal = C; window.closeModal = k;
window.scrollToPreviousPage = $; window.scrollToPreviousPage = $;
window.scrollToNextPage = M; window.scrollToNextPage = M;
window.scrollToBeilage = R; window.scrollToBeilage = R;
window.shareCurrentPage = z; window.shareCurrentPage = z;
window.generateCitation = V; window.generateCitation = O;
window.copyPagePermalink = O; window.copyPagePermalink = K;
window.generatePageCitation = D; window.generatePageCitation = D;
function W() { function Z() {
P(), w(), document.querySelector(".newspaper-page-container") && k(); C(), w(), document.querySelector(".newspaper-page-container") && P();
let o = function(t) { let r = function(t) {
P(), w(), K(), setTimeout(() => { C(), w(), j(), setTimeout(() => {
document.querySelector(".newspaper-page-container") && k(); document.querySelector(".newspaper-page-container") && P();
}, 50); }, 50);
}, e = function(t) { }, e = function(t) {
}; };
document.body.addEventListener("htmx:afterSettle", o), document.body.addEventListener("htmx:afterSettle", w), document.body.addEventListener("htmx:beforeRequest", e); document.body.addEventListener("htmx:afterSettle", r), document.body.addEventListener("htmx:afterSettle", w), document.body.addEventListener("htmx:beforeRequest", e);
} }
export { export {
W as setup Z as setup
}; };

File diff suppressed because one or more lines are too long

View File

@@ -5,10 +5,10 @@
{{ range $_, $l := .AvailableLetters }} {{ range $_, $l := .AvailableLetters }}
{{ if eq $l (Upper $.Search) }} {{ if eq $l (Upper $.Search) }}
<!-- This is the active letter --> <!-- This is the active letter -->
<span class="no-underline leading-none !m-0 !p-0 text-4xl font-bold text-red-600 pointer-events-none" aria-current="true">{{ $l }}</span> <span class="no-underline leading-none !m-0 !p-0 text-3xl font-bold text-red-600 pointer-events-none" aria-current="true">{{ $l }}</span>
{{ else }} {{ else }}
<!-- This is an inactive letter --> <!-- This is an inactive letter -->
<a href="/akteure/{{ $l }}" class="no-underline leading-none !m-0 !p-0 text-2xl font-medium text-gray-700 hover:text-red-600 transition-colors">{{ $l }}</a> <a href="/akteure/{{ $l }}" class="no-underline leading-none !m-0 !p-0 text-xl font-medium text-gray-700 hover:text-red-600 transition-colors">{{ $l }}</a>
{{ end }} {{ end }}
{{ end }} {{ end }}
<!-- Separator and Anonym link --> <!-- Separator and Anonym link -->
@@ -20,4 +20,4 @@
{{ end }} {{ end }}
</div> </div>
</div> </div>
</div> </div>

View File

@@ -1,15 +1,8 @@
{{- /* Shared back navigation for individual person pages */ -}} {{- /* Shared back navigation for individual person pages */ -}}
<div class="mb-6"> <div class="mb-6">
{{ if eq .ID "anonym" }}
<a href="/akteure/a" class="inline-flex items-center text-black hover:text-gray-700 transition-colors text-xl no-underline font-bold">
<i class="ri-arrow-left-line mr-3 text-xl font-bold"></i>
A
</a>
{{ else }}
{{ $letter := Upper (FirstLetter .ID) }} {{ $letter := Upper (FirstLetter .ID) }}
<a href="/akteure/{{ $letter }}" class="inline-flex items-center text-black hover:text-gray-700 transition-colors text-xl no-underline font-bold"> <a href="/akteure/{{ $letter }}" class="inline-flex items-center hover:text-black text-gray-600 transition-colors text-xl no-underline font-bold">
<i class="ri-arrow-left-line mr-3 text-xl font-bold"></i> <i class="ri-arrow-left-line mr-1 text-xl font-bold"></i>
{{ $letter }} {{ $letter }}
</a> </a>
{{ end }} </div>
</div>

View File

@@ -7,7 +7,7 @@
<div class="flex flex-col lg:flex-row gap-6 w-full min-h-screen"> <div class="flex flex-col lg:flex-row gap-6 w-full min-h-screen">
<!-- Column 1: Sticky Inhaltsverzeichnis --> <!-- Column 1: Sticky Inhaltsverzeichnis -->
<div class="lg:w-1/4 xl:w-1/4 2xl:w-1/4 3xl:w-1/5 flex-shrink-0 bg-slate-50 px-4 py-4"> <div class="lg:w-1/4 xl:w-1/4 2xl:w-1/4 3xl:w-1/5 flex-shrink-0 bg-slate-50 px-4 py-4">
<div class="sticky top-0 max-h-screen overflow-y-auto overscroll-contain bg-slate-50"> <div class="sticky top-4 max-h-screen overflow-y-auto overscroll-contain bg-slate-50">
<div class="mb-4"> <div class="mb-4">
{{ template "_title_nav" . }} {{ template "_title_nav" . }}
</div> </div>
@@ -18,12 +18,12 @@
</div> </div>
<!-- Column 2: Newspaper pages --> <!-- Column 2: Newspaper pages -->
<div class="flex-1 py-4"> <div class="flex-1 py-4 pr-8 3xl:pr-0">
{{ template "_newspaper_layout" . }} {{ template "_newspaper_layout" . }}
</div> </div>
<!-- Column 3: Navigation buttons --> <!-- Column 3: Navigation buttons -->
<div class="w-16 lg:w-20 xl:w-24 flex-shrink-0 "> <div class="w-16 lg:w-20 hidden 3xl:block xl:w-24 flex-shrink-0 ">
<div class="lg:sticky lg:top-12 lg:max-h-[calc(100vh-2rem)]"> <div class="lg:sticky lg:top-12 lg:max-h-[calc(100vh-2rem)]">
<div class="space-y-3 flex flex-col items-center px-2 pt-8"> <div class="space-y-3 flex flex-col items-center px-2 pt-8">
<button <button
@@ -55,25 +55,25 @@
<!-- Separator for utility buttons --> <!-- Separator for utility buttons -->
<div class="w-full border-t border-gray-200 my-4"></div> <!-- <div class="w-full border-t border-gray-200 my-4"></div> -->
<!-- Share Link Button --> <!-- Share Link Button -->
<button <!-- <button -->
id="shareLinkBtn" <!-- id="shareLinkBtn" -->
onclick="shareCurrentPage()" <!-- onclick="shareCurrentPage()" -->
class="w-14 h-10 lg:w-16 lg:h-12 px-2 py-1 bg-blue-100 hover:bg-blue-200 text-blue-700 hover:text-blue-800 border border-blue-300 transition-colors duration-200 flex items-center justify-center cursor-pointer" <!-- class="w-14 h-10 lg:w-16 lg:h-12 px-2 py-1 bg-blue-100 hover:bg-blue-200 text-blue-700 hover:text-blue-800 border border-blue-300 transition-colors duration-200 flex items-center justify-center cursor-pointer" -->
title="Link zur aktuellen Seite teilen"> <!-- title="Link zur aktuellen Seite teilen"> -->
<i class="ri-share-line text-lg lg:text-xl"></i> <!-- <i class="ri-share-line text-lg lg:text-xl"></i> -->
</button> <!-- </button> -->
<!-- Citation Button --> <!-- Citation Button -->
<button <!-- <button -->
id="citationBtn" <!-- id="citationBtn" -->
onclick="generateCitation()" <!-- onclick="generateCitation()" -->
class="w-14 h-10 lg:w-16 lg:h-12 px-2 py-1 bg-green-100 hover:bg-green-200 text-green-700 hover:text-green-800 border border-green-300 transition-colors duration-200 flex items-center justify-center cursor-pointer" <!-- class="w-14 h-10 lg:w-16 lg:h-12 px-2 py-1 bg-green-100 hover:bg-green-200 text-green-700 hover:text-green-800 border border-green-300 transition-colors duration-200 flex items-center justify-center cursor-pointer" -->
title="Zitation für diese Seite generieren"> <!-- title="Zitation für diese Seite generieren"> -->
<i class="ri-file-text-line text-lg lg:text-xl"></i> <!-- <i class="ri-file-text-line text-lg lg:text-xl"></i> -->
</button> <!-- </button> -->
</div> </div>
</div> </div>
</div> </div>

View File

@@ -1,10 +1,10 @@
{{ $model := .model }} {{ $model := .model }}
<div class="hyphens-auto mx-3"> <inhaltsverzeichnis-scrollspy class="hyphens-auto mx-3">
{{- if $model.Pieces.Pages -}} {{- if $model.Pieces.Pages -}}
<div class="space-y-4"> <div class="space-y-4">
<div class="mb-4"></div> <div class="mb-2"></div>
{{ range $page := $model.Pieces.Pages }} {{ range $page := $model.Pieces.Pages }}
{{ $pageItems := (index $model.Pieces.Items $page) }} {{ $pageItems := (index $model.Pieces.Items $page) }}
{{ $firstItem := "" }} {{ $firstItem := "" }}
@@ -13,7 +13,7 @@
<!-- Individual page entry --> <!-- Individual page entry -->
<div <div
class="mb-6 first:mb-0 pl-4 border-l-4 border-slate-300 page-entry" class="mb-4 first:mb-0 pl-2 3xl:pl-4 border-l-4 border-slate-300 page-entry"
data-page-container="{{ $page }}"> data-page-container="{{ $page }}">
<div class="flex items-center justify-between gap-2 mb-2"> <div class="flex items-center justify-between gap-2 mb-2">
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
@@ -46,13 +46,16 @@
{{ if $pageItems }} {{ if $pageItems }}
{{ range $individualPiece := $pageItems }} {{ range $individualPiece := $pageItems }}
<div <div
class="inhalts-entry py-1 px-0 bg-slate-50 rounded hover:bg-slate-100 transition-colors duration-200 {{ if $individualPiece.PieceByIssue.IsContinuation }} class="inhalts-entry py-1 px-0 rounded {{ if $individualPiece.PieceByIssue.IsContinuation }}
continuation-entry continuation-entry
{{ end }}" {{ end }}"
data-page="{{ $page }}" data-page="{{ $page }}"
{{ if $individualPiece.PieceByIssue.IsContinuation }} {{ if $individualPiece.PieceByIssue.IsContinuation }}
data-is-continuation="true" data-is-continuation="true"
{{ end }} {{ end }}
{{ if $individualPiece.PieceByIssue.ID }}
data-multipart-id="{{ $individualPiece.PieceByIssue.ID }}"
{{ end }}
style="{{ if $individualPiece.PieceByIssue.IsContinuation }} style="{{ if $individualPiece.PieceByIssue.IsContinuation }}
display: none; display: none;
{{ end }}"> {{ end }}">
@@ -61,7 +64,7 @@
<!-- Links zu anderen Teilen: --> <!-- Links zu anderen Teilen: -->
{{ if and (not $individualPiece.PieceByIssue.IsContinuation) (gt (len $individualPiece.IssueRefs) 1) }} {{ if and (not $individualPiece.PieceByIssue.IsContinuation) (gt (len $individualPiece.IssueRefs) 1) }}
<div class="mt-1 pt-1 border-t border-slate-100"> <div class="multipart-parts mt-1 pt-1 border-t border-slate-100">
<div class="flex items-center flex-wrap gap-1"> <div class="flex items-center flex-wrap gap-1">
<i class="ri-links-line text-slate-600 text-sm mr-1"></i> <i class="ri-links-line text-slate-600 text-sm mr-1"></i>
{{ range $index, $issue := $individualPiece.IssueRefs }} {{ range $index, $issue := $individualPiece.IssueRefs }}
@@ -147,7 +150,7 @@
<!-- Individual beilage page entry --> <!-- Individual beilage page entry -->
<div <div
class="mb-6 first:mb-0 pl-4 border-l-4 border-amber-400 page-entry" class="mb-4 first:mb-0 pl-2 3xl:pl-4 border-l-4 border-amber-400 page-entry"
data-page-container="{{ $page }}" data-page-container="{{ $page }}"
data-beilage="true"> data-beilage="true">
<div class="flex items-center justify-between gap-2 mb-2"> <div class="flex items-center justify-between gap-2 mb-2">
@@ -188,6 +191,9 @@
{{ if $individualPiece.PieceByIssue.IsContinuation }} {{ if $individualPiece.PieceByIssue.IsContinuation }}
data-is-continuation="true" data-is-continuation="true"
{{ end }} {{ end }}
{{ if $individualPiece.PieceByIssue.ID }}
data-multipart-id="{{ $individualPiece.PieceByIssue.ID }}"
{{ end }}
style="{{ if $individualPiece.PieceByIssue.IsContinuation }} style="{{ if $individualPiece.PieceByIssue.IsContinuation }}
display: none; display: none;
{{ end }}"> {{ end }}">
@@ -196,7 +202,7 @@
<!-- Links zu anderen Teilen: --> <!-- Links zu anderen Teilen: -->
{{ if and (not $individualPiece.PieceByIssue.IsContinuation) (gt (len $individualPiece.IssueRefs) 1) }} {{ if and (not $individualPiece.PieceByIssue.IsContinuation) (gt (len $individualPiece.IssueRefs) 1) }}
<div class="mt-1 pt-1 border-t border-slate-100"> <div class="multipart-parts mt-1 pt-1 border-t border-slate-100">
<div class="flex items-center flex-wrap gap-1"> <div class="flex items-center flex-wrap gap-1">
<i class="ri-links-line text-slate-600 text-sm mr-1"></i> <i class="ri-links-line text-slate-600 text-sm mr-1"></i>
{{ range $index, $issue := $individualPiece.IssueRefs }} {{ range $index, $issue := $individualPiece.IssueRefs }}
@@ -254,4 +260,4 @@
</div> </div>
{{- end -}} {{- end -}}
</div> </inhaltsverzeichnis-scrollspy>

View File

@@ -29,11 +29,11 @@
{{- end -}} {{- end -}}
<div class="columns-2 gap-6"> <div class="columns-2 gap-1 hyphens-auto">
{{- /* Display grouped pieces */ -}} {{- /* Display grouped pieces */ -}}
{{- range $groupKey, $groupedItems := $groupedPieces -}} {{- range $groupKey, $groupedItems := $groupedPieces -}}
<div class="break-inside-avoid pl-4"> <div class="break-inside-avoid pl-4">
<div class="pb-1"> <div class="pb-1 indent-4">
{{- /* Use first piece for display text */ -}} {{- /* Use first piece for display text */ -}}
{{ template "_piece_summary" (dict "Piece" (index $groupedItems 0).Item "CurrentActorID" $a.ID) }} {{ template "_piece_summary" (dict "Piece" (index $groupedItems 0).Item "CurrentActorID" $a.ID) }}
@@ -46,7 +46,10 @@
{{- /* Add "Ganzer Beitrag" link if piece spans multiple issues */ -}} {{- /* Add "Ganzer Beitrag" link if piece spans multiple issues */ -}}
{{- $firstGroupItem := index $groupedItems 0 -}} {{- $firstGroupItem := index $groupedItems 0 -}}
{{- if gt (len $firstGroupItem.Item.IssueRefs) 1 -}} {{- if gt (len $firstGroupItem.Item.IssueRefs) 1 -}}
{{ " " }}<div class="inline-flex items-center gap-1 px-2 py-1 bg-blue-50 hover:bg-blue-100 text-blue-700 hover:text-blue-800 border border-blue-200 hover:border-blue-300 rounded text-xs font-medium transition-colors duration-200"> {{ " " }}<div class="inline-flex items-center gap-1 px-2 py-1 bg-blue-50
hover:bg-blue-100 text-blue-700 hover:text-blue-800 border border-blue-200
hover:border-blue-300 rounded text-xs font-medium transition-colors duration-200
indent-0">
<i class="ri-file-copy-2-line text-xs"></i> <i class="ri-file-copy-2-line text-xs"></i>
<a href="{{ GetPieceURL $firstGroupItem.Item.ID }}" class=""> <a href="{{ GetPieceURL $firstGroupItem.Item.ID }}" class="">
Ganzer Beitrag Ganzer Beitrag

View File

@@ -0,0 +1,240 @@
/**
* InhaltsverzeichnisScrollspy Web Component
*
* Manages dynamic show/hide of content in the Inhaltsverzeichnis based on:
* 1. Page container visibility (>40% threshold)
* 2. Single page viewer mode
*
* Features:
* - Short mode: Hides continuation entries and multipart parts
* - Full mode: Shows all content when page is prominently visible
* - Self-contained with proper lifecycle management
* - HTMX-safe cleanup
*/
export class InhaltsverzeichnisScrollspy extends HTMLElement {
constructor() {
super();
this.pageObserver = null;
this.pageContainers = new Map(); // pageNumber -> { container, entries, state }
this.singlePageViewerActive = false;
this.singlePageViewerCurrentPage = null; // Track which page is currently viewed in single page mode
this.boundHandleSinglePageViewer = this.handleSinglePageViewer.bind(this);
}
connectedCallback() {
this.setupScrollspy();
this.setupSinglePageViewerDetection();
}
disconnectedCallback() {
this.cleanup();
}
setupScrollspy() {
// Find all page containers in the newspaper layout
const newspaperPageContainers = document.querySelectorAll('.newspaper-page-container[data-page-container]');
if (newspaperPageContainers.length === 0) {
return; // No page containers found
}
// Map page containers to their corresponding Inhaltsverzeichnis entries
newspaperPageContainers.forEach(container => {
const pageNumber = container.getAttribute('data-page-container');
const isBeilage = container.hasAttribute('data-beilage');
// Find corresponding Inhaltsverzeichnis entries
const entries = this.findInhaltsEntriesForPage(pageNumber, isBeilage);
if (entries.length > 0) {
this.pageContainers.set(pageNumber, {
container,
entries,
state: 'short', // Default state
isBeilage
});
}
});
// Set up intersection observer with 50% threshold
this.pageObserver = new IntersectionObserver((observerEntries) => {
observerEntries.forEach(entry => {
const pageNumber = entry.target.getAttribute('data-page-container');
const pageData = this.pageContainers.get(pageNumber);
if (pageData) {
// Use 50% visibility threshold for full mode
const shouldBeFullMode = entry.isIntersecting && entry.intersectionRatio >= 0.5;
const newState = shouldBeFullMode || this.singlePageViewerActive ? 'full' : 'short';
if (pageData.state !== newState) {
pageData.state = newState;
this.updateEntriesState(pageData);
}
}
});
}, {
threshold: [0, 0.5, 1.0], // Watch for 50% threshold
rootMargin: '0px'
});
// Observe all page containers
this.pageContainers.forEach(({ container }) => {
this.pageObserver.observe(container);
});
// Initialize all entries to short mode
this.pageContainers.forEach(pageData => {
this.updateEntriesState(pageData);
});
}
findInhaltsEntriesForPage(pageNumber, isBeilage = false) {
// Look for page entries in the Inhaltsverzeichnis that match this page
const selector = isBeilage
? `[data-page-container="${pageNumber}"][data-beilage="true"]`
: `[data-page-container="${pageNumber}"]:not([data-beilage])`;
const pageEntryContainer = this.querySelector(selector);
if (!pageEntryContainer) {
return [];
}
// Get all inhalts-entry elements within this page container
return Array.from(pageEntryContainer.querySelectorAll('.inhalts-entry'));
}
updateEntriesState(pageData) {
const { entries, state } = pageData;
if (state === 'full') {
// Page is expanded: show all entries and highlight page elements
entries.forEach(entry => {
entry.style.display = '';
});
this.highlightPageElements(pageData, true);
} else {
// Page is collapsed: hide continuation entries and remove highlighting
entries.forEach(entry => {
const isContinuation = entry.hasAttribute('data-is-continuation');
entry.style.display = isContinuation ? 'none' : '';
});
this.highlightPageElements(pageData, false);
}
}
highlightPageElements(pageData, highlight) {
const pageNumber = pageData.container.getAttribute('data-page-container');
// 1. Highlight in Inhaltsverzeichnis (page number + icon + border)
const pageLink = this.querySelector(`[data-page-number="${pageNumber}"]`);
const iconContainer = pageLink?.closest('.page-entry')?.querySelector('.icon-container');
const pageEntryContainer = pageLink?.closest('.page-entry');
// Keep page number and icons unchanged in Inhaltsverzeichnis
if (pageEntryContainer) {
if (highlight) {
pageEntryContainer.classList.add('!border-l-red-500');
pageEntryContainer.classList.remove('border-slate-300');
} else {
pageEntryContainer.classList.remove('!border-l-red-500');
pageEntryContainer.classList.add('border-slate-300');
}
}
// 2. Highlight in layout view (page indicator above image)
const layoutPageIndicator = document.querySelector(`[data-page="${pageNumber}"].page-indicator`);
if (layoutPageIndicator) {
// Only highlight primary (non-greyed) icons in layout view too
const layoutPrimaryIcons = layoutPageIndicator.querySelectorAll('i:not(.text-slate-400)');
if (highlight) {
layoutPageIndicator.classList.add('!bg-red-50', '!text-red-600');
layoutPrimaryIcons.forEach(icon => icon.classList.add('!text-red-600'));
} else {
layoutPageIndicator.classList.remove('!bg-red-50', '!text-red-600');
layoutPrimaryIcons.forEach(icon => icon.classList.remove('!text-red-600'));
}
}
}
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);
// Check initial state
this.checkSinglePageViewerState();
}
handleSinglePageViewer(event) {
const wasActive = this.singlePageViewerActive;
this.singlePageViewerActive = event.type === 'singlepageviewer:opened' ||
(event.type === 'singlepageviewer:pagechanged' && this.singlePageViewerActive);
// Track which page is currently being viewed in single page mode
if ((this.singlePageViewerActive || event.type === 'singlepageviewer:pagechanged') && event.detail?.pageNumber) {
this.singlePageViewerCurrentPage = event.detail.pageNumber.toString();
} else if (event.type === 'singlepageviewer:closed') {
this.singlePageViewerCurrentPage = null;
this.singlePageViewerActive = false;
}
// Re-evaluate all page states
this.pageContainers.forEach(pageData => {
const pageNumber = pageData.container.getAttribute('data-page-container');
let newState;
if (this.singlePageViewerActive) {
// In single page viewer: only expand and highlight the current page, collapse all others
newState = pageNumber === this.singlePageViewerCurrentPage ? 'full' : 'short';
} else {
// Normal mode: based on scroll position
newState = this.isPageContainerVisible(pageData.container) ? 'full' : 'short';
}
if (pageData.state !== newState) {
pageData.state = newState;
this.updateEntriesState(pageData);
}
});
}
checkSinglePageViewerState() {
// Check if single page viewer is currently active
const viewer = document.querySelector('single-page-viewer[active]');
this.singlePageViewerActive = viewer !== null;
}
isPageContainerVisible(container) {
const rect = container.getBoundingClientRect();
const viewportHeight = window.innerHeight;
const visibleTop = Math.max(rect.top, 0);
const visibleBottom = Math.min(rect.bottom, viewportHeight);
const visibleHeight = Math.max(0, visibleBottom - visibleTop);
const containerHeight = rect.height;
return (visibleHeight / containerHeight) >= 0.5;
}
cleanup() {
if (this.pageObserver) {
this.pageObserver.disconnect();
this.pageObserver = null;
}
document.removeEventListener('singlepageviewer:opened', this.boundHandleSinglePageViewer);
document.removeEventListener('singlepageviewer:closed', this.boundHandleSinglePageViewer);
document.removeEventListener('singlepageviewer:pagechanged', this.boundHandleSinglePageViewer);
this.pageContainers.clear();
}
}
// Register the custom element
customElements.define('inhaltsverzeichnis-scrollspy', InhaltsverzeichnisScrollspy);

View File

@@ -2,6 +2,7 @@ import "./site.css";
import "./akteure.js"; import "./akteure.js";
import { SinglePageViewer } from "./single-page-viewer.js"; import { SinglePageViewer } from "./single-page-viewer.js";
import { ScrollToTopButton } from "./scroll-to-top.js"; import { ScrollToTopButton } from "./scroll-to-top.js";
import { InhaltsverzeichnisScrollspy } from "./inhaltsverzeichnis-scrollspy.js";
import { import {
enlargePage, enlargePage,
closeModal, closeModal,

View File

@@ -242,6 +242,7 @@ export class SinglePageViewer extends HTMLElement {
this.updateNavigationButtons(); this.updateNavigationButtons();
this.style.display = "block"; this.style.display = "block";
this.setAttribute("active", "true");
// 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");
@@ -251,13 +252,24 @@ export class SinglePageViewer extends HTMLElement {
// Prevent background scrolling but allow scrolling within the viewer // Prevent background scrolling but allow scrolling within the viewer
document.body.style.overflow = "hidden"; document.body.style.overflow = "hidden";
// Dispatch event for scrollspy
document.dispatchEvent(new CustomEvent('singlepageviewer:opened', {
detail: { pageNumber: this.currentPageNumber, isBeilage: this.currentIsBeilage }
}));
} }
close() { close() {
this.style.display = "none"; this.style.display = "none";
this.removeAttribute("active");
// Restore background scrolling // Restore background scrolling
document.body.style.overflow = ""; document.body.style.overflow = "";
// Dispatch event for scrollspy
document.dispatchEvent(new CustomEvent('singlepageviewer:closed', {
detail: { pageNumber: this.currentPageNumber, isBeilage: this.currentIsBeilage }
}));
} }
disconnectedCallback() { disconnectedCallback() {
@@ -517,6 +529,11 @@ export class SinglePageViewer extends HTMLElement {
extractedIconType, extractedIconType,
extractedHeading, extractedHeading,
); );
// Dispatch event for scrollspy to update highlighting
document.dispatchEvent(new CustomEvent('singlepageviewer:pagechanged', {
detail: { pageNumber: this.currentPageNumber, isBeilage: this.currentIsBeilage }
}));
} }
} }
} }

View File

@@ -345,4 +345,20 @@ body.page-edition::before {
.scrollspy-hover:hover:not(.font-medium) { .scrollspy-hover:hover:not(.font-medium) {
background-color: rgb(254 242 242); /* red-50 */ background-color: rgb(254 242 242); /* red-50 */
} }
/* =============================
INHALTSVERZEICHNIS SCROLLSPY STYLES
============================= */
/* Remove default spacing from custom element */
inhaltsverzeichnis-scrollspy {
display: block;
margin: 0;
padding: 0;
}
/* Simple transition for entry visibility */
.inhalts-entry {
transition: opacity 0.3s ease;
}
} }