-
Notifications
You must be signed in to change notification settings - Fork 1
/
imglightbox.js
47 lines (46 loc) · 1.46 KB
/
imglightbox.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
/**
* imglightbox
* @version 1.0.5
* @author Ferenc Czigler <[email protected]>
* @see https://github.com/Serrin/imgLightbox
*
* <link href="imglightbox.css" rel="stylesheet" type="text/css">
* <script src="imglightbox.js"></script>
*/
var imgLightbox = (function(){
"use strict";
return {
config: {
version: "1.0.5",
download: false,
newwindow: false
},
open: function (filename, download, newwindow) {
if (typeof download !== "boolean") { download = this.config.download; }
if (typeof newwindow !== "boolean") { newwindow = this.config.newwindow; }
var els = document.getElementById("imgLightbox").style;
els.backgroundImage = "url('"+filename+"')";
els.display = "block";
var dlbtn = document.getElementById("imgLightbox-button-download");
var nwbtn = document.getElementById("imgLightbox-button-newwindow");
if (download) {
dlbtn.style.display = "inline-block";
dlbtn.href = filename;
dlbtn.target = "_blank";
dlbtn.download = filename;
} else {
dlbtn.style.display = "none";
}
if (newwindow) {
nwbtn.style.display = "inline-block";
nwbtn.href = filename;
nwbtn.target = "_blank";
} else {
nwbtn.style.display = "none";
}
},
close: function () {
document.getElementById("imgLightbox").style.display="none";
}
};
}());