Multi-Issues in Person Lists

This commit is contained in:
Simon Martens
2025-09-21 14:35:53 +02:00
parent f6af0cfa62
commit 3b47f0b1c6
7 changed files with 229 additions and 168 deletions

View File

@@ -1,5 +1,5 @@
const V = "script[xslt-onload]", P = "xslt-template", D = "xslt-transformed", C = /* @__PURE__ */ new Map(); const V = "script[xslt-onload]", P = "xslt-template", D = "xslt-transformed", T = /* @__PURE__ */ new Map();
function T() { function I() {
let o = htmx.findAll(V); let o = htmx.findAll(V);
for (let t of o) for (let t of o)
K(t); K(t);
@@ -7,12 +7,12 @@ function T() {
function K(o) { function K(o) {
if (o.getAttribute(D) === "true" || !o.hasAttribute(P)) if (o.getAttribute(D) === "true" || !o.hasAttribute(P))
return; return;
let t = "#" + o.getAttribute(P), e = C.get(t); let t = "#" + o.getAttribute(P), e = T.get(t);
if (!e) { if (!e) {
let s = htmx.find(t); let a = htmx.find(t);
if (s) { if (a) {
let a = s.innerHTML ? new DOMParser().parseFromString(s.innerHTML, "application/xml") : s.contentDocument; let s = a.innerHTML ? new DOMParser().parseFromString(a.innerHTML, "application/xml") : a.contentDocument;
e = new XSLTProcessor(), e.importStylesheet(a), C.set(t, e); e = new XSLTProcessor(), e.importStylesheet(s), T.set(t, e);
} else } else
throw new Error("Unknown XSLT template: " + t); throw new Error("Unknown XSLT template: " + t);
} }
@@ -31,8 +31,8 @@ function j() {
connectedCallback() { connectedCallback() {
let i = []; let i = [];
this.slots.forEach((r) => { this.slots.forEach((r) => {
let s = r.getAttribute("name"), a = this.querySelector(`[slot="${s}"]`); let a = r.getAttribute("name"), s = this.querySelector(`[slot="${a}"]`);
a && (r.replaceWith(a.cloneNode(!0)), i.push(a)); s && (r.replaceWith(s.cloneNode(!0)), i.push(s));
}), i.forEach((r) => { }), i.forEach((r) => {
r.remove(); r.remove();
}); });
@@ -51,7 +51,7 @@ function W() {
const o = document.querySelectorAll(".newspaper-page-container"); const o = document.querySelectorAll(".newspaper-page-container");
window.highlightObserver = new IntersectionObserver( window.highlightObserver = new IntersectionObserver(
(t) => { (t) => {
E(); A();
}, },
{ {
rootMargin: "-20% 0px -70% 0px" rootMargin: "-20% 0px -70% 0px"
@@ -60,12 +60,12 @@ function W() {
window.highlightObserver.observe(t); window.highlightObserver.observe(t);
}); });
} }
function E() { function A() {
const o = []; const o = [];
document.querySelectorAll(".newspaper-page-container").forEach((e) => { document.querySelectorAll(".newspaper-page-container").forEach((e) => {
const n = e.getBoundingClientRect(), i = window.innerHeight, r = Math.max(n.top, 0), s = Math.min(n.bottom, i), a = Math.max(0, s - r), l = n.height, g = a / l >= 0.5, d = e.querySelector("img[data-page]"), u = d ? d.getAttribute("data-page") : "unknown"; const n = e.getBoundingClientRect(), i = window.innerHeight, r = Math.max(n.top, 0), a = Math.min(n.bottom, i), s = Math.max(0, a - r), l = n.height, d = s / l >= 0.5, g = e.querySelector("img[data-page]"), u = g ? g.getAttribute("data-page") : "unknown";
g && d && u && !o.includes(u) && o.push(u); d && g && u && !o.includes(u) && o.push(u);
}), Z(o), o.length > 0 && L(o); }), Z(o), o.length > 0 && k(o);
} }
function Z(o) { function Z(o) {
document.querySelectorAll(".continuation-entry").forEach((t) => { document.querySelectorAll(".continuation-entry").forEach((t) => {
@@ -98,10 +98,10 @@ function F() {
}), e ? o.style.display = "" : o.style.display = "none"; }), e ? o.style.display = "" : o.style.display = "none";
}); });
} }
function A(o) {
L([o]);
}
function L(o) { function L(o) {
k([o]);
}
function k(o) {
console.log("markCurrentPagesInInhaltsverzeichnis called with:", o), document.querySelectorAll("[data-page-container]").forEach((e) => { console.log("markCurrentPagesInInhaltsverzeichnis called with:", o), document.querySelectorAll("[data-page-container]").forEach((e) => {
e.hasAttribute("data-beilage") ? (e.classList.remove("border-red-500"), e.classList.add("border-amber-400")) : (e.classList.remove("border-red-500"), e.classList.add("border-slate-300")); e.hasAttribute("data-beilage") ? (e.classList.remove("border-red-500"), e.classList.add("border-amber-400")) : (e.classList.remove("border-red-500"), e.classList.add("border-slate-300"));
}), document.querySelectorAll(".page-number-inhalts").forEach((e) => { }), document.querySelectorAll(".page-number-inhalts").forEach((e) => {
@@ -121,10 +121,10 @@ function L(o) {
const i = document.querySelector(`[data-page-container="${e}"]`); const i = document.querySelector(`[data-page-container="${e}"]`);
i && (i.classList.remove("border-slate-300", "border-amber-400"), i.classList.add("border-red-500")); i && (i.classList.remove("border-slate-300", "border-amber-400"), i.classList.add("border-red-500"));
const r = n.closest(".page-entry"); const r = n.closest(".page-entry");
r && (r.querySelectorAll(".inhalts-entry").forEach((a) => { r && (r.querySelectorAll(".inhalts-entry").forEach((s) => {
a.classList.remove("hover:bg-slate-100"), a.style.cursor = "default"; s.classList.remove("hover:bg-slate-100"), s.style.cursor = "default";
}), r.querySelectorAll('a[href*="/"]').forEach((a) => { }), r.querySelectorAll('a[href*="/"]').forEach((s) => {
a.getAttribute("aria-current") === "page" && (a.style.textDecoration = "none", a.style.pointerEvents = "none", a.classList.add("no-underline"), a.classList.remove("hover:bg-blue-100")); s.getAttribute("aria-current") === "page" && (s.style.textDecoration = "none", s.style.pointerEvents = "none", s.classList.add("no-underline"), s.classList.remove("hover:bg-blue-100"));
})); }));
} }
}), t.length > 0 && X(t[0]), document.querySelectorAll(".page-indicator").forEach((e) => { }), t.length > 0 && X(t[0]), document.querySelectorAll(".page-indicator").forEach((e) => {
@@ -147,14 +147,14 @@ function X(o) {
function U(o, t, e, n = null) { function U(o, t, e, n = null) {
let i = document.querySelector("single-page-viewer"); let i = document.querySelector("single-page-viewer");
i || (i = document.createElement("single-page-viewer"), document.body.appendChild(i)); i || (i = document.createElement("single-page-viewer"), document.body.appendChild(i));
const r = o.closest('[data-beilage="true"]') !== null, s = window.templateData && window.templateData.targetPage ? window.templateData.targetPage : 0; const r = o.closest('[data-beilage="true"]') !== null, a = window.templateData && window.templateData.targetPage ? window.templateData.targetPage : 0;
i.show(o.src, o.alt, t, r, s, n); i.show(o.src, o.alt, t, r, a, n);
} }
function k() { function q() {
document.getElementById("pageModal").classList.add("hidden"); document.getElementById("pageModal").classList.add("hidden");
} }
function G() { function G() {
if (window.pageObserver && (window.pageObserver.disconnect(), window.pageObserver = null), window.currentPageContainers = Array.from(document.querySelectorAll(".newspaper-page-container")), window.currentActiveIndex = 0, f(), 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, m(), document.querySelector(".newspaper-page-container")) {
let t = /* @__PURE__ */ new Set(); let t = /* @__PURE__ */ new Set();
window.pageObserver = new IntersectionObserver( window.pageObserver = new IntersectionObserver(
(e) => { (e) => {
@@ -162,8 +162,8 @@ function G() {
const i = window.currentPageContainers.indexOf(n.target); const i = window.currentPageContainers.indexOf(n.target);
i !== -1 && (n.isIntersecting ? t.add(i) : t.delete(i)); i !== -1 && (n.isIntersecting ? t.add(i) : t.delete(i));
}), t.size > 0) { }), t.size > 0) {
const i = Array.from(t).sort((r, s) => r - s)[0]; const i = Array.from(t).sort((r, a) => r - a)[0];
i !== window.currentActiveIndex && (window.currentActiveIndex = i, f()); i !== window.currentActiveIndex && (window.currentActiveIndex = i, m());
} }
}, },
{ {
@@ -179,8 +179,8 @@ function Y() {
let o = -1; let o = -1;
const t = []; const t = [];
window.currentPageContainers.forEach((n, i) => { window.currentPageContainers.forEach((n, i) => {
const r = n.getBoundingClientRect(), s = window.innerHeight, a = Math.max(r.top, 0), l = Math.min(r.bottom, s), c = Math.max(0, l - a), g = r.height; const r = n.getBoundingClientRect(), a = window.innerHeight, s = Math.max(r.top, 0), l = Math.min(r.bottom, a), c = Math.max(0, l - s), d = r.height;
c / g >= 0.3 && t.push(i); c / d >= 0.3 && t.push(i);
}); });
const e = Math.min(...t); const e = Math.min(...t);
for (let n = e - 1; n >= 0; n--) for (let n = e - 1; n >= 0; n--)
@@ -192,7 +192,7 @@ function Y() {
behavior: "smooth", behavior: "smooth",
block: "start" block: "start"
}), setTimeout(() => { }), setTimeout(() => {
f(); m();
}, 100)); }, 100));
} }
} }
@@ -201,8 +201,8 @@ function J() {
let o = -1; let o = -1;
const t = []; const t = [];
window.currentPageContainers.forEach((n, i) => { window.currentPageContainers.forEach((n, i) => {
const r = n.getBoundingClientRect(), s = window.innerHeight, a = Math.max(r.top, 0), l = Math.min(r.bottom, s), c = Math.max(0, l - a), g = r.height; const r = n.getBoundingClientRect(), a = window.innerHeight, s = Math.max(r.top, 0), l = Math.min(r.bottom, a), c = Math.max(0, l - s), d = r.height;
c / g >= 0.3 && t.push(i); c / d >= 0.3 && t.push(i);
}); });
const e = Math.max(...t); const e = Math.max(...t);
for (let n = e + 1; n < window.currentPageContainers.length; n++) for (let n = e + 1; n < window.currentPageContainers.length; n++)
@@ -214,12 +214,12 @@ function J() {
behavior: "smooth", behavior: "smooth",
block: "start" block: "start"
}), setTimeout(() => { }), setTimeout(() => {
f(); m();
}, 100)); }, 100));
} }
} }
function Q() { function Q() {
if (q()) { if (B()) {
const t = document.querySelector("#newspaper-content .newspaper-page-container"); const t = document.querySelector("#newspaper-content .newspaper-page-container");
t && t.scrollIntoView({ t && t.scrollIntoView({
behavior: "smooth", behavior: "smooth",
@@ -233,11 +233,11 @@ function Q() {
}); });
} }
} }
function q() { function B() {
const o = []; const o = [];
window.currentPageContainers.forEach((t, e) => { window.currentPageContainers.forEach((t, e) => {
const n = t.getBoundingClientRect(), i = window.innerHeight, r = Math.max(n.top, 0), s = Math.min(n.bottom, i), a = Math.max(0, s - r), l = n.height; const n = t.getBoundingClientRect(), i = window.innerHeight, r = Math.max(n.top, 0), a = Math.min(n.bottom, i), s = Math.max(0, a - r), l = n.height;
a / l >= 0.3 && o.push(e); s / l >= 0.3 && o.push(e);
}); });
for (const t of o) { for (const t of o) {
const e = window.currentPageContainers[t]; const e = window.currentPageContainers[t];
@@ -246,10 +246,10 @@ function q() {
} }
return !1; return !1;
} }
function f() { function m() {
const o = document.getElementById("prevPageBtn"), t = document.getElementById("nextPageBtn"), e = document.getElementById("beilageBtn"); const o = document.getElementById("prevPageBtn"), t = document.getElementById("nextPageBtn"), e = document.getElementById("beilageBtn");
if (o && (window.currentActiveIndex <= 0 ? o.style.display = "none" : o.style.display = "flex"), t && (window.currentActiveIndex >= window.currentPageContainers.length - 1 ? t.style.display = "none" : t.style.display = "flex"), e) { if (o && (window.currentActiveIndex <= 0 ? o.style.display = "none" : o.style.display = "flex"), t && (window.currentActiveIndex >= window.currentPageContainers.length - 1 ? t.style.display = "none" : t.style.display = "flex"), e) {
const n = q(), i = e.querySelector("i"); const n = B(), i = e.querySelector("i");
n ? (e.title = "Zur Hauptausgabe", e.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", i && (i.className = "ri-file-text-line text-lg lg:text-xl")) : (e.title = "Zu Beilage", e.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", i && (i.className = "ri-attachment-line text-lg lg:text-xl")); n ? (e.title = "Zur Hauptausgabe", e.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", i && (i.className = "ri-file-text-line text-lg lg:text-xl")) : (e.title = "Zu Beilage", e.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", i && (i.className = "ri-attachment-line text-lg lg:text-xl"));
} }
} }
@@ -265,24 +265,24 @@ function ee() {
title: document.title, title: document.title,
url: e url: e
}).catch((n) => { }).catch((n) => {
I(e, o); E(e, o);
}) : I(e, o); }) : E(e, o);
} }
function I(o, t) { function E(o, t) {
if (navigator.clipboard) if (navigator.clipboard)
navigator.clipboard.writeText(o).then(() => { navigator.clipboard.writeText(o).then(() => {
h(t, "Link kopiert!"); p(t, "Link kopiert!");
}).catch((e) => { }).catch((e) => {
h(t, "Kopieren fehlgeschlagen"); p(t, "Kopieren fehlgeschlagen");
}); });
else { else {
const e = document.createElement("textarea"); const e = document.createElement("textarea");
e.value = o, document.body.appendChild(e), e.select(); e.value = o, document.body.appendChild(e), e.select();
try { try {
const n = document.execCommand("copy"); const n = document.execCommand("copy");
h(t, n ? "Link kopiert!" : "Kopieren fehlgeschlagen"); p(t, n ? "Link kopiert!" : "Kopieren fehlgeschlagen");
} catch { } catch {
h(t, "Kopieren fehlgeschlagen"); p(t, "Kopieren fehlgeschlagen");
} finally { } finally {
document.body.removeChild(e); document.body.removeChild(e);
} }
@@ -295,24 +295,24 @@ function te() {
const n = (/* @__PURE__ */ new Date()).toLocaleDateString("de-DE"), i = `Königsberger Gelehrte und Politische Zeitung (KGPZ). ${t}. Digital verfügbar unter: ${e} (Zugriff: ${n}).`; const n = (/* @__PURE__ */ new Date()).toLocaleDateString("de-DE"), i = `Königsberger Gelehrte und Politische Zeitung (KGPZ). ${t}. Digital verfügbar unter: ${e} (Zugriff: ${n}).`;
if (navigator.clipboard) if (navigator.clipboard)
navigator.clipboard.writeText(i).then(() => { navigator.clipboard.writeText(i).then(() => {
h(o, "Zitation kopiert!"); p(o, "Zitation kopiert!");
}).catch((r) => { }).catch((r) => {
h(o, "Kopieren fehlgeschlagen"); p(o, "Kopieren fehlgeschlagen");
}); });
else { else {
const r = document.createElement("textarea"); const r = document.createElement("textarea");
r.value = i, document.body.appendChild(r), r.select(); r.value = i, document.body.appendChild(r), r.select();
try { try {
const s = document.execCommand("copy"); const a = document.execCommand("copy");
h(o, s ? "Zitation kopiert!" : "Kopieren fehlgeschlagen"); p(o, a ? "Zitation kopiert!" : "Kopieren fehlgeschlagen");
} catch { } catch {
h(o, "Kopieren fehlgeschlagen"); p(o, "Kopieren fehlgeschlagen");
} finally { } finally {
document.body.removeChild(r); document.body.removeChild(r);
} }
} }
} }
function h(o, t) { function p(o, t) {
const e = document.querySelector(".simple-popup"); const e = document.querySelector(".simple-popup");
e && e.remove(); e && e.remove();
const n = document.createElement("div"); const n = document.createElement("div");
@@ -330,10 +330,10 @@ function h(o, t) {
transition: opacity 0.2s ease; transition: opacity 0.2s ease;
white-space: nowrap; white-space: nowrap;
`; `;
const i = o.getBoundingClientRect(), r = window.innerHeight, s = window.innerWidth; const i = o.getBoundingClientRect(), r = window.innerHeight, a = window.innerWidth;
let a = i.left - 10, l = i.bottom + 8; let s = i.left - 10, l = i.bottom + 8;
const c = 120, g = 32; const c = 120, d = 32;
a + c > s && (a = i.right - c + 10), l + g > r && (l = i.top - g - 8), n.style.left = Math.max(5, a) + "px", n.style.top = Math.max(5, l) + "px", document.body.appendChild(n), setTimeout(() => { s + c > a && (s = i.right - c + 10), l + d > r && (l = i.top - d - 8), n.style.left = Math.max(5, s) + "px", n.style.top = Math.max(5, l) + "px", document.body.appendChild(n), setTimeout(() => {
n.style.opacity = "1"; n.style.opacity = "1";
}, 10), setTimeout(() => { }, 10), setTimeout(() => {
n.style.opacity = "0", setTimeout(() => { n.style.opacity = "0", setTimeout(() => {
@@ -361,42 +361,42 @@ function ne() {
t.scrollIntoView({ t.scrollIntoView({
behavior: "smooth", behavior: "smooth",
block: "start" block: "start"
}), A(o); }), L(o);
}, 300); }, 300);
} }
function y(o, t, e = !1) { function v(o, t, e = !1) {
let n = ""; let n = "";
if (e) if (e)
n = window.location.origin + window.location.pathname + `#beilage-1-page-${o}`; n = window.location.origin + window.location.pathname + `#beilage-1-page-${o}`;
else { else {
const r = window.location.pathname.split("/"); const r = window.location.pathname.split("/");
if (r.length >= 3) { if (r.length >= 3) {
const s = r[1], a = r[2]; const a = r[1], s = r[2];
n = `${window.location.origin}/${s}/${a}/${o}`; n = `${window.location.origin}/${a}/${s}/${o}`;
} else } else
n = window.location.origin + window.location.pathname + `/${o}`; n = window.location.origin + window.location.pathname + `/${o}`;
} }
const i = n; const i = n;
if (navigator.clipboard) if (navigator.clipboard)
navigator.clipboard.writeText(i).then(() => { navigator.clipboard.writeText(i).then(() => {
h(t, "Link kopiert!"); p(t, "Link kopiert!");
}).catch((r) => { }).catch((r) => {
h(t, "Kopieren fehlgeschlagen"); p(t, "Kopieren fehlgeschlagen");
}); });
else { else {
const r = document.createElement("textarea"); const r = document.createElement("textarea");
r.value = i, document.body.appendChild(r), r.select(); r.value = i, document.body.appendChild(r), r.select();
try { try {
const s = document.execCommand("copy"); const a = document.execCommand("copy");
h(t, s ? "Link kopiert!" : "Kopieren fehlgeschlagen"); p(t, a ? "Link kopiert!" : "Kopieren fehlgeschlagen");
} catch { } catch {
h(t, "Kopieren fehlgeschlagen"); p(t, "Kopieren fehlgeschlagen");
} finally { } finally {
document.body.removeChild(r); document.body.removeChild(r);
} }
} }
} }
function v(o, t) { function x(o, t) {
const e = document.title || "KGPZ", n = window.location.pathname.split("/"); const e = document.title || "KGPZ", n = window.location.pathname.split("/");
let i; let i;
if (n.length >= 3) { if (n.length >= 3) {
@@ -404,27 +404,27 @@ function v(o, t) {
i = `${window.location.origin}/${l}/${c}/${o}`; i = `${window.location.origin}/${l}/${c}/${o}`;
} else } else
i = `${window.location.origin}${window.location.pathname}/${o}`; i = `${window.location.origin}${window.location.pathname}/${o}`;
const r = i, s = (/* @__PURE__ */ new Date()).toLocaleDateString("de-DE"), a = `Königsberger Gelehrte und Politische Zeitung (KGPZ). ${e}, Seite ${o}. Digital verfügbar unter: ${r} (Zugriff: ${s}).`; const r = i, a = (/* @__PURE__ */ new Date()).toLocaleDateString("de-DE"), s = `Königsberger Gelehrte und Politische Zeitung (KGPZ). ${e}, Seite ${o}. Digital verfügbar unter: ${r} (Zugriff: ${a}).`;
if (navigator.clipboard) if (navigator.clipboard)
navigator.clipboard.writeText(a).then(() => { navigator.clipboard.writeText(s).then(() => {
h(t, "Zitation kopiert!"); p(t, "Zitation kopiert!");
}).catch((l) => { }).catch((l) => {
h(t, "Kopieren fehlgeschlagen"); p(t, "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 = s, document.body.appendChild(l), l.select();
try { try {
const c = document.execCommand("copy"); const c = document.execCommand("copy");
h(t, c ? "Zitation kopiert!" : "Kopieren fehlgeschlagen"); p(t, c ? "Zitation kopiert!" : "Kopieren fehlgeschlagen");
} catch { } catch {
h(t, "Kopieren fehlgeschlagen"); p(t, "Kopieren fehlgeschlagen");
} finally { } finally {
document.body.removeChild(l); document.body.removeChild(l);
} }
} }
} }
function b() { function w() {
H(); H();
const o = document.querySelectorAll(".author-section"), t = document.querySelectorAll(".scrollspy-link"); const o = document.querySelectorAll(".author-section"), t = document.querySelectorAll(".scrollspy-link");
if (o.length === 0 || t.length === 0) if (o.length === 0 || t.length === 0)
@@ -432,47 +432,57 @@ function b() {
function e() { function e() {
const i = []; const i = [];
o.forEach((s) => { o.forEach((s) => {
const a = s.getAttribute("id"), l = s.querySelector(".akteur-werke-section"), c = s.querySelector(".akteur-beitraege-section"); const l = s.getAttribute("id"), c = s.querySelector(".akteur-werke-section"), d = s.querySelector(".akteur-beitraege-section");
let g = !1; let g = !1;
if (l) { if (c) {
const d = l.getBoundingClientRect(), u = d.top < window.innerHeight, p = d.bottom > 0; const u = c.getBoundingClientRect(), h = u.top < window.innerHeight, f = u.bottom > 0;
u && p && (g = !0); h && f && (g = !0);
} }
if (c && !g) { if (d && !g) {
const d = c.getBoundingClientRect(), u = d.top < window.innerHeight, p = d.bottom > 0; const u = d.getBoundingClientRect(), h = u.top < window.innerHeight, f = u.bottom > 0;
u && p && (g = !0); h && f && (g = !0);
} }
if (!l && !c) { if (!c && !d) {
const d = s.querySelector("div:first-child"); const u = s.querySelector("div:first-child");
if (d) { if (u) {
const u = d.getBoundingClientRect(), p = u.top >= 0, m = u.bottom <= window.innerHeight; const h = u.getBoundingClientRect(), f = h.top >= 0, b = h.bottom <= window.innerHeight;
p && m && (g = !0); f && b && (g = !0);
} }
} }
g && i.push(a); g && i.push(l);
}); });
const r = []; const r = [], a = document.getElementById("scrollspy-slider");
t.forEach((s) => { if (t.forEach((s) => {
s.classList.remove("font-medium", "bg-red-100"), s.classList.add("text-gray-700", "bg-white"); s.classList.remove("font-medium");
const a = s.getAttribute("data-target"); const l = s.getAttribute("data-target");
i.includes(a) && (s.classList.remove("text-gray-700", "bg-white"), s.classList.add("font-medium", "bg-red-100"), r.push(s)); i.includes(l) && (s.classList.add("font-medium"), r.push(s));
}), r.length > 0 && n(r); }), r.length > 0 && a) {
const s = document.getElementById("scrollspy-nav"), l = s.getBoundingClientRect();
let c = 1 / 0, d = -1 / 0;
r.forEach((u) => {
const h = u.getBoundingClientRect(), f = h.top - l.top + s.scrollTop, b = f + h.height;
c = Math.min(c, f), d = Math.max(d, b);
});
let g = d - c;
a.style.top = `${c}px`, a.style.height = `${g}px`, a.style.opacity = "1";
} else a && (a.style.opacity = "0");
r.length > 0 && n(r);
} }
function n(i) { function n(i) {
if (window.scrollspyManualNavigation) return; if (window.scrollspyManualNavigation) return;
const r = document.getElementById("scrollspy-nav"); const r = document.getElementById("scrollspy-nav");
if (!r) return; if (!r) return;
const s = i[0], a = Math.max( const a = i[0], s = Math.max(
document.body.scrollHeight, document.body.scrollHeight,
document.body.offsetHeight, document.body.offsetHeight,
document.documentElement.clientHeight, document.documentElement.clientHeight,
document.documentElement.scrollHeight, document.documentElement.scrollHeight,
document.documentElement.offsetHeight document.documentElement.offsetHeight
), l = window.innerHeight, c = a - l, g = c > 0 ? window.scrollY / c : 0, d = r.clientHeight, p = r.scrollHeight - d; ), l = window.innerHeight, c = s - l, d = c > 0 ? window.scrollY / c : 0, g = r.clientHeight, h = r.scrollHeight - g;
if (p > 0) { if (h > 0) {
const m = g * p, B = s.getBoundingClientRect(), $ = r.getBoundingClientRect(), M = B.top - $.top + r.scrollTop, N = d / 2, R = M - N, x = 0.7, O = x * m + (1 - x) * R, S = Math.max(0, Math.min(p, O)), z = r.scrollTop; const f = d * h, b = a.getBoundingClientRect(), $ = r.getBoundingClientRect(), M = b.top - $.top + r.scrollTop, R = g / 2, N = M - R, S = 0.7, O = S * f + (1 - S) * N, C = Math.max(0, Math.min(h, O)), z = r.scrollTop;
Math.abs(S - z) > 10 && r.scrollTo({ Math.abs(C - z) > 10 && r.scrollTo({
top: S, top: C,
behavior: "smooth" behavior: "smooth"
}); });
} }
@@ -480,10 +490,10 @@ function b() {
window.scrollspyScrollHandler = function() { window.scrollspyScrollHandler = function() {
clearTimeout(window.scrollspyTimeout), window.scrollspyTimeout = setTimeout(e, 50); clearTimeout(window.scrollspyTimeout), window.scrollspyTimeout = setTimeout(e, 50);
}, window.addEventListener("scroll", window.scrollspyScrollHandler), window.scrollspyClickHandlers = [], t.forEach((i) => { }, window.addEventListener("scroll", window.scrollspyScrollHandler), window.scrollspyClickHandlers = [], t.forEach((i) => {
const r = function(s) { const r = function(a) {
s.preventDefault(); a.preventDefault();
const a = document.getElementById(this.getAttribute("data-target")); const s = document.getElementById(this.getAttribute("data-target"));
a && (window.scrollspyManualNavigation = !0, a.scrollIntoView({ s && (window.scrollspyManualNavigation = !0, s.scrollIntoView({
behavior: "smooth", behavior: "smooth",
block: "start" block: "start"
}), setTimeout(() => { }), setTimeout(() => {
@@ -494,42 +504,44 @@ function b() {
}), e(); }), e();
} }
function H() { function H() {
window.scrollspyScrollHandler && (window.removeEventListener("scroll", window.scrollspyScrollHandler), window.scrollspyScrollHandler = null), window.scrollspyTimeout && (clearTimeout(window.scrollspyTimeout), window.scrollspyTimeout = null), window.scrollspyClickHandlers && (window.scrollspyClickHandlers.forEach(({ link: o, handler: t }) => { window.scrollspyScrollHandler && (window.removeEventListener("scroll", window.scrollspyScrollHandler), window.scrollspyScrollHandler = null), window.scrollspyTimeout && (clearTimeout(window.scrollspyTimeout), window.scrollspyTimeout = null), window.scrollspyClickHandlers && (window.scrollspyClickHandlers.forEach(({ link: t, handler: e }) => {
o.removeEventListener("click", t); t.removeEventListener("click", e);
}), window.scrollspyClickHandlers = null), window.scrollspyManualNavigation = !1; }), window.scrollspyClickHandlers = null);
const o = document.getElementById("scrollspy-slider");
o && (o.style.opacity = "0", o.style.height = "0"), window.scrollspyManualNavigation = !1;
} }
function w() { function y() {
W(), G(), window.addEventListener("scroll", function() { W(), G(), window.addEventListener("scroll", function() {
clearTimeout(window.scrollTimeout), window.scrollTimeout = setTimeout(() => { clearTimeout(window.scrollTimeout), window.scrollTimeout = setTimeout(() => {
E(), f(); A(), m();
}, 50); }, 50);
}), ne(), document.addEventListener("keydown", function(o) { }), ne(), document.addEventListener("keydown", function(o) {
o.key === "Escape" && k(); o.key === "Escape" && q();
}); });
} }
window.enlargePage = U; window.enlargePage = U;
window.closeModal = k; window.closeModal = q;
window.scrollToPreviousPage = Y; window.scrollToPreviousPage = Y;
window.scrollToNextPage = J; window.scrollToNextPage = J;
window.scrollToBeilage = Q; window.scrollToBeilage = Q;
window.shareCurrentPage = ee; window.shareCurrentPage = ee;
window.generateCitation = te; window.generateCitation = te;
window.copyPagePermalink = y; window.copyPagePermalink = v;
window.generatePageCitation = v; window.generatePageCitation = x;
function re() { function re() {
T(), j(), document.querySelector(".newspaper-page-container") && w(), document.querySelector(".author-section") && b(), htmx.on("htmx:load", function(o) { I(), j(), document.querySelector(".newspaper-page-container") && y(), document.querySelector(".author-section") && w(), htmx.on("htmx:load", function(o) {
T(); I();
}), document.body.addEventListener("htmx:afterSwap", function(o) { }), document.body.addEventListener("htmx:afterSwap", function(o) {
setTimeout(() => { setTimeout(() => {
document.querySelector(".newspaper-page-container") && w(), document.querySelector(".author-section") && b(); document.querySelector(".newspaper-page-container") && y(), document.querySelector(".author-section") && w();
}, 100); }, 100);
}), document.body.addEventListener("htmx:afterSettle", function(o) { }), document.body.addEventListener("htmx:afterSettle", function(o) {
setTimeout(() => { setTimeout(() => {
document.querySelector(".newspaper-page-container") && w(), document.querySelector(".author-section") && b(); document.querySelector(".newspaper-page-container") && y(), document.querySelector(".author-section") && w();
}, 200); }, 200);
}), document.body.addEventListener("htmx:load", function(o) { }), document.body.addEventListener("htmx:load", function(o) {
setTimeout(() => { setTimeout(() => {
document.querySelector(".newspaper-page-container") && w(), document.querySelector(".author-section") && b(); document.querySelector(".newspaper-page-container") && y(), document.querySelector(".author-section") && w();
}, 100); }, 100);
}); });
} }
@@ -658,24 +670,24 @@ class oe extends HTMLElement {
t.style.width = e, console.log("Updated sidebar width to:", e); t.style.width = e, console.log("Updated sidebar width to:", e);
} }
} }
show(t, e, n, i = !1, r = 0, s = null) { show(t, e, n, i = !1, r = 0, a = null) {
const a = this.querySelector("#single-page-image"), l = this.querySelector("#page-number"), c = this.querySelector("#page-icon"); const s = this.querySelector("#single-page-image"), l = this.querySelector("#page-number"), c = this.querySelector("#page-icon");
this.querySelector("#page-indicator"), a.src = t, a.alt = e, this.currentPageNumber = n, this.currentIsBeilage = i, this.currentPartNumber = s; this.querySelector("#page-indicator"), s.src = t, s.alt = e, this.currentPageNumber = n, this.currentIsBeilage = i, this.currentPartNumber = a;
const g = this.getIssueContext(n); const d = this.getIssueContext(n);
if (l.innerHTML = g ? `${g}, ${n}` : `${n}`, r && n === r) { if (l.innerHTML = d ? `${d}, ${n}` : `${n}`, r && n === r) {
l.style.position = "relative"; l.style.position = "relative";
const d = l.querySelector(".target-page-dot"); const g = l.querySelector(".target-page-dot");
d && d.remove(); g && g.remove();
const u = document.createElement("span"); const u = document.createElement("span");
u.className = "target-page-dot absolute -top-1 -right-1 w-3 h-3 bg-red-500 rounded-full z-10", u.title = "verlinkte Seite", l.appendChild(u); u.className = "target-page-dot absolute -top-1 -right-1 w-3 h-3 bg-red-500 rounded-full z-10", u.title = "verlinkte Seite", l.appendChild(u);
} }
if (s !== null) if (a !== null)
c.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>`; c.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">${a}. Teil</span>`;
else { else {
const d = this.determinePageIconType(n, i); const g = this.determinePageIconType(n, i);
c.innerHTML = this.getPageIconHTML(d); c.innerHTML = this.getPageIconHTML(g);
} }
this.updateNavigationButtons(), this.style.display = "block", document.body.style.overflow = "hidden", A(n); this.updateNavigationButtons(), this.style.display = "block", document.body.style.overflow = "hidden", L(n);
} }
close() { close() {
this.style.display = "none", document.body.style.overflow = ""; this.style.display = "none", document.body.style.overflow = "";
@@ -692,8 +704,8 @@ class oe extends HTMLElement {
}).filter((l) => l !== null).sort((l, c) => l - c); }).filter((l) => l !== null).sort((l, c) => l - c);
if (r.length === 0) if (r.length === 0)
return "first"; return "first";
const s = r[0], a = r[r.length - 1]; const a = r[0], s = r[r.length - 1];
return t === s ? "first" : t === a ? "last" : t === s + 1 ? "even" : t === a - 1 ? "odd" : t % 2 === 0 ? "even" : "odd"; return t === a ? "first" : t === s ? "last" : t === a + 1 ? "even" : t === s - 1 ? "odd" : t % 2 === 0 ? "even" : "odd";
} }
// Generate page icon HTML based on type (same as Go PageIcon function) // Generate page icon HTML based on type (same as Go PageIcon function)
getPageIconHTML(t) { getPageIconHTML(t) {
@@ -713,16 +725,16 @@ class oe extends HTMLElement {
} }
// Share current page // Share current page
shareCurrentPage() { shareCurrentPage() {
if (typeof y == "function") { if (typeof v == "function") {
const t = this.querySelector("#share-btn"); const t = this.querySelector("#share-btn");
y(this.currentPageNumber, t, this.currentIsBeilage); v(this.currentPageNumber, t, this.currentIsBeilage);
} }
} }
// Generate citation for current page // Generate citation for current page
generatePageCitation() { generatePageCitation() {
if (typeof v == "function") { if (typeof x == "function") {
const t = this.querySelector("#cite-btn"); const t = this.querySelector("#cite-btn");
v(this.currentPageNumber, t); x(this.currentPageNumber, t);
} }
} }
// Update navigation button visibility based on available pages // Update navigation button visibility based on available pages
@@ -753,15 +765,15 @@ class oe extends HTMLElement {
"for", "for",
this.currentIsBeilage ? "beilage" : "main" this.currentIsBeilage ? "beilage" : "main"
); );
const n = e.map((a) => { const n = e.map((s) => {
const l = a.getAttribute("data-page-container"), c = l ? parseInt(l) : null; const l = s.getAttribute("data-page-container"), c = l ? parseInt(l) : null;
return console.log("Container page:", l, "parsed:", c), c; return console.log("Container page:", l, "parsed:", c), c;
}).filter((a) => a !== null).sort((a, l) => a - l); }).filter((s) => s !== null).sort((s, l) => s - l);
console.log("All pages found:", n), console.log("Current page:", this.currentPageNumber); console.log("All pages found:", n), console.log("Current page:", this.currentPageNumber);
const i = n.indexOf(this.currentPageNumber); const i = n.indexOf(this.currentPageNumber);
console.log("Current index:", i); console.log("Current index:", i);
let r = null, s = null; let r = null, a = null;
return i > 0 && (r = n[i - 1]), i < n.length - 1 && (s = n[i + 1]), console.log("Adjacent pages - prev:", r, "next:", s), { prevPage: r, nextPage: s }; return i > 0 && (r = n[i - 1]), i < n.length - 1 && (a = n[i + 1]), console.log("Adjacent pages - prev:", r, "next:", a), { prevPage: r, nextPage: a };
} }
// Navigate to previous page // Navigate to previous page
goToPreviousPage() { goToPreviousPage() {
@@ -810,8 +822,8 @@ class oe extends HTMLElement {
toggleSidebar() { toggleSidebar() {
const t = this.querySelector("#sidebar-spacer"), e = this.querySelector("#sidebar-toggle-btn"), n = e.querySelector("i"), i = t.style.width, r = i === "0px" || i === "0"; const t = this.querySelector("#sidebar-spacer"), e = this.querySelector("#sidebar-toggle-btn"), n = e.querySelector("i"), i = t.style.width, r = i === "0px" || i === "0";
if (console.log("Current state - isCollapsed:", r), console.log("Current width:", i), r) { if (console.log("Current state - isCollapsed:", r), console.log("Current width:", i), r) {
const s = this.detectSidebarWidth(); const a = this.detectSidebarWidth();
t.style.width = s, e.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", n.className = "ri-sidebar-fold-line text-lg font-bold", e.title = "Inhaltsverzeichnis ausblenden", console.log("Expanding sidebar to:", s); t.style.width = a, e.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", n.className = "ri-sidebar-fold-line text-lg font-bold", e.title = "Inhaltsverzeichnis ausblenden", console.log("Expanding sidebar to:", a);
} else } else
t.style.width = "0px", e.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", n.className = "ri-sidebar-unfold-line text-lg font-bold", e.title = "Inhaltsverzeichnis einblenden", console.log("Collapsing sidebar"); t.style.width = "0px", e.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", n.className = "ri-sidebar-unfold-line text-lg font-bold", e.title = "Inhaltsverzeichnis einblenden", console.log("Collapsing sidebar");
console.log("New width:", t.style.width); console.log("New width:", t.style.width);
@@ -820,14 +832,14 @@ class oe extends HTMLElement {
getIssueContext(t) { getIssueContext(t) {
const e = window.location.pathname, n = e.includes("/beitrag/"); const e = window.location.pathname, n = e.includes("/beitrag/");
if (n) { if (n) {
const s = document.querySelector(`[data-page-container="${t}"]`); const a = document.querySelector(`[data-page-container="${t}"]`);
if (s) { if (a) {
const c = s.querySelector(".page-indicator"); const c = a.querySelector(".page-indicator");
if (c) { if (c) {
const g = c.textContent.trim(), d = g.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 (d) if (g)
return d[1]; return g[1];
const u = g.match(/(\d{4})\s+Nr\.\s+(\d+)/); const u = d.match(/(\d{4})\s+Nr\.\s+(\d+)/);
if (u) if (u)
return `${u[1]} Nr. ${u[2]}`; return `${u[1]} Nr. ${u[2]}`;
} }
@@ -842,9 +854,9 @@ class oe extends HTMLElement {
return n ? `${i[1]} Nr. ${i[2]}` : ""; return n ? `${i[1]} Nr. ${i[2]}` : "";
const r = document.querySelector(".page-indicator"); const r = document.querySelector(".page-indicator");
if (r) { if (r) {
const a = r.textContent.trim().match(/(\d{4})\s+Nr\.\s+(\d+)/); const s = r.textContent.trim().match(/(\d{4})\s+Nr\.\s+(\d+)/);
if (a) if (s)
return `${a[1]} Nr. ${a[2]}`; return `${s[1]} Nr. ${s[2]}`;
} }
return "KGPZ"; return "KGPZ";
} }

File diff suppressed because one or more lines are too long

View File

@@ -44,9 +44,10 @@
{{- /* 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) }}
{{- /* Show all citations from all pieces in this group */ -}} {{- /* Show all citations from all pieces in this group inline with commas */ -}}
{{- range $_, $groupItem := $groupedItems -}} {{ " " }}{{- range $groupIndex, $groupItem := $groupedItems -}}
{{- range $i, $issue := $groupItem.Item.IssueRefs -}} {{- range $issueIndex, $issue := $groupItem.Item.IssueRefs -}}
{{- if or (gt $groupIndex 0) (gt $issueIndex 0) }}, {{ end -}}
{{ $issueData := GetIssue (printf "%d-%d" $issue.When.Year $issue.Nr) }} {{ $issueData := GetIssue (printf "%d-%d" $issue.When.Year $issue.Nr) }}
{{- $url := printf "/%s/%d" $issue.When $issue.Nr -}} {{- $url := printf "/%s/%d" $issue.When $issue.Nr -}}
{{- if $issue.Von -}} {{- if $issue.Von -}}
@@ -56,7 +57,7 @@
{{- $url = printf "%s/%d" $url $issue.Von -}} {{- $url = printf "%s/%d" $url $issue.Von -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
<a href="{{ $url }}" class="ml-1.5 inline-block text-blue-700 hover:text-blue-800"> <a href="{{ $url }}" class="text-blue-700 hover:text-blue-800">
{{- if $issueData -}} {{- if $issueData -}}
{{ $issueData.Datum.When.Day }}.{{ $issueData.Datum.When.Month }}.{{ $issueData.Datum.When.Year }}/{{ $issue.Nr }}, S. {{ $issue.Von }}{{- if and $issue.Bis (ne $issue.Von $issue.Bis) }}-{{ $issue.Bis }}{{ end }} {{ $issueData.Datum.When.Day }}.{{ $issueData.Datum.When.Month }}.{{ $issueData.Datum.When.Year }}/{{ $issue.Nr }}, S. {{ $issue.Von }}{{- if and $issue.Bis (ne $issue.Von $issue.Bis) }}-{{ $issue.Bis }}{{ end }}
{{- else -}} {{- else -}}

View File

@@ -152,9 +152,10 @@
{{ " " }}von {{ range $i, $authorID := $uniqueAuthorIDs }}{{- if gt $i 0 }} und {{ end }}{{- $agent := GetAgent $authorID -}}{{- if and $agent (gt (len $agent.Names) 0) -}}<a href="/akteure/{{ $authorID }}" class="">{{ index $agent.Names 0 }}</a>{{- end -}}{{ end }} {{ " " }}von {{ range $i, $authorID := $uniqueAuthorIDs }}{{- if gt $i 0 }} und {{ end }}{{- $agent := GetAgent $authorID -}}{{- if and $agent (gt (len $agent.Names) 0) -}}<a href="/akteure/{{ $authorID }}" class="">{{ index $agent.Names 0 }}</a>{{- end -}}{{ end }}
{{- end -}}{{ ":" }} {{- end -}}{{ ":" }}
</span> </span>
{{- /* Show all citations for this category */ -}} {{- /* Show all citations for this category inline with commas */ -}}
{{- range $_, $p := $categoryPieces -}} {{ " " }}{{- range $pieceIndex, $p := $categoryPieces -}}
{{- range $_, $issue := $p.Item.IssueRefs -}} {{- range $issueIndex, $issue := $p.Item.IssueRefs -}}
{{- if or (gt $pieceIndex 0) (gt $issueIndex 0) }}, {{ end -}}
{{ $issueData := GetIssue (printf "%d-%d" $issue.When.Year $issue.Nr) }} {{ $issueData := GetIssue (printf "%d-%d" $issue.When.Year $issue.Nr) }}
{{- $url := printf "/%s/%d" $issue.When $issue.Nr -}} {{- $url := printf "/%s/%d" $issue.When $issue.Nr -}}
{{- if $issue.Von -}} {{- if $issue.Von -}}
@@ -164,7 +165,7 @@
{{- $url = printf "%s/%d" $url $issue.Von -}} {{- $url = printf "%s/%d" $url $issue.Von -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
<a href="{{ $url }}" class="inline-block text-blue-700 hover:text-blue-800 rounded ml-2 "> <a href="{{ $url }}" class="text-blue-700 hover:text-blue-800">
{{- if $issueData -}} {{- if $issueData -}}
{{ $issueData.Datum.When.Day }}.{{ $issueData.Datum.When.Month }}.{{ $issueData.Datum.When.Year }}/{{ $issue.Nr }}, S. {{ $issue.Von }}{{- if and $issue.Bis (ne $issue.Von $issue.Bis) }}-{{ $issue.Bis }}{{ end }} {{ $issueData.Datum.When.Day }}.{{ $issueData.Datum.When.Month }}.{{ $issueData.Datum.When.Year }}/{{ $issue.Nr }}, S. {{ $issue.Von }}{{- if and $issue.Bis (ne $issue.Von $issue.Bis) }}-{{ $issue.Bis }}{{ end }}
{{- else -}} {{- else -}}

View File

@@ -7,11 +7,14 @@
<!-- Scrollspy Navigation - Hidden on smaller screens, shown on 2xl+ --> <!-- Scrollspy Navigation - Hidden on smaller screens, shown on 2xl+ -->
<div class="hidden 2xl:block w-96 flex-shrink-0"> <div class="hidden 2xl:block w-96 flex-shrink-0">
<div class="sticky top-0 max-h-screen bg-white rounded py-4 flex flex-col border-x-6 border-white"> <div class="sticky top-0 max-h-screen bg-white rounded py-4 flex flex-col border-x-6 border-white">
<nav class="flex-1 overflow-y-auto overscroll-contain" id="scrollspy-nav"> <nav class="flex-1 overflow-y-auto overscroll-contain relative" id="scrollspy-nav">
<!-- Sliding red background element -->
<div id="scrollspy-slider" class="absolute left-0 bg-red-100 rounded-sm transition-all duration-300 ease-out opacity-0 z-0" style="width: 100%; height: 0; top: 0;"></div>
{{ range $_, $id := $sorted }} {{ range $_, $id := $sorted }}
{{ $a := index $agents $id }} {{ $a := index $agents $id }}
<a href="#author-{{ $id }}" <a href="#author-{{ $id }}"
class="block px-2 py-0.5 text-lg text-gray-900 scrollspy-link no-underline box-content" class="block px-2 py-0.5 text-lg text-gray-900 scrollspy-link no-underline box-content relative z-10 scrollspy-hover"
data-target="author-{{ $id }}"> data-target="author-{{ $id }}">
{{ index $a.Names 0 }} {{ index $a.Names 0 }}
</a> </a>

View File

@@ -1042,20 +1042,52 @@ function initializeScrollspy() {
} }
}); });
// Update highlighting for all visible sections (instant, no transitions) // Update highlighting with sliding background animation
const activeLinks = []; const activeLinks = [];
const slider = document.getElementById("scrollspy-slider");
// Reset all links to default state (no background, just font weight for active)
navLinks.forEach((link) => { navLinks.forEach((link) => {
link.classList.remove("font-medium", "bg-red-100"); link.classList.remove("font-medium");
link.classList.add("text-gray-700", "bg-white");
const targetId = link.getAttribute("data-target"); const targetId = link.getAttribute("data-target");
if (visibleSections.includes(targetId)) { if (visibleSections.includes(targetId)) {
link.classList.remove("text-gray-700", "bg-white"); link.classList.add("font-medium");
link.classList.add("font-medium", "bg-red-100");
activeLinks.push(link); activeLinks.push(link);
} }
}); });
// Calculate and animate the sliding background
if (activeLinks.length > 0 && slider) {
// Get the nav container for relative positioning
const nav = document.getElementById("scrollspy-nav");
const navRect = nav.getBoundingClientRect();
// Calculate the combined area of all active links
let minTop = Infinity;
let maxBottom = -Infinity;
activeLinks.forEach((link) => {
const linkRect = link.getBoundingClientRect();
const relativeTop = linkRect.top - navRect.top + nav.scrollTop;
const relativeBottom = relativeTop + linkRect.height;
minTop = Math.min(minTop, relativeTop);
maxBottom = Math.max(maxBottom, relativeBottom);
});
// Handle gaps between non-consecutive active links
let totalHeight = maxBottom - minTop;
// Position and size the slider
slider.style.top = `${minTop}px`;
slider.style.height = `${totalHeight}px`;
slider.style.opacity = '1';
} else if (slider) {
// Hide slider when no active links
slider.style.opacity = '0';
}
// Implement proportional scrolling to keep active links visible // Implement proportional scrolling to keep active links visible
if (activeLinks.length > 0) { if (activeLinks.length > 0) {
updateSidebarScroll(activeLinks); updateSidebarScroll(activeLinks);
@@ -1187,6 +1219,13 @@ function cleanupScrollspy() {
window.scrollspyClickHandlers = null; window.scrollspyClickHandlers = null;
} }
// Reset slider
const slider = document.getElementById("scrollspy-slider");
if (slider) {
slider.style.opacity = '0';
slider.style.height = '0';
}
// Reset manual navigation flag // Reset manual navigation flag
window.scrollspyManualNavigation = false; window.scrollspyManualNavigation = false;
} }

View File

@@ -160,4 +160,9 @@ body::before {
background-color: rgb(254 215 170) !important; /* amber-200 */ background-color: rgb(254 215 170) !important; /* amber-200 */
color: rgb(146 64 14) !important; /* amber-800 */ color: rgb(146 64 14) !important; /* amber-800 */
} }
/* Scrollspy hover effect - only when not active */
.scrollspy-hover:hover:not(.font-medium) {
background-color: rgb(254 242 242); /* red-50 */
}
} }