forked from endless-sky/endless-sky.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
34 lines (32 loc) · 1.19 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* Functions for the screenshot gallery "lightbox." */
var lightboxElement;
function openLightbox(img) {
// Make sure the given element is a gallery image.
if(!isImage(img))
return;
// Display the image in the lightbox.
lightboxElement = img;
document.getElementById("lightbox-image").src = img.src;
document.getElementById("lightbox-title").innerHTML = img.title;
document.getElementById("lightbox-caption").innerHTML = img.alt;
document.getElementById("lightbox-back").style.display = "block";
// Check whether the previous and next buttons should be shown.
document.getElementById("lightbox-previous").style.display =
isImage(img.previousElementSibling) ? "block" : "none";
document.getElementById("lightbox-next").style.display =
isImage(img.nextElementSibling) ? "block" : "none";
}
function closeLightbox() {
document.getElementById("lightbox-back").style.display = "none";
}
function previousLightbox(event) {
event.stopPropagation();
openLightbox(lightboxElement.previousElementSibling);
}
function nextLightbox(event) {
event.stopPropagation();
openLightbox(lightboxElement.nextElementSibling);
}
function isImage(element) {
return (element != null && element.matches("img"));
}