Skip to content
Snippets Groups Projects
Commit 6c951e16 authored by Thomas Schneider's avatar Thomas Schneider
Browse files

frontend: Make index previews clickable as well

parent df4d126a
No related branches found
No related tags found
1 merge request!6apply layout of "template preview" for index page "schilder preview"
......@@ -19,20 +19,23 @@ window.addEventListener("load", () => {
for (const op of document.querySelectorAll('.option .preview')) {
console.debug(op);
const input_id = (op as HTMLElement).dataset.for;
if (!input_id) {
console.error("Missing data-for attribute for", op);
continue;
}
let handler: (_: Event) => void;
if (input_id) {
const input = document.getElementById(input_id);
if (!input || input === null) {
console.error("Unable to find input for", op);
continue;
}
const handler = (_: Event) => {
console.log("clicked");
handler = (_: Event) => {
(input as HTMLInputElement).checked = true;
};
}
} else {
const p = (op as HTMLElement).parentNode;
handler = (_: Event) => {
window.location.href = (p as HTMLAnchorElement).href;
}
}
op.addEventListener('click', handler);
(op as HTMLIFrameElement).contentDocument?.addEventListener('click', handler);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment