mirror of https://github.com/docker/docs.git
add check in modal.js
This commit is contained in:
parent
f08c1fe3d2
commit
eb774bd5fd
|
@ -1,31 +1,33 @@
|
||||||
// Get the modal for image 1
|
// Get the modal for image 1
|
||||||
var modal = document.getElementById("img-modal1");
|
var modal = document.getElementById("img-modal1");
|
||||||
|
|
||||||
// Get the image and insert it inside the modal - use its "alt" text as a caption
|
// If modal exists, get the image and insert it inside the modal - use its "alt" text as a caption
|
||||||
const images = document.querySelectorAll("main img");
|
if (modal) {
|
||||||
var modalImg = document.getElementById("img-modal-img1");
|
const images = document.querySelectorAll("main img");
|
||||||
var captionText = document.getElementById("img-modal-caption1");
|
var modalImg = document.getElementById("img-modal-img1");
|
||||||
function handleImageClick(event) {
|
var captionText = document.getElementById("img-modal-caption1");
|
||||||
modal.style.display = "block";
|
function handleImageClick(event) {
|
||||||
modalImg.src = event.target.src;
|
modal.style.display = "block";
|
||||||
modalImg.alt = event.target.alt;
|
modalImg.src = event.target.src;
|
||||||
captionText.innerHTML = event.target.alt;
|
modalImg.alt = event.target.alt;
|
||||||
window.addEventListener("keydown", handleModalClose)
|
captionText.innerHTML = event.target.alt;
|
||||||
}
|
window.addEventListener("keydown", handleModalClose)
|
||||||
images.forEach(image => image.addEventListener("click", handleImageClick))
|
}
|
||||||
|
images.forEach(image => image.addEventListener("click", handleImageClick))
|
||||||
|
|
||||||
|
|
||||||
// Get the element that closes the modal
|
// Get the element that closes the modal
|
||||||
var span = document.getElementById("img-modal-close1");
|
var span = document.getElementById("img-modal-close1");
|
||||||
function handleModalClose(event) {
|
function handleModalClose(event) {
|
||||||
if (event.type==="click"||event.key==="Escape"){
|
if (event.type==="click"||event.key==="Escape"){
|
||||||
modal.style.display = "none"
|
modal.style.display = "none"
|
||||||
window.removeEventListener("keydown", handleModalClose)
|
window.removeEventListener("keydown", handleModalClose)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
modal.addEventListener("click", handleModalClose)
|
||||||
|
|
||||||
|
// When the user clicks on (x), close the modal
|
||||||
|
span.onclick = function(){
|
||||||
|
modal.style.display = "none";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
modal.addEventListener("click", handleModalClose)
|
|
||||||
|
|
||||||
// When the user clicks on (x), close the modal
|
|
||||||
span.onclick = function(){
|
|
||||||
modal.style.display = "none";
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue