-
Notifications
You must be signed in to change notification settings - Fork 0
/
lightbox.min.js
1 lines (1 loc) · 1.84 KB
/
lightbox.min.js
1
(function(e,t){"use strict";function n(e,t,n){e.addEventListener?e.addEventListener(t,n):e.attachEvent("on"+t,function(){n.call(e)})}function a(){if(!l){l=!0;var n=t.createElement("div"),a=t.createElement("div"),s=t.createElement("img");a.id="imgWrapper",s.id="imgTag",n.id="mask",a.setAttribute("style","position:absolute;top:50%;left:50%;width:0;transform:translate(-50%,-50%);-ms-transfrom:translate(-50%,-50%);-webkit-transform:translate(-50%,-50%);-o-transform:translate(-50%,-50%);-moz-transform:translate(-50%,-50%);z-index: 100;transition:all 1s;-moz-transition:all 1s;-webkit-transition:all 1s;-o-transition:all 1s;cursor:pointer;box-shadow: rgba(255, 255, 255, 0.8) 0px 0px 1em 8px;"),n.setAttribute("style","position:absolute;top:0;left:0;width:100%;height:100%;z-index:99;background:rgba(0,0,0,.8);"),n.style.display="none",a.style.display="none",a.appendChild(s),t.body.appendChild(n),t.body.appendChild(a),n.addEventListener("click",r,!1),e.previewImage=i,e.removePreviewImage=r}}function i(e){var n=t.querySelector(e),a=n.querySelectorAll("img");a=[].slice.call(a);var i=t.getElementById("imgWrapper"),r=[];a.forEach(function(e){r.push(e.src)}),n.addEventListener("click",function(e){var n=e.target;if("img"===n.nodeName.toLowerCase()){var a=n.getAttribute("src");imgTag.setAttribute("src",a),t.body.appendChild(mask),t.getElementById("mask").style.display="block",t.getElementById("imgWrapper").style.display="block",setTimeout(function(){t.getElementById("imgWrapper").style.width="60%"},100)}},!1),i.addEventListener("click",function(e){var t=e.target,n=[].indexOf.call(r,t.src)+1;n>=r.length&&(n=0),imgTag.setAttribute("src",r[n])},!1)}function r(){t.getElementById("mask").style.display="none",t.getElementById("imgWrapper").style.display="none",t.getElementById("imgWrapper").style.width="0"}var l=!1;n(t,"DOMContentLoaded",a),n(t,"onload",a)})(window,document);