From 5a06eaec9ed10e410815ba1f2dc3251a7b42db5f Mon Sep 17 00:00:00 2001 From: Jonas Leder <git@jonasled.de> Date: Wed, 24 Mar 2021 23:19:18 +0100 Subject: [PATCH] got lightbox working on .clickSpan --- js/imgPreview.js | 7 +++---- public/bildquellen.php | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/js/imgPreview.js b/js/imgPreview.js index a167585..beb8311 100644 --- a/js/imgPreview.js +++ b/js/imgPreview.js @@ -1,15 +1,14 @@ import * as basicLightbox from 'basiclightbox' -let images = document.getElementsByTagName("img"); +let images = document.querySelectorAll("img, .clickSpan"); for(let i = 0; i < images.length; i++){ let element = images[i]; if(!(element.getAttribute("data-noPreview") === "true")) { element.onclick = () => { - console.log("render"); const instance = basicLightbox.create(` - <img src="${element.src}"> + <img src="${element.getAttribute("src")}"> `); - instance.show(() => console.log('lightbox now visible')) + instance.show(); } } } \ No newline at end of file diff --git a/public/bildquellen.php b/public/bildquellen.php index c2379bf..2dcdae2 100644 --- a/public/bildquellen.php +++ b/public/bildquellen.php @@ -6,8 +6,8 @@ include "internal/comments.php"; getHeader("Bildquellen", ""); ?> <ul> - <li><span class="clickSpan" onclick="createDialogImage('/img/bannerHome.webp')">Bild oben</span>: Photo by <a href="https://unsplash.com/@hishahadat?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Shahadat Rahman</a> on <a href="https://unsplash.com/s/photos/programmer?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a></li> - <li><span class="clickSpan" onclick="createDialogImage('/img/bildHome.webp')">Bild Startseite</span>: Photo by <a href="https://unsplash.com/@grohsfabian?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Fabian Grohs</a> on <a href="https://unsplash.com/s/photos/programmer?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a></li> + <li><span class="clickSpan" src='/img/bannerHome.webp'>Bild oben</span>: Photo by <a href="https://unsplash.com/@hishahadat?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Shahadat Rahman</a> on <a href="https://unsplash.com/s/photos/programmer?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a></li> + <li><span class="clickSpan" src='/img/bildHome.webp'>Bild Startseite</span>: Photo by <a href="https://unsplash.com/@grohsfabian?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Fabian Grohs</a> on <a href="https://unsplash.com/s/photos/programmer?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a></li> </ul> <?php getFooter(); \ No newline at end of file -- GitLab