-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlightBox.js
73 lines (69 loc) · 2.71 KB
/
lightBox.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
function lightBox() {
var lightBoxCount = document.getElementsByClassName('lightbox');
for (var i = 0; i < lightBoxCount.length; i++) {
var items = lightBoxCount[i];
var imageText = document.createElement('span');
var closeIcon = document.createElement('span');
imageText.className = "imageTxt";
imageText.innerHTML = "Click to view a larger version";
closeIcon.className = "close";
closeIcon.innerHTML = "×";
items.appendChild(imageText);
items.appendChild(closeIcon);
var image = items.getElementsByTagName('img')[0];
image.onmouseover = function() {
this.style.opacity = 0.7;
}
image.onmouseout = function() {
this.style.opacity = 1;
}
imageText.onmouseover = function() {
this.parentNode.getElementsByTagName('img')[0].style.opacity = 0.7;
}
imageText.onclick = function() {
resizeImage = this.parentNode.getElementsByTagName('img')[0];
this.parentNode.className += " modal";
//resizeImage.style.width = resizeImage.naturalWidth + "px";
resizeImage.style.height = resizeImage.naturalHeight + "px";
resizeImage.style.marginTop = "50px";
document.body.style.overflow = "hidden";
}
image.onclick = function() {
this.parentNode.className += " modal";
//this.style.width = this.naturalWidth + "px";
this.style.height = this.naturalHeight + "px";
this.style.marginTop = "50px";
document.body.style.overflow = "hidden";
}
closeIcon.onclick = function() {
resizeImage = this.parentNode.getElementsByTagName('img')[0];
this.parentNode.className = "lightbox";
//resizeImage.style.width = "300px";
resizeImage.style.height = "225px";
resizeImage.style.marginTop = 0;
document.body.style.overflow = "scroll";
};
};
}
lightBox();
var slideIndex = 1;
showSlides(slideIndex);
function plusSlides(n) {
showSlides(slideIndex += n);
}
function currentSlide(n) {
showSlides(slideIndex = n);
}
function showSlides(n) {
var i;
var slideshow = document.getElementsByClassName("slideshow")[0];
if (slideshow) {
var slides = slideshow.getElementsByClassName("lightbox");
if (slides && n > slides.length) { slideIndex = 1 }
if (slides && n < 1) { slideIndex = slides.length }
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
slides[slideIndex - 1].style.display = "block";
}
}