contentdb/app/public/static/gallery.js

18 lines
573 B
JavaScript
Raw Normal View History

2022-02-09 20:10:28 +01:00
// @author rubenwardy
// @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later
window.addEventListener("load", event => {
document.querySelectorAll(".gallery").forEach(gallery => {
const primary = gallery.querySelector(".primary-image img");
const images = gallery.querySelectorAll("a[data-image]");
images.forEach(image => {
const imageFullUrl = image.getAttribute("data-image");
image.removeAttribute("href");
image.addEventListener("click", event => {
primary.src = imageFullUrl;
})
});
});
});