mirror of
https://github.com/Theodor-Springmann-Stiftung/kgpz_web.git
synced 2025-10-29 09:05:30 +00:00
Single page view
This commit is contained in:
@@ -1,39 +1,39 @@
|
|||||||
const S = "script[xslt-onload]", w = "xslt-template", T = "xslt-transformed", f = /* @__PURE__ */ new Map();
|
const L = "script[xslt-onload]", w = "xslt-template", E = "xslt-transformed", y = /* @__PURE__ */ new Map();
|
||||||
function b() {
|
function v() {
|
||||||
let n = htmx.findAll(S);
|
let i = htmx.findAll(L);
|
||||||
for (let t of n)
|
for (let t of i)
|
||||||
A(t);
|
k(t);
|
||||||
}
|
}
|
||||||
function A(n) {
|
function k(i) {
|
||||||
if (n.getAttribute(T) === "true" || !n.hasAttribute(w))
|
if (i.getAttribute(E) === "true" || !i.hasAttribute(w))
|
||||||
return;
|
return;
|
||||||
let t = "#" + n.getAttribute(w), e = f.get(t);
|
let t = "#" + i.getAttribute(w), e = y.get(t);
|
||||||
if (!e) {
|
if (!e) {
|
||||||
let a = htmx.find(t);
|
let a = htmx.find(t);
|
||||||
if (a) {
|
if (a) {
|
||||||
let s = a.innerHTML ? new DOMParser().parseFromString(a.innerHTML, "application/xml") : a.contentDocument;
|
let s = a.innerHTML ? new DOMParser().parseFromString(a.innerHTML, "application/xml") : a.contentDocument;
|
||||||
e = new XSLTProcessor(), e.importStylesheet(s), f.set(t, e);
|
e = new XSLTProcessor(), e.importStylesheet(s), y.set(t, e);
|
||||||
} else
|
} else
|
||||||
throw new Error("Unknown XSLT template: " + t);
|
throw new Error("Unknown XSLT template: " + t);
|
||||||
}
|
}
|
||||||
let o = new DOMParser().parseFromString(n.innerHTML, "application/xml"), i = e.transformToFragment(o, document), r = new XMLSerializer().serializeToString(i);
|
let n = new DOMParser().parseFromString(i.innerHTML, "application/xml"), o = e.transformToFragment(n, document), r = new XMLSerializer().serializeToString(o);
|
||||||
n.outerHTML = r;
|
i.outerHTML = r;
|
||||||
}
|
}
|
||||||
function L() {
|
function q() {
|
||||||
document.querySelectorAll("template[simple]").forEach((t) => {
|
document.querySelectorAll("template[simple]").forEach((t) => {
|
||||||
let e = t.getAttribute("id"), o = t.content;
|
let e = t.getAttribute("id"), n = t.content;
|
||||||
customElements.define(
|
customElements.define(
|
||||||
e,
|
e,
|
||||||
class extends HTMLElement {
|
class extends HTMLElement {
|
||||||
constructor() {
|
constructor() {
|
||||||
super(), this.appendChild(o.cloneNode(!0)), this.slots = this.querySelectorAll("slot");
|
super(), this.appendChild(n.cloneNode(!0)), this.slots = this.querySelectorAll("slot");
|
||||||
}
|
}
|
||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
let i = [];
|
let o = [];
|
||||||
this.slots.forEach((r) => {
|
this.slots.forEach((r) => {
|
||||||
let a = r.getAttribute("name"), s = this.querySelector(`[slot="${a}"]`);
|
let a = r.getAttribute("name"), s = this.querySelector(`[slot="${a}"]`);
|
||||||
s && (r.replaceWith(s.cloneNode(!0)), i.push(s));
|
s && (r.replaceWith(s.cloneNode(!0)), o.push(s));
|
||||||
}), i.forEach((r) => {
|
}), o.forEach((r) => {
|
||||||
r.remove();
|
r.remove();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -48,61 +48,61 @@ window.pageObserver = window.pageObserver || null;
|
|||||||
window.scrollTimeout = window.scrollTimeout || null;
|
window.scrollTimeout = window.scrollTimeout || null;
|
||||||
function B() {
|
function B() {
|
||||||
window.highlightObserver && (window.highlightObserver.disconnect(), window.highlightObserver = null);
|
window.highlightObserver && (window.highlightObserver.disconnect(), window.highlightObserver = null);
|
||||||
const n = document.querySelectorAll(".newspaper-page-container");
|
const i = document.querySelectorAll(".newspaper-page-container");
|
||||||
window.highlightObserver = new IntersectionObserver(
|
window.highlightObserver = new IntersectionObserver(
|
||||||
(t) => {
|
(t) => {
|
||||||
x();
|
C();
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
rootMargin: "-20% 0px -70% 0px"
|
rootMargin: "-20% 0px -70% 0px"
|
||||||
}
|
}
|
||||||
), n.forEach((t) => {
|
), i.forEach((t) => {
|
||||||
window.highlightObserver.observe(t);
|
window.highlightObserver.observe(t);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function x() {
|
function C() {
|
||||||
const n = [];
|
const i = [];
|
||||||
document.querySelectorAll(".newspaper-page-container").forEach((e) => {
|
document.querySelectorAll(".newspaper-page-container").forEach((e) => {
|
||||||
const o = e.getBoundingClientRect(), i = window.innerHeight, r = Math.max(o.top, 0), a = Math.min(o.bottom, i), s = Math.max(0, a - r), l = o.height, g = s / l >= 0.5, u = e.querySelector("img[data-page]"), m = u ? u.getAttribute("data-page") : "unknown";
|
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 && m && !n.includes(m) && n.push(m);
|
g && u && f && !i.includes(f) && i.push(f);
|
||||||
}), q(n), n.length > 0 && E(n);
|
}), M(i), i.length > 0 && I(i);
|
||||||
}
|
}
|
||||||
function q(n) {
|
function M(i) {
|
||||||
document.querySelectorAll(".continuation-entry").forEach((t) => {
|
document.querySelectorAll(".continuation-entry").forEach((t) => {
|
||||||
t.style.display = "none";
|
t.style.display = "none";
|
||||||
}), n.forEach((t) => {
|
}), i.forEach((t) => {
|
||||||
const e = document.querySelector(`[data-page-container="${t}"]`);
|
const e = document.querySelector(`[data-page-container="${t}"]`);
|
||||||
e && e.querySelectorAll(".continuation-entry").forEach((i) => {
|
e && e.querySelectorAll(".continuation-entry").forEach((o) => {
|
||||||
i.style.display = "";
|
o.style.display = "";
|
||||||
});
|
});
|
||||||
}), k(n), M();
|
}), H(i), $();
|
||||||
}
|
}
|
||||||
function k(n) {
|
function H(i) {
|
||||||
document.querySelectorAll(".work-title").forEach((t) => {
|
document.querySelectorAll(".work-title").forEach((t) => {
|
||||||
const e = t.getAttribute("data-short-title");
|
const e = t.getAttribute("data-short-title");
|
||||||
e && (t.textContent = e);
|
e && (t.textContent = e);
|
||||||
}), n.forEach((t) => {
|
}), i.forEach((t) => {
|
||||||
const e = document.querySelector(`[data-page-container="${t}"]`);
|
const e = document.querySelector(`[data-page-container="${t}"]`);
|
||||||
e && e.querySelectorAll(".work-title").forEach((i) => {
|
e && e.querySelectorAll(".work-title").forEach((o) => {
|
||||||
const r = i.getAttribute("data-full-title");
|
const r = o.getAttribute("data-full-title");
|
||||||
r && r !== i.getAttribute("data-short-title") && (i.textContent = r);
|
r && r !== o.getAttribute("data-short-title") && (o.textContent = r);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function M() {
|
function $() {
|
||||||
document.querySelectorAll(".page-entry").forEach((n) => {
|
document.querySelectorAll(".page-entry").forEach((i) => {
|
||||||
const t = n.querySelectorAll(".inhalts-entry");
|
const t = i.querySelectorAll(".inhalts-entry");
|
||||||
let e = !1;
|
let e = !1;
|
||||||
t.forEach((o) => {
|
t.forEach((n) => {
|
||||||
window.getComputedStyle(o).display !== "none" && (e = !0);
|
window.getComputedStyle(n).display !== "none" && (e = !0);
|
||||||
}), e ? n.style.display = "" : n.style.display = "none";
|
}), e ? i.style.display = "" : i.style.display = "none";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function C(n) {
|
function S(i) {
|
||||||
E([n]);
|
I([i]);
|
||||||
}
|
}
|
||||||
function E(n) {
|
function I(i) {
|
||||||
console.log("markCurrentPagesInInhaltsverzeichnis called with:", n), document.querySelectorAll("[data-page-container]").forEach((e) => {
|
console.log("markCurrentPagesInInhaltsverzeichnis called with:", i), 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) => {
|
||||||
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");
|
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,62 +112,64 @@ function E(n) {
|
|||||||
e.classList.remove("no-underline"), e.classList.contains("bg-blue-50") && e.classList.add("hover:bg-blue-100");
|
e.classList.remove("no-underline"), e.classList.contains("bg-blue-50") && e.classList.add("hover:bg-blue-100");
|
||||||
});
|
});
|
||||||
const t = [];
|
const t = [];
|
||||||
n.forEach((e) => {
|
i.forEach((e) => {
|
||||||
const o = document.querySelector(
|
const n = document.querySelector(
|
||||||
`.page-number-inhalts[data-page-number="${e}"]`
|
`.page-number-inhalts[data-page-number="${e}"]`
|
||||||
);
|
);
|
||||||
if (o) {
|
if (n) {
|
||||||
o.classList.remove(
|
n.classList.remove(
|
||||||
"text-slate-700",
|
"text-slate-700",
|
||||||
"hover:bg-blue-100",
|
"hover:bg-blue-100",
|
||||||
"hover:bg-amber-100"
|
"hover:bg-amber-100"
|
||||||
), o.classList.add("text-red-600", "font-bold"), o.style.textDecoration = "none", o.style.pointerEvents = "none", t.push(o);
|
), n.classList.add("text-red-600", "font-bold"), n.style.textDecoration = "none", n.style.pointerEvents = "none", t.push(n);
|
||||||
const i = document.querySelector(`[data-page-container="${e}"]`);
|
const o = document.querySelector(`[data-page-container="${e}"]`);
|
||||||
i && (i.classList.remove("border-slate-300", "border-amber-400"), i.classList.add("border-red-500"));
|
o && (o.classList.remove("border-slate-300", "border-amber-400"), o.classList.add("border-red-500"));
|
||||||
const r = o.closest(".page-entry");
|
const r = n.closest(".page-entry");
|
||||||
r && (r.querySelectorAll(".inhalts-entry").forEach((s) => {
|
r && (r.querySelectorAll(".inhalts-entry").forEach((s) => {
|
||||||
s.classList.remove("hover:bg-slate-100"), s.style.cursor = "default";
|
s.classList.remove("hover:bg-slate-100"), s.style.cursor = "default";
|
||||||
}), r.querySelectorAll('a[href*="/"]').forEach((s) => {
|
}), r.querySelectorAll('a[href*="/"]').forEach((s) => {
|
||||||
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"));
|
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 && H(t[0]), document.querySelectorAll(".page-indicator").forEach((e) => {
|
}), t.length > 0 && N(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");
|
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");
|
||||||
}), n.forEach((e) => {
|
}), i.forEach((e) => {
|
||||||
const o = document.querySelector(`.page-indicator[data-page="${e}"]`);
|
const n = document.querySelector(`.page-indicator[data-page="${e}"]`);
|
||||||
o && (o.classList.remove("text-slate-600"), o.classList.add("text-red-600", "font-bold"));
|
n && (n.classList.remove("text-slate-600"), n.classList.add("text-red-600", "font-bold"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function H(n) {
|
function N(i) {
|
||||||
const t = n.closest(".lg\\:overflow-y-auto");
|
const t = i.closest(".lg\\:overflow-y-auto");
|
||||||
if (t) {
|
if (t) {
|
||||||
const e = t.getBoundingClientRect(), o = n.getBoundingClientRect(), i = o.top < e.top, r = o.bottom > e.bottom;
|
const e = t.getBoundingClientRect(), n = i.getBoundingClientRect(), o = n.top < e.top, r = n.bottom > e.bottom;
|
||||||
(i || r) && n.scrollIntoView({
|
(o || r) && i.scrollIntoView({
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
block: "center"
|
block: "center"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function R(n, t, e) {
|
function R(i, t, e) {
|
||||||
const o = document.getElementById("pageModal"), i = document.getElementById("modalImage");
|
let n = document.querySelector("single-page-viewer");
|
||||||
i.src = n.src, i.alt = n.alt, o.classList.remove("hidden"), C(t);
|
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);
|
||||||
}
|
}
|
||||||
function I() {
|
function T() {
|
||||||
document.getElementById("pageModal").classList.add("hidden");
|
document.getElementById("pageModal").classList.add("hidden");
|
||||||
}
|
}
|
||||||
function $() {
|
function O() {
|
||||||
if (window.pageObserver && (window.pageObserver.disconnect(), window.pageObserver = null), window.currentPageContainers = Array.from(
|
if (window.pageObserver && (window.pageObserver.disconnect(), window.pageObserver = null), window.currentPageContainers = Array.from(
|
||||||
document.querySelectorAll(".newspaper-page-container")
|
document.querySelectorAll(".newspaper-page-container")
|
||||||
), window.currentActiveIndex = 0, h(), document.querySelector(".newspaper-page-container")) {
|
), window.currentActiveIndex = 0, p(), 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) => {
|
||||||
if (e.forEach((o) => {
|
if (e.forEach((n) => {
|
||||||
const i = window.currentPageContainers.indexOf(o.target);
|
const o = window.currentPageContainers.indexOf(n.target);
|
||||||
i !== -1 && (o.isIntersecting ? t.add(i) : t.delete(i));
|
o !== -1 && (n.isIntersecting ? t.add(o) : t.delete(o));
|
||||||
}), t.size > 0) {
|
}), t.size > 0) {
|
||||||
const i = Array.from(t).sort((r, a) => r - a)[0];
|
const o = Array.from(t).sort((r, a) => r - a)[0];
|
||||||
i !== window.currentActiveIndex && (window.currentActiveIndex = i, h());
|
o !== window.currentActiveIndex && (window.currentActiveIndex = o, p());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -178,52 +180,52 @@ function $() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function O() {
|
function V() {
|
||||||
if (window.currentActiveIndex > 0) {
|
if (window.currentActiveIndex > 0) {
|
||||||
let n = -1;
|
let i = -1;
|
||||||
const t = [];
|
const t = [];
|
||||||
window.currentPageContainers.forEach((o, i) => {
|
window.currentPageContainers.forEach((n, o) => {
|
||||||
const r = o.getBoundingClientRect(), a = window.innerHeight, s = Math.max(r.top, 0), l = Math.min(r.bottom, a), d = Math.max(0, l - s), g = r.height;
|
const r = n.getBoundingClientRect(), a = window.innerHeight, s = Math.max(r.top, 0), l = Math.min(r.bottom, a), c = Math.max(0, l - s), g = r.height;
|
||||||
d / g >= 0.3 && t.push(i);
|
c / g >= 0.3 && t.push(o);
|
||||||
});
|
});
|
||||||
const e = Math.min(...t);
|
const e = Math.min(...t);
|
||||||
for (let o = e - 1; o >= 0; o--)
|
for (let n = e - 1; n >= 0; n--)
|
||||||
if (!t.includes(o)) {
|
if (!t.includes(n)) {
|
||||||
n = o;
|
i = n;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
n === -1 && e > 0 && (n = e - 1), n >= 0 && (window.currentActiveIndex = n, window.currentPageContainers[window.currentActiveIndex].scrollIntoView({
|
i === -1 && e > 0 && (i = e - 1), i >= 0 && (window.currentActiveIndex = i, window.currentPageContainers[window.currentActiveIndex].scrollIntoView({
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
block: "start"
|
block: "start"
|
||||||
}), setTimeout(() => {
|
}), setTimeout(() => {
|
||||||
h();
|
p();
|
||||||
}, 100));
|
}, 100));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function K() {
|
function K() {
|
||||||
if (window.currentActiveIndex < window.currentPageContainers.length - 1) {
|
if (window.currentActiveIndex < window.currentPageContainers.length - 1) {
|
||||||
let n = -1;
|
let i = -1;
|
||||||
const t = [];
|
const t = [];
|
||||||
window.currentPageContainers.forEach((o, i) => {
|
window.currentPageContainers.forEach((n, o) => {
|
||||||
const r = o.getBoundingClientRect(), a = window.innerHeight, s = Math.max(r.top, 0), l = Math.min(r.bottom, a), d = Math.max(0, l - s), g = r.height;
|
const r = n.getBoundingClientRect(), a = window.innerHeight, s = Math.max(r.top, 0), l = Math.min(r.bottom, a), c = Math.max(0, l - s), g = r.height;
|
||||||
d / g >= 0.3 && t.push(i);
|
c / g >= 0.3 && t.push(o);
|
||||||
});
|
});
|
||||||
const e = Math.max(...t);
|
const e = Math.max(...t);
|
||||||
for (let o = e + 1; o < window.currentPageContainers.length; o++)
|
for (let n = e + 1; n < window.currentPageContainers.length; n++)
|
||||||
if (!t.includes(o)) {
|
if (!t.includes(n)) {
|
||||||
n = o;
|
i = n;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
n === -1 && e < window.currentPageContainers.length - 1 && (n = e + 1), n >= 0 && n < window.currentPageContainers.length && (window.currentActiveIndex = n, window.currentPageContainers[window.currentActiveIndex].scrollIntoView({
|
i === -1 && e < window.currentPageContainers.length - 1 && (i = e + 1), i >= 0 && i < window.currentPageContainers.length && (window.currentActiveIndex = i, window.currentPageContainers[window.currentActiveIndex].scrollIntoView({
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
block: "start"
|
block: "start"
|
||||||
}), setTimeout(() => {
|
}), setTimeout(() => {
|
||||||
h();
|
p();
|
||||||
}, 100));
|
}, 100));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function V() {
|
function z() {
|
||||||
if (P()) {
|
if (A()) {
|
||||||
const t = document.querySelector("#newspaper-content .newspaper-page-container");
|
const t = document.querySelector("#newspaper-content .newspaper-page-container");
|
||||||
t && t.scrollIntoView({
|
t && t.scrollIntoView({
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
@@ -237,87 +239,87 @@ function V() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function P() {
|
function A() {
|
||||||
const n = [];
|
const i = [];
|
||||||
window.currentPageContainers.forEach((t, e) => {
|
window.currentPageContainers.forEach((t, e) => {
|
||||||
const o = t.getBoundingClientRect(), i = window.innerHeight, r = Math.max(o.top, 0), a = Math.min(o.bottom, i), s = Math.max(0, a - r), l = o.height;
|
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 && n.push(e);
|
s / l >= 0.3 && i.push(e);
|
||||||
});
|
});
|
||||||
for (const t of n) {
|
for (const t of i) {
|
||||||
const e = window.currentPageContainers[t];
|
const e = window.currentPageContainers[t];
|
||||||
if (e && e.id && e.id.includes("beilage-"))
|
if (e && e.id && e.id.includes("beilage-"))
|
||||||
return !0;
|
return !0;
|
||||||
}
|
}
|
||||||
return !1;
|
return !1;
|
||||||
}
|
}
|
||||||
function h() {
|
function p() {
|
||||||
const n = document.getElementById("prevPageBtn"), t = document.getElementById("nextPageBtn"), e = document.getElementById("beilageBtn");
|
const i = document.getElementById("prevPageBtn"), t = document.getElementById("nextPageBtn"), e = document.getElementById("beilageBtn");
|
||||||
if (n && (window.currentActiveIndex <= 0 ? n.style.display = "none" : n.style.display = "flex"), t && (window.currentActiveIndex >= window.currentPageContainers.length - 1 ? t.style.display = "none" : t.style.display = "flex"), e) {
|
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 o = P(), i = e.querySelector("i");
|
const n = A(), o = e.querySelector("i");
|
||||||
o ? (e.title = "Zur Hauptausgabe", e.className = "w-14 h-10 lg:w-16 lg:h-12 px-2 py-1 bg-gray-100 hover:bg-gray-200 text-gray-700 hover:text-gray-800 border border-gray-300 transition-colors duration-200 flex items-center justify-center cursor-pointer", i && (i.className = "ri-file-text-line text-lg lg:text-xl")) : (e.title = "Zu Beilage", e.className = "w-14 h-10 lg:w-16 lg:h-12 px-2 py-1 bg-amber-100 hover:bg-amber-200 text-amber-700 hover:text-amber-800 border border-amber-300 transition-colors duration-200 flex items-center justify-center cursor-pointer", i && (i.className = "ri-attachment-line text-lg lg:text-xl"));
|
n ? (e.title = "Zur Hauptausgabe", e.className = "w-14 h-10 lg:w-16 lg:h-12 px-2 py-1 bg-gray-100 hover:bg-gray-200 text-gray-700 hover:text-gray-800 border border-gray-300 transition-colors duration-200 flex items-center justify-center cursor-pointer", 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"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function D() {
|
function j() {
|
||||||
const n = document.getElementById("shareLinkBtn");
|
const i = document.getElementById("shareLinkBtn");
|
||||||
let t = "";
|
let t = "";
|
||||||
if (window.currentActiveIndex !== void 0 && window.currentPageContainers && window.currentPageContainers[window.currentActiveIndex]) {
|
if (window.currentActiveIndex !== void 0 && window.currentPageContainers && window.currentPageContainers[window.currentActiveIndex]) {
|
||||||
const i = window.currentPageContainers[window.currentActiveIndex].querySelector("[data-page]");
|
const o = window.currentPageContainers[window.currentActiveIndex].querySelector("[data-page]");
|
||||||
i && (t = `#page-${i.getAttribute("data-page")}`);
|
o && (t = `#page-${o.getAttribute("data-page")}`);
|
||||||
}
|
}
|
||||||
const e = window.location.origin + window.location.pathname + t;
|
const e = window.location.origin + window.location.pathname + t;
|
||||||
navigator.share ? navigator.share({
|
navigator.share ? navigator.share({
|
||||||
title: document.title,
|
title: document.title,
|
||||||
url: e
|
url: e
|
||||||
}).catch((o) => {
|
}).catch((n) => {
|
||||||
y(e, n);
|
x(e, i);
|
||||||
}) : y(e, n);
|
}) : x(e, i);
|
||||||
}
|
}
|
||||||
function y(n, t) {
|
function x(i, t) {
|
||||||
if (navigator.clipboard)
|
if (navigator.clipboard)
|
||||||
navigator.clipboard.writeText(n).then(() => {
|
navigator.clipboard.writeText(i).then(() => {
|
||||||
c(t, "Link kopiert!");
|
d(t, "Link kopiert!");
|
||||||
}).catch((e) => {
|
}).catch((e) => {
|
||||||
c(t, "Kopieren fehlgeschlagen");
|
d(t, "Kopieren fehlgeschlagen");
|
||||||
});
|
});
|
||||||
else {
|
else {
|
||||||
const e = document.createElement("textarea");
|
const e = document.createElement("textarea");
|
||||||
e.value = n, document.body.appendChild(e), e.select();
|
e.value = i, document.body.appendChild(e), e.select();
|
||||||
try {
|
try {
|
||||||
const o = document.execCommand("copy");
|
const n = document.execCommand("copy");
|
||||||
c(t, o ? "Link kopiert!" : "Kopieren fehlgeschlagen");
|
d(t, n ? "Link kopiert!" : "Kopieren fehlgeschlagen");
|
||||||
} catch {
|
} catch {
|
||||||
c(t, "Kopieren fehlgeschlagen");
|
d(t, "Kopieren fehlgeschlagen");
|
||||||
} finally {
|
} finally {
|
||||||
document.body.removeChild(e);
|
document.body.removeChild(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function Z() {
|
function D() {
|
||||||
const n = document.getElementById("citationBtn"), t = document.title || "KGPZ", e = window.location.href, o = (/* @__PURE__ */ new Date()).toLocaleDateString("de-DE"), i = `Königsberger Gelehrte und Politische Zeitung (KGPZ). ${t}. Digital verfügbar unter: ${e} (Zugriff: ${o}).`;
|
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}).`;
|
||||||
if (navigator.clipboard)
|
if (navigator.clipboard)
|
||||||
navigator.clipboard.writeText(i).then(() => {
|
navigator.clipboard.writeText(o).then(() => {
|
||||||
c(n, "Zitation kopiert!");
|
d(i, "Zitation kopiert!");
|
||||||
}).catch((r) => {
|
}).catch((r) => {
|
||||||
c(n, "Kopieren fehlgeschlagen");
|
d(i, "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 = o, document.body.appendChild(r), r.select();
|
||||||
try {
|
try {
|
||||||
const a = document.execCommand("copy");
|
const a = document.execCommand("copy");
|
||||||
c(n, a ? "Zitation kopiert!" : "Kopieren fehlgeschlagen");
|
d(i, a ? "Zitation kopiert!" : "Kopieren fehlgeschlagen");
|
||||||
} catch {
|
} catch {
|
||||||
c(n, "Kopieren fehlgeschlagen");
|
d(i, "Kopieren fehlgeschlagen");
|
||||||
} finally {
|
} finally {
|
||||||
document.body.removeChild(r);
|
document.body.removeChild(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function c(n, t) {
|
function d(i, t) {
|
||||||
const e = document.querySelector(".simple-popup");
|
const e = document.querySelector(".simple-popup");
|
||||||
e && e.remove();
|
e && e.remove();
|
||||||
const o = document.createElement("div");
|
const n = document.createElement("div");
|
||||||
o.className = "simple-popup", o.textContent = t, o.style.cssText = `
|
n.className = "simple-popup", n.textContent = t, n.style.cssText = `
|
||||||
position: fixed;
|
position: fixed;
|
||||||
background: #374151;
|
background: #374151;
|
||||||
color: white;
|
color: white;
|
||||||
@@ -331,125 +333,319 @@ function c(n, t) {
|
|||||||
transition: opacity 0.2s ease;
|
transition: opacity 0.2s ease;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
`;
|
`;
|
||||||
const i = n.getBoundingClientRect(), r = window.innerHeight, a = window.innerWidth;
|
const o = i.getBoundingClientRect(), r = window.innerHeight, a = window.innerWidth;
|
||||||
let s = i.left - 10, l = i.bottom + 8;
|
let s = o.left - 10, l = o.bottom + 8;
|
||||||
const d = 120, g = 32;
|
const c = 120, g = 32;
|
||||||
s + d > a && (s = i.right - d + 10), l + g > r && (l = i.top - g - 8), o.style.left = Math.max(5, s) + "px", o.style.top = Math.max(5, l) + "px", document.body.appendChild(o), setTimeout(() => {
|
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(() => {
|
||||||
o.style.opacity = "1";
|
n.style.opacity = "1";
|
||||||
}, 10), setTimeout(() => {
|
}, 10), setTimeout(() => {
|
||||||
o.style.opacity = "0", setTimeout(() => {
|
n.style.opacity = "0", setTimeout(() => {
|
||||||
o.parentNode && o.remove();
|
n.parentNode && n.remove();
|
||||||
}, 200);
|
}, 200);
|
||||||
}, 2e3);
|
}, 2e3);
|
||||||
}
|
}
|
||||||
function v() {
|
function P() {
|
||||||
const n = window.location.hash;
|
const i = window.location.hash;
|
||||||
let t = "", e = null;
|
let t = "", e = null;
|
||||||
if (n.startsWith("#page-")) {
|
if (i.startsWith("#page-")) {
|
||||||
if (t = n.replace("#page-", ""), e = document.getElementById(`page-${t}`), !e) {
|
if (t = i.replace("#page-", ""), e = document.getElementById(`page-${t}`), !e) {
|
||||||
const o = document.querySelectorAll(".newspaper-page-container[data-pages]");
|
const n = document.querySelectorAll(".newspaper-page-container[data-pages]");
|
||||||
for (const i of o) {
|
for (const o of n) {
|
||||||
const r = i.getAttribute("data-pages");
|
const r = o.getAttribute("data-pages");
|
||||||
if (r && r.split(",").includes(t)) {
|
if (r && r.split(",").includes(t)) {
|
||||||
e = i;
|
e = o;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
e || (e = document.getElementById(`beilage-1-page-${t}`) || document.getElementById(`beilage-2-page-${t}`) || document.querySelector(`[id*="beilage"][id*="page-${t}"]`));
|
e || (e = document.getElementById(`beilage-1-page-${t}`) || document.getElementById(`beilage-2-page-${t}`) || document.querySelector(`[id*="beilage"][id*="page-${t}"]`));
|
||||||
} else if (n.startsWith("#beilage-")) {
|
} else if (i.startsWith("#beilage-")) {
|
||||||
const o = n.match(/#beilage-(\d+)-page-(\d+)/);
|
const n = i.match(/#beilage-(\d+)-page-(\d+)/);
|
||||||
if (o) {
|
if (n) {
|
||||||
const i = o[1];
|
const o = n[1];
|
||||||
t = o[2], e = document.getElementById(`beilage-${i}-page-${t}`);
|
t = n[2], e = document.getElementById(`beilage-${o}-page-${t}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
e && t && setTimeout(() => {
|
e && t && setTimeout(() => {
|
||||||
e.scrollIntoView({
|
e.scrollIntoView({
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
block: "start"
|
block: "start"
|
||||||
}), C(t);
|
}), S(t);
|
||||||
}, 300);
|
}, 300);
|
||||||
}
|
}
|
||||||
function z(n, t, e = !1) {
|
function b(i, t, e = !1) {
|
||||||
let o = "";
|
let n = "";
|
||||||
e ? o = `#beilage-1-page-${n}` : o = `#page-${n}`;
|
e ? n = `#beilage-1-page-${i}` : n = `#page-${i}`;
|
||||||
const i = window.location.origin + window.location.pathname + o;
|
const o = window.location.origin + window.location.pathname + n;
|
||||||
if (navigator.clipboard)
|
if (navigator.clipboard)
|
||||||
navigator.clipboard.writeText(i).then(() => {
|
navigator.clipboard.writeText(o).then(() => {
|
||||||
c(t, "Link kopiert!");
|
d(t, "Link kopiert!");
|
||||||
}).catch((r) => {
|
}).catch((r) => {
|
||||||
c(t, "Kopieren fehlgeschlagen");
|
d(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 = o, document.body.appendChild(r), r.select();
|
||||||
try {
|
try {
|
||||||
const a = document.execCommand("copy");
|
const a = document.execCommand("copy");
|
||||||
c(t, a ? "Link kopiert!" : "Kopieren fehlgeschlagen");
|
d(t, a ? "Link kopiert!" : "Kopieren fehlgeschlagen");
|
||||||
} catch {
|
} catch {
|
||||||
c(t, "Kopieren fehlgeschlagen");
|
d(t, "Kopieren fehlgeschlagen");
|
||||||
} finally {
|
} finally {
|
||||||
document.body.removeChild(r);
|
document.body.removeChild(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function _(n, t) {
|
function m(i, t) {
|
||||||
const e = document.title || "KGPZ", o = `${window.location.origin}${window.location.pathname}#page-${n}`, i = (/* @__PURE__ */ new Date()).toLocaleDateString("de-DE"), r = `Königsberger Gelehrte und Politische Zeitung (KGPZ). ${e}, Seite ${n}. Digital verfügbar unter: ${o} (Zugriff: ${i}).`;
|
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}).`;
|
||||||
if (navigator.clipboard)
|
if (navigator.clipboard)
|
||||||
navigator.clipboard.writeText(r).then(() => {
|
navigator.clipboard.writeText(r).then(() => {
|
||||||
c(t, "Zitation kopiert!");
|
d(t, "Zitation kopiert!");
|
||||||
}).catch((a) => {
|
}).catch((a) => {
|
||||||
c(t, "Kopieren fehlgeschlagen");
|
d(t, "Kopieren fehlgeschlagen");
|
||||||
});
|
});
|
||||||
else {
|
else {
|
||||||
const a = document.createElement("textarea");
|
const a = document.createElement("textarea");
|
||||||
a.value = r, document.body.appendChild(a), a.select();
|
a.value = r, document.body.appendChild(a), a.select();
|
||||||
try {
|
try {
|
||||||
const s = document.execCommand("copy");
|
const s = document.execCommand("copy");
|
||||||
c(t, s ? "Zitation kopiert!" : "Kopieren fehlgeschlagen");
|
d(t, s ? "Zitation kopiert!" : "Kopieren fehlgeschlagen");
|
||||||
} catch {
|
} catch {
|
||||||
c(t, "Kopieren fehlgeschlagen");
|
d(t, "Kopieren fehlgeschlagen");
|
||||||
} finally {
|
} finally {
|
||||||
document.body.removeChild(a);
|
document.body.removeChild(a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function p() {
|
function h() {
|
||||||
B(), $(), window.addEventListener("scroll", function() {
|
B(), O(), window.addEventListener("scroll", function() {
|
||||||
clearTimeout(window.scrollTimeout), window.scrollTimeout = setTimeout(() => {
|
clearTimeout(window.scrollTimeout), window.scrollTimeout = setTimeout(() => {
|
||||||
x(), h();
|
C(), p();
|
||||||
}, 50);
|
}, 50);
|
||||||
}), v(), window.addEventListener("hashchange", v), document.addEventListener("keydown", function(n) {
|
}), P(), window.addEventListener("hashchange", P), document.addEventListener("keydown", function(i) {
|
||||||
n.key === "Escape" && I();
|
i.key === "Escape" && T();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
window.enlargePage = R;
|
window.enlargePage = R;
|
||||||
window.closeModal = I;
|
window.closeModal = T;
|
||||||
window.scrollToPreviousPage = O;
|
window.scrollToPreviousPage = V;
|
||||||
window.scrollToNextPage = K;
|
window.scrollToNextPage = K;
|
||||||
window.scrollToBeilage = V;
|
window.scrollToBeilage = z;
|
||||||
window.shareCurrentPage = D;
|
window.shareCurrentPage = j;
|
||||||
window.generateCitation = Z;
|
window.generateCitation = D;
|
||||||
window.copyPagePermalink = z;
|
window.copyPagePermalink = b;
|
||||||
window.generatePageCitation = _;
|
window.generatePageCitation = m;
|
||||||
function F() {
|
function _() {
|
||||||
b(), L(), document.querySelector(".newspaper-page-container") && p(), htmx.on("htmx:load", function(n) {
|
v(), q(), document.querySelector(".newspaper-page-container") && h(), htmx.on("htmx:load", function(i) {
|
||||||
b();
|
v();
|
||||||
}), document.body.addEventListener("htmx:afterSwap", function(n) {
|
}), document.body.addEventListener("htmx:afterSwap", function(i) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
document.querySelector(".newspaper-page-container") && p();
|
document.querySelector(".newspaper-page-container") && h();
|
||||||
}, 100);
|
}, 100);
|
||||||
}), document.body.addEventListener("htmx:afterSettle", function(n) {
|
}), document.body.addEventListener("htmx:afterSettle", function(i) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
document.querySelector(".newspaper-page-container") && p();
|
document.querySelector(".newspaper-page-container") && h();
|
||||||
}, 200);
|
}, 200);
|
||||||
}), document.body.addEventListener("htmx:load", function(n) {
|
}), document.body.addEventListener("htmx:load", function(i) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
document.querySelector(".newspaper-page-container") && p();
|
document.querySelector(".newspaper-page-container") && h();
|
||||||
}, 100);
|
}, 100);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
class Z extends HTMLElement {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
connectedCallback() {
|
||||||
|
this.innerHTML = `
|
||||||
|
<div class="fixed inset-0 z-50 flex">
|
||||||
|
<!-- 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="relative min-h-full flex flex-col">
|
||||||
|
<!-- Header with page info and buttons -->
|
||||||
|
<div class="flex items-center justify-between p-4">
|
||||||
|
<!-- Left: Sidebar toggle and page indicator -->
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<!-- Sidebar toggle button -->
|
||||||
|
<button
|
||||||
|
id="sidebar-toggle-btn"
|
||||||
|
onclick="this.closest('single-page-viewer').toggleSidebar()"
|
||||||
|
class="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"
|
||||||
|
title="Inhaltsverzeichnis ein-/ausblenden">
|
||||||
|
<i class="ri-sidebar-unfold-line text-lg font-bold"></i>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<!-- Page indicator with icon -->
|
||||||
|
<div id="page-indicator" class="text-slate-800 flex items-center gap-3">
|
||||||
|
<span id="page-icon" class="text-lg"></span>
|
||||||
|
<span id="page-number" class="text-2xl font-serif font-bold"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Right: Action buttons -->
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<!-- Previous page button -->
|
||||||
|
<button
|
||||||
|
id="prev-page-btn"
|
||||||
|
onclick="this.closest('single-page-viewer').goToPreviousPage()"
|
||||||
|
class="w-10 h-10 bg-gray-100 hover:bg-gray-200 text-gray-700 border border-gray-300 rounded flex items-center justify-center transition-colors duration-200 cursor-pointer"
|
||||||
|
title="Vorherige Seite">
|
||||||
|
<i class="ri-arrow-left-line text-lg font-bold"></i>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<!-- Next page button -->
|
||||||
|
<button
|
||||||
|
id="next-page-btn"
|
||||||
|
onclick="this.closest('single-page-viewer').goToNextPage()"
|
||||||
|
class="w-10 h-10 bg-gray-100 hover:bg-gray-200 text-gray-700 border border-gray-300 rounded flex items-center justify-center transition-colors duration-200 cursor-pointer"
|
||||||
|
title="Nächste Seite">
|
||||||
|
<i class="ri-arrow-right-line text-lg font-bold"></i>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<!-- Separator -->
|
||||||
|
<div class="w-px h-6 bg-gray-300"></div>
|
||||||
|
|
||||||
|
<!-- Share button -->
|
||||||
|
<button
|
||||||
|
id="share-btn"
|
||||||
|
onclick="this.closest('single-page-viewer').shareCurrentPage()"
|
||||||
|
class="w-10 h-10 bg-blue-100 hover:bg-blue-200 text-blue-700 border border-blue-300 rounded flex items-center justify-center transition-colors duration-200 cursor-pointer"
|
||||||
|
title="Link zu dieser Seite kopieren">
|
||||||
|
<i class="ri-share-line text-lg font-bold"></i>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<!-- Cite button -->
|
||||||
|
<button
|
||||||
|
id="cite-btn"
|
||||||
|
onclick="this.closest('single-page-viewer').generatePageCitation()"
|
||||||
|
class="w-10 h-10 bg-green-100 hover:bg-green-200 text-green-700 border border-green-300 rounded flex items-center justify-center transition-colors duration-200 cursor-pointer"
|
||||||
|
title="Zitation für diese Seite generieren">
|
||||||
|
<i class="ri-file-text-line text-lg font-bold"></i>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<!-- Close button -->
|
||||||
|
<button
|
||||||
|
onclick="this.closest('single-page-viewer').close()"
|
||||||
|
class="w-10 h-10 bg-gray-100 hover:bg-gray-200 text-gray-700 border border-gray-300 rounded flex items-center justify-center transition-colors duration-200 cursor-pointer"
|
||||||
|
title="Schließen">
|
||||||
|
<i class="ri-close-line text-lg font-bold"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Image container that can scroll -->
|
||||||
|
<div class="flex-1 flex items-center justify-center p-4 pb-8">
|
||||||
|
<img
|
||||||
|
id="single-page-image"
|
||||||
|
src=""
|
||||||
|
alt=""
|
||||||
|
class="w-full h-auto rounded-lg shadow-2xl"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
show(t, e, n, o = !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);
|
||||||
|
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 = "";
|
||||||
|
}
|
||||||
|
// 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) => {
|
||||||
|
const c = l.getAttribute("data-page-container");
|
||||||
|
return c ? parseInt(c) : null;
|
||||||
|
}).filter((l) => l !== null).sort((l, c) => l - c);
|
||||||
|
if (r.length === 0)
|
||||||
|
return "first";
|
||||||
|
const a = r[0], s = r[r.length - 1];
|
||||||
|
return t === a ? "first" : t === s ? "last" : t === a + 1 ? "even" : t === s - 1 ? "odd" : t % 2 === 0 ? "even" : "odd";
|
||||||
|
}
|
||||||
|
// Generate page icon HTML based on type (same as Go PageIcon function)
|
||||||
|
getPageIconHTML(t) {
|
||||||
|
const e = "ri-file-text-line text-lg";
|
||||||
|
switch (t) {
|
||||||
|
case "first":
|
||||||
|
return `<i class="${e} text-black"></i>`;
|
||||||
|
case "last":
|
||||||
|
return `<i class="${e} text-black" style="transform: scaleX(-1); display: inline-block;"></i>`;
|
||||||
|
case "even":
|
||||||
|
return `<i class="${e} text-black" style="margin-left: 2px; transform: scaleX(-1); display: inline-block;"></i><i class="${e} text-slate-400"></i>`;
|
||||||
|
case "odd":
|
||||||
|
return `<i class="${e} text-slate-400" style="margin-left: 2px; transform: scaleX(-1); display: inline-block;"></i><i class="${e} text-black"></i>`;
|
||||||
|
default:
|
||||||
|
return `<i class="${e} text-black"></i>`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Share current page
|
||||||
|
shareCurrentPage() {
|
||||||
|
if (typeof b == "function") {
|
||||||
|
const t = this.querySelector("#share-btn");
|
||||||
|
b(this.currentPageNumber, t, this.currentIsBeilage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Generate citation for current page
|
||||||
|
generatePageCitation() {
|
||||||
|
if (typeof m == "function") {
|
||||||
|
const t = this.querySelector("#cite-btn");
|
||||||
|
m(this.currentPageNumber, t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 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"));
|
||||||
|
}
|
||||||
|
// Get previous and next page numbers
|
||||||
|
getAdjacentPages() {
|
||||||
|
let t;
|
||||||
|
this.currentIsBeilage ? t = '.newspaper-page-container[data-beilage="true"]' : t = ".newspaper-page-container:not([data-beilage])";
|
||||||
|
const e = Array.from(document.querySelectorAll(t));
|
||||||
|
console.log("Found containers:", e.length, "for", this.currentIsBeilage ? "beilage" : "main");
|
||||||
|
const n = e.map((s) => {
|
||||||
|
const l = s.getAttribute("data-page-container"), c = l ? parseInt(l) : null;
|
||||||
|
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);
|
||||||
|
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 };
|
||||||
|
}
|
||||||
|
// Navigate to previous page
|
||||||
|
goToPreviousPage() {
|
||||||
|
const { prevPage: t } = this.getAdjacentPages();
|
||||||
|
t !== null && this.navigateToPage(t);
|
||||||
|
}
|
||||||
|
// Navigate to next page
|
||||||
|
goToNextPage() {
|
||||||
|
const { nextPage: t } = this.getAdjacentPages();
|
||||||
|
t !== null && this.navigateToPage(t);
|
||||||
|
}
|
||||||
|
// Navigate to a specific page
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
customElements.define("single-page-viewer", Z);
|
||||||
export {
|
export {
|
||||||
F as setup
|
_ as setup
|
||||||
};
|
};
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -248,7 +248,7 @@
|
|||||||
{{- if (or (eq $agentref.Category "") (eq $agentref.Category "autor")) -}}
|
{{- if (or (eq $agentref.Category "") (eq $agentref.Category "autor")) -}}
|
||||||
{{- $agent := GetAgent $agentref.Ref -}}
|
{{- $agent := GetAgent $agentref.Ref -}}
|
||||||
{{- if and $agent (gt (len $agent.Names) 0) -}}
|
{{- if and $agent (gt (len $agent.Names) 0) -}}
|
||||||
<a href="/akteure/{{ $agentref.Ref }}" class="author-link text-slate-700 hover:text-slate-900 underline decoration-slate-400 hover:decoration-slate-600">{{ index $agent.Names 0 }}</a>,
|
{{ Safe $fortsPrefix }}<a href="/akteure/{{ $agentref.Ref }}" class="author-link text-slate-700 hover:text-slate-900 underline decoration-slate-400 hover:decoration-slate-600">{{ index $agent.Names 0 }}</a>,
|
||||||
{{ if $hasKommentar }}
|
{{ if $hasKommentar }}
|
||||||
Gedicht mit Kommentar
|
Gedicht mit Kommentar
|
||||||
{{ else if $hasUebersetzung }}
|
{{ else if $hasUebersetzung }}
|
||||||
@@ -264,7 +264,7 @@
|
|||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- if not $authorFound -}}
|
{{- if not $authorFound -}}
|
||||||
{{ if $hasKommentar }}
|
{{ Safe $fortsPrefix }}{{ if $hasKommentar }}
|
||||||
Gedicht mit Kommentar
|
Gedicht mit Kommentar
|
||||||
{{ else if $hasUebersetzung }}
|
{{ else if $hasUebersetzung }}
|
||||||
Gedichtübersetzung
|
Gedichtübersetzung
|
||||||
|
|||||||
@@ -127,7 +127,7 @@
|
|||||||
{{ $linkPrefix = "#page-" }}
|
{{ $linkPrefix = "#page-" }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
<div class="newspaper-page-container" id="{{ $idPrefix }}-{{ $page.PageNumber }}">
|
<div class="newspaper-page-container" id="{{ $idPrefix }}-{{ $page.PageNumber }}" data-page-container="{{ $page.PageNumber }}"{{ if $isBeilage }} data-beilage="true"{{ end }}>
|
||||||
<!-- Page indicator row -->
|
<!-- Page indicator row -->
|
||||||
<div class="flex {{ if $isLeft }}justify-end{{ else }}justify-start{{ end }} items-center gap-1 mb-2">
|
<div class="flex {{ if $isLeft }}justify-end{{ else }}justify-start{{ end }} items-center gap-1 mb-2">
|
||||||
{{ if $isLeft }}
|
{{ if $isLeft }}
|
||||||
@@ -138,6 +138,9 @@
|
|||||||
<button onclick="generatePageCitation('{{ $page.PageNumber }}', this)" class="w-6 h-6 bg-green-100 hover:bg-green-200 text-green-700 border border-green-300 rounded flex items-center justify-center transition-colors duration-200 cursor-pointer" title="Zitation für Seite {{ $page.PageNumber }} generieren">
|
<button onclick="generatePageCitation('{{ $page.PageNumber }}', this)" class="w-6 h-6 bg-green-100 hover:bg-green-200 text-green-700 border border-green-300 rounded flex items-center justify-center transition-colors duration-200 cursor-pointer" title="Zitation für Seite {{ $page.PageNumber }} generieren">
|
||||||
<i class="ri-file-text-line text-xs"></i>
|
<i class="ri-file-text-line text-xs"></i>
|
||||||
</button>
|
</button>
|
||||||
|
<button onclick="enlargePage(document.querySelector('#{{ $idPrefix }}-{{ $page.PageNumber }} .newspaper-page-image'), {{ $page.PageNumber }}, false)" class="w-6 h-6 bg-purple-100 hover:bg-purple-200 text-purple-700 border border-purple-300 rounded flex items-center justify-center transition-colors duration-200 cursor-pointer" title="Seite {{ $page.PageNumber }} vergrößern">
|
||||||
|
<i class="ri-zoom-in-line text-xs"></i>
|
||||||
|
</button>
|
||||||
<span class="page-indicator text-sm font-bold text-slate-600 {{ $bgColor }} px-2 py-1 rounded transition-all duration-300 shadow-sm flex items-center gap-1" data-page="{{ $page.PageNumber }}">
|
<span class="page-indicator text-sm font-bold text-slate-600 {{ $bgColor }} px-2 py-1 rounded transition-all duration-300 shadow-sm flex items-center gap-1" data-page="{{ $page.PageNumber }}">
|
||||||
{{ $page.PageNumber }}
|
{{ $page.PageNumber }}
|
||||||
<i class="ri-file-text-line {{ if $isBeilage }}text-amber-600{{ else }}text-black{{ end }} text-sm scale-x-[-1]"></i>
|
<i class="ri-file-text-line {{ if $isBeilage }}text-amber-600{{ else }}text-black{{ end }} text-sm scale-x-[-1]"></i>
|
||||||
@@ -154,10 +157,13 @@
|
|||||||
<button onclick="generatePageCitation('{{ $page.PageNumber }}', this)" class="w-6 h-6 bg-green-100 hover:bg-green-200 text-green-700 border border-green-300 rounded flex items-center justify-center transition-colors duration-200 cursor-pointer" title="Zitation für Seite {{ $page.PageNumber }} generieren">
|
<button onclick="generatePageCitation('{{ $page.PageNumber }}', this)" class="w-6 h-6 bg-green-100 hover:bg-green-200 text-green-700 border border-green-300 rounded flex items-center justify-center transition-colors duration-200 cursor-pointer" title="Zitation für Seite {{ $page.PageNumber }} generieren">
|
||||||
<i class="ri-file-text-line text-xs"></i>
|
<i class="ri-file-text-line text-xs"></i>
|
||||||
</button>
|
</button>
|
||||||
|
<button onclick="enlargePage(document.querySelector('#{{ $idPrefix }}-{{ $page.PageNumber }} .newspaper-page-image'), {{ $page.PageNumber }}, false)" class="w-6 h-6 bg-purple-100 hover:bg-purple-200 text-purple-700 border border-purple-300 rounded flex items-center justify-center transition-colors duration-200 cursor-pointer" title="Seite {{ $page.PageNumber }} vergrößern">
|
||||||
|
<i class="ri-zoom-in-line text-xs"></i>
|
||||||
|
</button>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
<div class="single-page bg-white p-4 rounded border {{ $borderColor }} {{ $hoverColor }} transition-colors duration-200">
|
<div class="single-page bg-white p-4 rounded border {{ $borderColor }} {{ $hoverColor }} transition-colors duration-200">
|
||||||
<img src="{{ $page.ImagePath }}" alt="{{ if $isBeilage }}Beilage 1, {{ end }}Seite {{ $page.PageNumber }}" class="newspaper-page-image cursor-pointer rounded-sm hover:scale-[1.02] transition-transform duration-200" onclick="enlargePage(this, {{ $page.PageNumber }}, false)" data-page="{{ $page.PageNumber }}" loading="lazy" />
|
<img src="{{ $page.ImagePath }}" alt="{{ if $isBeilage }}Beilage 1, {{ end }}Seite {{ $page.PageNumber }}" class="newspaper-page-image cursor-zoom-in rounded-sm hover:scale-[1.02] transition-transform duration-200" onclick="enlargePage(this, {{ $page.PageNumber }}, false)" data-page="{{ $page.PageNumber }}" loading="lazy" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|||||||
@@ -369,16 +369,18 @@ function scrollToHighlightedPage(element) {
|
|||||||
|
|
||||||
// Modal functions
|
// Modal functions
|
||||||
function enlargePage(imgElement, pageNumber, isFromSpread) {
|
function enlargePage(imgElement, pageNumber, isFromSpread) {
|
||||||
const modal = document.getElementById("pageModal");
|
// Get or create the single page viewer component
|
||||||
const modalImage = document.getElementById("modalImage");
|
let viewer = document.querySelector('single-page-viewer');
|
||||||
|
if (!viewer) {
|
||||||
|
viewer = document.createElement('single-page-viewer');
|
||||||
|
document.body.appendChild(viewer);
|
||||||
|
}
|
||||||
|
|
||||||
modalImage.src = imgElement.src;
|
// Determine if this is a beilage page
|
||||||
modalImage.alt = imgElement.alt;
|
const isBeilage = imgElement.closest('[data-beilage="true"]') !== null;
|
||||||
|
|
||||||
modal.classList.remove("hidden");
|
// Show the page in the viewer
|
||||||
|
viewer.show(imgElement.src, imgElement.alt, pageNumber, isBeilage);
|
||||||
// Mark current page when enlarged
|
|
||||||
markCurrentPageInInhaltsverzeichnis(pageNumber);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeModal() {
|
function closeModal() {
|
||||||
@@ -1031,4 +1033,378 @@ function setup() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Single Page Viewer Web Component
|
||||||
|
class SinglePageViewer extends HTMLElement {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
// No shadow DOM - use regular DOM to allow Tailwind CSS
|
||||||
|
}
|
||||||
|
|
||||||
|
connectedCallback() {
|
||||||
|
this.innerHTML = `
|
||||||
|
<div class="fixed inset-0 z-50 flex">
|
||||||
|
<!-- 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="relative min-h-full flex flex-col">
|
||||||
|
<!-- Header with page info and buttons -->
|
||||||
|
<div class="flex items-center justify-between p-4">
|
||||||
|
<!-- Left: Sidebar toggle and page indicator -->
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<!-- Sidebar toggle button -->
|
||||||
|
<button
|
||||||
|
id="sidebar-toggle-btn"
|
||||||
|
onclick="this.closest('single-page-viewer').toggleSidebar()"
|
||||||
|
class="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"
|
||||||
|
title="Inhaltsverzeichnis ein-/ausblenden">
|
||||||
|
<i class="ri-sidebar-unfold-line text-lg font-bold"></i>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<!-- Page indicator with icon -->
|
||||||
|
<div id="page-indicator" class="text-slate-800 flex items-center gap-3">
|
||||||
|
<span id="page-icon" class="text-lg"></span>
|
||||||
|
<span id="page-number" class="text-2xl font-serif font-bold"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Right: Action buttons -->
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<!-- Previous page button -->
|
||||||
|
<button
|
||||||
|
id="prev-page-btn"
|
||||||
|
onclick="this.closest('single-page-viewer').goToPreviousPage()"
|
||||||
|
class="w-10 h-10 bg-gray-100 hover:bg-gray-200 text-gray-700 border border-gray-300 rounded flex items-center justify-center transition-colors duration-200 cursor-pointer"
|
||||||
|
title="Vorherige Seite">
|
||||||
|
<i class="ri-arrow-left-line text-lg font-bold"></i>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<!-- Next page button -->
|
||||||
|
<button
|
||||||
|
id="next-page-btn"
|
||||||
|
onclick="this.closest('single-page-viewer').goToNextPage()"
|
||||||
|
class="w-10 h-10 bg-gray-100 hover:bg-gray-200 text-gray-700 border border-gray-300 rounded flex items-center justify-center transition-colors duration-200 cursor-pointer"
|
||||||
|
title="Nächste Seite">
|
||||||
|
<i class="ri-arrow-right-line text-lg font-bold"></i>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<!-- Separator -->
|
||||||
|
<div class="w-px h-6 bg-gray-300"></div>
|
||||||
|
|
||||||
|
<!-- Share button -->
|
||||||
|
<button
|
||||||
|
id="share-btn"
|
||||||
|
onclick="this.closest('single-page-viewer').shareCurrentPage()"
|
||||||
|
class="w-10 h-10 bg-blue-100 hover:bg-blue-200 text-blue-700 border border-blue-300 rounded flex items-center justify-center transition-colors duration-200 cursor-pointer"
|
||||||
|
title="Link zu dieser Seite kopieren">
|
||||||
|
<i class="ri-share-line text-lg font-bold"></i>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<!-- Cite button -->
|
||||||
|
<button
|
||||||
|
id="cite-btn"
|
||||||
|
onclick="this.closest('single-page-viewer').generatePageCitation()"
|
||||||
|
class="w-10 h-10 bg-green-100 hover:bg-green-200 text-green-700 border border-green-300 rounded flex items-center justify-center transition-colors duration-200 cursor-pointer"
|
||||||
|
title="Zitation für diese Seite generieren">
|
||||||
|
<i class="ri-file-text-line text-lg font-bold"></i>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<!-- Close button -->
|
||||||
|
<button
|
||||||
|
onclick="this.closest('single-page-viewer').close()"
|
||||||
|
class="w-10 h-10 bg-gray-100 hover:bg-gray-200 text-gray-700 border border-gray-300 rounded flex items-center justify-center transition-colors duration-200 cursor-pointer"
|
||||||
|
title="Schließen">
|
||||||
|
<i class="ri-close-line text-lg font-bold"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Image container that can scroll -->
|
||||||
|
<div class="flex-1 flex items-center justify-center p-4 pb-8">
|
||||||
|
<img
|
||||||
|
id="single-page-image"
|
||||||
|
src=""
|
||||||
|
alt=""
|
||||||
|
class="w-full h-auto rounded-lg shadow-2xl"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
show(imgSrc, imgAlt, pageNumber, isBeilage = false) {
|
||||||
|
const img = this.querySelector('#single-page-image');
|
||||||
|
const pageNumberSpan = this.querySelector('#page-number');
|
||||||
|
const pageIconSpan = this.querySelector('#page-icon');
|
||||||
|
const pageIndicator = this.querySelector('#page-indicator');
|
||||||
|
|
||||||
|
img.src = imgSrc;
|
||||||
|
img.alt = imgAlt;
|
||||||
|
|
||||||
|
// Store current page info for button actions
|
||||||
|
this.currentPageNumber = pageNumber;
|
||||||
|
this.currentIsBeilage = isBeilage;
|
||||||
|
|
||||||
|
// Set page number
|
||||||
|
pageNumberSpan.textContent = pageNumber;
|
||||||
|
|
||||||
|
// Set page icon based on position and type
|
||||||
|
const iconType = this.determinePageIconType(pageNumber, isBeilage);
|
||||||
|
pageIconSpan.innerHTML = this.getPageIconHTML(iconType);
|
||||||
|
|
||||||
|
// Page indicator styling is now consistent (white background)
|
||||||
|
|
||||||
|
// Update navigation button visibility
|
||||||
|
this.updateNavigationButtons();
|
||||||
|
|
||||||
|
this.style.display = 'block';
|
||||||
|
|
||||||
|
// Prevent background scrolling but allow scrolling within the viewer
|
||||||
|
document.body.style.overflow = 'hidden';
|
||||||
|
|
||||||
|
// Mark current page in Inhaltsverzeichnis
|
||||||
|
markCurrentPageInInhaltsverzeichnis(pageNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
close() {
|
||||||
|
this.style.display = 'none';
|
||||||
|
|
||||||
|
// Restore background scrolling
|
||||||
|
document.body.style.overflow = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine page icon type based on page position and whether it's beilage
|
||||||
|
determinePageIconType(pageNumber, isBeilage) {
|
||||||
|
// Get all page containers to determine position
|
||||||
|
const containerSelector = isBeilage ? '.newspaper-page-container[data-beilage="true"]' : '.newspaper-page-container:not([data-beilage])';
|
||||||
|
const pageContainers = Array.from(document.querySelectorAll(containerSelector));
|
||||||
|
|
||||||
|
// Extract page numbers and sort them
|
||||||
|
const allPages = pageContainers
|
||||||
|
.map(container => {
|
||||||
|
const pageAttr = container.getAttribute('data-page-container');
|
||||||
|
return pageAttr ? parseInt(pageAttr) : null;
|
||||||
|
})
|
||||||
|
.filter(p => p !== null)
|
||||||
|
.sort((a, b) => a - b);
|
||||||
|
|
||||||
|
if (allPages.length === 0) {
|
||||||
|
return "first";
|
||||||
|
}
|
||||||
|
|
||||||
|
const firstPage = allPages[0];
|
||||||
|
const lastPage = allPages[allPages.length - 1];
|
||||||
|
|
||||||
|
// Same logic as Go determinePageIcon function
|
||||||
|
if (pageNumber === firstPage) {
|
||||||
|
return "first"; // Front page - normal icon
|
||||||
|
} else if (pageNumber === lastPage) {
|
||||||
|
return "last"; // Back page - mirrored icon
|
||||||
|
} else {
|
||||||
|
// For middle pages in newspaper layout
|
||||||
|
if (pageNumber === firstPage + 1) {
|
||||||
|
return "even"; // Page 2 - black + mirrored grey
|
||||||
|
} else if (pageNumber === lastPage - 1) {
|
||||||
|
return "odd"; // Page 3 - grey + black
|
||||||
|
} else {
|
||||||
|
// For newspapers with more than 4 pages, use alternating pattern
|
||||||
|
if (pageNumber % 2 === 0) {
|
||||||
|
return "even";
|
||||||
|
} else {
|
||||||
|
return "odd";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate page icon HTML based on type (same as Go PageIcon function)
|
||||||
|
getPageIconHTML(iconType) {
|
||||||
|
const baseClass = "ri-file-text-line text-lg";
|
||||||
|
|
||||||
|
switch (iconType) {
|
||||||
|
case "first":
|
||||||
|
return `<i class="${baseClass} text-black"></i>`;
|
||||||
|
case "last":
|
||||||
|
return `<i class="${baseClass} text-black" style="transform: scaleX(-1); display: inline-block;"></i>`;
|
||||||
|
case "even":
|
||||||
|
return `<i class="${baseClass} text-black" style="margin-left: 2px; transform: scaleX(-1); display: inline-block;"></i><i class="${baseClass} text-slate-400"></i>`;
|
||||||
|
case "odd":
|
||||||
|
return `<i class="${baseClass} text-slate-400" style="margin-left: 2px; transform: scaleX(-1); display: inline-block;"></i><i class="${baseClass} text-black"></i>`;
|
||||||
|
default:
|
||||||
|
return `<i class="${baseClass} text-black"></i>`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Share current page
|
||||||
|
shareCurrentPage() {
|
||||||
|
if (typeof copyPagePermalink === 'function') {
|
||||||
|
// Use the actual button element
|
||||||
|
const shareBtn = this.querySelector('#share-btn');
|
||||||
|
copyPagePermalink(this.currentPageNumber, shareBtn, this.currentIsBeilage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate citation for current page
|
||||||
|
generatePageCitation() {
|
||||||
|
if (typeof generatePageCitation === 'function') {
|
||||||
|
// Use the actual button element
|
||||||
|
const citeBtn = this.querySelector('#cite-btn');
|
||||||
|
generatePageCitation(this.currentPageNumber, citeBtn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update navigation button visibility based on available pages
|
||||||
|
updateNavigationButtons() {
|
||||||
|
const prevBtn = this.querySelector('#prev-page-btn');
|
||||||
|
const nextBtn = this.querySelector('#next-page-btn');
|
||||||
|
|
||||||
|
const { prevPage, nextPage } = this.getAdjacentPages();
|
||||||
|
|
||||||
|
// Enable/disable previous page button
|
||||||
|
if (prevPage !== null) {
|
||||||
|
prevBtn.disabled = false;
|
||||||
|
prevBtn.className = prevBtn.className.replace('opacity-50 cursor-not-allowed', '');
|
||||||
|
prevBtn.className = prevBtn.className.replace('bg-gray-50 text-gray-400', 'bg-gray-100 text-gray-700');
|
||||||
|
} else {
|
||||||
|
prevBtn.disabled = true;
|
||||||
|
if (!prevBtn.className.includes('opacity-50')) {
|
||||||
|
prevBtn.className += ' opacity-50 cursor-not-allowed';
|
||||||
|
}
|
||||||
|
prevBtn.className = prevBtn.className.replace('bg-gray-100 text-gray-700', 'bg-gray-50 text-gray-400');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable/disable next page button
|
||||||
|
if (nextPage !== null) {
|
||||||
|
nextBtn.disabled = false;
|
||||||
|
nextBtn.className = nextBtn.className.replace('opacity-50 cursor-not-allowed', '');
|
||||||
|
nextBtn.className = nextBtn.className.replace('bg-gray-50 text-gray-400', 'bg-gray-100 text-gray-700');
|
||||||
|
} else {
|
||||||
|
nextBtn.disabled = true;
|
||||||
|
if (!nextBtn.className.includes('opacity-50')) {
|
||||||
|
nextBtn.className += ' opacity-50 cursor-not-allowed';
|
||||||
|
}
|
||||||
|
nextBtn.className = nextBtn.className.replace('bg-gray-100 text-gray-700', 'bg-gray-50 text-gray-400');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get previous and next page numbers
|
||||||
|
getAdjacentPages() {
|
||||||
|
// Get all page containers of the same type (main or beilage)
|
||||||
|
let containerSelector;
|
||||||
|
if (this.currentIsBeilage) {
|
||||||
|
containerSelector = '.newspaper-page-container[data-beilage="true"]';
|
||||||
|
} else {
|
||||||
|
containerSelector = '.newspaper-page-container:not([data-beilage])';
|
||||||
|
}
|
||||||
|
|
||||||
|
const pageContainers = Array.from(document.querySelectorAll(containerSelector));
|
||||||
|
console.log('Found containers:', pageContainers.length, 'for', this.currentIsBeilage ? 'beilage' : 'main');
|
||||||
|
|
||||||
|
// Extract page numbers and sort them
|
||||||
|
const allPages = pageContainers
|
||||||
|
.map(container => {
|
||||||
|
const pageAttr = container.getAttribute('data-page-container');
|
||||||
|
const pageNum = pageAttr ? parseInt(pageAttr) : null;
|
||||||
|
console.log('Container page:', pageAttr, 'parsed:', pageNum);
|
||||||
|
return pageNum;
|
||||||
|
})
|
||||||
|
.filter(p => p !== null)
|
||||||
|
.sort((a, b) => a - b);
|
||||||
|
|
||||||
|
console.log('All pages found:', allPages);
|
||||||
|
console.log('Current page:', this.currentPageNumber);
|
||||||
|
|
||||||
|
const currentIndex = allPages.indexOf(this.currentPageNumber);
|
||||||
|
console.log('Current index:', currentIndex);
|
||||||
|
|
||||||
|
let prevPage = null;
|
||||||
|
let nextPage = null;
|
||||||
|
|
||||||
|
if (currentIndex > 0) {
|
||||||
|
prevPage = allPages[currentIndex - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentIndex < allPages.length - 1) {
|
||||||
|
nextPage = allPages[currentIndex + 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('Adjacent pages - prev:', prevPage, 'next:', nextPage);
|
||||||
|
return { prevPage, nextPage };
|
||||||
|
}
|
||||||
|
|
||||||
|
// Navigate to previous page
|
||||||
|
goToPreviousPage() {
|
||||||
|
const { prevPage } = this.getAdjacentPages();
|
||||||
|
if (prevPage !== null) {
|
||||||
|
this.navigateToPage(prevPage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Navigate to next page
|
||||||
|
goToNextPage() {
|
||||||
|
const { nextPage } = this.getAdjacentPages();
|
||||||
|
if (nextPage !== null) {
|
||||||
|
this.navigateToPage(nextPage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Navigate to a specific page
|
||||||
|
navigateToPage(pageNumber) {
|
||||||
|
// Find the image element for the target page
|
||||||
|
const containerSelector = this.currentIsBeilage ? '.newspaper-page-container[data-beilage="true"]' : '.newspaper-page-container:not([data-beilage])';
|
||||||
|
const targetContainer = document.querySelector(`${containerSelector}[data-page-container="${pageNumber}"]`);
|
||||||
|
|
||||||
|
if (targetContainer) {
|
||||||
|
const imgElement = targetContainer.querySelector('.newspaper-page-image');
|
||||||
|
if (imgElement) {
|
||||||
|
// Update the current view with the new page
|
||||||
|
this.show(imgElement.src, imgElement.alt, pageNumber, this.currentIsBeilage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Toggle sidebar visibility
|
||||||
|
toggleSidebar() {
|
||||||
|
const sidebarSpacer = this.querySelector('#sidebar-spacer');
|
||||||
|
const toggleBtn = this.querySelector('#sidebar-toggle-btn');
|
||||||
|
const toggleIcon = toggleBtn.querySelector('i');
|
||||||
|
|
||||||
|
// Check if sidebar is currently collapsed by looking at classes
|
||||||
|
const isCollapsed = sidebarSpacer.classList.contains('w-0');
|
||||||
|
|
||||||
|
console.log('Current state - isCollapsed:', isCollapsed);
|
||||||
|
console.log('Current classes:', sidebarSpacer.className);
|
||||||
|
|
||||||
|
if (isCollapsed) {
|
||||||
|
// Sidebar is collapsed, expand it
|
||||||
|
sidebarSpacer.classList.remove('w-0');
|
||||||
|
sidebarSpacer.classList.add('lg:w-1/4', 'xl:w-1/5');
|
||||||
|
|
||||||
|
// Update button to normal state (sidebar visible)
|
||||||
|
toggleBtn.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';
|
||||||
|
toggleIcon.className = 'ri-sidebar-unfold-line text-lg font-bold';
|
||||||
|
toggleBtn.title = 'Inhaltsverzeichnis ausblenden';
|
||||||
|
console.log('Expanding sidebar');
|
||||||
|
} else {
|
||||||
|
// Sidebar is expanded, collapse it
|
||||||
|
sidebarSpacer.classList.remove('lg:w-1/4', 'xl:w-1/5');
|
||||||
|
sidebarSpacer.classList.add('w-0');
|
||||||
|
|
||||||
|
// Update button to active state (sidebar hidden - orange highlight)
|
||||||
|
toggleBtn.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';
|
||||||
|
toggleIcon.className = 'ri-sidebar-fold-line text-lg font-bold';
|
||||||
|
toggleBtn.title = 'Inhaltsverzeichnis einblenden';
|
||||||
|
console.log('Collapsing sidebar');
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('New classes:', sidebarSpacer.className);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register the web component
|
||||||
|
customElements.define('single-page-viewer', SinglePageViewer);
|
||||||
|
|
||||||
export { setup };
|
export { setup };
|
||||||
|
|||||||
Reference in New Issue
Block a user