mirror of
https://github.com/Theodor-Springmann-Stiftung/kgpz_web.git
synced 2025-10-29 17:15:31 +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();
|
const V = "script[xslt-onload]", P = "xslt-template", D = "xslt-transformed", C = /* @__PURE__ */ new Map();
|
||||||
function C() {
|
function T() {
|
||||||
let o = htmx.findAll(D);
|
let o = htmx.findAll(V);
|
||||||
for (let t of o)
|
for (let t of o)
|
||||||
K(t);
|
K(t);
|
||||||
}
|
}
|
||||||
function K(o) {
|
function K(o) {
|
||||||
if (o.getAttribute(V) === "true" || !o.hasAttribute(S))
|
if (o.getAttribute(D) === "true" || !o.hasAttribute(P))
|
||||||
return;
|
return;
|
||||||
let t = "#" + o.getAttribute(S), e = P.get(t);
|
let t = "#" + o.getAttribute(P), e = C.get(t);
|
||||||
if (!e) {
|
if (!e) {
|
||||||
let s = htmx.find(t);
|
let s = htmx.find(t);
|
||||||
if (s) {
|
if (s) {
|
||||||
let a = s.innerHTML ? new DOMParser().parseFromString(s.innerHTML, "application/xml") : s.contentDocument;
|
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
|
} else
|
||||||
throw new Error("Unknown XSLT template: " + t);
|
throw new Error("Unknown XSLT template: " + t);
|
||||||
}
|
}
|
||||||
@@ -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) => {
|
||||||
I();
|
E();
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
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 I() {
|
function E() {
|
||||||
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]"), h = d ? d.getAttribute("data-page") : "unknown";
|
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 && h && !o.includes(h) && o.push(h);
|
g && d && u && !o.includes(u) && o.push(u);
|
||||||
}), Z(o), o.length > 0 && A(o);
|
}), Z(o), o.length > 0 && L(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 E(o) {
|
|
||||||
A([o]);
|
|
||||||
}
|
|
||||||
function A(o) {
|
function A(o) {
|
||||||
|
L([o]);
|
||||||
|
}
|
||||||
|
function L(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) => {
|
||||||
@@ -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;
|
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);
|
i.show(o.src, o.alt, t, r, s, n);
|
||||||
}
|
}
|
||||||
function L() {
|
function k() {
|
||||||
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, 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();
|
let t = /* @__PURE__ */ new Set();
|
||||||
window.pageObserver = new IntersectionObserver(
|
window.pageObserver = new IntersectionObserver(
|
||||||
(e) => {
|
(e) => {
|
||||||
@@ -163,7 +163,7 @@ function G() {
|
|||||||
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, 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",
|
behavior: "smooth",
|
||||||
block: "start"
|
block: "start"
|
||||||
}), setTimeout(() => {
|
}), setTimeout(() => {
|
||||||
p();
|
f();
|
||||||
}, 100));
|
}, 100));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -214,7 +214,7 @@ function J() {
|
|||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
block: "start"
|
block: "start"
|
||||||
}), setTimeout(() => {
|
}), setTimeout(() => {
|
||||||
p();
|
f();
|
||||||
}, 100));
|
}, 100));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -246,7 +246,7 @@ function q() {
|
|||||||
}
|
}
|
||||||
return !1;
|
return !1;
|
||||||
}
|
}
|
||||||
function p() {
|
function f() {
|
||||||
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 = q(), i = e.querySelector("i");
|
||||||
@@ -265,24 +265,24 @@ function ee() {
|
|||||||
title: document.title,
|
title: document.title,
|
||||||
url: e
|
url: e
|
||||||
}).catch((n) => {
|
}).catch((n) => {
|
||||||
T(e, o);
|
I(e, o);
|
||||||
}) : T(e, o);
|
}) : I(e, o);
|
||||||
}
|
}
|
||||||
function T(o, t) {
|
function I(o, t) {
|
||||||
if (navigator.clipboard)
|
if (navigator.clipboard)
|
||||||
navigator.clipboard.writeText(o).then(() => {
|
navigator.clipboard.writeText(o).then(() => {
|
||||||
u(t, "Link kopiert!");
|
h(t, "Link kopiert!");
|
||||||
}).catch((e) => {
|
}).catch((e) => {
|
||||||
u(t, "Kopieren fehlgeschlagen");
|
h(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");
|
||||||
u(t, n ? "Link kopiert!" : "Kopieren fehlgeschlagen");
|
h(t, n ? "Link kopiert!" : "Kopieren fehlgeschlagen");
|
||||||
} catch {
|
} catch {
|
||||||
u(t, "Kopieren fehlgeschlagen");
|
h(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(() => {
|
||||||
u(o, "Zitation kopiert!");
|
h(o, "Zitation kopiert!");
|
||||||
}).catch((r) => {
|
}).catch((r) => {
|
||||||
u(o, "Kopieren fehlgeschlagen");
|
h(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 s = document.execCommand("copy");
|
||||||
u(o, s ? "Zitation kopiert!" : "Kopieren fehlgeschlagen");
|
h(o, s ? "Zitation kopiert!" : "Kopieren fehlgeschlagen");
|
||||||
} catch {
|
} catch {
|
||||||
u(o, "Kopieren fehlgeschlagen");
|
h(o, "Kopieren fehlgeschlagen");
|
||||||
} finally {
|
} finally {
|
||||||
document.body.removeChild(r);
|
document.body.removeChild(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function u(o, t) {
|
function h(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");
|
||||||
@@ -361,10 +361,10 @@ function ne() {
|
|||||||
t.scrollIntoView({
|
t.scrollIntoView({
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
block: "start"
|
block: "start"
|
||||||
}), E(o);
|
}), A(o);
|
||||||
}, 300);
|
}, 300);
|
||||||
}
|
}
|
||||||
function m(o, t, e = !1) {
|
function y(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}`;
|
||||||
@@ -379,24 +379,24 @@ function m(o, t, e = !1) {
|
|||||||
const i = n;
|
const i = n;
|
||||||
if (navigator.clipboard)
|
if (navigator.clipboard)
|
||||||
navigator.clipboard.writeText(i).then(() => {
|
navigator.clipboard.writeText(i).then(() => {
|
||||||
u(t, "Link kopiert!");
|
h(t, "Link kopiert!");
|
||||||
}).catch((r) => {
|
}).catch((r) => {
|
||||||
u(t, "Kopieren fehlgeschlagen");
|
h(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 s = document.execCommand("copy");
|
||||||
u(t, s ? "Link kopiert!" : "Kopieren fehlgeschlagen");
|
h(t, s ? "Link kopiert!" : "Kopieren fehlgeschlagen");
|
||||||
} catch {
|
} catch {
|
||||||
u(t, "Kopieren fehlgeschlagen");
|
h(t, "Kopieren fehlgeschlagen");
|
||||||
} finally {
|
} finally {
|
||||||
document.body.removeChild(r);
|
document.body.removeChild(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function y(o, t) {
|
function v(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) {
|
||||||
@@ -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}).`;
|
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)
|
if (navigator.clipboard)
|
||||||
navigator.clipboard.writeText(a).then(() => {
|
navigator.clipboard.writeText(a).then(() => {
|
||||||
u(t, "Zitation kopiert!");
|
h(t, "Zitation kopiert!");
|
||||||
}).catch((l) => {
|
}).catch((l) => {
|
||||||
u(t, "Kopieren fehlgeschlagen");
|
h(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 = a, document.body.appendChild(l), l.select();
|
||||||
try {
|
try {
|
||||||
const c = document.execCommand("copy");
|
const c = document.execCommand("copy");
|
||||||
u(t, c ? "Zitation kopiert!" : "Kopieren fehlgeschlagen");
|
h(t, c ? "Zitation kopiert!" : "Kopieren fehlgeschlagen");
|
||||||
} catch {
|
} catch {
|
||||||
u(t, "Kopieren fehlgeschlagen");
|
h(t, "Kopieren fehlgeschlagen");
|
||||||
} finally {
|
} finally {
|
||||||
document.body.removeChild(l);
|
document.body.removeChild(l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function f() {
|
function b() {
|
||||||
k();
|
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)
|
||||||
return;
|
return;
|
||||||
function e() {
|
function e() {
|
||||||
const i = [];
|
const i = [];
|
||||||
o.forEach((s) => {
|
o.forEach((s) => {
|
||||||
s.getBoundingClientRect().top + window.scrollY;
|
const a = s.getAttribute("id"), l = s.querySelector(".akteur-werke-section"), c = s.querySelector(".akteur-beitraege-section");
|
||||||
const l = s.querySelector("div:first-child");
|
let g = !1;
|
||||||
if (l) {
|
if (l) {
|
||||||
const c = l.getBoundingClientRect();
|
const d = l.getBoundingClientRect(), u = d.top < window.innerHeight, p = d.bottom > 0;
|
||||||
c.top + window.scrollY + c.height;
|
u && p && (g = !0);
|
||||||
const d = c.top >= 0, h = c.bottom <= window.innerHeight;
|
|
||||||
d && h && i.push(s.getAttribute("id"));
|
|
||||||
}
|
}
|
||||||
|
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 = [];
|
const r = [];
|
||||||
t.forEach((s) => {
|
t.forEach((s) => {
|
||||||
@@ -458,11 +468,11 @@ function f() {
|
|||||||
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, w = r.scrollHeight - d;
|
), l = window.innerHeight, c = a - l, g = c > 0 ? window.scrollY / c : 0, d = r.clientHeight, p = r.scrollHeight - d;
|
||||||
if (w > 0) {
|
if (p > 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;
|
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(x - z) > 10 && r.scrollTo({
|
Math.abs(S - z) > 10 && r.scrollTo({
|
||||||
top: x,
|
top: S,
|
||||||
behavior: "smooth"
|
behavior: "smooth"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -483,43 +493,43 @@ function f() {
|
|||||||
window.scrollspyClickHandlers.push({ link: i, handler: r }), i.addEventListener("click", r);
|
window.scrollspyClickHandlers.push({ link: i, handler: r }), i.addEventListener("click", r);
|
||||||
}), e();
|
}), 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 }) => {
|
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);
|
o.removeEventListener("click", t);
|
||||||
}), window.scrollspyClickHandlers = null), window.scrollspyManualNavigation = !1;
|
}), window.scrollspyClickHandlers = null), window.scrollspyManualNavigation = !1;
|
||||||
}
|
}
|
||||||
function b() {
|
function w() {
|
||||||
W(), G(), window.addEventListener("scroll", function() {
|
W(), G(), window.addEventListener("scroll", function() {
|
||||||
clearTimeout(window.scrollTimeout), window.scrollTimeout = setTimeout(() => {
|
clearTimeout(window.scrollTimeout), window.scrollTimeout = setTimeout(() => {
|
||||||
I(), p();
|
E(), f();
|
||||||
}, 50);
|
}, 50);
|
||||||
}), ne(), document.addEventListener("keydown", function(o) {
|
}), ne(), document.addEventListener("keydown", function(o) {
|
||||||
o.key === "Escape" && L();
|
o.key === "Escape" && k();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
window.enlargePage = U;
|
window.enlargePage = U;
|
||||||
window.closeModal = L;
|
window.closeModal = k;
|
||||||
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 = m;
|
window.copyPagePermalink = y;
|
||||||
window.generatePageCitation = y;
|
window.generatePageCitation = v;
|
||||||
function re() {
|
function re() {
|
||||||
C(), j(), document.querySelector(".newspaper-page-container") && b(), document.querySelector(".author-section") && f(), htmx.on("htmx:load", function(o) {
|
T(), j(), document.querySelector(".newspaper-page-container") && w(), document.querySelector(".author-section") && b(), htmx.on("htmx:load", function(o) {
|
||||||
C();
|
T();
|
||||||
}), document.body.addEventListener("htmx:afterSwap", function(o) {
|
}), document.body.addEventListener("htmx:afterSwap", function(o) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
document.querySelector(".newspaper-page-container") && b(), document.querySelector(".author-section") && f();
|
document.querySelector(".newspaper-page-container") && w(), document.querySelector(".author-section") && b();
|
||||||
}, 100);
|
}, 100);
|
||||||
}), document.body.addEventListener("htmx:afterSettle", function(o) {
|
}), document.body.addEventListener("htmx:afterSettle", function(o) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
document.querySelector(".newspaper-page-container") && b(), document.querySelector(".author-section") && f();
|
document.querySelector(".newspaper-page-container") && w(), document.querySelector(".author-section") && b();
|
||||||
}, 200);
|
}, 200);
|
||||||
}), document.body.addEventListener("htmx:load", function(o) {
|
}), document.body.addEventListener("htmx:load", function(o) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
document.querySelector(".newspaper-page-container") && b(), document.querySelector(".author-section") && f();
|
document.querySelector(".newspaper-page-container") && w(), document.querySelector(".author-section") && b();
|
||||||
}, 100);
|
}, 100);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -656,8 +666,8 @@ class oe extends HTMLElement {
|
|||||||
l.style.position = "relative";
|
l.style.position = "relative";
|
||||||
const d = l.querySelector(".target-page-dot");
|
const d = l.querySelector(".target-page-dot");
|
||||||
d && d.remove();
|
d && d.remove();
|
||||||
const h = document.createElement("span");
|
const u = 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);
|
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 (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>`;
|
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);
|
const d = this.determinePageIconType(n, i);
|
||||||
c.innerHTML = this.getPageIconHTML(d);
|
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() {
|
close() {
|
||||||
this.style.display = "none", document.body.style.overflow = "";
|
this.style.display = "none", document.body.style.overflow = "";
|
||||||
@@ -703,16 +713,16 @@ class oe extends HTMLElement {
|
|||||||
}
|
}
|
||||||
// Share current page
|
// Share current page
|
||||||
shareCurrentPage() {
|
shareCurrentPage() {
|
||||||
if (typeof m == "function") {
|
if (typeof y == "function") {
|
||||||
const t = this.querySelector("#share-btn");
|
const t = this.querySelector("#share-btn");
|
||||||
m(this.currentPageNumber, t, this.currentIsBeilage);
|
y(this.currentPageNumber, t, this.currentIsBeilage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Generate citation for current page
|
// Generate citation for current page
|
||||||
generatePageCitation() {
|
generatePageCitation() {
|
||||||
if (typeof y == "function") {
|
if (typeof v == "function") {
|
||||||
const t = this.querySelector("#cite-btn");
|
const t = this.querySelector("#cite-btn");
|
||||||
y(this.currentPageNumber, t);
|
v(this.currentPageNumber, t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Update navigation button visibility based on available pages
|
// 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+)/);
|
const g = c.textContent.trim(), d = g.match(/(\d{1,2}\.\d{1,2}\.\d{4}\s+Nr\.\s+\d+)/);
|
||||||
if (d)
|
if (d)
|
||||||
return d[1];
|
return d[1];
|
||||||
const h = g.match(/(\d{4})\s+Nr\.\s+(\d+)/);
|
const u = g.match(/(\d{4})\s+Nr\.\s+(\d+)/);
|
||||||
if (h)
|
if (u)
|
||||||
return `${h[1]} Nr. ${h[2]}`;
|
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+)/);
|
||||||
@@ -842,7 +852,7 @@ class oe extends HTMLElement {
|
|||||||
customElements.define("single-page-viewer", oe);
|
customElements.define("single-page-viewer", oe);
|
||||||
document.body.addEventListener("htmx:beforeRequest", function(o) {
|
document.body.addEventListener("htmx:beforeRequest", function(o) {
|
||||||
const t = document.querySelector("single-page-viewer");
|
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() {
|
window.addEventListener("beforeunload", function() {
|
||||||
const o = document.querySelector("single-page-viewer");
|
const o = document.querySelector("single-page-viewer");
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -59,34 +59,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Two Column Layout: Scrollspy + Content -->
|
{{ template "_scrollspy_layout" .model }}
|
||||||
<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>
|
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|||||||
@@ -18,37 +18,5 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<!-- Two Column Layout: Scrollspy + Content -->
|
{{ template "_scrollspy_layout" .model }}
|
||||||
<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>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{{ $a := . }}
|
{{ $a := . }}
|
||||||
{{ $pieces := LookupPieces $a }}
|
{{ $pieces := LookupPieces $a }}
|
||||||
{{ if ne (len $pieces) 0 }}
|
{{ if ne (len $pieces) 0 }}
|
||||||
<div class="mt-4">
|
<div class="mt-4 akteur-beitraege-section">
|
||||||
<div class="py-1 rounded-lg mb-1">
|
<div class="py-1 rounded-lg mb-1">
|
||||||
<h2 class="text-lg font-bold">
|
<h2 class="text-lg font-bold">
|
||||||
<i class="ri-newspaper-line mr-2"></i><u class="decoration underline-offset-3">Beiträge</u>
|
<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">
|
<div class="columns-2 gap-6">
|
||||||
{{- /* Display grouped pieces */ -}}
|
{{- /* Display grouped pieces */ -}}
|
||||||
{{- range $groupKey, $groupedItems := $groupedPieces -}}
|
{{- range $groupKey, $groupedItems := $groupedPieces -}}
|
||||||
<div class="break-inside-avoid">
|
<div class="break-inside-avoid pl-4">
|
||||||
<div class="text-lg pb-1">
|
<div class="text-lg pb-1">
|
||||||
{{- /* Use first piece for display text */ -}}
|
{{- /* Use first piece for display text */ -}}
|
||||||
<span class="inline-block indent-6">
|
|
||||||
{{ template "_piece_summary" (dict "Piece" (index $groupedItems 0).Item "CurrentActorID" $a.ID) }}
|
{{ template "_piece_summary" (dict "Piece" (index $groupedItems 0).Item "CurrentActorID" $a.ID) }}
|
||||||
</span>
|
|
||||||
|
|
||||||
{{- /* Show all citations from all pieces in this group */ -}}
|
{{- /* Show all citations from all pieces in this group */ -}}
|
||||||
{{- range $_, $groupItem := $groupedItems -}}
|
{{- range $_, $groupItem := $groupedItems -}}
|
||||||
@@ -70,7 +68,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{{ $a := . }}
|
{{ $a := . }}
|
||||||
{{ $works := LookupWorks $a }}
|
{{ $works := LookupWorks $a }}
|
||||||
{{- if ne (len $works) 0 -}}
|
{{- if ne (len $works) 0 -}}
|
||||||
<div class="mt-4">
|
<div class="mt-4 akteur-werke-section">
|
||||||
<div class="py-1 rounded-lg mb-1">
|
<div class="py-1 rounded-lg mb-1">
|
||||||
<h2 class="text-lg font-bold">
|
<h2 class="text-lg font-bold">
|
||||||
<i class="ri-book-line mr-2"></i><u class="decoration underline-offset-3">Werke</u>
|
<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 viewportTop = window.scrollY;
|
||||||
const viewportBottom = viewportTop + window.innerHeight;
|
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) => {
|
sections.forEach((section) => {
|
||||||
const sectionRect = section.getBoundingClientRect();
|
const sectionId = section.getAttribute("id");
|
||||||
const sectionTop = sectionRect.top + window.scrollY;
|
|
||||||
|
|
||||||
// Find the header element (name, life data, professions)
|
// Find Werke and Beiträge sections within this author section
|
||||||
const headerElement = section.querySelector("div:first-child");
|
const werkeSection = section.querySelector(".akteur-werke-section");
|
||||||
if (headerElement) {
|
const beitraegeSection = section.querySelector(".akteur-beitraege-section");
|
||||||
const headerRect = headerElement.getBoundingClientRect();
|
|
||||||
const headerTop = headerRect.top + window.scrollY;
|
|
||||||
const headerBottom = headerTop + headerRect.height;
|
|
||||||
|
|
||||||
// Check if the entire header is visible in the viewport
|
let isVisible = false;
|
||||||
const headerTopVisible = headerRect.top >= 0;
|
|
||||||
const headerBottomVisible = headerRect.bottom <= window.innerHeight;
|
|
||||||
|
|
||||||
if (headerTopVisible && headerBottomVisible) {
|
// Check if any part of Werke section is visible
|
||||||
visibleSections.push(section.getAttribute("id"));
|
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 = [];
|
const activeLinks = [];
|
||||||
navLinks.forEach((link) => {
|
navLinks.forEach((link) => {
|
||||||
link.classList.remove("font-medium", "bg-red-100");
|
link.classList.remove("font-medium", "bg-red-100");
|
||||||
|
|||||||
Reference in New Issue
Block a user