/*! By André Rinas, www.andrerinas.de Documentation, www.simplelightbox.de Available for use under the MIT License Version 2.1.2 */ "use strict";function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,e){for(var i=0;i",this.p.d=document.createElement("div"),this.p.d.classList.add("sl-navigation"),this.p.d.innerHTML='"),this.p.c=document.createElement("div"),this.p.c.classList.add("sl-counter"),this.p.c.innerHTML='/',this.p.g=document.createElement("div"),this.p.g.classList.add("sl-caption","pos-"+this.options.captionPosition),this.options.captionClass&&this.p.g.classList.add(this.options.captionClass),this.p.h=document.createElement("div"),this.p.h.classList.add("sl-image"),this.p.a=document.createElement("div"),this.p.a.classList.add("sl-wrapper"),this.options.className&&this.p.a.classList.add(this.options.className),this.options.rtl&&this.p.a.classList.add("sl-dir-rtl")}},{key:"throttle",value:function(t,e){var i;return function(){i||(t.apply(this,arguments),i=!0,setTimeout(function(){return i=!1},e))}}},{key:"isValidLink",value:function(t){return!this.options.fileExt||"pathname"in t&&new RegExp("("+this.options.fileExt+")$","i").test(t.pathname)}},{key:"calculateTransitionPrefix",value:function(){var t=(document.body||document.documentElement).style;return"transition"in t?"":"WebkitTransition"in t?"-webkit-":"MozTransition"in t?"-moz-":"OTransition"in t&&"-o"}},{key:"toggleScrollbar",value:function(t){var e=0;if("hide"===t){var i=window.innerWidth;if(!i){var n=document.documentElement.getBoundingClientRect();i=n.right-Math.abs(n.left)}if(document.body.clientWidth=this.relatedElements.length)&&!1===this.options.loop)return!1;this.nIndex=n<0?this.relatedElements.length-1:n>this.relatedElements.length-1?0:n,this.p.c.querySelector(".sl-current").innerHTML=this.nIndex+1,this.options.animationSlide&&this.slide(this.options.animationSpeed/1e3,-100*i-this.v.a+"px"),this.fadeOut(this.p.h,300,function(){e.h=!0,setTimeout(function(){var t=e.relatedElements[e.nIndex];e.n.setAttribute("src",t.getAttribute(e.options.sourceAttr)),-1===e.q.indexOf(t.getAttribute(e.options.sourceAttr))&&e.show(e.p.e),e.p.h.contains(e.p.g)&&e.p.h.removeChild(e.p.g),e.adjustImage(i),e.options.preloading&&e.preload()},100)})}},{key:"adjustImage",value:function(a){var r=this;if(!this.n)return!1;var t=new Image,l=window.innerWidth*this.options.widthRatio,h=window.innerHeight*this.options.heightRatio;t.setAttribute("src",this.n.getAttribute("src")),this.n.dataset.scale=1,this.n.dataset.translateX=0,this.n.dataset.translateY=0,this.zoomPanElement(0,0,1),t.addEventListener("error",function(t){r.relatedElements[r.nIndex].dispatchEvent(new Event("error."+r.o)),r.h=!1,r.g=!1,r.p.e.style.display="none";var e=1===a||-1===a;if(r.r===r.nIndex&&e)return r.close();r.options.alertError&&alert(r.options.alertErrorMessage),r.loadImage(e?a:1)}),t.addEventListener("load",function(t){void 0!==a&&(r.relatedElements[r.nIndex].dispatchEvent(new Event("changed."+r.o)),r.relatedElements[r.nIndex].dispatchEvent(new Event((1===a?"nextDone":"prevDone")+"."+r.o))),r.options.history&&r.updateURL(),-1===r.q.indexOf(r.n.getAttribute("src"))&&r.q.push(r.n.getAttribute("src"));var e=t.target.width,i=t.target.height;if(r.options.scaleImageToRatio||l=r.relatedElements.length-1&&r.hide(r.p.d.querySelector(".sl-next")),0=i.relatedElements.length-1&&0i.options.swipeTolerance&&e?i.loadImage(0m){var i=!0,n=!1,s=void 0;try{for(var o,a=p[Symbol.iterator]();!(i=(o=a.next()).done);i=!0){o.value.style.opacity=""}}catch(t){n=!0,s=t}finally{try{i||null==a.return||a.return()}finally{if(n)throw s}}c&&c.call(u,p)}else{var r=!0,l=!1,h=void 0;try{for(var v,d=p[Symbol.iterator]();!(r=(v=d.next()).done);r=!0){v.value.style.opacity=e}}catch(t){l=!0,h=t}finally{try{r||null==d.return||d.return()}finally{if(l)throw h}}requestAnimationFrame(t)}}()}},{key:"hide",value:function(t){t=this.wrap(t);var e=!0,i=!1,n=void 0;try{for(var s,o=t[Symbol.iterator]();!(e=(s=o.next()).done);e=!0){var a=s.value;a.dataset.initialDisplay=a.style.display,a.style.display="none"}}catch(t){i=!0,n=t}finally{try{e||null==o.return||o.return()}finally{if(i)throw n}}}},{key:"show",value:function(t,e){t=this.wrap(t);var i=!0,n=!1,s=void 0;try{for(var o,a=t[Symbol.iterator]();!(i=(o=a.next()).done);i=!0){var r=o.value;r.style.display=r.dataset.initialDisplay||e||"block"}}catch(t){n=!0,s=t}finally{try{i||null==a.return||a.return()}finally{if(n)throw s}}}},{key:"wrap",value:function(t){return"function"==typeof t[Symbol.iterator]&&"string"!=typeof t?t:[t]}},{key:"on",value:function(t,e){t=this.wrap(t);var i=!0,n=!1,s=void 0;try{for(var o,a=this.elements[Symbol.iterator]();!(i=(o=a.next()).done);i=!0){var r=o.value;r.fullyNamespacedEvents||(r.fullyNamespacedEvents={});var l=!0,h=!1,v=void 0;try{for(var d,p=t[Symbol.iterator]();!(l=(d=p.next()).done);l=!0){var c=d.value;r.fullyNamespacedEvents[c]=e,r.addEventListener(c,e)}}catch(t){h=!0,v=t}finally{try{l||null==p.return||p.return()}finally{if(h)throw v}}}}catch(t){n=!0,s=t}finally{try{i||null==a.return||a.return()}finally{if(n)throw s}}return this}},{key:"off",value:function(t){t=this.wrap(t);var e=!0,i=!1,n=void 0;try{for(var s,o=this.elements[Symbol.iterator]();!(e=(s=o.next()).done);e=!0){var a=s.value,r=!0,l=!1,h=void 0;try{for(var v,d=t[Symbol.iterator]();!(r=(v=d.next()).done);r=!0){var p=v.value;p in a.fullyNamespacedEvents&&a.removeEventListener(p,a.fullyNamespacedEvents[p])}}catch(t){l=!0,h=t}finally{try{r||null==d.return||d.return()}finally{if(l)throw h}}}}catch(t){i=!0,n=t}finally{try{e||null==o.return||o.return()}finally{if(i)throw n}}return this}},{key:"open",value:function(t){t=t||this.elements[0],this.r=this.elements.indexOf(t),this.openImage(t)}},{key:"next",value:function(){this.loadImage(1)}},{key:"prev",value:function(){this.loadImage(-1)}},{key:"destroy",value:function(){this.off(["close."+this.o,"closed."+this.o,"nextImageLoaded."+this.o,"prevImageLoaded."+this.o,"change."+this.o,"nextDone."+this.o,"prevDone."+this.o,"error."+this.o,"changed."+this.o,"next."+this.o,"prev."+this.o,"show."+this.o,"shown."+this.o]),this.removeEventListener(this.elements,"click."+this.o),this.removeEventListener(document.body,"contextmenu."+this.o),this.removeEventListener(document.body,"keyup."+this.o),this.removeEventListener(this.p.d,"click."+this.o),this.removeEventListener(this.p.b,"click."+this.o),this.removeEventListener(window,"resize."+this.o),this.removeEventListener(window,"hashchange."+this.o),this.close(),this.g&&(document.body.removeChild(this.p.a),document.body.removeChild(this.p.f)),this.elements=null}},{key:"refresh",value:function(){if(!this.t)throw"refreshing only works when you initialize using a selector!";var t=this.options,e=this.t;return this.destroy(),this.constructor(e,t),this}},{key:"hash",get:function(){return window.location.hash.substring(1)}}]),n}();!function(t){t.fn.simpleLightbox=function(t){return new SimpleLightbox(this.get(),t)}}(jQuery,(window,document));