BUGFIX RUN: Single page view

This commit is contained in:
Simon Martens
2025-09-19 12:58:39 +02:00
parent 5bfba49101
commit 04d62d9e67
3 changed files with 180 additions and 135 deletions

View File

@@ -1,13 +1,13 @@
const L = "script[xslt-onload]", w = "xslt-template", E = "xslt-transformed", y = /* @__PURE__ */ new Map();
function v() {
let i = htmx.findAll(L);
for (let t of i)
k(t);
let o = htmx.findAll(L);
for (let t of o)
q(t);
}
function k(i) {
if (i.getAttribute(E) === "true" || !i.hasAttribute(w))
function q(o) {
if (o.getAttribute(E) === "true" || !o.hasAttribute(w))
return;
let t = "#" + i.getAttribute(w), e = y.get(t);
let t = "#" + o.getAttribute(w), e = y.get(t);
if (!e) {
let a = htmx.find(t);
if (a) {
@@ -16,10 +16,10 @@ function k(i) {
} else
throw new Error("Unknown XSLT template: " + t);
}
let n = new DOMParser().parseFromString(i.innerHTML, "application/xml"), o = e.transformToFragment(n, document), r = new XMLSerializer().serializeToString(o);
i.outerHTML = r;
let n = new DOMParser().parseFromString(o.innerHTML, "application/xml"), i = e.transformToFragment(n, document), r = new XMLSerializer().serializeToString(i);
o.outerHTML = r;
}
function q() {
function k() {
document.querySelectorAll("template[simple]").forEach((t) => {
let e = t.getAttribute("id"), n = t.content;
customElements.define(
@@ -29,11 +29,11 @@ function q() {
super(), this.appendChild(n.cloneNode(!0)), this.slots = this.querySelectorAll("slot");
}
connectedCallback() {
let o = [];
let i = [];
this.slots.forEach((r) => {
let a = r.getAttribute("name"), s = this.querySelector(`[slot="${a}"]`);
s && (r.replaceWith(s.cloneNode(!0)), o.push(s));
}), o.forEach((r) => {
s && (r.replaceWith(s.cloneNode(!0)), i.push(s));
}), i.forEach((r) => {
r.remove();
});
}
@@ -48,7 +48,7 @@ window.pageObserver = window.pageObserver || null;
window.scrollTimeout = window.scrollTimeout || null;
function B() {
window.highlightObserver && (window.highlightObserver.disconnect(), window.highlightObserver = null);
const i = document.querySelectorAll(".newspaper-page-container");
const o = document.querySelectorAll(".newspaper-page-container");
window.highlightObserver = new IntersectionObserver(
(t) => {
C();
@@ -56,53 +56,53 @@ function B() {
{
rootMargin: "-20% 0px -70% 0px"
}
), i.forEach((t) => {
), o.forEach((t) => {
window.highlightObserver.observe(t);
});
}
function C() {
const i = [];
const o = [];
document.querySelectorAll(".newspaper-page-container").forEach((e) => {
const n = e.getBoundingClientRect(), o = window.innerHeight, r = Math.max(n.top, 0), a = Math.min(n.bottom, o), s = Math.max(0, a - r), l = n.height, g = s / l >= 0.5, u = e.querySelector("img[data-page]"), f = u ? u.getAttribute("data-page") : "unknown";
g && u && f && !i.includes(f) && i.push(f);
}), M(i), i.length > 0 && I(i);
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, g = s / l >= 0.5, u = e.querySelector("img[data-page]"), f = u ? u.getAttribute("data-page") : "unknown";
g && u && f && !o.includes(f) && o.push(f);
}), M(o), o.length > 0 && I(o);
}
function M(i) {
function M(o) {
document.querySelectorAll(".continuation-entry").forEach((t) => {
t.style.display = "none";
}), i.forEach((t) => {
}), o.forEach((t) => {
const e = document.querySelector(`[data-page-container="${t}"]`);
e && e.querySelectorAll(".continuation-entry").forEach((o) => {
o.style.display = "";
e && e.querySelectorAll(".continuation-entry").forEach((i) => {
i.style.display = "";
});
}), H(i), $();
}), H(o), N();
}
function H(i) {
function H(o) {
document.querySelectorAll(".work-title").forEach((t) => {
const e = t.getAttribute("data-short-title");
e && (t.textContent = e);
}), i.forEach((t) => {
}), o.forEach((t) => {
const e = document.querySelector(`[data-page-container="${t}"]`);
e && e.querySelectorAll(".work-title").forEach((o) => {
const r = o.getAttribute("data-full-title");
r && r !== o.getAttribute("data-short-title") && (o.textContent = r);
e && e.querySelectorAll(".work-title").forEach((i) => {
const r = i.getAttribute("data-full-title");
r && r !== i.getAttribute("data-short-title") && (i.textContent = r);
});
});
}
function $() {
document.querySelectorAll(".page-entry").forEach((i) => {
const t = i.querySelectorAll(".inhalts-entry");
function N() {
document.querySelectorAll(".page-entry").forEach((o) => {
const t = o.querySelectorAll(".inhalts-entry");
let e = !1;
t.forEach((n) => {
window.getComputedStyle(n).display !== "none" && (e = !0);
}), e ? i.style.display = "" : i.style.display = "none";
}), e ? o.style.display = "" : o.style.display = "none";
});
}
function S(i) {
I([i]);
function S(o) {
I([o]);
}
function I(i) {
console.log("markCurrentPagesInInhaltsverzeichnis called with:", i), document.querySelectorAll("[data-page-container]").forEach((e) => {
function I(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) => {
e.classList.remove("text-red-600", "font-bold"), e.classList.add("text-slate-700", "font-semibold"), e.style.textDecoration = "", e.style.pointerEvents = "", e.classList.contains("bg-blue-50") ? e.classList.add("hover:bg-blue-100") : e.classList.contains("bg-amber-50") && e.classList.add("hover:bg-amber-100"), !e.classList.contains("bg-amber-50") && !e.classList.contains("bg-blue-50") && e.classList.add("bg-blue-50");
@@ -112,7 +112,7 @@ function I(i) {
e.classList.remove("no-underline"), e.classList.contains("bg-blue-50") && e.classList.add("hover:bg-blue-100");
});
const t = [];
i.forEach((e) => {
o.forEach((e) => {
const n = document.querySelector(
`.page-number-inhalts[data-page-number="${e}"]`
);
@@ -122,8 +122,8 @@ function I(i) {
"hover:bg-blue-100",
"hover:bg-amber-100"
), n.classList.add("text-red-600", "font-bold"), n.style.textDecoration = "none", n.style.pointerEvents = "none", t.push(n);
const o = document.querySelector(`[data-page-container="${e}"]`);
o && (o.classList.remove("border-slate-300", "border-amber-400"), o.classList.add("border-red-500"));
const i = document.querySelector(`[data-page-container="${e}"]`);
i && (i.classList.remove("border-slate-300", "border-amber-400"), i.classList.add("border-red-500"));
const r = n.closest(".page-entry");
r && (r.querySelectorAll(".inhalts-entry").forEach((s) => {
s.classList.remove("hover:bg-slate-100"), s.style.cursor = "default";
@@ -131,28 +131,28 @@ function I(i) {
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 && N(t[0]), document.querySelectorAll(".page-indicator").forEach((e) => {
}), t.length > 0 && $(t[0]), document.querySelectorAll(".page-indicator").forEach((e) => {
e.classList.remove("text-red-600", "font-bold"), e.classList.add("text-slate-600", "font-semibold"), e.classList.contains("bg-amber-50") || e.classList.add("bg-blue-50");
}), i.forEach((e) => {
}), o.forEach((e) => {
const n = document.querySelector(`.page-indicator[data-page="${e}"]`);
n && (n.classList.remove("text-slate-600"), n.classList.add("text-red-600", "font-bold"));
});
}
function N(i) {
const t = i.closest(".lg\\:overflow-y-auto");
function $(o) {
const t = o.closest(".lg\\:overflow-y-auto");
if (t) {
const e = t.getBoundingClientRect(), n = i.getBoundingClientRect(), o = n.top < e.top, r = n.bottom > e.bottom;
(o || r) && i.scrollIntoView({
const e = t.getBoundingClientRect(), n = o.getBoundingClientRect(), i = n.top < e.top, r = n.bottom > e.bottom;
(i || r) && o.scrollIntoView({
behavior: "smooth",
block: "center"
});
}
}
function R(i, t, e) {
function R(o, t, e) {
let n = document.querySelector("single-page-viewer");
n || (n = document.createElement("single-page-viewer"), document.body.appendChild(n));
const o = i.closest('[data-beilage="true"]') !== null;
n.show(i.src, i.alt, t, o);
const i = o.closest('[data-beilage="true"]') !== null;
n.show(o.src, o.alt, t, i);
}
function T() {
document.getElementById("pageModal").classList.add("hidden");
@@ -165,11 +165,11 @@ function O() {
window.pageObserver = new IntersectionObserver(
(e) => {
if (e.forEach((n) => {
const o = window.currentPageContainers.indexOf(n.target);
o !== -1 && (n.isIntersecting ? t.add(o) : t.delete(o));
const i = window.currentPageContainers.indexOf(n.target);
i !== -1 && (n.isIntersecting ? t.add(i) : t.delete(i));
}), t.size > 0) {
const o = Array.from(t).sort((r, a) => r - a)[0];
o !== window.currentActiveIndex && (window.currentActiveIndex = o, p());
const i = Array.from(t).sort((r, a) => r - a)[0];
i !== window.currentActiveIndex && (window.currentActiveIndex = i, p());
}
},
{
@@ -180,21 +180,21 @@ function O() {
});
}
}
function V() {
function K() {
if (window.currentActiveIndex > 0) {
let i = -1;
let o = -1;
const t = [];
window.currentPageContainers.forEach((n, o) => {
window.currentPageContainers.forEach((n, i) => {
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), g = r.height;
c / g >= 0.3 && t.push(o);
c / g >= 0.3 && t.push(i);
});
const e = Math.min(...t);
for (let n = e - 1; n >= 0; n--)
if (!t.includes(n)) {
i = n;
o = n;
break;
}
i === -1 && e > 0 && (i = e - 1), i >= 0 && (window.currentActiveIndex = i, window.currentPageContainers[window.currentActiveIndex].scrollIntoView({
o === -1 && e > 0 && (o = e - 1), o >= 0 && (window.currentActiveIndex = o, window.currentPageContainers[window.currentActiveIndex].scrollIntoView({
behavior: "smooth",
block: "start"
}), setTimeout(() => {
@@ -202,21 +202,21 @@ function V() {
}, 100));
}
}
function K() {
function V() {
if (window.currentActiveIndex < window.currentPageContainers.length - 1) {
let i = -1;
let o = -1;
const t = [];
window.currentPageContainers.forEach((n, o) => {
window.currentPageContainers.forEach((n, i) => {
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), g = r.height;
c / g >= 0.3 && t.push(o);
c / g >= 0.3 && t.push(i);
});
const e = Math.max(...t);
for (let n = e + 1; n < window.currentPageContainers.length; n++)
if (!t.includes(n)) {
i = n;
o = n;
break;
}
i === -1 && e < window.currentPageContainers.length - 1 && (i = e + 1), i >= 0 && i < window.currentPageContainers.length && (window.currentActiveIndex = i, window.currentPageContainers[window.currentActiveIndex].scrollIntoView({
o === -1 && e < window.currentPageContainers.length - 1 && (o = e + 1), o >= 0 && o < window.currentPageContainers.length && (window.currentActiveIndex = o, window.currentPageContainers[window.currentActiveIndex].scrollIntoView({
behavior: "smooth",
block: "start"
}), setTimeout(() => {
@@ -240,12 +240,12 @@ function z() {
}
}
function A() {
const i = [];
const o = [];
window.currentPageContainers.forEach((t, e) => {
const n = t.getBoundingClientRect(), o = window.innerHeight, r = Math.max(n.top, 0), a = Math.min(n.bottom, o), s = Math.max(0, a - r), l = n.height;
s / l >= 0.3 && i.push(e);
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;
s / l >= 0.3 && o.push(e);
});
for (const t of i) {
for (const t of o) {
const e = window.currentPageContainers[t];
if (e && e.id && e.id.includes("beilage-"))
return !0;
@@ -253,37 +253,37 @@ function A() {
return !1;
}
function p() {
const i = document.getElementById("prevPageBtn"), t = document.getElementById("nextPageBtn"), e = document.getElementById("beilageBtn");
if (i && (window.currentActiveIndex <= 0 ? i.style.display = "none" : i.style.display = "flex"), t && (window.currentActiveIndex >= window.currentPageContainers.length - 1 ? t.style.display = "none" : t.style.display = "flex"), e) {
const n = A(), o = 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", o && (o.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", o && (o.className = "ri-attachment-line text-lg lg:text-xl"));
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 = A(), 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"));
}
}
function j() {
const i = document.getElementById("shareLinkBtn");
const o = document.getElementById("shareLinkBtn");
let t = "";
if (window.currentActiveIndex !== void 0 && window.currentPageContainers && window.currentPageContainers[window.currentActiveIndex]) {
const o = window.currentPageContainers[window.currentActiveIndex].querySelector("[data-page]");
o && (t = `#page-${o.getAttribute("data-page")}`);
const i = window.currentPageContainers[window.currentActiveIndex].querySelector("[data-page]");
i && (t = `#page-${i.getAttribute("data-page")}`);
}
const e = window.location.origin + window.location.pathname + t;
navigator.share ? navigator.share({
title: document.title,
url: e
}).catch((n) => {
x(e, i);
}) : x(e, i);
x(e, o);
}) : x(e, o);
}
function x(i, t) {
function x(o, t) {
if (navigator.clipboard)
navigator.clipboard.writeText(i).then(() => {
navigator.clipboard.writeText(o).then(() => {
d(t, "Link kopiert!");
}).catch((e) => {
d(t, "Kopieren fehlgeschlagen");
});
else {
const e = document.createElement("textarea");
e.value = i, document.body.appendChild(e), e.select();
e.value = o, document.body.appendChild(e), e.select();
try {
const n = document.execCommand("copy");
d(t, n ? "Link kopiert!" : "Kopieren fehlgeschlagen");
@@ -295,27 +295,27 @@ function x(i, t) {
}
}
function D() {
const i = document.getElementById("citationBtn"), t = document.title || "KGPZ", e = window.location.href, n = (/* @__PURE__ */ new Date()).toLocaleDateString("de-DE"), o = `Königsberger Gelehrte und Politische Zeitung (KGPZ). ${t}. Digital verfügbar unter: ${e} (Zugriff: ${n}).`;
const o = document.getElementById("citationBtn"), t = document.title || "KGPZ", e = window.location.href, 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(o).then(() => {
d(i, "Zitation kopiert!");
navigator.clipboard.writeText(i).then(() => {
d(o, "Zitation kopiert!");
}).catch((r) => {
d(i, "Kopieren fehlgeschlagen");
d(o, "Kopieren fehlgeschlagen");
});
else {
const r = document.createElement("textarea");
r.value = o, document.body.appendChild(r), r.select();
r.value = i, document.body.appendChild(r), r.select();
try {
const a = document.execCommand("copy");
d(i, a ? "Zitation kopiert!" : "Kopieren fehlgeschlagen");
d(o, a ? "Zitation kopiert!" : "Kopieren fehlgeschlagen");
} catch {
d(i, "Kopieren fehlgeschlagen");
d(o, "Kopieren fehlgeschlagen");
} finally {
document.body.removeChild(r);
}
}
}
function d(i, t) {
function d(o, t) {
const e = document.querySelector(".simple-popup");
e && e.remove();
const n = document.createElement("div");
@@ -333,10 +333,10 @@ function d(i, t) {
transition: opacity 0.2s ease;
white-space: nowrap;
`;
const o = i.getBoundingClientRect(), r = window.innerHeight, a = window.innerWidth;
let s = o.left - 10, l = o.bottom + 8;
const i = o.getBoundingClientRect(), r = window.innerHeight, a = window.innerWidth;
let s = i.left - 10, l = i.bottom + 8;
const c = 120, g = 32;
s + c > a && (s = o.right - c + 10), l + g > r && (l = o.top - g - 8), n.style.left = Math.max(5, s) + "px", n.style.top = Math.max(5, l) + "px", document.body.appendChild(n), setTimeout(() => {
s + c > a && (s = i.right - c + 10), l + g > r && (l = i.top - g - 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";
}, 10), setTimeout(() => {
n.style.opacity = "0", setTimeout(() => {
@@ -345,25 +345,25 @@ function d(i, t) {
}, 2e3);
}
function P() {
const i = window.location.hash;
const o = window.location.hash;
let t = "", e = null;
if (i.startsWith("#page-")) {
if (t = i.replace("#page-", ""), e = document.getElementById(`page-${t}`), !e) {
if (o.startsWith("#page-")) {
if (t = o.replace("#page-", ""), e = document.getElementById(`page-${t}`), !e) {
const n = document.querySelectorAll(".newspaper-page-container[data-pages]");
for (const o of n) {
const r = o.getAttribute("data-pages");
for (const i of n) {
const r = i.getAttribute("data-pages");
if (r && r.split(",").includes(t)) {
e = o;
e = i;
break;
}
}
}
e || (e = document.getElementById(`beilage-1-page-${t}`) || document.getElementById(`beilage-2-page-${t}`) || document.querySelector(`[id*="beilage"][id*="page-${t}"]`));
} else if (i.startsWith("#beilage-")) {
const n = i.match(/#beilage-(\d+)-page-(\d+)/);
} else if (o.startsWith("#beilage-")) {
const n = o.match(/#beilage-(\d+)-page-(\d+)/);
if (n) {
const o = n[1];
t = n[2], e = document.getElementById(`beilage-${o}-page-${t}`);
const i = n[1];
t = n[2], e = document.getElementById(`beilage-${i}-page-${t}`);
}
}
e && t && setTimeout(() => {
@@ -373,19 +373,19 @@ function P() {
}), S(t);
}, 300);
}
function b(i, t, e = !1) {
function b(o, t, e = !1) {
let n = "";
e ? n = `#beilage-1-page-${i}` : n = `#page-${i}`;
const o = window.location.origin + window.location.pathname + n;
e ? n = `#beilage-1-page-${o}` : n = `#page-${o}`;
const i = window.location.origin + window.location.pathname + n;
if (navigator.clipboard)
navigator.clipboard.writeText(o).then(() => {
navigator.clipboard.writeText(i).then(() => {
d(t, "Link kopiert!");
}).catch((r) => {
d(t, "Kopieren fehlgeschlagen");
});
else {
const r = document.createElement("textarea");
r.value = o, document.body.appendChild(r), r.select();
r.value = i, document.body.appendChild(r), r.select();
try {
const a = document.execCommand("copy");
d(t, a ? "Link kopiert!" : "Kopieren fehlgeschlagen");
@@ -396,8 +396,8 @@ function b(i, t, e = !1) {
}
}
}
function m(i, t) {
const e = document.title || "KGPZ", n = `${window.location.origin}${window.location.pathname}#page-${i}`, o = (/* @__PURE__ */ new Date()).toLocaleDateString("de-DE"), r = `Königsberger Gelehrte und Politische Zeitung (KGPZ). ${e}, Seite ${i}. Digital verfügbar unter: ${n} (Zugriff: ${o}).`;
function m(o, t) {
const e = document.title || "KGPZ", n = `${window.location.origin}${window.location.pathname}#page-${o}`, i = (/* @__PURE__ */ new Date()).toLocaleDateString("de-DE"), r = `Königsberger Gelehrte und Politische Zeitung (KGPZ). ${e}, Seite ${o}. Digital verfügbar unter: ${n} (Zugriff: ${i}).`;
if (navigator.clipboard)
navigator.clipboard.writeText(r).then(() => {
d(t, "Zitation kopiert!");
@@ -422,31 +422,31 @@ function h() {
clearTimeout(window.scrollTimeout), window.scrollTimeout = setTimeout(() => {
C(), p();
}, 50);
}), P(), window.addEventListener("hashchange", P), document.addEventListener("keydown", function(i) {
i.key === "Escape" && T();
}), P(), window.addEventListener("hashchange", P), document.addEventListener("keydown", function(o) {
o.key === "Escape" && T();
});
}
window.enlargePage = R;
window.closeModal = T;
window.scrollToPreviousPage = V;
window.scrollToNextPage = K;
window.scrollToPreviousPage = K;
window.scrollToNextPage = V;
window.scrollToBeilage = z;
window.shareCurrentPage = j;
window.generateCitation = D;
window.copyPagePermalink = b;
window.generatePageCitation = m;
function _() {
v(), q(), document.querySelector(".newspaper-page-container") && h(), htmx.on("htmx:load", function(i) {
v(), k(), document.querySelector(".newspaper-page-container") && h(), htmx.on("htmx:load", function(o) {
v();
}), document.body.addEventListener("htmx:afterSwap", function(i) {
}), document.body.addEventListener("htmx:afterSwap", function(o) {
setTimeout(() => {
document.querySelector(".newspaper-page-container") && h();
}, 100);
}), document.body.addEventListener("htmx:afterSettle", function(i) {
}), document.body.addEventListener("htmx:afterSettle", function(o) {
setTimeout(() => {
document.querySelector(".newspaper-page-container") && h();
}, 200);
}), document.body.addEventListener("htmx:load", function(i) {
}), document.body.addEventListener("htmx:load", function(o) {
setTimeout(() => {
document.querySelector(".newspaper-page-container") && h();
}, 100);
@@ -458,12 +458,12 @@ class Z extends HTMLElement {
}
connectedCallback() {
this.innerHTML = `
<div class="fixed inset-0 z-50 flex">
<div class="fixed inset-0 z-50 flex pointer-events-none">
<!-- Keep Inhaltsverzeichnis area empty/transparent (collapsible) -->
<div id="sidebar-spacer" class="lg:w-1/4 xl:w-1/5 flex-shrink-0 transition-all duration-300"></div>
<!-- Cover the right columns with the zoomed view -->
<div class="flex-1 bg-slate-50 overflow-auto">
<div class="flex-1 bg-slate-50 overflow-auto pointer-events-auto">
<div class="relative min-h-full flex flex-col">
<!-- Header with page info and buttons -->
<div class="flex items-center justify-between p-4">
@@ -542,7 +542,9 @@ class Z extends HTMLElement {
id="single-page-image"
src=""
alt=""
class="w-full h-auto rounded-lg shadow-2xl"
class="w-full h-auto rounded-lg shadow-2xl cursor-pointer"
onclick="this.closest('single-page-viewer').close()"
title="Klicken zum Schließen"
/>
</div>
</div>
@@ -550,15 +552,19 @@ class Z extends HTMLElement {
</div>
`;
}
show(t, e, n, o = !1) {
show(t, e, n, i = !1) {
const r = this.querySelector("#single-page-image"), a = this.querySelector("#page-number"), s = this.querySelector("#page-icon");
this.querySelector("#page-indicator"), r.src = t, r.alt = e, this.currentPageNumber = n, this.currentIsBeilage = o, a.textContent = n;
const l = this.determinePageIconType(n, o);
this.querySelector("#page-indicator"), r.src = t, r.alt = e, this.currentPageNumber = n, this.currentIsBeilage = i, a.textContent = n;
const l = this.determinePageIconType(n, i);
s.innerHTML = this.getPageIconHTML(l), this.updateNavigationButtons(), this.style.display = "block", document.body.style.overflow = "hidden", S(n);
}
close() {
this.style.display = "none", document.body.style.overflow = "";
}
// Clean up component completely
destroy() {
document.body.style.overflow = "", this.parentNode && this.parentNode.removeChild(this);
}
// Determine page icon type based on page position and whether it's beilage
determinePageIconType(t, e) {
const n = e ? '.newspaper-page-container[data-beilage="true"]' : ".newspaper-page-container:not([data-beilage])", r = Array.from(document.querySelectorAll(n)).map((l) => {
@@ -602,8 +608,8 @@ class Z extends HTMLElement {
}
// Update navigation button visibility based on available pages
updateNavigationButtons() {
const t = this.querySelector("#prev-page-btn"), e = this.querySelector("#next-page-btn"), { prevPage: n, nextPage: o } = this.getAdjacentPages();
n !== null ? (t.disabled = !1, t.className = t.className.replace("opacity-50 cursor-not-allowed", ""), t.className = t.className.replace("bg-gray-50 text-gray-400", "bg-gray-100 text-gray-700")) : (t.disabled = !0, t.className.includes("opacity-50") || (t.className += " opacity-50 cursor-not-allowed"), t.className = t.className.replace("bg-gray-100 text-gray-700", "bg-gray-50 text-gray-400")), o !== null ? (e.disabled = !1, e.className = e.className.replace("opacity-50 cursor-not-allowed", ""), e.className = e.className.replace("bg-gray-50 text-gray-400", "bg-gray-100 text-gray-700")) : (e.disabled = !0, e.className.includes("opacity-50") || (e.className += " opacity-50 cursor-not-allowed"), e.className = e.className.replace("bg-gray-100 text-gray-700", "bg-gray-50 text-gray-400"));
const t = this.querySelector("#prev-page-btn"), e = this.querySelector("#next-page-btn"), { prevPage: n, nextPage: i } = this.getAdjacentPages();
n !== null ? (t.disabled = !1, t.className = t.className.replace("opacity-50 cursor-not-allowed", ""), t.className = t.className.replace("bg-gray-50 text-gray-400", "bg-gray-100 text-gray-700")) : (t.disabled = !0, t.className.includes("opacity-50") || (t.className += " opacity-50 cursor-not-allowed"), t.className = t.className.replace("bg-gray-100 text-gray-700", "bg-gray-50 text-gray-400")), i !== null ? (e.disabled = !1, e.className = e.className.replace("opacity-50 cursor-not-allowed", ""), e.className = e.className.replace("bg-gray-50 text-gray-400", "bg-gray-100 text-gray-700")) : (e.disabled = !0, e.className.includes("opacity-50") || (e.className += " opacity-50 cursor-not-allowed"), e.className = e.className.replace("bg-gray-100 text-gray-700", "bg-gray-50 text-gray-400"));
}
// Get previous and next page numbers
getAdjacentPages() {
@@ -616,10 +622,10 @@ class Z extends HTMLElement {
return console.log("Container page:", l, "parsed:", c), c;
}).filter((s) => s !== null).sort((s, l) => s - l);
console.log("All pages found:", n), console.log("Current page:", this.currentPageNumber);
const o = n.indexOf(this.currentPageNumber);
console.log("Current index:", o);
const i = n.indexOf(this.currentPageNumber);
console.log("Current index:", i);
let r = null, a = null;
return o > 0 && (r = n[o - 1]), o < n.length - 1 && (a = n[o + 1]), console.log("Adjacent pages - prev:", r, "next:", a), { prevPage: r, nextPage: a };
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
goToPreviousPage() {
@@ -635,17 +641,25 @@ class Z extends HTMLElement {
navigateToPage(t) {
const e = this.currentIsBeilage ? '.newspaper-page-container[data-beilage="true"]' : ".newspaper-page-container:not([data-beilage])", n = document.querySelector(`${e}[data-page-container="${t}"]`);
if (n) {
const o = n.querySelector(".newspaper-page-image");
o && this.show(o.src, o.alt, t, this.currentIsBeilage);
const i = n.querySelector(".newspaper-page-image");
i && this.show(i.src, i.alt, t, this.currentIsBeilage);
}
}
// Toggle sidebar visibility
toggleSidebar() {
const t = this.querySelector("#sidebar-spacer"), e = this.querySelector("#sidebar-toggle-btn"), n = e.querySelector("i"), o = t.classList.contains("w-0");
console.log("Current state - isCollapsed:", o), console.log("Current classes:", t.className), o ? (t.classList.remove("w-0"), t.classList.add("lg:w-1/4", "xl:w-1/5"), 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-unfold-line text-lg font-bold", e.title = "Inhaltsverzeichnis ausblenden", console.log("Expanding sidebar")) : (t.classList.remove("lg:w-1/4", "xl:w-1/5"), t.classList.add("w-0"), 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-fold-line text-lg font-bold", e.title = "Inhaltsverzeichnis einblenden", console.log("Collapsing sidebar")), console.log("New classes:", t.className);
const t = this.querySelector("#sidebar-spacer"), e = this.querySelector("#sidebar-toggle-btn"), n = e.querySelector("i"), i = t.classList.contains("w-0");
console.log("Current state - isCollapsed:", i), console.log("Current classes:", t.className), i ? (t.classList.remove("w-0"), t.classList.add("lg:w-1/4", "xl:w-1/5"), 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-unfold-line text-lg font-bold", e.title = "Inhaltsverzeichnis ausblenden", console.log("Expanding sidebar")) : (t.classList.remove("lg:w-1/4", "xl:w-1/5"), t.classList.add("w-0"), 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-fold-line text-lg font-bold", e.title = "Inhaltsverzeichnis einblenden", console.log("Collapsing sidebar")), console.log("New classes:", t.className);
}
}
customElements.define("single-page-viewer", Z);
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());
});
window.addEventListener("beforeunload", function() {
const o = document.querySelector("single-page-viewer");
o && o.destroy();
});
export {
_ as setup
};

File diff suppressed because one or more lines are too long