snappymail/vendors/lightgallery/dist/js/lightgallery.min.js

5 lines
16 KiB
JavaScript
Raw Normal View History

2018-03-30 05:43:46 +08:00
/*! lightgallery - v1.2.21 - 2016-06-28
* http://sachinchoolur.github.io/lightGallery/
* Copyright (c) 2016 Sachin N; Licensed Apache 2.0 */
2020-08-13 19:16:08 +08:00
((e,s)=>{"use strict";var t={mode:"lg-slide",cssEasing:"ease",easing:"linear",speed:600,height:"100%",width:"100%",addClass:"",startClass:"lg-start-zoom",backdropDuration:150,hideBarsDelay:6e3,useLeft:!1,closable:!0,loop:!0,escKey:!0,keyPress:!0,controls:!0,slideEndAnimatoin:!0,hideControlOnEnd:!1,mousewheel:!0,getCaptionFromTitleOrAlt:!0,appendSubHtmlTo:".lg-sub-html",subHtmlSelectorRelative:!1,preload:1,showAfterLoad:!0,selector:"",selectWithin:"",nextHtml:"",prevHtml:"",index:!1,iframeMaxWidth:"100%",download:!0,counter:!0,appendCounterTo:".lg-toolbar",swipeThreshold:50,enableSwipe:!0,enableDrag:!0,dynamic:!1,dynamicEl:[],galleryId:1};class l{constructor(s,l){if(this.el=s,this.$el=e(s),this.s=e.extend({},t,l),this.s.dynamic&&"undefined"!==this.s.dynamicEl&&this.s.dynamicEl.constructor===Array&&!this.s.dynamicEl.length)throw"When using dynamic mode, you must also define dynamicEl as an Array.";return this.modules={},this.lGalleryOn=!1,this.lgBusy=!1,this.hideBartimeout=!1,this.isTouch="ontouchstart"in document.documentElement,this.s.slideEndAnimatoin&&(this.s.hideControlOnEnd=!1),this.s.dynamic?this.$items=this.s.dynamicEl:"this"===this.s.selector?this.$items=this.$el:""!==this.s.selector?this.s.selectWithin?this.$items=e(this.s.selectWithin).find(this.s.selector):this.$items=this.$el.find(e(this.s.selector)):this.$items=this.$el.children(),this.$slide="",this.$outer="",this.init(),this}init(){var s=this;s.s.preload>s.$items.length&&(s.s.preload=s.$items.length);var t=location.hash;t.indexOf("lg="+this.s.galleryId)>0&&(s.index=parseInt(t.split("&slide=")[1],10),e("body").addClass("lg-from-hash"),e("body").hasClass("lg-on")||setTimeout(()=>{s.build(s.index),e("body").addClass("lg-on")})),s.s.dynamic?(s.$el.trigger("onBeforeOpen.lg"),s.index=s.s.index||0,e("body").hasClass("lg-on")||setTimeout(()=>{s.build(s.index),e("body").addClass("lg-on")})):s.$items.on("click.lgcustom",function(t){t.preventDefault(),s.$el.trigger("onBeforeOpen.lg"),s.index=s.s.index||s.$items.index(this),e("body").hasClass("lg-on")||(s.build(s.index),e("body").addClass("lg-on"))})}build(s){var t=this;t.structure(),e.each(e.fn.lightGallery.modules,s=>t.modules[s]=new e.fn.lightGallery.modules[s](t.el)),t.slide(s,!1,!1),t.s.keyPress&&t.keyPress(),t.$items.length>1&&(t.arrow(),setTimeout(()=>{t.enableDrag(),t.enableSwipe()},50),t.s.mousewheel&&t.mousewheel()),t.counter(),t.closeGallery(),t.$el.trigger("onAfterOpen.lg"),t.$outer.on("mousemove.lg click.lg touchstart.lg",()=>{t.$outer.removeClass("lg-hide-items"),clearTimeout(t.hideBartimeout),t.hideBartimeout=setTimeout(()=>t.$outer.addClass("lg-hide-items"),t.s.hideBarsDelay)})}structure(){var t,l="",i="",a=0,d="",o=this;for(e("body").append('<div class="lg-backdrop"></div>'),e(".lg-backdrop").css("transition-duration",this.s.backdropDuration+"ms"),a=0;a<this.$items.length;a++)l+='<div class="lg-item"></div>';if(this.s.controls&&this.$items.length>1&&(i='<div class="lg-actions"><div class="lg-prev lg-icon">'+this.s.prevHtml+'</div><div class="lg-next lg-icon">'+this.s.nextHtml+"</div></div>"),".lg-sub-html"===this.s.appendSubHtmlTo&&(d='<div class="lg-sub-html"></div>'),t='<div class="lg-outer '+this.s.addClass+" "+this.s.startClass+'"><div class="lg" style="width:'+this.s.width+"; height:"+this.s.height+'"><div class="lg-inner">'+l+'</div><div class="lg-toolbar group"><span class="lg-close lg-icon"></span></div>'+i+d+"</div></div>",e("body").append(t),this.$outer=e(".lg-outer"),this.$slide=this.$outer.find(".lg-item"),this.s.useLeft?(this.$outer.addClass("lg-use-left"),this.s.mode="lg-slide"):this.$outer.addClass("lg-use-css3"),o.setTop(),e(s).on("resize.lg orientationchange.lg",()=>setTimeout(()=>o.setTop(),100)),this.$slide.eq(this.index).addClass("lg-current"),this.doCss()?this.$outer.addClass("lg-css3"):(this.$outer.addClass("lg-css"),this.s.speed=0),this.$outer.addClass(this.s.mode),this.s.enableDrag&&this.$items.length>1&&this.$outer.addClass("lg-grab"),this.s.showAfterLoad&&this.$outer.addClass("lg-show-after-load"),this.doCss()){var r=this.$outer.find(".lg-inner");r.css("transition-timing-func