const imageGrid = document.querySelector(".image-grid"); const links = imageGrid.querySelectorAll("a"); const imgs = imageGrid.querySelectorAll("img"); const lightboxModal = document.getElementById("lightbox-modal"); const bsModal = new bootstrap.Modal(lightboxModal); const modalBody = document.querySelector(".modal-body .container-fluid"); for (const link of links) { link.addEventListener("click", function (e) { e.preventDefault(); const currentImg = link.querySelector("img"); const lightboxCarousel = document.getElementById("lightboxCarousel"); if (lightboxCarousel) { const parentCol = link.parentElement.parentElement; const index = [...parentCol.parentElement.children].indexOf(parentCol); const bsCarousel = new bootstrap.Carousel(lightboxCarousel); bsCarousel.to(index); } else { createCarousel(currentImg); } bsModal.show(); }); } function createCarousel(img) { const markup = `
`; modalBody.innerHTML = markup; } function createSlides(img) { let markup = ""; const currentImgSrc = img.getAttribute("src"); for (const img of imgs) { const imgSrc = img.getAttribute("src"); const imgAlt = img.getAttribute("alt"); const imgCaption = img.getAttribute("data-caption"); markup += `${caption}