/*! lg-thumbnail - v1.1.0 - 2017-08-08
* http://sachinchoolur.github.io/lightgallery
* copyright (c) 2017 sachin n; licensed gplv3 */
!function(a,b){"function"==typeof define&&define.amd?define(["jquery"],function(a){return b(a)}):"object"==typeof exports?module.exports=b(require("jquery")):b(jquery)}(this,function(a){!function(){"use strict";var b={thumbnail:!0,animatethumb:!0,currentpagerposition:"middle",thumbwidth:100,thumbheight:"80px",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},c=function(c){return this.core=a(c).data("lightgallery"),this.core.s=a.extend({},b,this.core.s),this.$el=a(c),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.core.s.animatethumb&&(this.core.s.thumbheight="100%"),this.left=0,this.init(),this};c.prototype.init=function(){var a=this;this.core.s.thumbnail&&this.core.$items.length>1&&(this.core.s.showthumbbydefault&&settimeout(function(){a.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.docss()?(this.core.s.enablethumbdrag&&this.enablethumbdrag(),this.core.s.enablethumbswipe&&this.enablethumbswipe(),this.thumbclickable=!1):this.thumbclickable=!0,this.toogle(),this.thumbkeypress())},c.prototype.build=function(){function b(a,b,c){var g,h=d.core.isvideo(a,c)||{},i="";h.youtube||h.vimeo||h.dailymotion?h.youtube?g=d.core.s.loadyoutubethumbnail?"//img.youtube.com/vi/"+h.youtube[1]+"/"+d.core.s.youtubethumbsize+".jpg":b:h.vimeo?d.core.s.loadvimeothumbnail?(g="//i.vimeocdn.com/video/error_"+f+".jpg",i=h.vimeo[1]):g=b:h.dailymotion&&(g=d.core.s.loaddailymotionthumbnail?"//www.dailymotion.com/thumbnail/video/"+h.dailymotion[1]:b):g=b,e+='
',i=""}var c,d=this,e="",f="",g='';switch(this.core.s.vimeothumbsize){case"thumbnail_large":f="640";break;case"thumbnail_medium":f="200x150";break;case"thumbnail_small":f="100x75"}if(d.core.$outer.addclass("lg-has-thumb"),d.core.$outer.find(".lg").append(g),d.$thumbouter=d.core.$outer.find(".lg-thumb-outer"),d.thumbouterwidth=d.$thumbouter.width(),d.core.s.animatethumb&&d.core.$outer.find(".lg-thumb").css({width:d.thumbtotalwidth+"px",position:"relative"}),this.core.s.animatethumb&&d.$thumbouter.css("height",d.core.s.thumbcontheight+"px"),d.core.s.dynamic)for(var h=0;hthis.thumbtotalwidth-this.thumbouterwidth&&(this.left=this.thumbtotalwidth-this.thumbouterwidth),this.left<0&&(this.left=0),this.core.lgalleryon?(b.hasclass("on")||this.core.$outer.find(".lg-thumb").css("transition-duration",this.core.s.speed+"ms"),this.core.docss()||b.animate({left:-this.left+"px"},this.core.s.speed)):this.core.docss()||b.css("left",-this.left+"px"),this.settranslate(this.left)}},c.prototype.enablethumbdrag=function(){var b=this,c=0,d=0,e=!1,f=!1,g=0;b.$thumbouter.addclass("lg-grab"),b.core.$outer.find(".lg-thumb").on("mousedown.lg.thumb",function(a){b.thumbtotalwidth>b.thumbouterwidth&&(a.preventdefault(),c=a.pagex,e=!0,b.core.$outer.scrollleft+=1,b.core.$outer.scrollleft-=1,b.thumbclickable=!1,b.$thumbouter.removeclass("lg-grab").addclass("lg-grabbing"))}),a(window).on("mousemove.lg.thumb",function(a){e&&(g=b.left,f=!0,d=a.pagex,b.$thumbouter.addclass("lg-dragging"),g-=d-c,g>b.thumbtotalwidth-b.thumbouterwidth&&(g=b.thumbtotalwidth-b.thumbouterwidth),g<0&&(g=0),b.settranslate(g))}),a(window).on("mouseup.lg.thumb",function(){f?(f=!1,b.$thumbouter.removeclass("lg-dragging"),b.left=g,math.abs(d-c)a.thumbouterwidth&&(c.preventdefault(),b=c.originalevent.targettouches[0].pagex,a.thumbclickable=!1)}),a.core.$outer.find(".lg-thumb").on("touchmove.lg",function(f){a.thumbtotalwidth>a.thumbouterwidth&&(f.preventdefault(),c=f.originalevent.targettouches[0].pagex,d=!0,a.$thumbouter.addclass("lg-dragging"),e=a.left,e-=c-b,e>a.thumbtotalwidth-a.thumbouterwidth&&(e=a.thumbtotalwidth-a.thumbouterwidth),e<0&&(e=0),a.settranslate(e))}),a.core.$outer.find(".lg-thumb").on("touchend.lg",function(){a.thumbtotalwidth>a.thumbouterwidth&&d?(d=!1,a.$thumbouter.removeclass("lg-dragging"),math.abs(c-b)'),a.core.$outer.find(".lg-toogle-thumb").on("click.lg",function(){a.core.$outer.toggleclass("lg-thumb-open")}))},c.prototype.thumbkeypress=function(){var b=this;a(window).on("keydown.lg.thumb",function(a){38===a.keycode?(a.preventdefault(),b.core.$outer.addclass("lg-thumb-open")):40===a.keycode&&(a.preventdefault(),b.core.$outer.removeclass("lg-thumb-open"))})},c.prototype.destroy=function(){this.core.s.thumbnail&&this.core.$items.length>1&&(a(window).off("resize.lg.thumb orientationchange.lg.thumb keydown.lg.thumb"),this.$thumbouter.remove(),this.core.$outer.removeclass("lg-has-thumb"))},a.fn.lightgallery.modules.thumbnail=c}()});