2020-08-13 19:16:08 +08:00
|
|
|
((t,e)=>{"use strict";var i={thumbnail:!0,animateThumb:!0,currentPagerPosition:"middle",thumbWidth:100,thumbContHeight:100,thumbMargin:5,exThumbImage:!1,showThumbByDefault:!0,toogleThumb:!0,pullCaptionUp:!0,enableThumbDrag:!0,enableThumbSwipe:!0,swipeThreshold:50,loadYoutubeThumbnail:!0,youtubeThumbSize:1,loadVimeoThumbnail:!0,vimeoThumbSize:"thumbnail_small",loadDailymotionThumbnail:!0};t.fn.lightGallery.modules.Thumbnail=class{constructor(e){return this.core=t(e).data("lightGallery"),this.core.s=t.extend({},i,this.core.s),this.$el=t(e),this.$thumbOuter=null,this.thumbOuterWidth=0,this.thumbTotalWidth=this.core.$items.length*(this.core.s.thumbWidth+this.core.s.thumbMargin),this.thumbIndex=this.core.index,this.left=0,this.init(),this}init(){var t=this;this.core.s.thumbnail&&this.core.$items.length>1&&(this.core.s.showThumbByDefault&&setTimeout(function(){t.core.$outer.addClass("lg-thumb-open")},700),this.core.s.pullCaptionUp&&this.core.$outer.addClass("lg-pull-caption-up"),this.build(),this.core.s.animateThumb?(this.core.s.enableThumbDrag&&!this.core.isTouch&&this.core.doCss()&&this.enableThumbDrag(),this.core.s.enableThumbSwipe&&this.core.isTouch&&this.core.doCss()&&this.enableThumbSwipe(),this.thumbClickable=!1):this.thumbClickable=!0,this.toogle(),this.thumbkeyPress())}build(){var i,h=this,o="",s="";switch(this.core.s.vimeoThumbSize){case"thumbnail_large":s="640";break;case"thumbnail_medium":s="200x150";break;case"thumbnail_small":s="100x75"}function u(t,e,i){var u,r=h.core.isVideo(t,i)||{},a="";r.youtube||r.vimeo||r.dailymotion?r.youtube?u=h.core.s.loadYoutubeThumbnail?"//img.youtube.com/vi/"+r.youtube[1]+"/"+h.core.s.youtubeThumbSize+".jpg":e:r.vimeo?h.core.s.loadVimeoThumbnail?(u="//i.vimeocdn.com/video/error_"+s+".jpg",a=r.vimeo[1]):u=e:r.dailymotion&&(u=h.core.s.loadDailymotionThumbnail?"//www.dailymotion.com/thumbnail/video/"+r.dailymotion[1]:e):u=e,o+='<div data-vimeo-id="'+a+'" class="lg-thumb-item" style="width:'+h.core.s.thumbWidth+"px; margin-right: "+h.core.s.thumbMargin+'px"><img src="'+u+'" /></div>',a=""}if(h.core.$outer.addClass("lg-has-thumb"),h.core.$outer.find(".lg").append('<div class="lg-thumb-outer"><div class="lg-thumb group"></div></div>'),h.$thumbOuter=h.core.$outer.find(".lg-thumb-outer"),h.thumbOuterWidth=h.$thumbOuter.width(),h.core.s.animateThumb&&h.core.$outer.find(".lg-thumb").css({width:h.thumbTotalWidth+"px",position:"relative"}),this.core.s.animateThumb&&h.$thumbOuter.css("height",h.core.s.thumbContHeight+"px"),h.core.s.dynamic)for(var r=0;r<h.core.s.dynamicEl.length;r++)u(h.core.s.dynamicEl[r].src,h.core.s.dynamicEl[r].thumb,r);else h.core.$items.each(function(e){h.core.s.exThumbImage?u(t(this).attr("href")||t(this).attr("data-src"),t(this).attr(h.core.s.exThumbImage),e):u(t(this).attr("href")||t(this).attr("data-src"),t(this).find("img").attr("src"),e)});h.core.$outer.find(".lg-thumb").html(o),(i=h.core.$outer.find(".lg-thumb-item")).each(function(){var e=t(this),i=e.attr("data-vimeo-id");i&&t.getJSON("//www.vimeo.com/api/v2/video/"+i+".json?callback=?",{format:"json"},function(t){e.find("img").attr("src",t[0][h.core.s.vimeoThumbSize])})}),i.eq(h.core.index).addClass("active"),h.core.$el.on("onBeforeSlide.lg.tm",function(){i.removeClass("active"),i.eq(h.core.index).addClass("active")}),i.on("click.lg touchend.lg",function(){var e=t(this);setTimeout(function(){(h.thumbClickable&&!h.core.lgBusy||!h.core.doCss())&&(h.core.index=e.index(),h.core.slide(h.core.index,!1,!0))},50)}),h.core.$el.on("onBeforeSlide.lg.tm",function(){h.animateThumb(h.core.index)}),t(e).on("resize.lg.thumb orientationchange.lg.thumb",function(){setTimeout(function(){h.animateThumb(h.core.index),h.thumbOuterWidth=h.$thumbOuter.width()},200)})}setTranslate(t){this.core.$outer.find(".lg-thumb").css({transform:"translate3d(-"+t+"px, 0px, 0px)"})}animateThumb(t){var e=this.core.$outer.find(".lg-thumb");if(this.core.s.animateThumb){var i;switch(this.core.s.currentPagerPosition){case"left":i=0;break;case"middle":i=this.thumbOuterWidth/2-this.core.s.thumbWidth/2;break;case"right":i=this.thumbOuterWidth-this.core.s.thumb
|