forked from ZwiiCMS-Team/ZwiiCMS
1 line
45 KiB
JavaScript
Executable File
1 line
45 KiB
JavaScript
Executable File
!function n(i,s,a){function r(e,t){if(!s[e]){if(!i[e]){var o="function"==typeof require&&require;if(!t&&o)return o(e,!0);if(l)return l(e,!0);throw(o=new Error("Cannot find module '"+e+"'")).code="MODULE_NOT_FOUND",o}o=s[e]={exports:{}},i[e][0].call(o.exports,function(t){return r(i[e][1][t]||t)},o,o.exports,n,i,s,a)}return s[e].exports}for(var l="function"==typeof require&&require,t=0;t<a.length;t++)r(a[t]);return r}({1:[function(t,e,o){"use strict";t("./simple-lightbox"),t=jQuery,window,document,t.fn.simpleLightbox=function(t){return this.length?new SimpleLightbox(this.get(),t):null}},{"./simple-lightbox":2}],2:[function(t,e,o){!function(e){!function(){"use strict";function h(t){return(h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function m(t,e){var o="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!o){if(Array.isArray(t)||(o=function(t,e){if(t){if("string"==typeof t)return r(t,e);var o=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(o="Object"===o&&t.constructor?t.constructor.name:o)||"Set"===o?Array.from(t):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?r(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){o&&(t=o);var n=0,e=function(){};return{s:e,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,s=!0,a=!1;return{s:function(){o=o.call(t)},n:function(){var t=o.next();return s=t.done,t},e:function(t){a=!0,i=t},f:function(){try{s||null==o.return||o.return()}finally{if(a)throw i}}}}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var o=0,n=new Array(e);o<e;o++)n[o]=t[o];return n}function n(t,e){for(var o=0;o<e.length;o++){var n=e[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function s(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}Object.defineProperty(o,"__esModule",{value:!0}),o.default=void 0;var t=function(){function i(t,e){var o,n=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,i),s(this,"defaultOptions",{sourceAttr:"href",overlay:!0,spinner:!0,nav:!0,navText:["‹","›"],captions:!0,captionDelay:0,captionSelector:"img",captionType:"attr",captionsData:"title",captionPosition:"bottom",captionClass:"",close:!0,closeText:"×",swipeClose:!0,showCounter:!0,fileExt:"png|jpg|jpeg|gif|webp",animationSlide:!0,animationSpeed:250,preloading:!0,enableKeyboard:!0,loop:!0,rel:!1,docClose:!0,swipeTolerance:50,className:"simple-lightbox",widthRatio:.8,heightRatio:.9,scaleImageToRatio:!1,disableRightClick:!1,disableScroll:!0,alertError:!0,alertErrorMessage:"Image not found, next image will be loaded",additionalHtml:!1,history:!0,throttleInterval:0,doubleTapZoom:2,maxZoom:10,htmlClass:"has-lightbox",rtl:!1,fixedClass:"sl-fixed",fadeSpeed:300,uniqueImages:!0,focus:!0,scrollZoom:!0,scrollZoomFactor:.5}),s(this,"transitionPrefix",void 0),s(this,"isPassiveEventsSupported",void 0),s(this,"transitionCapable",!1),s(this,"isTouchDevice","ontouchstart"in window),s(this,"isAppleDevice",/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform)),s(this,"initialLocationHash",void 0),s(this,"pushStateSupport","pushState"in history),s(this,"isOpen",!1),s(this,"isAnimating",!1),s(this,"isClosing",!1),s(this,"isFadeIn",!1),s(this,"urlChangedOnce",!1),s(this,"hashReseted",!1),s(this,"historyHasChanges",!1),s(this,"historyUpdateTimeout",null),s(this,"currentImage",void 0),s(this,"eventNamespace","simplelightbox"),s(this,"domNodes",{}),s(this,"loadedImages",[]),s(this,"initialImageIndex",0),s(this,"currentImageIndex",0),s(this,"initialSelector",null),s(this,"globalScrollbarWidth",0),s(this,"controlCoordinates",{swipeDiff:0,swipeYDiff:0,swipeStart:0,swipeEnd:0,swipeYStart:0,swipeYEnd:0,mousedown:!1,imageLeft:0,zoomed:!1,containerHeight:0,containerWidth:0,containerOffsetX:0,containerOffsetY:0,imgHeight:0,imgWidth:0,capture:!1,initialOffsetX:0,initialOffsetY:0,initialPointerOffsetX:0,initialPointerOffsetY:0,initialPointerOffsetX2:0,initialPointerOffsetY2:0,initialScale:1,initialPinchDistance:0,pointerOffsetX:0,pointerOffsetY:0,pointerOffsetX2:0,pointerOffsetY2:0,targetOffsetX:0,targetOffsetY:0,targetScale:0,pinchOffsetX:0,pinchOffsetY:0,limitOffsetX:0,limitOffsetY:0,scaleDifference:0,targetPinchDistance:0,touchCount:0,doubleTapped:!1,touchmoveCount:0}),this.options=Object.assign(this.defaultOptions,e),this.isPassiveEventsSupported=this.checkPassiveEventsSupport(),"string"==typeof t?(this.initialSelector=t,this.elements=Array.from(document.querySelectorAll(t))):this.elements=void 0!==t.length&&0<t.length?Array.from(t):[t],this.relatedElements=[],this.transitionPrefix=this.calculateTransitionPrefix(),this.transitionCapable=!1!==this.transitionPrefix,this.initialLocationHash=this.hash,this.options.rel&&(this.elements=this.getRelated(this.options.rel)),this.options.uniqueImages&&(o=[],this.elements=Array.from(this.elements).filter(function(t){t=t.getAttribute(n.options.sourceAttr);return-1===o.indexOf(t)&&(o.push(t),!0)})),this.createDomNodes(),this.options.close&&this.domNodes.wrapper.appendChild(this.domNodes.closeButton),this.options.nav&&this.domNodes.wrapper.appendChild(this.domNodes.navigation),this.options.spinner&&this.domNodes.wrapper.appendChild(this.domNodes.spinner),this.addEventListener(this.elements,"click."+this.eventNamespace,function(t){if(n.isValidLink(t.currentTarget)){if(t.preventDefault(),n.isAnimating)return!1;n.initialImageIndex=n.elements.indexOf(t.currentTarget),n.openImage(t.currentTarget)}}),this.options.docClose&&this.addEventListener(this.domNodes.wrapper,["click."+this.eventNamespace,"touchstart."+this.eventNamespace],function(t){n.isOpen&&t.target===t.currentTarget&&n.close()}),this.options.disableRightClick&&this.addEventListener(document.body,"contextmenu."+this.eventNamespace,function(t){t.target.parentElement.classList.contains("sl-image")&&t.preventDefault()}),this.options.enableKeyboard&&this.addEventListener(document.body,"keyup."+this.eventNamespace,this.throttle(function(t){return n.controlCoordinates.swipeDiff=0,n.isAnimating&&"Escape"===t.key?(n.currentImage.setAttribute("src",""),n.isAnimating=!1,n.close()):void(n.isOpen&&(t.preventDefault(),"Escape"===t.key&&n.close(),!n.isAnimating&&-1<["ArrowLeft","ArrowRight"].indexOf(t.key)&&n.loadImage("ArrowRight"===t.key?1:-1)))},this.options.throttleInterval)),this.addEvents()}var t,e,o;return t=i,(e=[{key:"checkPassiveEventsSupport",value:function(){var t=!1;try{var e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("testPassive",null,e),window.removeEventListener("testPassive",null,e)}catch(t){}return t}},{key:"createDomNodes",value:function(){this.domNodes.overlay=document.createElement("div"),this.domNodes.overlay.classList.add("sl-overlay"),this.domNodes.overlay.dataset.opacityTarget=".7",this.domNodes.closeButton=document.createElement("button"),this.domNodes.closeButton.classList.add("sl-close"),this.domNodes.closeButton.innerHTML=this.options.closeText,this.domNodes.spinner=document.createElement("div"),this.domNodes.spinner.classList.add("sl-spinner"),this.domNodes.spinner.innerHTML="<div></div>",this.domNodes.navigation=document.createElement("div"),this.domNodes.navigation.classList.add("sl-navigation"),this.domNodes.navigation.innerHTML='<button class="sl-prev">'.concat(this.options.navText[0],'</button><button class="sl-next">').concat(this.options.navText[1],"</button>"),this.domNodes.counter=document.createElement("div"),this.domNodes.counter.classList.add("sl-counter"),this.domNodes.counter.innerHTML='<span class="sl-current"></span>/<span class="sl-total"></span>',this.domNodes.caption=document.createElement("div"),this.domNodes.caption.classList.add("sl-caption","pos-"+this.options.captionPosition),this.options.captionClass&&this.domNodes.caption.classList.add(this.options.captionClass),this.domNodes.image=document.createElement("div"),this.domNodes.image.classList.add("sl-image"),this.domNodes.wrapper=document.createElement("div"),this.domNodes.wrapper.classList.add("sl-wrapper"),this.domNodes.wrapper.setAttribute("tabindex",-1),this.domNodes.wrapper.setAttribute("role","dialog"),this.domNodes.wrapper.setAttribute("aria-hidden",!1),this.options.className&&this.domNodes.wrapper.classList.add(this.options.className),this.options.rtl&&this.domNodes.wrapper.classList.add("sl-dir-rtl")}},{key:"throttle",value:function(t,e){var o;return function(){o||(t.apply(this,arguments),o=!0,setTimeout(function(){return o=!1},e))}}},{key:"isValidLink",value:function(t){return!this.options.fileExt||t.getAttribute(this.options.sourceAttr)&&new RegExp("("+this.options.fileExt+")$","i").test(t.getAttribute(this.options.sourceAttr))}},{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,n=0,o=[].slice.call(document.querySelectorAll("."+this.options.fixedClass));return"hide"===t?((t=window.innerWidth)||(t=(e=document.documentElement.getBoundingClientRect()).right-Math.abs(e.left)),(document.body.clientWidth<t||this.isAppleDevice)&&(e=document.createElement("div"),t=parseInt(document.body.style.paddingRight||0,10),e.classList.add("sl-scrollbar-measure"),document.body.appendChild(e),n=e.offsetWidth-e.clientWidth,document.body.removeChild(e),document.body.dataset.originalPaddingRight=t,(0<n||0==n&&this.isAppleDevice)&&(document.body.classList.add("hidden-scroll"),document.body.style.paddingRight=t+n+"px",o.forEach(function(t){var e=t.style.paddingRight,o=window.getComputedStyle(t)["padding-right"];t.dataset.originalPaddingRight=e,t.style.paddingRight="".concat(parseFloat(o)+n,"px")})))):(document.body.classList.remove("hidden-scroll"),document.body.style.paddingRight=document.body.dataset.originalPaddingRight,o.forEach(function(t){var e=t.dataset.originalPaddingRight;void 0!==e&&(t.style.paddingRight=e)})),n}},{key:"close",value:function(){var t=this;if(!this.isOpen||this.isAnimating||this.isClosing)return!1;this.isClosing=!0;var e,o=this.relatedElements[this.currentImageIndex];for(e in o.dispatchEvent(new Event("close.simplelightbox")),this.options.history&&(this.historyHasChanges=!1,this.hashReseted||this.resetHash()),this.removeEventListener(document,"focusin."+this.eventNamespace),this.fadeOut(document.querySelectorAll(".sl-image img, .sl-overlay, .sl-close, .sl-navigation, .sl-image .sl-caption, .sl-counter"),this.options.fadeSpeed,function(){t.options.disableScroll&&t.toggleScrollbar("show"),t.options.htmlClass&&""!==t.options.htmlClass&&document.querySelector("html").classList.remove(t.options.htmlClass),document.body.removeChild(t.domNodes.wrapper),document.body.removeChild(t.domNodes.overlay),t.domNodes.additionalHtml=null,o.dispatchEvent(new Event("closed.simplelightbox")),t.isClosing=!1}),this.currentImage=null,this.isOpen=!1,this.isAnimating=!1,this.controlCoordinates)this.controlCoordinates[e]=0;this.controlCoordinates.mousedown=!1,this.controlCoordinates.zoomed=!1,this.controlCoordinates.capture=!1,this.controlCoordinates.initialScale=this.minMax(1,1,this.options.maxZoom),this.controlCoordinates.doubleTapped=!1}},{key:"hash",get:function(){return window.location.hash.substring(1)}},{key:"preload",value:function(){var e=this,o=this.currentImageIndex,t=this.relatedElements.length,n=o+1<0?t-1:t-1<=o+1?0:o+1,i=o-1<0?t-1:t-1<=o-1?0:o-1,s=new Image,t=new Image;s.addEventListener("load",function(t){t=t.target.getAttribute("src");-1===e.loadedImages.indexOf(t)&&e.loadedImages.push(t),e.relatedElements[o].dispatchEvent(new Event("nextImageLoaded."+e.eventNamespace))}),s.setAttribute("src",this.relatedElements[n].getAttribute(this.options.sourceAttr)),t.addEventListener("load",function(t){t=t.target.getAttribute("src");-1===e.loadedImages.indexOf(t)&&e.loadedImages.push(t),e.relatedElements[o].dispatchEvent(new Event("prevImageLoaded."+e.eventNamespace))}),t.setAttribute("src",this.relatedElements[i].getAttribute(this.options.sourceAttr))}},{key:"loadImage",value:function(t){var e=this,o=t;this.options.rtl&&(t=-t),this.relatedElements[this.currentImageIndex].dispatchEvent(new Event("change."+this.eventNamespace)),this.relatedElements[this.currentImageIndex].dispatchEvent(new Event((1===t?"next":"prev")+"."+this.eventNamespace));t=this.currentImageIndex+t;if(this.isAnimating||(t<0||t>=this.relatedElements.length)&&!1===this.options.loop)return!1;this.currentImageIndex=t<0?this.relatedElements.length-1:t>this.relatedElements.length-1?0:t,this.domNodes.counter.querySelector(".sl-current").innerHTML=this.currentImageIndex+1,this.options.animationSlide&&this.slide(this.options.animationSpeed/1e3,-100*o-this.controlCoordinates.swipeDiff+"px"),this.fadeOut(this.domNodes.image,this.options.fadeSpeed,function(){e.isAnimating=!0,e.isClosing?e.isAnimating=!1:setTimeout(function(){var t=e.relatedElements[e.currentImageIndex];e.currentImage.setAttribute("src",t.getAttribute(e.options.sourceAttr)),-1===e.loadedImages.indexOf(t.getAttribute(e.options.sourceAttr))&&e.show(e.domNodes.spinner),e.domNodes.image.contains(e.domNodes.caption)&&e.domNodes.image.removeChild(e.domNodes.caption),e.adjustImage(o),e.options.preloading&&e.preload()},100)})}},{key:"adjustImage",value:function(s){var a=this;if(!this.currentImage)return!1;var t=new Image,r=window.innerWidth*this.options.widthRatio,l=window.innerHeight*this.options.heightRatio;t.setAttribute("src",this.currentImage.getAttribute("src")),this.currentImage.dataset.scale=1,this.currentImage.dataset.translateX=0,this.currentImage.dataset.translateY=0,this.zoomPanElement(0,0,1),t.addEventListener("error",function(t){a.relatedElements[a.currentImageIndex].dispatchEvent(new Event("error."+a.eventNamespace)),a.isAnimating=!1,a.isOpen=!0,a.domNodes.spinner.style.display="none";var e=1===s||-1===s;if(a.initialImageIndex===a.currentImageIndex&&e)return a.close();a.options.alertError&&alert(a.options.alertErrorMessage),a.loadImage(e?s:1)}),t.addEventListener("load",function(t){void 0!==s&&(a.relatedElements[a.currentImageIndex].dispatchEvent(new Event("changed."+a.eventNamespace)),a.relatedElements[a.currentImageIndex].dispatchEvent(new Event((1===s?"nextDone":"prevDone")+"."+a.eventNamespace))),a.options.history&&a.updateURL(),-1===a.loadedImages.indexOf(a.currentImage.getAttribute("src"))&&a.loadedImages.push(a.currentImage.getAttribute("src"));var e,o,n=t.target.width,i=t.target.height;(a.options.scaleImageToRatio||r<n||l<i)&&(n/=t=r/l<n/i?n/r:i/l,i/=t),a.domNodes.image.style.top=(window.innerHeight-i)/2+"px",a.domNodes.image.style.left=(window.innerWidth-n-a.globalScrollbarWidth)/2+"px",a.domNodes.image.style.width=n+"px",a.domNodes.image.style.height=i+"px",a.domNodes.spinner.style.display="none",a.options.focus&&a.forceFocus(),a.fadeIn(a.currentImage,a.options.fadeSpeed,function(){a.options.focus&&a.domNodes.wrapper.focus()}),a.isOpen=!0,"string"==typeof a.options.captionSelector?e="self"===a.options.captionSelector?a.relatedElements[a.currentImageIndex]:a.relatedElements[a.currentImageIndex].querySelector(a.options.captionSelector):"function"==typeof a.options.captionSelector&&(e=a.options.captionSelector(a.relatedElements[a.currentImageIndex])),a.options.captions&&e&&(o="data"===a.options.captionType?e.dataset[a.options.captionsData]:"text"===a.options.captionType?e.innerHTML:e.getAttribute(a.options.captionsData)),a.options.loop?1===a.relatedElements.length?a.hide(a.domNodes.navigation.querySelectorAll(".sl-prev, .sl-next")):a.show(a.domNodes.navigation.querySelectorAll(".sl-prev, .sl-next")):(0===a.currentImageIndex&&a.hide(a.domNodes.navigation.querySelector(".sl-prev")),a.currentImageIndex>=a.relatedElements.length-1&&a.hide(a.domNodes.navigation.querySelector(".sl-next")),0<a.currentImageIndex&&a.show(a.domNodes.navigation.querySelector(".sl-prev")),a.currentImageIndex<a.relatedElements.length-1&&a.show(a.domNodes.navigation.querySelector(".sl-next"))),1===s||-1===s?(a.options.animationSlide&&(a.slide(0,100*s+"px"),setTimeout(function(){a.slide(a.options.animationSpeed/1e3,"0px")},50)),a.fadeIn(a.domNodes.image,a.options.fadeSpeed,function(){a.isAnimating=!1,a.setCaption(o,n)})):(a.isAnimating=!1,a.setCaption(o,n)),a.options.additionalHtml&&!a.domNodes.additionalHtml&&(a.domNodes.additionalHtml=document.createElement("div"),a.domNodes.additionalHtml.classList.add("sl-additional-html"),a.domNodes.additionalHtml.innerHTML=a.options.additionalHtml,a.domNodes.image.appendChild(a.domNodes.additionalHtml))})}},{key:"zoomPanElement",value:function(t,e,o){this.currentImage.style[this.transitionPrefix+"transform"]="translate("+t+","+e+") scale("+o+")"}},{key:"minMax",value:function(t,e,o){return t<e?e:o<t?o:t}},{key:"setZoomData",value:function(t,e,o){this.currentImage.dataset.scale=t,this.currentImage.dataset.translateX=e,this.currentImage.dataset.translateY=o}},{key:"hashchangeHandler",value:function(){this.isOpen&&this.hash===this.initialLocationHash&&(this.hashReseted=!0,this.close())}},{key:"addEvents",value:function(){var o,n=this;this.addEventListener(window,"resize."+this.eventNamespace,function(t){n.isOpen&&n.adjustImage()}),this.addEventListener(this.domNodes.closeButton,["click."+this.eventNamespace,"touchstart."+this.eventNamespace],this.close.bind(this)),this.options.history&&setTimeout(function(){n.addEventListener(window,"hashchange."+n.eventNamespace,function(t){n.isOpen&&n.hashchangeHandler()})},40),this.addEventListener(this.domNodes.navigation.getElementsByTagName("button"),"click."+this.eventNamespace,function(t){return!t.currentTarget.tagName.match(/button/i)||(t.preventDefault(),n.controlCoordinates.swipeDiff=0,void n.loadImage(t.currentTarget.classList.contains("sl-next")?1:-1))}),this.options.scrollZoom&&(o=1,this.addEventListener(this.domNodes.image,["mousewheel","DOMMouseScroll"],function(t){if(n.controlCoordinates.mousedown||n.isAnimating||n.isClosing||!n.isOpen)return!0;0==n.controlCoordinates.containerHeight&&(n.controlCoordinates.containerHeight=n.getDimensions(n.domNodes.image).height,n.controlCoordinates.containerWidth=n.getDimensions(n.domNodes.image).width,n.controlCoordinates.imgHeight=n.getDimensions(n.currentImage).height,n.controlCoordinates.imgWidth=n.getDimensions(n.currentImage).width,n.controlCoordinates.containerOffsetX=n.domNodes.image.offsetLeft,n.controlCoordinates.containerOffsetY=n.domNodes.image.offsetTop,n.controlCoordinates.initialOffsetX=parseFloat(n.currentImage.dataset.translateX),n.controlCoordinates.initialOffsetY=parseFloat(n.currentImage.dataset.translateY)),t.preventDefault();var e=t.delta||t.wheelDelta;void 0===e&&(e=t.detail),e=Math.max(-1,Math.min(1,e)),o+=e*n.options.scrollZoomFactor*o,o=Math.max(1,Math.min(n.options.maxZoom,o)),n.controlCoordinates.targetScale=o,n.controlCoordinates.pinchOffsetX=t.pageX,n.controlCoordinates.pinchOffsetY=t.pageY,n.controlCoordinates.limitOffsetX=(n.controlCoordinates.imgWidth*n.controlCoordinates.targetScale-n.controlCoordinates.containerWidth)/2,n.controlCoordinates.limitOffsetY=(n.controlCoordinates.imgHeight*n.controlCoordinates.targetScale-n.controlCoordinates.containerHeight)/2,n.controlCoordinates.scaleDifference=n.controlCoordinates.targetScale-n.controlCoordinates.initialScale,n.controlCoordinates.targetOffsetX=n.controlCoordinates.imgWidth*n.controlCoordinates.targetScale<=n.controlCoordinates.containerWidth?0:n.minMax(n.controlCoordinates.initialOffsetX-(n.controlCoordinates.pinchOffsetX-n.controlCoordinates.containerOffsetX-n.controlCoordinates.containerWidth/2-n.controlCoordinates.initialOffsetX)/(n.controlCoordinates.targetScale-n.controlCoordinates.scaleDifference)*n.controlCoordinates.scaleDifference,-1*n.controlCoordinates.limitOffsetX,n.controlCoordinates.limitOffsetX),n.controlCoordinates.targetOffsetY=n.controlCoordinates.imgHeight*n.controlCoordinates.targetScale<=n.controlCoordinates.containerHeight?0:n.minMax(n.controlCoordinates.initialOffsetY-(n.controlCoordinates.pinchOffsetY-n.controlCoordinates.containerOffsetY-n.controlCoordinates.containerHeight/2-n.controlCoordinates.initialOffsetY)/(n.controlCoordinates.targetScale-n.controlCoordinates.scaleDifference)*n.controlCoordinates.scaleDifference,-1*n.controlCoordinates.limitOffsetY,n.controlCoordinates.limitOffsetY),n.zoomPanElement(n.controlCoordinates.targetOffsetX+"px",n.controlCoordinates.targetOffsetY+"px",n.controlCoordinates.targetScale),1<n.controlCoordinates.targetScale?(n.controlCoordinates.zoomed=!0,n.domNodes.caption.style.opacity||"none"===n.domNodes.caption.style.display||n.fadeOut(n.domNodes.caption,n.options.fadeSpeed)):(1===n.controlCoordinates.initialScale&&(n.controlCoordinates.zoomed=!1,"none"===n.domNodes.caption.style.display&&n.fadeIn(n.domNodes.caption,n.options.fadeSpeed)),n.controlCoordinates.initialPinchDistance=null,n.controlCoordinates.capture=!1),n.controlCoordinates.initialPinchDistance=n.controlCoordinates.targetPinchDistance,n.controlCoordinates.initialScale=n.controlCoordinates.targetScale,n.controlCoordinates.initialOffsetX=n.controlCoordinates.targetOffsetX,n.controlCoordinates.initialOffsetY=n.controlCoordinates.targetOffsetY,n.setZoomData(n.controlCoordinates.targetScale,n.controlCoordinates.targetOffsetX,n.controlCoordinates.targetOffsetY),n.zoomPanElement(n.controlCoordinates.targetOffsetX+"px",n.controlCoordinates.targetOffsetY+"px",n.controlCoordinates.targetScale)})),this.addEventListener(this.domNodes.image,["touchstart."+this.eventNamespace,"mousedown."+this.eventNamespace],function(t){if("A"===t.target.tagName&&"touchstart"===t.type)return!0;if("mousedown"===t.type)t.preventDefault(),n.controlCoordinates.initialPointerOffsetX=t.clientX,n.controlCoordinates.initialPointerOffsetY=t.clientY,n.controlCoordinates.containerHeight=n.getDimensions(n.domNodes.image).height,n.controlCoordinates.containerWidth=n.getDimensions(n.domNodes.image).width,n.controlCoordinates.imgHeight=n.getDimensions(n.currentImage).height,n.controlCoordinates.imgWidth=n.getDimensions(n.currentImage).width,n.controlCoordinates.containerOffsetX=n.domNodes.image.offsetLeft,n.controlCoordinates.containerOffsetY=n.domNodes.image.offsetTop,n.controlCoordinates.initialOffsetX=parseFloat(n.currentImage.dataset.translateX),n.controlCoordinates.initialOffsetY=parseFloat(n.currentImage.dataset.translateY),n.controlCoordinates.capture=!0;else{if(n.controlCoordinates.touchCount=t.touches.length,n.controlCoordinates.initialPointerOffsetX=t.touches[0].clientX,n.controlCoordinates.initialPointerOffsetY=t.touches[0].clientY,n.controlCoordinates.containerHeight=n.getDimensions(n.domNodes.image).height,n.controlCoordinates.containerWidth=n.getDimensions(n.domNodes.image).width,n.controlCoordinates.imgHeight=n.getDimensions(n.currentImage).height,n.controlCoordinates.imgWidth=n.getDimensions(n.currentImage).width,n.controlCoordinates.containerOffsetX=n.domNodes.image.offsetLeft,n.controlCoordinates.containerOffsetY=n.domNodes.image.offsetTop,1===n.controlCoordinates.touchCount){if(n.controlCoordinates.doubleTapped)return n.currentImage.classList.add("sl-transition"),n.controlCoordinates.zoomed?(n.controlCoordinates.initialScale=1,n.setZoomData(n.controlCoordinates.initialScale,0,0),n.zoomPanElement("0px","0px",n.controlCoordinates.initialScale),n.controlCoordinates.zoomed=!1):(n.controlCoordinates.initialScale=n.options.doubleTapZoom,n.setZoomData(n.controlCoordinates.initialScale,0,0),n.zoomPanElement("0px","0px",n.controlCoordinates.initialScale),n.domNodes.caption.style.opacity||"none"===n.domNodes.caption.style.display||n.fadeOut(n.domNodes.caption,n.options.fadeSpeed),n.controlCoordinates.zoomed=!0),setTimeout(function(){n.currentImage&&n.currentImage.classList.remove("sl-transition")},200),!1;n.controlCoordinates.doubleTapped=!0,setTimeout(function(){n.controlCoordinates.doubleTapped=!1},300),n.controlCoordinates.initialOffsetX=parseFloat(n.currentImage.dataset.translateX),n.controlCoordinates.initialOffsetY=parseFloat(n.currentImage.dataset.translateY)}else 2===n.controlCoordinates.touchCount&&(n.controlCoordinates.initialPointerOffsetX2=t.touches[1].clientX,n.controlCoordinates.initialPointerOffsetY2=t.touches[1].clientY,n.controlCoordinates.initialOffsetX=parseFloat(n.currentImage.dataset.translateX),n.controlCoordinates.initialOffsetY=parseFloat(n.currentImage.dataset.translateY),n.controlCoordinates.pinchOffsetX=(n.controlCoordinates.initialPointerOffsetX+n.controlCoordinates.initialPointerOffsetX2)/2,n.controlCoordinates.pinchOffsetY=(n.controlCoordinates.initialPointerOffsetY+n.controlCoordinates.initialPointerOffsetY2)/2,n.controlCoordinates.initialPinchDistance=Math.sqrt((n.controlCoordinates.initialPointerOffsetX-n.controlCoordinates.initialPointerOffsetX2)*(n.controlCoordinates.initialPointerOffsetX-n.controlCoordinates.initialPointerOffsetX2)+(n.controlCoordinates.initialPointerOffsetY-n.controlCoordinates.initialPointerOffsetY2)*(n.controlCoordinates.initialPointerOffsetY-n.controlCoordinates.initialPointerOffsetY2)));n.controlCoordinates.capture=!0}return!!n.controlCoordinates.mousedown||(n.transitionCapable&&(n.controlCoordinates.imageLeft=parseInt(n.domNodes.image.style.left,10)),n.controlCoordinates.mousedown=!0,n.controlCoordinates.swipeDiff=0,n.controlCoordinates.swipeYDiff=0,n.controlCoordinates.swipeStart=t.pageX||t.touches[0].pageX,n.controlCoordinates.swipeYStart=t.pageY||t.touches[0].pageY,!1)}),this.addEventListener(this.domNodes.image,["touchmove."+this.eventNamespace,"mousemove."+this.eventNamespace,"MSPointerMove"],function(t){if(!n.controlCoordinates.mousedown)return!0;if("touchmove"===t.type){if(!1===n.controlCoordinates.capture)return!1;n.controlCoordinates.pointerOffsetX=t.touches[0].clientX,n.controlCoordinates.pointerOffsetY=t.touches[0].clientY,n.controlCoordinates.touchCount=t.touches.length,n.controlCoordinates.touchmoveCount++,1<n.controlCoordinates.touchCount?(n.controlCoordinates.pointerOffsetX2=t.touches[1].clientX,n.controlCoordinates.pointerOffsetY2=t.touches[1].clientY,n.controlCoordinates.targetPinchDistance=Math.sqrt((n.controlCoordinates.pointerOffsetX-n.controlCoordinates.pointerOffsetX2)*(n.controlCoordinates.pointerOffsetX-n.controlCoordinates.pointerOffsetX2)+(n.controlCoordinates.pointerOffsetY-n.controlCoordinates.pointerOffsetY2)*(n.controlCoordinates.pointerOffsetY-n.controlCoordinates.pointerOffsetY2)),null===n.controlCoordinates.initialPinchDistance&&(n.controlCoordinates.initialPinchDistance=n.controlCoordinates.targetPinchDistance),1<=Math.abs(n.controlCoordinates.initialPinchDistance-n.controlCoordinates.targetPinchDistance)&&(n.controlCoordinates.targetScale=n.minMax(n.controlCoordinates.targetPinchDistance/n.controlCoordinates.initialPinchDistance*n.controlCoordinates.initialScale,1,n.options.maxZoom),n.controlCoordinates.limitOffsetX=(n.controlCoordinates.imgWidth*n.controlCoordinates.targetScale-n.controlCoordinates.containerWidth)/2,n.controlCoordinates.limitOffsetY=(n.controlCoordinates.imgHeight*n.controlCoordinates.targetScale-n.controlCoordinates.containerHeight)/2,n.controlCoordinates.scaleDifference=n.controlCoordinates.targetScale-n.controlCoordinates.initialScale,n.controlCoordinates.targetOffsetX=n.controlCoordinates.imgWidth*n.controlCoordinates.targetScale<=n.controlCoordinates.containerWidth?0:n.minMax(n.controlCoordinates.initialOffsetX-(n.controlCoordinates.pinchOffsetX-n.controlCoordinates.containerOffsetX-n.controlCoordinates.containerWidth/2-n.controlCoordinates.initialOffsetX)/(n.controlCoordinates.targetScale-n.controlCoordinates.scaleDifference)*n.controlCoordinates.scaleDifference,-1*n.controlCoordinates.limitOffsetX,n.controlCoordinates.limitOffsetX),n.controlCoordinates.targetOffsetY=n.controlCoordinates.imgHeight*n.controlCoordinates.targetScale<=n.controlCoordinates.containerHeight?0:n.minMax(n.controlCoordinates.initialOffsetY-(n.controlCoordinates.pinchOffsetY-n.controlCoordinates.containerOffsetY-n.controlCoordinates.containerHeight/2-n.controlCoordinates.initialOffsetY)/(n.controlCoordinates.targetScale-n.controlCoordinates.scaleDifference)*n.controlCoordinates.scaleDifference,-1*n.controlCoordinates.limitOffsetY,n.controlCoordinates.limitOffsetY),n.zoomPanElement(n.controlCoordinates.targetOffsetX+"px",n.controlCoordinates.targetOffsetY+"px",n.controlCoordinates.targetScale),1<n.controlCoordinates.targetScale&&(n.controlCoordinates.zoomed=!0,n.domNodes.caption.style.opacity||"none"===n.domNodes.caption.style.display||n.fadeOut(n.domNodes.caption,n.options.fadeSpeed)),n.controlCoordinates.initialPinchDistance=n.controlCoordinates.targetPinchDistance,n.controlCoordinates.initialScale=n.controlCoordinates.targetScale,n.controlCoordinates.initialOffsetX=n.controlCoordinates.targetOffsetX,n.controlCoordinates.initialOffsetY=n.controlCoordinates.targetOffsetY)):(n.controlCoordinates.targetScale=n.controlCoordinates.initialScale,n.controlCoordinates.limitOffsetX=(n.controlCoordinates.imgWidth*n.controlCoordinates.targetScale-n.controlCoordinates.containerWidth)/2,n.controlCoordinates.limitOffsetY=(n.controlCoordinates.imgHeight*n.controlCoordinates.targetScale-n.controlCoordinates.containerHeight)/2,n.controlCoordinates.targetOffsetX=n.controlCoordinates.imgWidth*n.controlCoordinates.targetScale<=n.controlCoordinates.containerWidth?0:n.minMax(n.controlCoordinates.pointerOffsetX-(n.controlCoordinates.initialPointerOffsetX-n.controlCoordinates.initialOffsetX),-1*n.controlCoordinates.limitOffsetX,n.controlCoordinates.limitOffsetX),n.controlCoordinates.targetOffsetY=n.controlCoordinates.imgHeight*n.controlCoordinates.targetScale<=n.controlCoordinates.containerHeight?0:n.minMax(n.controlCoordinates.pointerOffsetY-(n.controlCoordinates.initialPointerOffsetY-n.controlCoordinates.initialOffsetY),-1*n.controlCoordinates.limitOffsetY,n.controlCoordinates.limitOffsetY),Math.abs(n.controlCoordinates.targetOffsetX)===Math.abs(n.controlCoordinates.limitOffsetX)&&(n.controlCoordinates.initialOffsetX=n.controlCoordinates.targetOffsetX,n.controlCoordinates.initialPointerOffsetX=n.controlCoordinates.pointerOffsetX),Math.abs(n.controlCoordinates.targetOffsetY)===Math.abs(n.controlCoordinates.limitOffsetY)&&(n.controlCoordinates.initialOffsetY=n.controlCoordinates.targetOffsetY,n.controlCoordinates.initialPointerOffsetY=n.controlCoordinates.pointerOffsetY),n.setZoomData(n.controlCoordinates.initialScale,n.controlCoordinates.targetOffsetX,n.controlCoordinates.targetOffsetY),n.zoomPanElement(n.controlCoordinates.targetOffsetX+"px",n.controlCoordinates.targetOffsetY+"px",n.controlCoordinates.targetScale))}if("mousemove"===t.type&&n.controlCoordinates.mousedown){if("touchmove"==t.type)return!0;if(t.preventDefault(),!1===n.controlCoordinates.capture)return!1;n.controlCoordinates.pointerOffsetX=t.clientX,n.controlCoordinates.pointerOffsetY=t.clientY,n.controlCoordinates.targetScale=n.controlCoordinates.initialScale,n.controlCoordinates.limitOffsetX=(n.controlCoordinates.imgWidth*n.controlCoordinates.targetScale-n.controlCoordinates.containerWidth)/2,n.controlCoordinates.limitOffsetY=(n.controlCoordinates.imgHeight*n.controlCoordinates.targetScale-n.controlCoordinates.containerHeight)/2,n.controlCoordinates.targetOffsetX=n.controlCoordinates.imgWidth*n.controlCoordinates.targetScale<=n.controlCoordinates.containerWidth?0:n.minMax(n.controlCoordinates.pointerOffsetX-(n.controlCoordinates.initialPointerOffsetX-n.controlCoordinates.initialOffsetX),-1*n.controlCoordinates.limitOffsetX,n.controlCoordinates.limitOffsetX),n.controlCoordinates.targetOffsetY=n.controlCoordinates.imgHeight*n.controlCoordinates.targetScale<=n.controlCoordinates.containerHeight?0:n.minMax(n.controlCoordinates.pointerOffsetY-(n.controlCoordinates.initialPointerOffsetY-n.controlCoordinates.initialOffsetY),-1*n.controlCoordinates.limitOffsetY,n.controlCoordinates.limitOffsetY),Math.abs(n.controlCoordinates.targetOffsetX)===Math.abs(n.controlCoordinates.limitOffsetX)&&(n.controlCoordinates.initialOffsetX=n.controlCoordinates.targetOffsetX,n.controlCoordinates.initialPointerOffsetX=n.controlCoordinates.pointerOffsetX),Math.abs(n.controlCoordinates.targetOffsetY)===Math.abs(n.controlCoordinates.limitOffsetY)&&(n.controlCoordinates.initialOffsetY=n.controlCoordinates.targetOffsetY,n.controlCoordinates.initialPointerOffsetY=n.controlCoordinates.pointerOffsetY),n.setZoomData(n.controlCoordinates.initialScale,n.controlCoordinates.targetOffsetX,n.controlCoordinates.targetOffsetY),n.zoomPanElement(n.controlCoordinates.targetOffsetX+"px",n.controlCoordinates.targetOffsetY+"px",n.controlCoordinates.targetScale)}n.controlCoordinates.zoomed||(n.controlCoordinates.swipeEnd=t.pageX||t.touches[0].pageX,n.controlCoordinates.swipeYEnd=t.pageY||t.touches[0].pageY,n.controlCoordinates.swipeDiff=n.controlCoordinates.swipeStart-n.controlCoordinates.swipeEnd,n.controlCoordinates.swipeYDiff=n.controlCoordinates.swipeYStart-n.controlCoordinates.swipeYEnd,n.options.animationSlide&&n.slide(0,-n.controlCoordinates.swipeDiff+"px"))}),this.addEventListener(this.domNodes.image,["touchend."+this.eventNamespace,"mouseup."+this.eventNamespace,"touchcancel."+this.eventNamespace,"mouseleave."+this.eventNamespace,"pointerup","pointercancel","MSPointerUp","MSPointerCancel"],function(t){n.isTouchDevice&&"touchend"===t.type&&(n.controlCoordinates.touchCount=t.touches.length,0===n.controlCoordinates.touchCount?(n.currentImage&&n.setZoomData(n.controlCoordinates.initialScale,n.controlCoordinates.targetOffsetX,n.controlCoordinates.targetOffsetY),1===n.controlCoordinates.initialScale&&(n.controlCoordinates.zoomed=!1,"none"===n.domNodes.caption.style.display&&n.fadeIn(n.domNodes.caption,n.options.fadeSpeed)),n.controlCoordinates.initialPinchDistance=null,n.controlCoordinates.capture=!1):1===n.controlCoordinates.touchCount?(n.controlCoordinates.initialPointerOffsetX=t.touches[0].clientX,n.controlCoordinates.initialPointerOffsetY=t.touches[0].clientY):1<n.controlCoordinates.touchCount&&(n.controlCoordinates.initialPinchDistance=null)),n.controlCoordinates.mousedown&&(t=!(n.controlCoordinates.mousedown=!1),n.options.loop||(0===n.currentImageIndex&&n.controlCoordinates.swipeDiff<0&&(t=!1),n.currentImageIndex>=n.relatedElements.length-1&&0<n.controlCoordinates.swipeDiff&&(t=!1)),Math.abs(n.controlCoordinates.swipeDiff)>n.options.swipeTolerance&&t?n.loadImage(0<n.controlCoordinates.swipeDiff?1:-1):n.options.animationSlide&&n.slide(n.options.animationSpeed/1e3,"0px"),n.options.swipeClose&&50<Math.abs(n.controlCoordinates.swipeYDiff)&&Math.abs(n.controlCoordinates.swipeDiff)<n.options.swipeTolerance&&n.close())}),this.addEventListener(this.domNodes.image,["dblclick"],function(t){if(!n.isTouchDevice)return n.controlCoordinates.initialPointerOffsetX=t.clientX,n.controlCoordinates.initialPointerOffsetY=t.clientY,n.controlCoordinates.containerHeight=n.getDimensions(n.domNodes.image).height,n.controlCoordinates.containerWidth=n.getDimensions(n.domNodes.image).width,n.controlCoordinates.imgHeight=n.getDimensions(n.currentImage).height,n.controlCoordinates.imgWidth=n.getDimensions(n.currentImage).width,n.controlCoordinates.containerOffsetX=n.domNodes.image.offsetLeft,n.controlCoordinates.containerOffsetY=n.domNodes.image.offsetTop,n.currentImage.classList.add("sl-transition"),n.controlCoordinates.zoomed?(n.controlCoordinates.initialScale=1,n.setZoomData(n.controlCoordinates.initialScale,0,0),n.zoomPanElement("0px","0px",n.controlCoordinates.initialScale),n.controlCoordinates.zoomed=!1,"none"===n.domNodes.caption.style.display&&n.fadeIn(n.domNodes.caption,n.options.fadeSpeed)):(n.controlCoordinates.initialScale=n.options.doubleTapZoom,n.setZoomData(n.controlCoordinates.initialScale,0,0),n.zoomPanElement("0px","0px",n.controlCoordinates.initialScale),n.domNodes.caption.style.opacity||"none"===n.domNodes.caption.style.display||n.fadeOut(n.domNodes.caption,n.options.fadeSpeed),n.controlCoordinates.zoomed=!0),setTimeout(function(){n.currentImage&&(n.currentImage.classList.remove("sl-transition"),n.currentImage.style[n.transitionPrefix+"transform-origin"]=null)},200),!(n.controlCoordinates.capture=!0)})}},{key:"getDimensions",value:function(t){var e=window.getComputedStyle(t),o=t.offsetHeight,n=t.offsetWidth,t=parseFloat(e.borderTopWidth);return{height:o-parseFloat(e.borderBottomWidth)-t-parseFloat(e.paddingTop)-parseFloat(e.paddingBottom),width:n-parseFloat(e.borderLeftWidth)-parseFloat(e.borderRightWidth)-parseFloat(e.paddingLeft)-parseFloat(e.paddingRight)}}},{key:"updateHash",value:function(){var t="pid="+(this.currentImageIndex+1),e=window.location.href.split("#")[0]+"#"+t;this.hashReseted=!1,this.pushStateSupport?window.history[this.historyHasChanges?"replaceState":"pushState"]("",document.title,e):this.historyHasChanges?window.location.replace(e):window.location.hash=t,this.historyHasChanges||(this.urlChangedOnce=!0),this.historyHasChanges=!0}},{key:"resetHash",value:function(){this.hashReseted=!0,this.urlChangedOnce?history.back():this.pushStateSupport?history.pushState("",document.title,window.location.pathname+window.location.search):window.location.hash="",clearTimeout(this.historyUpdateTimeout)}},{key:"updateURL",value:function(){clearTimeout(this.historyUpdateTimeout),this.historyHasChanges?this.historyUpdateTimeout=setTimeout(this.updateHash.bind(this),800):this.updateHash()}},{key:"setCaption",value:function(t,e){var o=this;this.options.captions&&t&&""!==t&&void 0!==t&&(this.hide(this.domNodes.caption),this.domNodes.caption.style.width=e+"px",this.domNodes.caption.innerHTML=t,this.domNodes.image.appendChild(this.domNodes.caption),setTimeout(function(){o.fadeIn(o.domNodes.caption,o.options.fadeSpeed)},this.options.captionDelay))}},{key:"slide",value:function(t,e){if(!this.transitionCapable)return this.domNodes.image.style.left=e;this.domNodes.image.style[this.transitionPrefix+"transform"]="translateX("+e+")",this.domNodes.image.style[this.transitionPrefix+"transition"]=this.transitionPrefix+"transform "+t+"s linear"}},{key:"getRelated",value:function(e){var t=e&&!1!==e&&"nofollow"!==e?Array.from(this.elements).filter(function(t){return t.getAttribute("rel")===e}):this.elements;return t}},{key:"openImage",value:function(t){var e=this;t.dispatchEvent(new Event("show."+this.eventNamespace)),this.options.disableScroll&&(this.globalScrollbarWidth=this.toggleScrollbar("hide")),this.options.htmlClass&&""!==this.options.htmlClass&&document.querySelector("html").classList.add(this.options.htmlClass),document.body.appendChild(this.domNodes.wrapper),this.domNodes.wrapper.appendChild(this.domNodes.image),this.options.overlay&&document.body.appendChild(this.domNodes.overlay),this.relatedElements=this.getRelated(t.rel),this.options.showCounter&&(1==this.relatedElements.length&&this.domNodes.wrapper.contains(this.domNodes.counter)?this.domNodes.wrapper.removeChild(this.domNodes.counter):1<this.relatedElements.length&&!this.domNodes.wrapper.contains(this.domNodes.counter)&&this.domNodes.wrapper.appendChild(this.domNodes.counter)),this.isAnimating=!0,this.currentImageIndex=this.relatedElements.indexOf(t);var o=t.getAttribute(this.options.sourceAttr);this.currentImage=document.createElement("img"),this.currentImage.style.display="none",this.currentImage.setAttribute("src",o),this.currentImage.dataset.scale=1,this.currentImage.dataset.translateX=0,this.currentImage.dataset.translateY=0,-1===this.loadedImages.indexOf(o)&&this.loadedImages.push(o),this.domNodes.image.innerHTML="",this.domNodes.image.setAttribute("style",""),this.domNodes.image.appendChild(this.currentImage),this.fadeIn(this.domNodes.overlay,this.options.fadeSpeed),this.fadeIn([this.domNodes.counter,this.domNodes.navigation,this.domNodes.closeButton],this.options.fadeSpeed),this.show(this.domNodes.spinner),this.domNodes.counter.querySelector(".sl-current").innerHTML=this.currentImageIndex+1,this.domNodes.counter.querySelector(".sl-total").innerHTML=this.relatedElements.length,this.adjustImage(),this.options.preloading&&this.preload(),setTimeout(function(){t.dispatchEvent(new Event("shown."+e.eventNamespace))},this.options.animationSpeed)}},{key:"forceFocus",value:function(){var e=this;this.removeEventListener(document,"focusin."+this.eventNamespace),this.addEventListener(document,"focusin."+this.eventNamespace,function(t){document===t.target||e.domNodes.wrapper===t.target||e.domNodes.wrapper.contains(t.target)||e.domNodes.wrapper.focus()})}},{key:"addEventListener",value:function(t,e,o,n){t=this.wrap(t),e=this.wrap(e);var i,s=m(t);try{for(s.s();!(i=s.n()).done;){var a=i.value;a.namespaces||(a.namespaces={});var r,l=m(e);try{for(l.s();!(r=l.n()).done;){var d=r.value,c=n||!1;0<=["touchstart","touchmove"].indexOf(d.split(".")[0])&&this.isPassiveEventsSupported&&("object"===h(c)?c.passive=!0:c={passive:!0}),a.namespaces[d]=o,a.addEventListener(d.split(".")[0],o,c)}}catch(t){l.e(t)}finally{l.f()}}}catch(t){s.e(t)}finally{s.f()}}},{key:"removeEventListener",value:function(t,e){t=this.wrap(t),e=this.wrap(e);var o,n=m(t);try{for(n.s();!(o=n.n()).done;){var i,s=o.value,a=m(e);try{for(a.s();!(i=a.n()).done;){var r=i.value;s.namespaces&&s.namespaces[r]&&(s.removeEventListener(r.split(".")[0],s.namespaces[r]),delete s.namespaces[r])}}catch(t){a.e(t)}finally{a.f()}}}catch(t){n.e(t)}finally{n.f()}}},{key:"fadeOut",value:function(r,t,l){var e,d=this,o=m(r=this.wrap(r));try{for(o.s();!(e=o.n()).done;)e.value.style.opacity=1}catch(t){o.e(t)}finally{o.f()}this.isFadeIn=!1;var c=16.66666/(t||this.options.fadeSpeed);(function t(){var e=parseFloat(r[0].style.opacity);if((e-=c)<0){var o,n=m(r);try{for(n.s();!(o=n.n()).done;){var i=o.value;i.style.display="none",i.style.opacity=1}}catch(t){n.e(t)}finally{n.f()}l&&l.call(d,r)}else{var s,a=m(r);try{for(a.s();!(s=a.n()).done;)s.value.style.opacity=e}catch(t){a.e(t)}finally{a.f()}requestAnimationFrame(t)}})()}},{key:"fadeIn",value:function(a,t,r,e){var o,l=this,n=m(a=this.wrap(a));try{for(n.s();!(o=n.n()).done;){var i=o.value;i.style.opacity=0,i.style.display=e||"block"}}catch(t){n.e(t)}finally{n.f()}this.isFadeIn=!0;var d=parseFloat(a[0].dataset.opacityTarget||1),c=16.66666*d/(t||this.options.fadeSpeed);(function t(){var e=parseFloat(a[0].style.opacity);if((e+=c)>d){var o,n=m(a);try{for(n.s();!(o=n.n()).done;)o.value.style.opacity=""}catch(t){n.e(t)}finally{n.f()}r&&r.call(l,a)}else{var i,s=m(a);try{for(s.s();!(i=s.n()).done;)i.value.style.opacity=e}catch(t){s.e(t)}finally{s.f()}l.isFadeIn&&requestAnimationFrame(t)}})()}},{key:"hide",value:function(t){var e,o=m(t=this.wrap(t));try{for(o.s();!(e=o.n()).done;){var n=e.value;"none"!=n.style.display&&(n.dataset.initialDisplay=n.style.display),n.style.display="none"}}catch(t){o.e(t)}finally{o.f()}}},{key:"show",value:function(t,e){var o,n=m(t=this.wrap(t));try{for(n.s();!(o=n.n()).done;){var i=o.value;i.style.display=i.dataset.initialDisplay||e||"block"}}catch(t){n.e(t)}finally{n.f()}}},{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 o,n=m(this.elements);try{for(n.s();!(o=n.n()).done;){var i=o.value;i.fullyNamespacedEvents||(i.fullyNamespacedEvents={});var s,a=m(t);try{for(a.s();!(s=a.n()).done;){var r=s.value;i.fullyNamespacedEvents[r]=e,i.addEventListener(r,e)}}catch(t){a.e(t)}finally{a.f()}}}catch(t){n.e(t)}finally{n.f()}return this}},{key:"off",value:function(t){t=this.wrap(t);var e,o=m(this.elements);try{for(o.s();!(e=o.n()).done;){var n,i=e.value,s=m(t);try{for(s.s();!(n=s.n()).done;){var a=n.value;void 0!==i.fullyNamespacedEvents&&a in i.fullyNamespacedEvents&&i.removeEventListener(a,i.fullyNamespacedEvents[a])}}catch(t){s.e(t)}finally{s.f()}}}catch(t){o.e(t)}finally{o.f()}return this}},{key:"open",value:function(t){t=t||this.elements[0],"undefined"!=typeof jQuery&&t instanceof jQuery&&(t=t.get(0)),this.initialImageIndex=this.elements.indexOf(t),-1<this.initialImageIndex&&this.openImage(t)}},{key:"next",value:function(){this.loadImage(1)}},{key:"prev",value:function(){this.loadImage(-1)}},{key:"getLighboxData",value:function(){return{currentImageIndex:this.currentImageIndex,currentImage:this.currentImage,globalScrollbarWidth:this.globalScrollbarWidth}}},{key:"destroy",value:function(){this.off(["close."+this.eventNamespace,"closed."+this.eventNamespace,"nextImageLoaded."+this.eventNamespace,"prevImageLoaded."+this.eventNamespace,"change."+this.eventNamespace,"nextDone."+this.eventNamespace,"prevDone."+this.eventNamespace,"error."+this.eventNamespace,"changed."+this.eventNamespace,"next."+this.eventNamespace,"prev."+this.eventNamespace,"show."+this.eventNamespace,"shown."+this.eventNamespace]),this.removeEventListener(this.elements,"click."+this.eventNamespace),this.removeEventListener(document,"focusin."+this.eventNamespace),this.removeEventListener(document.body,"contextmenu."+this.eventNamespace),this.removeEventListener(document.body,"keyup."+this.eventNamespace),this.removeEventListener(this.domNodes.navigation.getElementsByTagName("button"),"click."+this.eventNamespace),this.removeEventListener(this.domNodes.closeButton,"click."+this.eventNamespace),this.removeEventListener(window,"resize."+this.eventNamespace),this.removeEventListener(window,"hashchange."+this.eventNamespace),this.close(),this.isOpen&&(document.body.removeChild(this.domNodes.wrapper),document.body.removeChild(this.domNodes.overlay)),this.elements=null}},{key:"refresh",value:function(){if(!this.initialSelector)throw"refreshing only works when you initialize using a selector!";var t=this.options,e=this.initialSelector;return this.destroy(),this.constructor(e,t),this}}])&&n(t.prototype,e),o&&n(t,o),i}();o.default=t,e.SimpleLightbox=t}.call(this)}.call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1]); |