mirror of
https://github.com/Theodor-Springmann-Stiftung/kgpz_web.git
synced 2025-10-29 00:55:32 +00:00
Scrollspy
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
const D = "script[xslt-onload]", S = "xslt-template", V = "xslt-transformed", P = /* @__PURE__ */ new Map();
|
||||
function C() {
|
||||
let o = htmx.findAll(D);
|
||||
const V = "script[xslt-onload]", P = "xslt-template", D = "xslt-transformed", C = /* @__PURE__ */ new Map();
|
||||
function T() {
|
||||
let o = htmx.findAll(V);
|
||||
for (let t of o)
|
||||
K(t);
|
||||
}
|
||||
function K(o) {
|
||||
if (o.getAttribute(V) === "true" || !o.hasAttribute(S))
|
||||
if (o.getAttribute(D) === "true" || !o.hasAttribute(P))
|
||||
return;
|
||||
let t = "#" + o.getAttribute(S), e = P.get(t);
|
||||
let t = "#" + o.getAttribute(P), e = C.get(t);
|
||||
if (!e) {
|
||||
let s = htmx.find(t);
|
||||
if (s) {
|
||||
let a = s.innerHTML ? new DOMParser().parseFromString(s.innerHTML, "application/xml") : s.contentDocument;
|
||||
e = new XSLTProcessor(), e.importStylesheet(a), P.set(t, e);
|
||||
e = new XSLTProcessor(), e.importStylesheet(a), C.set(t, e);
|
||||
} else
|
||||
throw new Error("Unknown XSLT template: " + t);
|
||||
}
|
||||
@@ -51,7 +51,7 @@ function W() {
|
||||
const o = document.querySelectorAll(".newspaper-page-container");
|
||||
window.highlightObserver = new IntersectionObserver(
|
||||
(t) => {
|
||||
I();
|
||||
E();
|
||||
},
|
||||
{
|
||||
rootMargin: "-20% 0px -70% 0px"
|
||||
@@ -60,12 +60,12 @@ function W() {
|
||||
window.highlightObserver.observe(t);
|
||||
});
|
||||
}
|
||||
function I() {
|
||||
function E() {
|
||||
const o = [];
|
||||
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]"), h = d ? d.getAttribute("data-page") : "unknown";
|
||||
g && d && h && !o.includes(h) && o.push(h);
|
||||
}), Z(o), o.length > 0 && A(o);
|
||||
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";
|
||||
g && d && u && !o.includes(u) && o.push(u);
|
||||
}), Z(o), o.length > 0 && L(o);
|
||||
}
|
||||
function Z(o) {
|
||||
document.querySelectorAll(".continuation-entry").forEach((t) => {
|
||||
@@ -98,10 +98,10 @@ function F() {
|
||||
}), e ? o.style.display = "" : o.style.display = "none";
|
||||
});
|
||||
}
|
||||
function E(o) {
|
||||
A([o]);
|
||||
}
|
||||
function A(o) {
|
||||
L([o]);
|
||||
}
|
||||
function L(o) {
|
||||
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"));
|
||||
}), document.querySelectorAll(".page-number-inhalts").forEach((e) => {
|
||||
@@ -150,11 +150,11 @@ function U(o, t, e, n = null) {
|
||||
const r = o.closest('[data-beilage="true"]') !== null, s = window.templateData && window.templateData.targetPage ? window.templateData.targetPage : 0;
|
||||
i.show(o.src, o.alt, t, r, s, n);
|
||||
}
|
||||
function L() {
|
||||
function k() {
|
||||
document.getElementById("pageModal").classList.add("hidden");
|
||||
}
|
||||
function G() {
|
||||
if (window.pageObserver && (window.pageObserver.disconnect(), window.pageObserver = null), window.currentPageContainers = Array.from(document.querySelectorAll(".newspaper-page-container")), window.currentActiveIndex = 0, p(), 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, f(), document.querySelector(".newspaper-page-container")) {
|
||||
let t = /* @__PURE__ */ new Set();
|
||||
window.pageObserver = new IntersectionObserver(
|
||||
(e) => {
|
||||
@@ -163,7 +163,7 @@ function G() {
|
||||
i !== -1 && (n.isIntersecting ? t.add(i) : t.delete(i));
|
||||
}), t.size > 0) {
|
||||
const i = Array.from(t).sort((r, s) => r - s)[0];
|
||||
i !== window.currentActiveIndex && (window.currentActiveIndex = i, p());
|
||||
i !== window.currentActiveIndex && (window.currentActiveIndex = i, f());
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -192,7 +192,7 @@ function Y() {
|
||||
behavior: "smooth",
|
||||
block: "start"
|
||||
}), setTimeout(() => {
|
||||
p();
|
||||
f();
|
||||
}, 100));
|
||||
}
|
||||
}
|
||||
@@ -214,7 +214,7 @@ function J() {
|
||||
behavior: "smooth",
|
||||
block: "start"
|
||||
}), setTimeout(() => {
|
||||
p();
|
||||
f();
|
||||
}, 100));
|
||||
}
|
||||
}
|
||||
@@ -246,7 +246,7 @@ function q() {
|
||||
}
|
||||
return !1;
|
||||
}
|
||||
function p() {
|
||||
function f() {
|
||||
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) {
|
||||
const n = q(), i = e.querySelector("i");
|
||||
@@ -265,24 +265,24 @@ function ee() {
|
||||
title: document.title,
|
||||
url: e
|
||||
}).catch((n) => {
|
||||
T(e, o);
|
||||
}) : T(e, o);
|
||||
I(e, o);
|
||||
}) : I(e, o);
|
||||
}
|
||||
function T(o, t) {
|
||||
function I(o, t) {
|
||||
if (navigator.clipboard)
|
||||
navigator.clipboard.writeText(o).then(() => {
|
||||
u(t, "Link kopiert!");
|
||||
h(t, "Link kopiert!");
|
||||
}).catch((e) => {
|
||||
u(t, "Kopieren fehlgeschlagen");
|
||||
h(t, "Kopieren fehlgeschlagen");
|
||||
});
|
||||
else {
|
||||
const e = document.createElement("textarea");
|
||||
e.value = o, document.body.appendChild(e), e.select();
|
||||
try {
|
||||
const n = document.execCommand("copy");
|
||||
u(t, n ? "Link kopiert!" : "Kopieren fehlgeschlagen");
|
||||
h(t, n ? "Link kopiert!" : "Kopieren fehlgeschlagen");
|
||||
} catch {
|
||||
u(t, "Kopieren fehlgeschlagen");
|
||||
h(t, "Kopieren fehlgeschlagen");
|
||||
} finally {
|
||||
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}).`;
|
||||
if (navigator.clipboard)
|
||||
navigator.clipboard.writeText(i).then(() => {
|
||||
u(o, "Zitation kopiert!");
|
||||
h(o, "Zitation kopiert!");
|
||||
}).catch((r) => {
|
||||
u(o, "Kopieren fehlgeschlagen");
|
||||
h(o, "Kopieren fehlgeschlagen");
|
||||
});
|
||||
else {
|
||||
const r = document.createElement("textarea");
|
||||
r.value = i, document.body.appendChild(r), r.select();
|
||||
try {
|
||||
const s = document.execCommand("copy");
|
||||
u(o, s ? "Zitation kopiert!" : "Kopieren fehlgeschlagen");
|
||||
h(o, s ? "Zitation kopiert!" : "Kopieren fehlgeschlagen");
|
||||
} catch {
|
||||
u(o, "Kopieren fehlgeschlagen");
|
||||
h(o, "Kopieren fehlgeschlagen");
|
||||
} finally {
|
||||
document.body.removeChild(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
function u(o, t) {
|
||||
function h(o, t) {
|
||||
const e = document.querySelector(".simple-popup");
|
||||
e && e.remove();
|
||||
const n = document.createElement("div");
|
||||
@@ -361,10 +361,10 @@ function ne() {
|
||||
t.scrollIntoView({
|
||||
behavior: "smooth",
|
||||
block: "start"
|
||||
}), E(o);
|
||||
}), A(o);
|
||||
}, 300);
|
||||
}
|
||||
function m(o, t, e = !1) {
|
||||
function y(o, t, e = !1) {
|
||||
let n = "";
|
||||
if (e)
|
||||
n = window.location.origin + window.location.pathname + `#beilage-1-page-${o}`;
|
||||
@@ -379,24 +379,24 @@ function m(o, t, e = !1) {
|
||||
const i = n;
|
||||
if (navigator.clipboard)
|
||||
navigator.clipboard.writeText(i).then(() => {
|
||||
u(t, "Link kopiert!");
|
||||
h(t, "Link kopiert!");
|
||||
}).catch((r) => {
|
||||
u(t, "Kopieren fehlgeschlagen");
|
||||
h(t, "Kopieren fehlgeschlagen");
|
||||
});
|
||||
else {
|
||||
const r = document.createElement("textarea");
|
||||
r.value = i, document.body.appendChild(r), r.select();
|
||||
try {
|
||||
const s = document.execCommand("copy");
|
||||
u(t, s ? "Link kopiert!" : "Kopieren fehlgeschlagen");
|
||||
h(t, s ? "Link kopiert!" : "Kopieren fehlgeschlagen");
|
||||
} catch {
|
||||
u(t, "Kopieren fehlgeschlagen");
|
||||
h(t, "Kopieren fehlgeschlagen");
|
||||
} finally {
|
||||
document.body.removeChild(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
function y(o, t) {
|
||||
function v(o, t) {
|
||||
const e = document.title || "KGPZ", n = window.location.pathname.split("/");
|
||||
let i;
|
||||
if (n.length >= 3) {
|
||||
@@ -407,39 +407,49 @@ function y(o, t) {
|
||||
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}).`;
|
||||
if (navigator.clipboard)
|
||||
navigator.clipboard.writeText(a).then(() => {
|
||||
u(t, "Zitation kopiert!");
|
||||
h(t, "Zitation kopiert!");
|
||||
}).catch((l) => {
|
||||
u(t, "Kopieren fehlgeschlagen");
|
||||
h(t, "Kopieren fehlgeschlagen");
|
||||
});
|
||||
else {
|
||||
const l = document.createElement("textarea");
|
||||
l.value = a, document.body.appendChild(l), l.select();
|
||||
try {
|
||||
const c = document.execCommand("copy");
|
||||
u(t, c ? "Zitation kopiert!" : "Kopieren fehlgeschlagen");
|
||||
h(t, c ? "Zitation kopiert!" : "Kopieren fehlgeschlagen");
|
||||
} catch {
|
||||
u(t, "Kopieren fehlgeschlagen");
|
||||
h(t, "Kopieren fehlgeschlagen");
|
||||
} finally {
|
||||
document.body.removeChild(l);
|
||||
}
|
||||
}
|
||||
}
|
||||
function f() {
|
||||
k();
|
||||
function b() {
|
||||
H();
|
||||
const o = document.querySelectorAll(".author-section"), t = document.querySelectorAll(".scrollspy-link");
|
||||
if (o.length === 0 || t.length === 0)
|
||||
return;
|
||||
function e() {
|
||||
const i = [];
|
||||
o.forEach((s) => {
|
||||
s.getBoundingClientRect().top + window.scrollY;
|
||||
const l = s.querySelector("div:first-child");
|
||||
const a = s.getAttribute("id"), l = s.querySelector(".akteur-werke-section"), c = s.querySelector(".akteur-beitraege-section");
|
||||
let g = !1;
|
||||
if (l) {
|
||||
const c = l.getBoundingClientRect();
|
||||
c.top + window.scrollY + c.height;
|
||||
const d = c.top >= 0, h = c.bottom <= window.innerHeight;
|
||||
d && h && i.push(s.getAttribute("id"));
|
||||
const d = l.getBoundingClientRect(), u = d.top < window.innerHeight, p = d.bottom > 0;
|
||||
u && p && (g = !0);
|
||||
}
|
||||
if (c && !g) {
|
||||
const d = c.getBoundingClientRect(), u = d.top < window.innerHeight, p = d.bottom > 0;
|
||||
u && p && (g = !0);
|
||||
}
|
||||
if (!l && !c) {
|
||||
const d = s.querySelector("div:first-child");
|
||||
if (d) {
|
||||
const u = d.getBoundingClientRect(), p = u.top >= 0, m = u.bottom <= window.innerHeight;
|
||||
p && m && (g = !0);
|
||||
}
|
||||
}
|
||||
g && i.push(a);
|
||||
});
|
||||
const r = [];
|
||||
t.forEach((s) => {
|
||||
@@ -458,11 +468,11 @@ function f() {
|
||||
document.documentElement.clientHeight,
|
||||
document.documentElement.scrollHeight,
|
||||
document.documentElement.offsetHeight
|
||||
), l = window.innerHeight, c = a - l, g = c > 0 ? window.scrollY / c : 0, d = r.clientHeight, w = r.scrollHeight - d;
|
||||
if (w > 0) {
|
||||
const H = g * w, B = s.getBoundingClientRect(), $ = r.getBoundingClientRect(), M = B.top - $.top + r.scrollTop, N = d / 2, R = M - N, v = 0.7, O = v * H + (1 - v) * R, x = Math.max(0, Math.min(w, O)), z = r.scrollTop;
|
||||
Math.abs(x - z) > 10 && r.scrollTo({
|
||||
top: x,
|
||||
), l = window.innerHeight, c = a - l, g = c > 0 ? window.scrollY / c : 0, d = r.clientHeight, p = r.scrollHeight - d;
|
||||
if (p > 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;
|
||||
Math.abs(S - z) > 10 && r.scrollTo({
|
||||
top: S,
|
||||
behavior: "smooth"
|
||||
});
|
||||
}
|
||||
@@ -483,43 +493,43 @@ function f() {
|
||||
window.scrollspyClickHandlers.push({ link: i, handler: r }), i.addEventListener("click", r);
|
||||
}), e();
|
||||
}
|
||||
function k() {
|
||||
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 }) => {
|
||||
o.removeEventListener("click", t);
|
||||
}), window.scrollspyClickHandlers = null), window.scrollspyManualNavigation = !1;
|
||||
}
|
||||
function b() {
|
||||
function w() {
|
||||
W(), G(), window.addEventListener("scroll", function() {
|
||||
clearTimeout(window.scrollTimeout), window.scrollTimeout = setTimeout(() => {
|
||||
I(), p();
|
||||
E(), f();
|
||||
}, 50);
|
||||
}), ne(), document.addEventListener("keydown", function(o) {
|
||||
o.key === "Escape" && L();
|
||||
o.key === "Escape" && k();
|
||||
});
|
||||
}
|
||||
window.enlargePage = U;
|
||||
window.closeModal = L;
|
||||
window.closeModal = k;
|
||||
window.scrollToPreviousPage = Y;
|
||||
window.scrollToNextPage = J;
|
||||
window.scrollToBeilage = Q;
|
||||
window.shareCurrentPage = ee;
|
||||
window.generateCitation = te;
|
||||
window.copyPagePermalink = m;
|
||||
window.generatePageCitation = y;
|
||||
window.copyPagePermalink = y;
|
||||
window.generatePageCitation = v;
|
||||
function re() {
|
||||
C(), j(), document.querySelector(".newspaper-page-container") && b(), document.querySelector(".author-section") && f(), htmx.on("htmx:load", function(o) {
|
||||
C();
|
||||
T(), j(), document.querySelector(".newspaper-page-container") && w(), document.querySelector(".author-section") && b(), htmx.on("htmx:load", function(o) {
|
||||
T();
|
||||
}), document.body.addEventListener("htmx:afterSwap", function(o) {
|
||||
setTimeout(() => {
|
||||
document.querySelector(".newspaper-page-container") && b(), document.querySelector(".author-section") && f();
|
||||
document.querySelector(".newspaper-page-container") && w(), document.querySelector(".author-section") && b();
|
||||
}, 100);
|
||||
}), document.body.addEventListener("htmx:afterSettle", function(o) {
|
||||
setTimeout(() => {
|
||||
document.querySelector(".newspaper-page-container") && b(), document.querySelector(".author-section") && f();
|
||||
document.querySelector(".newspaper-page-container") && w(), document.querySelector(".author-section") && b();
|
||||
}, 200);
|
||||
}), document.body.addEventListener("htmx:load", function(o) {
|
||||
setTimeout(() => {
|
||||
document.querySelector(".newspaper-page-container") && b(), document.querySelector(".author-section") && f();
|
||||
document.querySelector(".newspaper-page-container") && w(), document.querySelector(".author-section") && b();
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
@@ -656,8 +666,8 @@ class oe extends HTMLElement {
|
||||
l.style.position = "relative";
|
||||
const d = l.querySelector(".target-page-dot");
|
||||
d && d.remove();
|
||||
const h = document.createElement("span");
|
||||
h.className = "target-page-dot absolute -top-1 -right-1 w-3 h-3 bg-red-500 rounded-full z-10", h.title = "verlinkte Seite", l.appendChild(h);
|
||||
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);
|
||||
}
|
||||
if (s !== 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>`;
|
||||
@@ -665,7 +675,7 @@ class oe extends HTMLElement {
|
||||
const d = this.determinePageIconType(n, i);
|
||||
c.innerHTML = this.getPageIconHTML(d);
|
||||
}
|
||||
this.updateNavigationButtons(), this.style.display = "block", document.body.style.overflow = "hidden", E(n);
|
||||
this.updateNavigationButtons(), this.style.display = "block", document.body.style.overflow = "hidden", A(n);
|
||||
}
|
||||
close() {
|
||||
this.style.display = "none", document.body.style.overflow = "";
|
||||
@@ -703,16 +713,16 @@ class oe extends HTMLElement {
|
||||
}
|
||||
// Share current page
|
||||
shareCurrentPage() {
|
||||
if (typeof m == "function") {
|
||||
if (typeof y == "function") {
|
||||
const t = this.querySelector("#share-btn");
|
||||
m(this.currentPageNumber, t, this.currentIsBeilage);
|
||||
y(this.currentPageNumber, t, this.currentIsBeilage);
|
||||
}
|
||||
}
|
||||
// Generate citation for current page
|
||||
generatePageCitation() {
|
||||
if (typeof y == "function") {
|
||||
if (typeof v == "function") {
|
||||
const t = this.querySelector("#cite-btn");
|
||||
y(this.currentPageNumber, t);
|
||||
v(this.currentPageNumber, t);
|
||||
}
|
||||
}
|
||||
// Update navigation button visibility based on available pages
|
||||
@@ -817,9 +827,9 @@ class oe extends HTMLElement {
|
||||
const g = c.textContent.trim(), d = g.match(/(\d{1,2}\.\d{1,2}\.\d{4}\s+Nr\.\s+\d+)/);
|
||||
if (d)
|
||||
return d[1];
|
||||
const h = g.match(/(\d{4})\s+Nr\.\s+(\d+)/);
|
||||
if (h)
|
||||
return `${h[1]} Nr. ${h[2]}`;
|
||||
const u = g.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+)/);
|
||||
@@ -842,7 +852,7 @@ class oe extends HTMLElement {
|
||||
customElements.define("single-page-viewer", oe);
|
||||
document.body.addEventListener("htmx:beforeRequest", function(o) {
|
||||
const t = document.querySelector("single-page-viewer");
|
||||
t && t.style.display !== "none" && (console.log("Cleaning up single page viewer before HTMX navigation"), t.destroy()), k();
|
||||
t && t.style.display !== "none" && (console.log("Cleaning up single page viewer before HTMX navigation"), t.destroy()), H();
|
||||
});
|
||||
window.addEventListener("beforeunload", function() {
|
||||
const o = document.querySelector("single-page-viewer");
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -59,34 +59,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Two Column Layout: Scrollspy + Content -->
|
||||
<div class="flex gap-8">
|
||||
<!-- Scrollspy Navigation - Hidden on smaller screens, shown on 2xl+ -->
|
||||
<div class="hidden 2xl:block w-96 flex-shrink-0">
|
||||
<div class="sticky top-0 max-h-screen bg-white rounded py-4 h-full flex flex-col border-x-6 border-white">
|
||||
<nav class="flex-1 overflow-y-auto overscroll-contain" id="scrollspy-nav">
|
||||
{{ range $_, $id := .model.Sorted }}
|
||||
{{ $a := index $.model.Agents $id }}
|
||||
<a href="#author-{{ $id }}"
|
||||
class="block px-2 py-0.5 text-lg text-gray-900 hover:bg-red-50 scrollspy-link
|
||||
transition-colors no-underline box-content"
|
||||
data-target="author-{{ $id }}">
|
||||
{{ index $a.Names 0 }}
|
||||
</a>
|
||||
{{ end }}
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- People List - Main Content -->
|
||||
<div class="flex-1 space-y-6 bg-white">
|
||||
{{ range $_, $id := .model.Sorted }}
|
||||
{{ $a := index $.model.Agents $id }}
|
||||
<div id="author-{{ $id }}" class="p-6 scroll-mt-8 author-section">
|
||||
{{ template "_akteur" $a }}
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
{{ template "_scrollspy_layout" .model }}
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
@@ -18,37 +18,5 @@
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Two Column Layout: Scrollspy + Content -->
|
||||
<div class="flex gap-8">
|
||||
<!-- Scrollspy Navigation - Hidden on smaller screens, shown on 2xl+ -->
|
||||
<div class="hidden 2xl:block w-80 flex-shrink-0">
|
||||
<div class="sticky top-8 h-screen">
|
||||
<div class="bg-white border border-gray-200 rounded-lg p-4 h-full flex flex-col">
|
||||
<h3 class="text-lg font-bold text-gray-900 mb-4">Auf dieser Seite</h3>
|
||||
<nav class="flex-1 overflow-y-auto" id="scrollspy-nav">
|
||||
{{ range $_, $id := .model.Sorted }}
|
||||
{{ $a := index $.model.Agents $id }}
|
||||
<a href="#author-{{ $id }}"
|
||||
class="block px-3 py-1 text-base text-gray-600 hover:text-blue-600 hover:bg-blue-50 rounded scrollspy-link transition-colors border-l-4 border-transparent"
|
||||
data-target="author-{{ $id }}">
|
||||
{{ index $a.Names 0 }}
|
||||
</a>
|
||||
{{ end }}
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Authors List - Main Content -->
|
||||
<div class="flex-1 space-y-6">
|
||||
{{ range $_, $id := .model.Sorted }}
|
||||
{{ $a := index $.model.Agents $id }}
|
||||
<div id="author-{{ $id }}" class="bg-stone-100 rounded-lg p-6 border border-stone-200 scroll-mt-8 author-section">
|
||||
{{ template "_akteur_header" $a }}
|
||||
{{ template "_akteur_beitraege" $a }}
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ template "_scrollspy_layout" .model }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{{ $a := . }}
|
||||
{{ $pieces := LookupPieces $a }}
|
||||
{{ if ne (len $pieces) 0 }}
|
||||
<div class="mt-4">
|
||||
<div class="mt-4 akteur-beitraege-section">
|
||||
<div class="py-1 rounded-lg mb-1">
|
||||
<h2 class="text-lg font-bold">
|
||||
<i class="ri-newspaper-line mr-2"></i><u class="decoration underline-offset-3">Beiträge</u>
|
||||
@@ -39,12 +39,10 @@
|
||||
<div class="columns-2 gap-6">
|
||||
{{- /* Display grouped pieces */ -}}
|
||||
{{- range $groupKey, $groupedItems := $groupedPieces -}}
|
||||
<div class="break-inside-avoid">
|
||||
<div class="break-inside-avoid pl-4">
|
||||
<div class="text-lg pb-1">
|
||||
{{- /* Use first piece for display text */ -}}
|
||||
<span class="inline-block indent-6">
|
||||
{{ template "_piece_summary" (dict "Piece" (index $groupedItems 0).Item "CurrentActorID" $a.ID) }}
|
||||
</span>
|
||||
|
||||
{{- /* Show all citations from all pieces in this group */ -}}
|
||||
{{- range $_, $groupItem := $groupedItems -}}
|
||||
@@ -70,7 +68,7 @@
|
||||
</div>
|
||||
</div>
|
||||
{{- end -}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{{ $a := . }}
|
||||
{{ $works := LookupWorks $a }}
|
||||
{{- if ne (len $works) 0 -}}
|
||||
<div class="mt-4">
|
||||
<div class="mt-4 akteur-werke-section">
|
||||
<div class="py-1 rounded-lg mb-1">
|
||||
<h2 class="text-lg font-bold">
|
||||
<i class="ri-book-line mr-2"></i><u class="decoration underline-offset-3">Werke</u>
|
||||
|
||||
32
views/routes/components/_scrollspy_layout.gohtml
Normal file
32
views/routes/components/_scrollspy_layout.gohtml
Normal file
@@ -0,0 +1,32 @@
|
||||
{{- /* Shared two-column layout with scrollspy navigation for agent pages */ -}}
|
||||
{{- $agents := .Agents -}}
|
||||
{{- $sorted := .Sorted -}}
|
||||
|
||||
<!-- Two Column Layout: Scrollspy + Content -->
|
||||
<div class="flex gap-8">
|
||||
<!-- Scrollspy Navigation - Hidden on smaller screens, shown on 2xl+ -->
|
||||
<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">
|
||||
<nav class="flex-1 overflow-y-auto overscroll-contain" id="scrollspy-nav">
|
||||
{{ range $_, $id := $sorted }}
|
||||
{{ $a := index $agents $id }}
|
||||
<a href="#author-{{ $id }}"
|
||||
class="block px-2 py-0.5 text-lg text-gray-900 scrollspy-link no-underline box-content"
|
||||
data-target="author-{{ $id }}">
|
||||
{{ index $a.Names 0 }}
|
||||
</a>
|
||||
{{ end }}
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- People List - Main Content -->
|
||||
<div class="flex-1 space-y-6 bg-white">
|
||||
{{ range $_, $id := $sorted }}
|
||||
{{ $a := index $agents $id }}
|
||||
<div id="author-{{ $id }}" class="p-6 scroll-mt-8 author-section">
|
||||
{{ template "_akteur" $a }}
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
@@ -994,29 +994,55 @@ function initializeScrollspy() {
|
||||
const viewportTop = window.scrollY;
|
||||
const viewportBottom = viewportTop + window.innerHeight;
|
||||
|
||||
// Check which sections are fully visible (header must be completely visible)
|
||||
// Check which sections have any part of their Werke or Beiträge visible
|
||||
sections.forEach((section) => {
|
||||
const sectionRect = section.getBoundingClientRect();
|
||||
const sectionTop = sectionRect.top + window.scrollY;
|
||||
const sectionId = section.getAttribute("id");
|
||||
|
||||
// Find the header element (name, life data, professions)
|
||||
const headerElement = section.querySelector("div:first-child");
|
||||
if (headerElement) {
|
||||
const headerRect = headerElement.getBoundingClientRect();
|
||||
const headerTop = headerRect.top + window.scrollY;
|
||||
const headerBottom = headerTop + headerRect.height;
|
||||
// Find Werke and Beiträge sections within this author section
|
||||
const werkeSection = section.querySelector(".akteur-werke-section");
|
||||
const beitraegeSection = section.querySelector(".akteur-beitraege-section");
|
||||
|
||||
// Check if the entire header is visible in the viewport
|
||||
const headerTopVisible = headerRect.top >= 0;
|
||||
const headerBottomVisible = headerRect.bottom <= window.innerHeight;
|
||||
let isVisible = false;
|
||||
|
||||
if (headerTopVisible && headerBottomVisible) {
|
||||
visibleSections.push(section.getAttribute("id"));
|
||||
// Check if any part of Werke section is visible
|
||||
if (werkeSection) {
|
||||
const werkeRect = werkeSection.getBoundingClientRect();
|
||||
const werkeTopVisible = werkeRect.top < window.innerHeight;
|
||||
const werkeBottomVisible = werkeRect.bottom > 0;
|
||||
if (werkeTopVisible && werkeBottomVisible) {
|
||||
isVisible = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if any part of Beiträge section is visible
|
||||
if (beitraegeSection && !isVisible) {
|
||||
const beitraegeRect = beitraegeSection.getBoundingClientRect();
|
||||
const beitraegeTopVisible = beitraegeRect.top < window.innerHeight;
|
||||
const beitraegeBottomVisible = beitraegeRect.bottom > 0;
|
||||
if (beitraegeTopVisible && beitraegeBottomVisible) {
|
||||
isVisible = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback: if no Werke/Beiträge sections, check header visibility (for authors without content)
|
||||
if (!werkeSection && !beitraegeSection) {
|
||||
const headerElement = section.querySelector("div:first-child");
|
||||
if (headerElement) {
|
||||
const headerRect = headerElement.getBoundingClientRect();
|
||||
const headerTopVisible = headerRect.top >= 0;
|
||||
const headerBottomVisible = headerRect.bottom <= window.innerHeight;
|
||||
if (headerTopVisible && headerBottomVisible) {
|
||||
isVisible = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isVisible) {
|
||||
visibleSections.push(sectionId);
|
||||
}
|
||||
});
|
||||
|
||||
// Update highlighting for all visible sections
|
||||
// Update highlighting for all visible sections (instant, no transitions)
|
||||
const activeLinks = [];
|
||||
navLinks.forEach((link) => {
|
||||
link.classList.remove("font-medium", "bg-red-100");
|
||||
|
||||
Reference in New Issue
Block a user