mirror of
https://github.com/Theodor-Springmann-Stiftung/lenz-web.git
synced 2025-10-29 09:15:33 +00:00
global startup script
This commit is contained in:
@@ -303,8 +303,27 @@ class ToolTip extends HTMLElement {
|
||||
}
|
||||
}
|
||||
|
||||
function Letter() {
|
||||
function Startup() {
|
||||
let pagedPreviewer = null;
|
||||
const positionedIntervals = [];
|
||||
|
||||
// INFO: Generate a print preview of the page if the URL has ?print=true
|
||||
if (new URL(window.location).searchParams.get("print") === "true") {
|
||||
showPreview();
|
||||
}
|
||||
|
||||
// INFO: Listeners for sidenotes
|
||||
window.addEventListener("load", () => {
|
||||
alignSidenotes();
|
||||
});
|
||||
|
||||
window.addEventListener("resize", alignSidenotes);
|
||||
|
||||
if (htmx) {
|
||||
window.addEventListener("htmx:afterSettle", (_) => {
|
||||
alignSidenotes();
|
||||
});
|
||||
}
|
||||
|
||||
function showPreview() {
|
||||
if (!pagedPreviewer) {
|
||||
@@ -315,23 +334,19 @@ function Letter() {
|
||||
document.body.classList.add("previewing");
|
||||
});
|
||||
|
||||
window.addEventListener("popstate", (event) => {
|
||||
// INFO: this is probably not neccessary since we open the preview in a new window
|
||||
// but just in case.
|
||||
window.addEventListener("popstate", (_) => {
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
|
||||
// On initial page load, check if ?print=true is set
|
||||
if (new URL(window.location).searchParams.get("print") === "true") {
|
||||
showPreview();
|
||||
}
|
||||
|
||||
function alignSidenotes() {
|
||||
_alignSidenotes(".count", ".page", ".eanchor-page");
|
||||
_alignSidenotes(".notes", ".note-hand", ".hand");
|
||||
_alignSidenotes(".notes", ".note-sidenote-meta", ".sidenote");
|
||||
}
|
||||
|
||||
const positionedIntervals = [];
|
||||
function _alignSidenotes(container, align, alignto) {
|
||||
const fulltext = document.querySelector(".fulltext");
|
||||
const cont = document.querySelector(container);
|
||||
@@ -389,19 +404,10 @@ function Letter() {
|
||||
|
||||
note.style.top = `${top}px`;
|
||||
});
|
||||
console.log("Aligned sidenotes", positionedIntervals);
|
||||
}
|
||||
|
||||
window.addEventListener("load", () => {
|
||||
alignSidenotes();
|
||||
});
|
||||
|
||||
window.addEventListener("resize", alignSidenotes);
|
||||
|
||||
alignSidenotes();
|
||||
}
|
||||
|
||||
customElements.define(SCROLL_BUTTON_ELEMENT, ScrollButton);
|
||||
customElements.define(TOOLTIP_ELEMENT, ToolTip);
|
||||
|
||||
export { XSLTParseProcess, ScrollButton, Previewer, Letter };
|
||||
export { XSLTParseProcess, ScrollButton, Previewer, Startup };
|
||||
|
||||
Reference in New Issue
Block a user