/*! lightgallery - v1.6.12 - 2019-02-19 * http://sachinchoolur.github.io/lightGallery/ * Copyright (c) 2019 Sachin N; Licensed GPLv3 */ (function(a,b){if(typeof define==="function"&&define.amd){define(["jquery"],function(c){return(b(c))})}else{if(typeof module==="object"&&module.exports){module.exports=b(require("jquery"))}else{b(a.jQuery)}}}(this,function(a){(function(){var c={mode:"lg-slide",cssEasing:"ease",easing:"linear",speed:600,height:"100%",width:"100%",addClass:"",startClass:"lg-start-zoom",backdropDuration:150,hideBarsDelay:6000,useLeft:false,closable:true,loop:true,escKey:true,keyPress:true,controls:true,slideEndAnimatoin:true,hideControlOnEnd:false,mousewheel:true,getCaptionFromTitleOrAlt:true,appendSubHtmlTo:".lg-sub-html",subHtmlSelectorRelative:false,preload:1,showAfterLoad:true,selector:"",selectWithin:"",nextHtml:"",prevHtml:"",index:false,iframeMaxWidth:"100%",download:true,counter:true,appendCounterTo:".lg-toolbar",swipeThreshold:50,enableSwipe:true,enableDrag:true,dynamic:false,dynamicEl:[],galleryId:1};function b(e,d){this.el=e;this.$el=a(e);this.s=a.extend({},c,d);if(this.s.dynamic&&this.s.dynamicEl!=="undefined"&&this.s.dynamicEl.constructor===Array&&!this.s.dynamicEl.length){throw ("When using dynamic mode, you must also define dynamicEl as an Array.")}this.modules={};this.lGalleryOn=false;this.lgBusy=false;this.hideBartimeout=false;this.isTouch=("ontouchstart" in document.documentElement);if(this.s.slideEndAnimatoin){this.s.hideControlOnEnd=false}if(this.s.dynamic){this.$items=this.s.dynamicEl}else{if(this.s.selector==="this"){this.$items=this.$el}else{if(this.s.selector!==""){if(this.s.selectWithin){this.$items=a(this.s.selectWithin).find(this.s.selector)}else{this.$items=this.$el.find(a(this.s.selector))}}else{this.$items=this.$el.children()}}}this.$slide="";this.$outer="";this.init();return this}b.prototype.init=function(){var e=this;if(e.s.preload>e.$items.length){e.s.preload=e.$items.length}var d=window.location.hash;if(d.indexOf("lg="+this.s.galleryId)>0){e.index=parseInt(d.split("&slide=")[1],10);a("body").addClass("lg-from-hash");if(!a("body").hasClass("lg-on")){setTimeout(function(){e.build(e.index)});a("body").addClass("lg-on")}}if(e.s.dynamic){e.$el.trigger("onBeforeOpen.lg");e.index=e.s.index||0;if(!a("body").hasClass("lg-on")){setTimeout(function(){e.build(e.index);a("body").addClass("lg-on")})}}else{e.$items.on("click.lgcustom",function(f){try{f.preventDefault();f.preventDefault()}catch(g){f.returnValue=false}e.$el.trigger("onBeforeOpen.lg");e.index=e.s.index||e.$items.index(this);if(!a("body").hasClass("lg-on")){e.build(e.index);a("body").addClass("lg-on")}})}};b.prototype.build=function(d){var e=this;e.structure();a.each(a.fn.lightGallery.modules,function(f){e.modules[f]=new a.fn.lightGallery.modules[f](e.el)});e.slide(d,false,false,false);if(e.s.keyPress){e.keyPress()}if(e.$items.length>1){e.arrow();setTimeout(function(){e.enableDrag();e.enableSwipe()},50);if(e.s.mousewheel){e.mousewheel()}}else{e.$slide.on("click.lg",function(){e.$el.trigger("onSlideClick.lg")})}e.counter();e.closeGallery();e.$el.trigger("onAfterOpen.lg");e.$outer.on("mousemove.lg click.lg touchstart.lg",function(){e.$outer.removeClass("lg-hide-items");clearTimeout(e.hideBartimeout);e.hideBartimeout=setTimeout(function(){e.$outer.addClass("lg-hide-items")},e.s.hideBarsDelay)});e.$outer.trigger("mousemove.lg")};b.prototype.structure=function(){var h="";var d="";var e=0;var g="";var f;var k=this;a("body").append('
');a(".lg-backdrop").css("transition-duration",this.s.backdropDuration+"ms");for(e=0;e'}if(this.s.controls&&this.$items.length>1){d='
"}if(this.s.appendSubHtmlTo===".lg-sub-html"){g='
'}f='
'+h+'
'+d+g+"
";a("body").append(f);this.$outer=a(".lg-outer");this.$slide=this.$outer.find(".lg-item");if(this.s.useLeft){this.$outer.addClass("lg-use-left");this.s.mode="lg-slide"}else{this.$outer.addClass("lg-use-css3")}k.setTop();a(window).on("resize.lg orientationchange.lg",function(){setTimeout(function(){k.setTop()},100)});this.$slide.eq(this.index).addClass("lg-current");if(this.doCss()){this.$outer.addClass("lg-css3")}else{this.$outer.addClass("lg-css");this.s.speed=0}this.$outer.addClass(this.s.mode);if(this.s.enableDrag&&this.$items.length>1){this.$outer.addClass("lg-grab")}if(this.s.showAfterLoad){this.$outer.addClass("lg-show-after-load")}if(this.doCss()){var j=this.$outer.find(".lg-inner");j.css("transition-timing-function",this.s.cssEasing);j.css("transition-duration",this.s.speed+"ms")}setTimeout(function(){a(".lg-backdrop").addClass("in")});setTimeout(function(){k.$outer.addClass("lg-visible")},this.s.backdropDuration);if(this.s.download){this.$outer.find(".lg-toolbar").append('')}this.prevScrollTop=a(window).scrollTop()};b.prototype.setTop=function(){if(this.s.height!=="100%"){var d=a(window).height();var f=(d-parseInt(this.s.height,10))/2;var e=this.$outer.find(".lg");if(d>=parseInt(this.s.height,10)){e.css("top",f+"px")}else{e.css("top","0px")}}};b.prototype.doCss=function(){var d=function(){var g=["transition","MozTransition","WebkitTransition","OTransition","msTransition","KhtmlTransition"];var e=document.documentElement;var f=0;for(f=0;f'+(parseInt(this.index,10)+1)+' / '+this.$items.length+"")}};b.prototype.addHtml=function(e){var g=null;var h;var d;if(this.s.dynamic){if(this.s.dynamicEl[e].subHtmlUrl){h=this.s.dynamicEl[e].subHtmlUrl}else{g=this.s.dynamicEl[e].subHtml}}else{d=this.$items.eq(e);if(d.attr("data-sub-html-url")){h=d.attr("data-sub-html-url")}else{g=d.attr("data-sub-html");if(this.s.getCaptionFromTitleOrAlt&&!g){g=d.attr("title")||d.find("img").first().attr("alt")}}}if(!h){if(typeof g!=="undefined"&&g!==null){var f=g.substring(0,1);if(f==="."||f==="#"){if(this.s.subHtmlSelectorRelative&&!this.s.dynamic){g=d.find(g).html()}else{g=a(g).html()}}}else{g=""}}if(this.s.appendSubHtmlTo===".lg-sub-html"){if(h){this.$outer.find(this.s.appendSubHtmlTo).load(h)}else{this.$outer.find(this.s.appendSubHtmlTo).html(g)}}else{if(h){this.$slide.eq(e).load(h)}else{this.$slide.eq(e).append(g)}}if(typeof g!=="undefined"&&g!==null){if(g===""){this.$outer.find(this.s.appendSubHtmlTo).addClass("lg-empty-html")}else{this.$outer.find(this.s.appendSubHtmlTo).removeClass("lg-empty-html")}}this.$el.trigger("onAfterAppendSubHtml.lg",[e])};b.prototype.preload=function(e){var f=1;var d=1;for(f=1;f<=this.s.preload;f++){if(f>=this.$items.length-e){break}this.loadContent(e+f,false,0)}for(d=1;d<=this.s.preload;d++){if(e-d<0){break}this.loadContent(e-d,false,0)}};b.prototype.loadContent=function(h,i,u){var o=this;var q=false;var v;var l;var t;var g;var n;var f;var m=function(A){var e=[];var x=[];for(var z=0;zy){l=x[w];break}}};if(o.s.dynamic){if(o.s.dynamicEl[h].poster){q=true;t=o.s.dynamicEl[h].poster}f=o.s.dynamicEl[h].html;l=o.s.dynamicEl[h].src;if(o.s.dynamicEl[h].responsive){var s=o.s.dynamicEl[h].responsive.split(",");m(s)}g=o.s.dynamicEl[h].srcset;n=o.s.dynamicEl[h].sizes}else{if(o.$items.eq(h).attr("data-poster")){q=true;t=o.$items.eq(h).attr("data-poster")}f=o.$items.eq(h).attr("data-html");l=o.$items.eq(h).attr("href")||o.$items.eq(h).attr("data-src");if(o.$items.eq(h).attr("data-responsive")){var j=o.$items.eq(h).attr("data-responsive").split(",");m(j)}g=o.$items.eq(h).attr("data-srcset");n=o.$items.eq(h).attr("data-sizes")}var k=false;if(o.s.dynamic){if(o.s.dynamicEl[h].iframe){k=true}}else{if(o.$items.eq(h).attr("data-iframe")==="true"){k=true}}var p=o.isVideo(l,h);if(!o.$slide.eq(h).hasClass("lg-loaded")){if(k){o.$slide.eq(h).prepend('
')}else{if(q){var d="";if(p&&p.youtube){d="lg-has-youtube"}else{if(p&&p.vimeo){d="lg-has-vimeo"}else{d="lg-has-html5"}}o.$slide.eq(h).prepend('
')}else{if(p){o.$slide.eq(h).prepend('
');o.$el.trigger("hasVideo.lg",[h,l,f])}else{o.$slide.eq(h).prepend('
')}}}o.$el.trigger("onAferAppendSlide.lg",[h]);v=o.$slide.eq(h).find(".lg-object");if(n){v.attr("sizes",n)}if(g){v.attr("srcset",g);try{picturefill({elements:[v[0]]})}catch(r){console.warn("lightGallery :- If you want srcset to be supported for older browser please include picturefil version 2 javascript library in your document.")}}if(this.s.appendSubHtmlTo!==".lg-sub-html"){o.addHtml(h)}o.$slide.eq(h).addClass("lg-loaded")}o.$slide.eq(h).find(".lg-object").on("load.lg error.lg",function(){var e=0;if(u&&!a("body").hasClass("lg-from-hash")){e=u}setTimeout(function(){o.$slide.eq(h).addClass("lg-complete");o.$el.trigger("onSlideItemLoad.lg",[h,u||0])},e)});if(p&&p.html5&&!q){o.$slide.eq(h).addClass("lg-complete")}if(i===true){if(!o.$slide.eq(h).hasClass("lg-complete")){o.$slide.eq(h).find(".lg-object").on("load.lg error.lg",function(){o.preload(h)})}else{o.preload(h)}}};b.prototype.slide=function(h,j,e,l){var f=this.$outer.find(".lg-current").index();var g=this;if(g.lGalleryOn&&(f===h)){return}var i=this.$slide.length;var n=g.lGalleryOn?this.s.speed:0;if(!g.lgBusy){if(this.s.download){var d;if(g.s.dynamic){d=g.s.dynamicEl[h].downloadUrl!==false&&(g.s.dynamicEl[h].downloadUrl||g.s.dynamicEl[h].src)}else{d=g.$items.eq(h).attr("data-download-url")!=="false"&&(g.$items.eq(h).attr("data-download-url")||g.$items.eq(h).attr("href")||g.$items.eq(h).attr("data-src"))}if(d){a("#lg-download").attr("href",d);g.$outer.removeClass("lg-hide-download")}else{g.$outer.addClass("lg-hide-download")}}this.$el.trigger("onBeforeSlide.lg",[f,h,j,e]);g.lgBusy=true;clearTimeout(g.hideBartimeout);if(this.s.appendSubHtmlTo===".lg-sub-html"){setTimeout(function(){g.addHtml(h)},n)}this.arrowDisable(h);if(!l){if(hf){l="next"}}}if(!j){g.$outer.addClass("lg-no-trans");this.$slide.removeClass("lg-prev-slide lg-next-slide");if(l==="prev"){this.$slide.eq(h).addClass("lg-prev-slide");this.$slide.eq(f).addClass("lg-next-slide")}else{this.$slide.eq(h).addClass("lg-next-slide");this.$slide.eq(f).addClass("lg-prev-slide")}setTimeout(function(){g.$slide.removeClass("lg-current");g.$slide.eq(h).addClass("lg-current");g.$outer.removeClass("lg-no-trans")},50)}else{this.$slide.removeClass("lg-prev-slide lg-current lg-next-slide");var k;var m;if(i>2){k=h-1;m=h+1;if((h===0)&&(f===i-1)){m=0;k=i-1}else{if((h===i-1)&&(f===0)){m=0;k=i-1}}}else{k=0;m=1}if(l==="prev"){g.$slide.eq(m).addClass("lg-next-slide")}else{g.$slide.eq(k).addClass("lg-prev-slide")}g.$slide.eq(h).addClass("lg-current")}if(g.lGalleryOn){setTimeout(function(){g.loadContent(h,true,0)},this.s.speed+50);setTimeout(function(){g.lgBusy=false;g.$el.trigger("onAfterSlide.lg",[f,h,j,e])},this.s.speed)}else{g.loadContent(h,true,g.s.backdropDuration);g.lgBusy=false;g.$el.trigger("onAfterSlide.lg",[f,h,j,e])}g.lGalleryOn=true;if(this.s.counter){a("#lg-counter-current").text(h+1)}}g.index=h};b.prototype.goToNextSlide=function(d){var f=this;var e=f.s.loop;if(d&&f.$slide.length<3){e=false}if(!f.lgBusy){if((f.index+1)0){f.index--;f.$el.trigger("onBeforePrevSlide.lg",[f.index,d]);f.slide(f.index,d,false,"prev")}else{if(e){f.index=f.$items.length-1;f.$el.trigger("onBeforePrevSlide.lg",[f.index,d]);f.slide(f.index,d,false,"prev")}else{if(f.s.slideEndAnimatoin&&!d){f.$outer.addClass("lg-left-end");setTimeout(function(){f.$outer.removeClass("lg-left-end")},400)}}}}};b.prototype.keyPress=function(){var d=this;if(this.$items.length>1){a(window).on("keyup.lg",function(f){if(d.$items.length>1){if(f.keyCode===37){f.preventDefault();d.goToPrevSlide()}if(f.keyCode===39){f.preventDefault();d.goToNextSlide()}}})}a(window).on("keydown.lg",function(f){if(d.s.escKey===true&&f.keyCode===27){f.preventDefault();if(!d.$outer.hasClass("lg-thumb-open")){d.destroy()}else{d.$outer.removeClass("lg-thumb-open")}}})};b.prototype.arrow=function(){var d=this;this.$outer.find(".lg-prev").on("click.lg",function(){d.goToPrevSlide()});this.$outer.find(".lg-next").on("click.lg",function(){d.goToNextSlide()})};b.prototype.arrowDisable=function(d){if(!this.s.loop&&this.s.hideControlOnEnd){if((d+1)0){this.$outer.find(".lg-prev").removeAttr("disabled").removeClass("disabled")}else{this.$outer.find(".lg-prev").attr("disabled","disabled").addClass("disabled")}}};b.prototype.setTranslate=function(e,f,d){if(this.s.useLeft){e.css("left",f)}else{e.css({transform:"translate3d("+(f)+"px, "+d+"px, 0px)"})}};b.prototype.touchMove=function(e,d){var f=d-e;if(Math.abs(f)>15){this.$outer.addClass("lg-dragging");this.setTranslate(this.$slide.eq(this.index),f,0);this.setTranslate(a(".lg-prev-slide"),-this.$slide.eq(this.index).width()+f,0);this.setTranslate(a(".lg-next-slide"),this.$slide.eq(this.index).width()+f,0)}};b.prototype.touchEnd=function(e){var d=this;if(d.s.mode!=="lg-slide"){d.$outer.addClass("lg-slide")}this.$slide.not(".lg-current, .lg-prev-slide, .lg-next-slide").css("opacity","0");setTimeout(function(){d.$outer.removeClass("lg-dragging");if((e<0)&&(Math.abs(e)>d.s.swipeThreshold)){d.goToNextSlide(true)}else{if((e>0)&&(Math.abs(e)>d.s.swipeThreshold)){d.goToPrevSlide(true)}else{if(Math.abs(e)<5){d.$el.trigger("onSlideClick.lg")}}}d.$slide.removeAttr("style")});setTimeout(function(){if(!d.$outer.hasClass("lg-dragging")&&d.s.mode!=="lg-slide"){d.$outer.removeClass("lg-slide")}},d.s.speed+100)};b.prototype.enableSwipe=function(){var g=this;var f=0;var d=0;var e=false;if(g.s.enableSwipe&&g.doCss()){g.$slide.on("touchstart.lg",function(h){if(!g.$outer.hasClass("lg-zoomed")&&!g.lgBusy){h.preventDefault();g.manageSwipeClass();f=h.originalEvent.targetTouches[0].pageX}});g.$slide.on("touchmove.lg",function(h){if(!g.$outer.hasClass("lg-zoomed")){h.preventDefault();d=h.originalEvent.targetTouches[0].pageX;g.touchMove(f,d);e=true}});g.$slide.on("touchend.lg",function(){if(!g.$outer.hasClass("lg-zoomed")){if(e){e=false;g.touchEnd(d-f)}else{g.$el.trigger("onSlideClick.lg")}}})}};b.prototype.enableDrag=function(){var h=this;var g=0;var e=0;var d=false;var f=false;if(h.s.enableDrag&&h.doCss()){h.$slide.on("mousedown.lg",function(i){if(!h.$outer.hasClass("lg-zoomed")&&!h.lgBusy&&!a(i.target).text().trim()){i.preventDefault();h.manageSwipeClass();g=i.pageX;d=true;h.$outer.scrollLeft+=1;h.$outer.scrollLeft-=1;h.$outer.removeClass("lg-grab").addClass("lg-grabbing");h.$el.trigger("onDragstart.lg")}});a(window).on("mousemove.lg",function(i){if(d){f=true;e=i.pageX;h.touchMove(g,e);h.$el.trigger("onDragmove.lg")}});a(window).on("mouseup.lg",function(i){if(f){f=false;h.touchEnd(e-g);h.$el.trigger("onDragend.lg")}else{if(a(i.target).hasClass("lg-object")||a(i.target).hasClass("lg-video-play")){h.$el.trigger("onSlideClick.lg")}}if(d){d=false;h.$outer.removeClass("lg-grabbing").addClass("lg-grab")}})}};b.prototype.manageSwipeClass=function(){var d=this.index+1;var e=this.index-1;if(this.s.loop&&this.$slide.length>2){if(this.index===0){e=this.$slide.length-1}else{if(this.index===this.$slide.length-1){d=0}}}this.$slide.removeClass("lg-next-slide lg-prev-slide");if(e>-1){this.$slide.eq(e).addClass("lg-prev-slide")}this.$slide.eq(d).addClass("lg-next-slide")};b.prototype.mousewheel=function(){var d=this;d.$outer.on("mousewheel.lg",function(f){if(!f.deltaY){return}if(f.deltaY>0){d.goToPrevSlide()}else{d.goToNextSlide()}f.preventDefault()})};b.prototype.closeGallery=function(){var e=this;var d=false;this.$outer.find(".lg-close").on("click.lg",function(){e.destroy()});if(e.s.closable){e.$outer.on("mousedown.lg",function(f){if(a(f.target).is(".lg-outer")||a(f.target).is(".lg-item ")||a(f.target).is(".lg-img-wrap")){d=true}else{d=false}});e.$outer.on("mousemove.lg",function(){d=false});e.$outer.on("mouseup.lg",function(f){if(a(f.target).is(".lg-outer")||a(f.target).is(".lg-item ")||a(f.target).is(".lg-img-wrap")&&d){if(!e.$outer.hasClass("lg-dragging")){e.destroy()}}})}};b.prototype.destroy=function(e){var f=this;if(!e){f.$el.trigger("onBeforeClose.lg");a(window).scrollTop(f.prevScrollTop)}if(e){if(!f.s.dynamic){this.$items.off("click.lg click.lgcustom")}a.removeData(f.el,"lightGallery")}this.$el.off(".lg.tm");a.each(a.fn.lightGallery.modules,function(d){if(f.modules[d]){f.modules[d].destroy()}});this.lGalleryOn=false;clearTimeout(f.hideBartimeout);this.hideBartimeout=false;a(window).off(".lg");a("body").removeClass("lg-on lg-from-hash");if(f.$outer){f.$outer.removeClass("lg-visible")}a(".lg-backdrop").removeClass("in");setTimeout(function(){if(f.$outer){f.$outer.remove()}a(".lg-backdrop").remove();if(!e){f.$el.trigger("onCloseAfter.lg")}},f.s.backdropDuration+50)};a.fn.lightGallery=function(d){return this.each(function(){if(!a.data(this,"lightGallery")){a.data(this,"lightGallery",new b(this,d))}else{try{a(this).data("lightGallery").init()}catch(e){console.error("lightGallery has not initiated properly")}}})};a.fn.lightGallery.modules={}})()}));