mirror of
https://github.com/Theodor-Springmann-Stiftung/musenalm.git
synced 2025-10-29 17:25:32 +00:00
759 lines
26 KiB
JavaScript
759 lines
26 KiB
JavaScript
var v = (r) => {
|
|
throw TypeError(r);
|
|
};
|
|
var f = (r, t, e) => t.has(r) || v("Cannot " + e);
|
|
var g = (r, t, e) => (f(r, t, "read from private field"), e ? e.call(r) : t.get(r)), d = (r, t, e) => t.has(r) ? v("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(r) : t.set(r, e), c = (r, t, e, i) => (f(r, t, "write to private field"), i ? i.call(r, e) : t.set(r, e), e), m = (r, t, e) => (f(r, t, "access private method"), e);
|
|
class x extends HTMLElement {
|
|
constructor() {
|
|
super(), this._value = "", this.render();
|
|
}
|
|
static get observedAttributes() {
|
|
return ["data-text", "data-queryparam", "data-value"];
|
|
}
|
|
set value(t) {
|
|
this.setAttribute("data-value", t);
|
|
}
|
|
get value() {
|
|
return this.getAttribute("data-value") || "";
|
|
}
|
|
set text(t) {
|
|
this.setAttribute("data-text", t);
|
|
}
|
|
get text() {
|
|
return this.getAttribute("data-text") || "";
|
|
}
|
|
set queryparam(t) {
|
|
this.setAttribute("data-queryparam", t);
|
|
}
|
|
get queryparam() {
|
|
return this.getAttribute("data-queryparam") || "";
|
|
}
|
|
connectedCallback() {
|
|
this._filter = this.text, this._queryparam = this.queryparam, this.render(), htmx.process(this);
|
|
}
|
|
attributeChangedCallback(t, e, i) {
|
|
e !== i && (t === "data-text" && (this._filter = i), t === "data-queryparam" && (this._queryparam = i), t === "data-value" && (this._value = i), this.render());
|
|
}
|
|
getURL() {
|
|
if (this._queryparam) {
|
|
let t = new URL(window.location), e = new URLSearchParams(t.search);
|
|
return e.delete(this._queryparam), e.delete("page"), t.search = e.toString(), t.toString();
|
|
}
|
|
return "#";
|
|
}
|
|
render() {
|
|
this.innerHTML = `
|
|
<a href="${this.getURL()}" class="!no-underline block text-base" hx-target="#searchresults" hx-select="#searchresults" hx-indicator="body" hx-swap="outerHTML show:window:top">
|
|
<div class="flex flex-row filter-pill rounded-lg bg-orange-100 hover:saturate-50 px-2.5">
|
|
${this.renderIcon()}
|
|
<div class="flex flex-row filter-pill-label-value !items-baseline text-slate-700">
|
|
<div class="filter-pill-label font-bold mr-1.5 align-baseline">${this.text}</div>
|
|
${this.renderValue()}
|
|
</div>
|
|
</div>
|
|
</a>
|
|
`;
|
|
}
|
|
renderIcon() {
|
|
return this.value === "true" || this.value === "false" ? `
|
|
<div href="${this.getURL()}" class="filter-pill-close no-underline font-bold mr-1 text-orange-900 hover:text-orange-800">
|
|
<i class="ri-close-circle-line"></i>
|
|
</div>
|
|
` : `<div
|
|
href="${this.getURL()}"
|
|
class="filter-pill-close no-underline font-bold mr-1 text-orange-900 hover:text-orange-800">
|
|
<i class="ri-arrow-left-s-line"></i>
|
|
</div>
|
|
`;
|
|
}
|
|
renderValue() {
|
|
return this.value === "true" || this.value === "false" ? "" : `
|
|
<div class="filter-pill-value">${this.value}</div>
|
|
`;
|
|
}
|
|
}
|
|
const u = "filter-list-list", y = "filter-list-item", T = "filter-list-input", _ = "filter-list-searchable";
|
|
var l, h, b;
|
|
class w extends HTMLElement {
|
|
constructor() {
|
|
super();
|
|
d(this, h);
|
|
d(this, l, !1);
|
|
this._items = [], this._url = "", this._filterstart = !1, this._placeholder = "Liste filtern...", this._queryparam = "", this._startparams = null, this.render();
|
|
}
|
|
static get observedAttributes() {
|
|
return ["data-url"];
|
|
}
|
|
set items(e) {
|
|
Array.isArray(e) && (this._items = e, this.render());
|
|
}
|
|
get items() {
|
|
return this._items;
|
|
}
|
|
connectedCallback() {
|
|
this._url = this.getAttribute("data-url") || "./", this._filterstart = this.getAttribute("data-filterstart") === "true", this._placeholder = this.getAttribute("data-placeholder") || "Liste filtern...", this._queryparam = this.getAttribute("data-queryparam") || "", this._queryparam, this._filterstart && c(this, l, !0), this.addEventListener("input", this.onInput.bind(this)), this.addEventListener("keydown", this.onEnter.bind(this)), this.addEventListener("focusin", this.onGainFocus.bind(this)), this.addEventListener("focusout", this.onLoseFocus.bind(this));
|
|
}
|
|
attributeChangedCallback(e, i, s) {
|
|
e === "data-url" && i !== s && (this._url = s, this.render()), e === "data-filterstart" && i !== s && (this._filterstart = s === "true", this.render()), e === "data-placeholder" && i !== s && (this._placeholder = s, this.render()), e === "data-queryparam" && i !== s && (this._queryparam = s, this.render());
|
|
}
|
|
onInput(e) {
|
|
e.target && e.target.tagName.toLowerCase() === "input" && (this._filter = e.target.value, this.renderList());
|
|
}
|
|
onGainFocus(e) {
|
|
e.target && e.target.tagName.toLowerCase() === "input" && (c(this, l, !1), this.renderList());
|
|
}
|
|
onLoseFocus(e) {
|
|
let i = this.querySelector("input");
|
|
if (e.target && e.target === i) {
|
|
if (relatedElement = e.relatedTarget, relatedElement && this.contains(relatedElement))
|
|
return;
|
|
i.value = "", this._filter = "", this._filterstart && c(this, l, !0), this.renderList();
|
|
}
|
|
}
|
|
onEnter(e) {
|
|
if (e.target && e.target.tagName.toLowerCase() === "input" && e.key === "Enter") {
|
|
e.preventDefault();
|
|
const i = this.querySelector("a");
|
|
i && i.click();
|
|
}
|
|
}
|
|
mark() {
|
|
if (typeof Mark != "function")
|
|
return;
|
|
let e = this.querySelector("#" + u);
|
|
if (!e)
|
|
return;
|
|
let i = new Mark(e.querySelectorAll("." + _));
|
|
this._filter && i.mark(this._filter, {
|
|
separateWordSearch: !0
|
|
});
|
|
}
|
|
// INFO: allows for setting a custom HREF of the list item
|
|
// The function takes the item as parameter fn(item) and should return a string.
|
|
setHREFFunc(e) {
|
|
this.getHREF = e, this.render();
|
|
}
|
|
// INFO: allows for setting a custom link text of the list item
|
|
// The function takes the item as parameter fn(item) and should return a string or
|
|
// an HTML template literal.
|
|
setLinkTextFunc(e) {
|
|
this.getLinkText = e, this.render();
|
|
}
|
|
// INFO: allows for setting the text that will be filtered for.
|
|
// The function takes the item as parameter fn(item) and should return a string.
|
|
setSearchTextFunc(e) {
|
|
this.getSearchText = e, this.render();
|
|
}
|
|
getHREF(e) {
|
|
if (e) {
|
|
if (!e.id)
|
|
return "";
|
|
} else return "";
|
|
return e.id;
|
|
}
|
|
getHREFEncoded(e) {
|
|
return encodeURIComponent(this.getHREF(e));
|
|
}
|
|
getSearchText(e) {
|
|
if (e) {
|
|
if (!e.name)
|
|
return "";
|
|
} else return "";
|
|
return e.name;
|
|
}
|
|
getLinkText(e) {
|
|
let i = this.getSearchText(e);
|
|
return i === "" ? "" : `<span class="${_}">${i}</span>`;
|
|
}
|
|
getURL(e) {
|
|
if (this._queryparam) {
|
|
let i = new URL(window.location), s = new URLSearchParams(i.search);
|
|
return s.set(this._queryparam, this.getHREF(e)), s.delete("page"), i.search = s.toString(), i.toString();
|
|
}
|
|
return this._url + this.getHREFEncoded(e);
|
|
}
|
|
renderList() {
|
|
let e = this.querySelector("#" + u);
|
|
e && (e.outerHTML = this.List()), this.mark();
|
|
}
|
|
render() {
|
|
this.innerHTML = `
|
|
<div class="font-serif text-base shadow-inner border border-stone-100">
|
|
${this.Input()}
|
|
${this.List()}
|
|
</div>
|
|
`, htmx && htmx.process(this);
|
|
}
|
|
ActiveDot(e) {
|
|
return m(this, h, b).call(this, e), "";
|
|
}
|
|
NoItems(e) {
|
|
return e.length === 0 ? '<div class="px-2 py-0.5 italic text-gray-500">Keine Einträge gefunden</div>' : "";
|
|
}
|
|
Input() {
|
|
return `
|
|
<div class="flex w-full py-0.5 border-b border-zinc-600 bg-stone-50">
|
|
<i class="ri-arrow-right-s-line pl-2"></i>
|
|
<div class="grow">
|
|
<input
|
|
type="text"
|
|
placeholder="${this._placeholder}"
|
|
class="${T} w-full placeholder:italic px-2 py-0.5" />
|
|
</div>
|
|
</div>
|
|
`;
|
|
}
|
|
List() {
|
|
let e = this._items;
|
|
if (this._filter)
|
|
if (this._filterstart)
|
|
e = this._items.filter((i) => this.getSearchText(i).toLowerCase().startsWith(this._filter.toLowerCase()));
|
|
else {
|
|
let i = this._filter.split(" ");
|
|
e = this._items.filter((s) => i.every((a) => this.getSearchText(s).toLowerCase().includes(a.toLowerCase())));
|
|
}
|
|
return `
|
|
<div id="${u}" class="${u} pt-1 max-h-60 overflow-auto bg-stone-50 ${g(this, l) ? "hidden" : ""}">
|
|
${e.map(
|
|
(i, s) => `
|
|
<a
|
|
href="${this.getURL(i)}"
|
|
hx-indicator="body"
|
|
hx-swap="outerHTML show:none"
|
|
hx-select="main"
|
|
hx-target="main"
|
|
class="${y} block px-2.5 py-0.5 hover:bg-slate-200 no-underline ${s % 2 === 0 ? "bg-stone-100" : "bg-stone-50"}"
|
|
${m(this, h, b).call(this, i) ? 'aria-current="page"' : ""}>
|
|
${this.ActiveDot(i)}
|
|
${this.getLinkText(i)}
|
|
</a>
|
|
`
|
|
).join("")}
|
|
${this.NoItems(e)}
|
|
</div>
|
|
`;
|
|
}
|
|
}
|
|
l = new WeakMap(), h = new WeakSet(), b = function(e) {
|
|
if (!e)
|
|
return !1;
|
|
let i = this.getHREF(e);
|
|
return i === "" ? !1 : this._queryparam && (new URLSearchParams(window.location.search).get(this._queryparam) || "") === i ? !0 : !!window.location.href.endsWith(i);
|
|
};
|
|
class E extends HTMLElement {
|
|
constructor() {
|
|
super(), this.handleScroll = this.handleScroll.bind(this), this.scrollToTop = this.scrollToTop.bind(this);
|
|
}
|
|
connectedCallback() {
|
|
this.innerHTML = `
|
|
<button
|
|
class="
|
|
scroll-to-top
|
|
fixed bottom-5 right-5
|
|
hidden
|
|
bg-gray-800 text-white
|
|
p-2
|
|
rounded-md
|
|
cursor-pointer
|
|
text-2xl
|
|
hover:opacity-80
|
|
transition-opacity
|
|
border-0
|
|
"
|
|
aria-label="Scroll to top"
|
|
>
|
|
<i class="ri-arrow-up-double-line"></i>
|
|
</button>
|
|
`, this._button = this.querySelector(".scroll-to-top"), window.addEventListener("scroll", this.handleScroll), this._button.addEventListener("click", this.scrollToTop);
|
|
}
|
|
disconnectedCallback() {
|
|
window.removeEventListener("scroll", this.handleScroll), this._button.removeEventListener("click", this.scrollToTop);
|
|
}
|
|
handleScroll() {
|
|
(window.scrollY || document.documentElement.scrollTop) > 300 ? this._button.classList.remove("hidden") : this._button.classList.add("hidden");
|
|
}
|
|
scrollToTop() {
|
|
window.scrollTo({ top: 0, behavior: "smooth" });
|
|
}
|
|
}
|
|
class A extends HTMLElement {
|
|
static get observedAttributes() {
|
|
return ["position", "timeout"];
|
|
}
|
|
constructor() {
|
|
super(), this._tooltipBox = null, this._timeout = 200, this._hideTimeout = null, this._hiddenTimeout = null;
|
|
}
|
|
connectedCallback() {
|
|
this.classList.add("relative", "block", "leading-none", "[&>*]:leading-normal");
|
|
const t = this.querySelector(".data-tip"), e = t ? t.innerHTML : "Tooltip";
|
|
t && t.classList.add("hidden"), this._tooltipBox = document.createElement("div"), this._tooltipBox.innerHTML = e, this._tooltipBox.className = [
|
|
"opacity-0",
|
|
"hidden",
|
|
"absolute",
|
|
"px-2",
|
|
"py-1",
|
|
"text-sm",
|
|
"text-white",
|
|
"bg-gray-900",
|
|
"rounded",
|
|
"shadow",
|
|
"z-10",
|
|
"whitespace-nowrap",
|
|
"transition-all",
|
|
"duration-200",
|
|
"font-sans"
|
|
].join(" "), this.appendChild(this._tooltipBox), this._updatePosition(), this.addEventListener("mouseenter", () => this._showTooltip()), this.addEventListener("mouseleave", () => this._hideTooltip());
|
|
}
|
|
attributeChangedCallback(t, e, i) {
|
|
t === "position" && this._tooltipBox && this._updatePosition(), t === "timeout" && i && (this._timeout = parseInt(i) || 200);
|
|
}
|
|
_showTooltip() {
|
|
clearTimeout(this._hideTimeout), clearTimeout(this._hiddenTimeout), this._tooltipBox.classList.remove("hidden"), setTimeout(() => {
|
|
this._tooltipBox.classList.remove("opacity-0"), this._tooltipBox.classList.add("opacity-100");
|
|
}, 16);
|
|
}
|
|
_hideTooltip() {
|
|
this._hideTimeout = setTimeout(() => {
|
|
this._tooltipBox.classList.remove("opacity-100"), this._tooltipBox.classList.add("opacity-0"), this._hiddenTimeout = setTimeout(() => {
|
|
this._tooltipBox.classList.add("hidden");
|
|
}, this._timeout + 100);
|
|
}, this._timeout);
|
|
}
|
|
_updatePosition() {
|
|
switch (this._tooltipBox.classList.remove(
|
|
"bottom-full",
|
|
"left-1/2",
|
|
"-translate-x-1/2",
|
|
"mb-2",
|
|
// top
|
|
"top-full",
|
|
"mt-2",
|
|
// bottom
|
|
"right-full",
|
|
"-translate-y-1/2",
|
|
"mr-2",
|
|
"top-1/2",
|
|
// left
|
|
"left-full",
|
|
"ml-2"
|
|
// right
|
|
), this.getAttribute("position") || "top") {
|
|
case "bottom":
|
|
this._tooltipBox.classList.add(
|
|
"top-full",
|
|
"left-1/2",
|
|
"transform",
|
|
"-translate-x-1/2",
|
|
"mt-0.5"
|
|
);
|
|
break;
|
|
case "left":
|
|
this._tooltipBox.classList.add(
|
|
"right-full",
|
|
"top-1/2",
|
|
"transform",
|
|
"-translate-y-1/2",
|
|
"mr-0.5"
|
|
);
|
|
break;
|
|
case "right":
|
|
this._tooltipBox.classList.add(
|
|
"left-full",
|
|
"top-1/2",
|
|
"transform",
|
|
"-translate-y-1/2",
|
|
"ml-0.5"
|
|
);
|
|
break;
|
|
case "top":
|
|
default:
|
|
this._tooltipBox.classList.add(
|
|
"bottom-full",
|
|
"left-1/2",
|
|
"transform",
|
|
"-translate-x-1/2",
|
|
"mb-0.5"
|
|
);
|
|
}
|
|
}
|
|
}
|
|
class k extends HTMLElement {
|
|
constructor() {
|
|
super(), this.overlay = null, this._others = null, this._thisindex = -1, this._preview = null, this._description = null, this._imageURL = "", this._hideDLButton = !1;
|
|
}
|
|
connectedCallback() {
|
|
this.classList.add("cursor-pointer"), this.classList.add("select-none"), this._imageURL = this.getAttribute("data-image-url") || "", this._hideDLButton = this.getAttribute("data-hide-dl-button") || !1, this._preview = this.querySelector("img"), this._description = this.querySelector(".image-description"), this._preview && this._preview.addEventListener("click", () => {
|
|
this.showOverlay();
|
|
});
|
|
let t = this.closest("image-reel, .image-reel");
|
|
t || (t = document), this._others = Array.from(t.querySelectorAll("popup-image:not(.hidden)")), this._thisindex = this._others.indexOf(this);
|
|
}
|
|
disconnectedCallback() {
|
|
this.overlay && this.overlay.parentNode && this.overlay.parentNode.removeChild(this.overlay);
|
|
}
|
|
Keys(t) {
|
|
t.repeat || (t.preventDefault(), t.key === "ArrowRight" ? this.next() : t.key === "ArrowLeft" ? this.prev() : t.key === "Escape" && this.hideOverlay());
|
|
}
|
|
next() {
|
|
this._others[this._thisindex + 1] ? (this.hideOverlay(), this._others[this._thisindex + 1].showOverlay()) : document.addEventListener("keydown", this.Keys.bind(this), { once: !0 });
|
|
}
|
|
prev() {
|
|
this._others[this._thisindex - 1] ? (this.hideOverlay(), this._others[this._thisindex - 1].showOverlay()) : document.addEventListener("keydown", this.Keys.bind(this), { once: !0 });
|
|
}
|
|
showOverlay() {
|
|
this.overlay = document.createElement("div"), this.overlay.classList.add(
|
|
"fixed",
|
|
"inset-0",
|
|
"z-50",
|
|
"bg-black/70",
|
|
"flex",
|
|
"items-center",
|
|
"justify-center",
|
|
"p-4"
|
|
), this.overlay.innerHTML = `
|
|
<div class="relative w-max max-w-dvw max-h-dvh shadow-lg flex flex-col items-center justify-center gap-4">
|
|
<div>
|
|
<div class="absolute -right-16 text-white text-4xl flex flex-col">
|
|
<button class="hover:text-gray-300 cursor-pointer focus:outline-none" aria-label="Close popup" id="closebutton">
|
|
<i class="ri-close-fill text-4xl"></i>
|
|
</button>
|
|
${this.downloadButton()}
|
|
${this.nextButton()}
|
|
${this.prevButton()}
|
|
</div>
|
|
<img
|
|
src="${this._imageURL}"
|
|
alt="Popup Image"
|
|
class="full max-h-[80vh] max-w-[80vw] object-contain block relative ${this.descriptionImgClass()}"
|
|
/>
|
|
${this.description()}
|
|
</div>
|
|
</div>
|
|
`;
|
|
const t = this.overlay.querySelector("#closebutton");
|
|
t && t.addEventListener("click", () => {
|
|
this.hideOverlay();
|
|
});
|
|
const e = this.overlay.querySelector("#nextbtn");
|
|
e && e.addEventListener("click", this.next.bind(this));
|
|
const i = this.overlay.querySelector("#prevbtn");
|
|
i && i.addEventListener("click", this.prev.bind(this)), this.overlay.addEventListener("click", (s) => {
|
|
s.target === this.overlay && this.hideOverlay();
|
|
}), document.addEventListener("keydown", this.Keys.bind(this), { once: !0 }), document.body.appendChild(this.overlay);
|
|
}
|
|
descriptionImgClass() {
|
|
return this.description ? "" : "0";
|
|
}
|
|
nextButton() {
|
|
return this._others[this._thisindex + 1] ? `
|
|
<tool-tip position="right">
|
|
<button class="hover:text-gray-300 cursor-pointer focus:outline-none" aria-label="Next image" id="nextbtn">
|
|
<i class="ri-arrow-right-box-line"></i>
|
|
</button>
|
|
<div class="data-tip">Nächstes Bild</div>
|
|
</tool-tip>
|
|
` : "";
|
|
}
|
|
prevButton() {
|
|
return this._others[this._thisindex - 1] ? `
|
|
<tool-tip position="right">
|
|
<button class="hover:text-gray-300 cursor-pointer focus:outline-none" aria-label="Previous image" id="prevbtn">
|
|
<i class="ri-arrow-left-box-line"></i>
|
|
</button>
|
|
<div class="data-tip">Vorheriges Bild</div>
|
|
</tool-tip>
|
|
` : "";
|
|
}
|
|
description() {
|
|
return this._description ? `
|
|
<div class="font-serif text-left description-content mt-3 text-slate-900 ">
|
|
<div class="max-w-[80ch] hyphens-auto px-6 py-2 bg-stone-50 shadow-lg">
|
|
${this._description.innerHTML}
|
|
</div>
|
|
</div>
|
|
` : "";
|
|
}
|
|
downloadButton() {
|
|
return this._hideDLButton ? "" : `
|
|
<tool-tip position="right">
|
|
<a href="${this._imageURL}" target="_blank" class="text-white no-underline hover:text-gray-300"><i class="ri-file-download-line"></i></a>
|
|
<div class="data-tip">Bild herunterladen</div>
|
|
</tool-tip>
|
|
`;
|
|
}
|
|
hideOverlay() {
|
|
this.overlay.parentNode.removeChild(this.overlay), this.overlay = null;
|
|
}
|
|
}
|
|
class S extends HTMLElement {
|
|
static get observedAttributes() {
|
|
}
|
|
constructor() {
|
|
super(), this._showall = !1, this.shown = -1, this._headings = [], this._contents = [];
|
|
}
|
|
connectedCallback() {
|
|
this._headings = Array.from(this.querySelectorAll(".tab-list-head")), this._contents = Array.from(this.querySelectorAll(".tab-list-panel")), this.hookupEvtHandlers(), this.hideDependent(), this._headings.length === 1 && this.expand(0);
|
|
}
|
|
expand(t) {
|
|
t < 0 || t >= this._headings.length || (this.shown = t, this._contents.forEach((e, i) => {
|
|
i === t ? (e.classList.remove("hidden"), this._headings[i].setAttribute("aria-pressed", "true")) : (e.classList.add("hidden"), this._headings[i].setAttribute("aria-pressed", "false"));
|
|
}));
|
|
}
|
|
hookupEvtHandlers() {
|
|
for (let t of this._headings)
|
|
t.addEventListener("click", this.handleTabClick.bind(this)), t.classList.add("cursor-pointer"), t.classList.add("select-none"), t.setAttribute("role", "button"), t.setAttribute("aria-pressed", "false"), t.setAttribute("tabindex", "0");
|
|
for (let t of this._contents)
|
|
t.classList.add("hidden");
|
|
}
|
|
restore() {
|
|
for (let t of this._headings)
|
|
t.classList.add("cursor-pointer"), t.classList.add("select-none"), t.setAttribute("role", "button"), t.setAttribute("aria-pressed", "false"), t.setAttribute("tabindex", "0"), t.classList.remove("pointer-events-none"), t.classList.remove("!text-slate-900");
|
|
for (let t of this._contents)
|
|
t.classList.add("hidden");
|
|
}
|
|
disable() {
|
|
for (let t of this._headings)
|
|
t.classList.remove("cursor-pointer"), t.classList.remove("select-none"), t.removeAttribute("role"), t.removeAttribute("aria-pressed"), t.removeAttribute("tabindex"), t.classList.add("pointer-events-none"), t.classList.add("!text-slate-900");
|
|
}
|
|
showAll() {
|
|
this._showall = !0, this.shown = -1, this.disable(), this._contents.forEach((t, e) => {
|
|
t.classList.remove("hidden");
|
|
let i = this._headings[e], s = i.querySelectorAll(".show-opened");
|
|
for (let n of s)
|
|
n.classList.add("hidden");
|
|
let a = i.querySelectorAll(".show-closed");
|
|
for (let n of a)
|
|
n.classList.add("hidden");
|
|
});
|
|
}
|
|
default() {
|
|
this._showall = !1, this.restore(), this.hideDependent();
|
|
}
|
|
hideDependent() {
|
|
if (this.shown < 0)
|
|
for (const t of this._headings)
|
|
this._hideAllDep(t, !1);
|
|
else
|
|
this._headings.forEach((t, e) => {
|
|
this._hideAllDep(t, e === this.shown);
|
|
});
|
|
}
|
|
_hideAllDep(t, e) {
|
|
const i = t.querySelectorAll(".show-closed");
|
|
for (let a of i)
|
|
e ? a.classList.add("hidden") : a.classList.remove("hidden");
|
|
const s = Array.from(t.querySelectorAll(".show-opened"));
|
|
for (let a of s)
|
|
e ? a.classList.remove("hidden") : a.classList.add("hidden");
|
|
}
|
|
handleTabClick(t) {
|
|
if (!t.target) {
|
|
console.warn("Invalid event target");
|
|
return;
|
|
}
|
|
const e = this.findParentWithClass(t.target, "tab-list-head");
|
|
if (!e) {
|
|
console.warn("No parent found with class 'tab-list-head'");
|
|
return;
|
|
}
|
|
const i = this._headings.indexOf(e);
|
|
i === this.shown ? (this._contents[i].classList.toggle("hidden"), this._headings[i].setAttribute("aria-pressed", "false"), this.shown = -1) : this.expand(i), this.hideDependent();
|
|
}
|
|
findParentWithClass(t, e) {
|
|
for (; t; ) {
|
|
if (t.classList && t.classList.contains(e))
|
|
return t;
|
|
t = t.parentElement;
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
class o extends HTMLElement {
|
|
static get observedAttributes() {
|
|
return ["data-text", "data-abbrevmap"];
|
|
}
|
|
static get defaultAbbrevMap() {
|
|
return {
|
|
"#": "Hinweis auf weitere Informationen in der Anmerkung.",
|
|
$: "vermutlich",
|
|
"+++": "Inhalte aus mehreren Almanachen interpoliert",
|
|
B: "Blatt",
|
|
BB: "Blätter",
|
|
C: "Corrigenda",
|
|
Diagr: "Diagramm",
|
|
G: "Graphik",
|
|
"G-Verz": "Verzeichnis der Kupfer u. ä.",
|
|
GG: "Graphiken",
|
|
Hrsg: "Herausgeber",
|
|
"I-Verz": "Inhaltsverzeichnis",
|
|
Kal: "Kalendarium",
|
|
Kr: "Karte",
|
|
MusB: "Musikbeigabe",
|
|
MusBB: "Musikbeigaben",
|
|
S: "Seite",
|
|
SS: "Seiten",
|
|
Sp: "Spiegel",
|
|
T: "Titel",
|
|
TG: "Titelgraphik, Titelportrait etc",
|
|
"TG r": "Titelgraphik, Titelportrait etc recto",
|
|
"TG v": "Titelgraphik, Titelportrait etc verso",
|
|
Tab: "Tabelle",
|
|
UG: "Umschlaggraphik",
|
|
"UG r": "Umschlaggraphik recto",
|
|
"UG v": "Umschlaggraphik verso",
|
|
VB: "Vorsatzblatt",
|
|
Vf: "Verfasser",
|
|
VrlgM: "Verlagsmitteilung",
|
|
Vrwrt: "Vorwort",
|
|
ar: "arabische Paginierung",
|
|
ar1: "erste arabische Paginierung",
|
|
ar2: "zweite arabische Paginierung",
|
|
ar3: "dritte arabische Paginierung",
|
|
ar4: "vierte arabische Paginierung",
|
|
ar5: "fünfte arabische Paginierung",
|
|
ar6: "sechste arabische Paginierung",
|
|
ar7: "siebte arabische Paginierung",
|
|
gA: "graphische Anleitung",
|
|
gT: "graphischer Titel",
|
|
gTzA: "graphische Tanzanleitung",
|
|
nT: "Nachtitel",
|
|
röm: "römische Paginierung",
|
|
röm1: "erste römische Paginierung",
|
|
röm2: "zweite römische Paginierung",
|
|
röm3: "dritte römische Paginierung",
|
|
röm4: "vierte römische Paginierung",
|
|
röm5: "fünfte römische Paginierung",
|
|
röm6: "sechste römische Paginierung",
|
|
röm7: "siebte römische Paginierung",
|
|
vT: "Vortitel",
|
|
zT: "Zwischentitel",
|
|
"§§": "Hinweis auf Mängel im Almanach (Beschädigungen, fehlende Graphiken, unvollständige Sammlungen etc) in der Anmerkung"
|
|
};
|
|
}
|
|
constructor() {
|
|
super(), this._abbrevMap = o.defaultAbbrevMap;
|
|
}
|
|
connectedCallback() {
|
|
this.render();
|
|
}
|
|
attributeChangedCallback(t, e, i) {
|
|
e !== i && (t === "data-abbrevmap" && this._parseAndSetAbbrevMap(i), this.render());
|
|
}
|
|
_parseAndSetAbbrevMap(t) {
|
|
if (!t) {
|
|
this._abbrevMap = o.defaultAbbrevMap;
|
|
return;
|
|
}
|
|
try {
|
|
this._abbrevMap = JSON.parse(t);
|
|
} catch {
|
|
this._abbrevMap = o.defaultAbbrevMap;
|
|
}
|
|
}
|
|
setAbbrevMap(t) {
|
|
typeof t == "object" && t !== null && (this._abbrevMap = t, this.render());
|
|
}
|
|
get text() {
|
|
return this.getAttribute("data-text") || "";
|
|
}
|
|
set text(t) {
|
|
this.setAttribute("data-text", t);
|
|
}
|
|
render() {
|
|
this.innerHTML = this.transformText(this.text, this._abbrevMap);
|
|
}
|
|
transformText(t, e) {
|
|
let i = "", s = 0;
|
|
for (; s < t.length; ) {
|
|
if (s > 0 && !this.isSpaceOrPunct(t[s - 1])) {
|
|
i += t[s], s++;
|
|
continue;
|
|
}
|
|
const a = this.findLongestAbbrevAt(t, s, e);
|
|
if (a) {
|
|
const { match: n, meaning: L } = a;
|
|
i += `
|
|
<tool-tip position="top" class="!inline" timeout="300">
|
|
<div class="data-tip p-2 text-sm text-white bg-gray-700 rounded shadow">
|
|
${L}
|
|
</div>
|
|
<span class="cursor-help text-blue-900 hover:text-slate-800">
|
|
${n}
|
|
</span>
|
|
</tool-tip>
|
|
`, s += n.length;
|
|
} else
|
|
i += t[s], s++;
|
|
}
|
|
return i;
|
|
}
|
|
findLongestAbbrevAt(t, e, i) {
|
|
let s = null, a = 0;
|
|
for (const n of Object.keys(i))
|
|
t.startsWith(n, e) && n.length > a && (s = n, a = n.length);
|
|
return s ? { match: s, meaning: i[s] } : null;
|
|
}
|
|
isSpaceOrPunct(t) {
|
|
return /\s|[.,;:!?]/.test(t);
|
|
}
|
|
}
|
|
class B extends HTMLElement {
|
|
constructor() {
|
|
super();
|
|
}
|
|
connectedCallback() {
|
|
this.style.cursor = "pointer", this.addEventListener("click", this.handleClick);
|
|
}
|
|
disconnectedCallback() {
|
|
this.removeEventListener("click", this.handleClick);
|
|
}
|
|
handleClick(t) {
|
|
const e = this.getAttribute("data-jump");
|
|
if (e) {
|
|
const i = document.querySelector(e);
|
|
i ? i.scrollIntoView({ behavior: "smooth" }) : console.warn(`No element found for selector: ${e}`);
|
|
}
|
|
}
|
|
}
|
|
var p;
|
|
class M extends HTMLElement {
|
|
constructor() {
|
|
super();
|
|
d(this, p, 176);
|
|
this._images = [];
|
|
}
|
|
connectedCallback() {
|
|
this._images = Array.from(this.querySelectorAll(".primages")), this.calculateShownImages();
|
|
const e = new ResizeObserver((i, s) => {
|
|
this.calculateShownImages();
|
|
});
|
|
this._resizeObserver = e, e.observe(this);
|
|
}
|
|
disconnectedCallback() {
|
|
this._resizeObserver.unobserve(this);
|
|
}
|
|
calculateShownImages() {
|
|
const e = this.getBoundingClientRect();
|
|
console.log(e);
|
|
const i = Math.floor(e.width / (g(this, p) + 10));
|
|
for (let s = 0; s < this._images.length; s++)
|
|
s < i - 1 ? this._images[s].classList.remove("hidden") : this._images[s].classList.add("hidden");
|
|
}
|
|
}
|
|
p = new WeakMap();
|
|
const C = "filter-list", I = "scroll-button", q = "tool-tip", R = "abbrev-tooltips", P = "int-link", $ = "popup-image", H = "tab-list", N = "filter-pill", O = "image-reel";
|
|
customElements.define(P, B);
|
|
customElements.define(R, o);
|
|
customElements.define(C, w);
|
|
customElements.define(I, E);
|
|
customElements.define(q, A);
|
|
customElements.define($, k);
|
|
customElements.define(H, S);
|
|
customElements.define(N, x);
|
|
customElements.define(O, M);
|
|
export {
|
|
o as AbbreviationTooltips,
|
|
w as FilterList,
|
|
E as ScrollButton
|
|
};
|