File: /home/adventp/www/wp-content/themes/brooklyn/assets/vendor/lightGallery/js/lg-autoplay.min.js
/*! lightgallery - v1.2.6 - 2015-10-07
* http://sachinchoolur.github.io/lightGallery/
* Copyright (c) 2015 Sachin N; Licensed Apache 2.0 */
(function(c,b,a,f){var e={autoplay:false,pause:5000,progressBar:true,fourceAutoplay:false,autoplayControls:true,appendAutoplayControlsTo:".lg-toolbar"};var d=function(g){this.core=c(g).data("lightGallery");this.$el=c(g);if(this.core.$items.length<2){return false}this.core.s=c.extend({},e,this.core.s);this.interval=false;this.fromAuto=true;this.canceledOnTouch=false;this.fourceAutoplayTemp=this.core.s.fourceAutoplay;if(!this.core.doCss()){this.core.s.progressBar=false}this.init();return this};d.prototype.init=function(){var g=this;if(g.core.s.autoplayControls){g.controls()}if(g.core.s.progressBar){g.core.$outer.find(".lg").append('<div class="lg-progress-bar"><div class="lg-progress"></div></div>')}g.progress();if(g.core.s.autoplay){g.startlAuto()}g.$el.on("onDragstart.lg.tm touchstart.lg.tm",function(){if(g.interval){g.cancelAuto();g.canceledOnTouch=true}});g.$el.on("onDragend.lg.tm touchend.lg.tm onSlideClick.lg.tm",function(){if(!g.interval&&g.canceledOnTouch){g.startlAuto();g.canceledOnTouch=false}})};d.prototype.progress=function(){var i=this;var h;var g;i.$el.on("onBeforeSlide.lg.tm",function(){if(i.core.s.progressBar&&i.fromAuto){h=i.core.$outer.find(".lg-progress-bar");g=i.core.$outer.find(".lg-progress");if(i.interval){g.removeAttr("style");h.removeClass("lg-start");setTimeout(function(){g.css("transition","width "+(i.core.s.speed+i.core.s.pause)+"ms ease 0s");h.addClass("lg-start")},20)}}if(!i.fromAuto&&!i.core.s.fourceAutoplay){i.cancelAuto()}i.fromAuto=false})};d.prototype.controls=function(){var h=this;var g='<span class="lg-autoplay-button lg-icon"></span>';c(this.core.s.appendAutoplayControlsTo).append(g);h.core.$outer.find(".lg-autoplay-button").on("click.lg",function(){if(c(h.core.$outer).hasClass("lg-show-autoplay")){h.cancelAuto();h.core.s.fourceAutoplay=false}else{if(!h.interval){h.startlAuto();h.core.s.fourceAutoplay=h.fourceAutoplayTemp}}})};d.prototype.startlAuto=function(){var g=this;g.core.$outer.find(".lg-progress").css("transition","width "+(g.core.s.speed+g.core.s.pause)+"ms ease 0s");g.core.$outer.addClass("lg-show-autoplay");g.core.$outer.find(".lg-progress-bar").addClass("lg-start");g.interval=setInterval(function(){if(g.core.index+1<g.core.$items.length){g.core.index=g.core.index}else{g.core.index=-1}g.core.index++;g.fromAuto=true;g.core.slide(g.core.index,false,false)},g.core.s.speed+g.core.s.pause)};d.prototype.cancelAuto=function(){clearInterval(this.interval);this.interval=false;this.core.$outer.find(".lg-progress").removeAttr("style");this.core.$outer.removeClass("lg-show-autoplay");this.core.$outer.find(".lg-progress-bar").removeClass("lg-start")};d.prototype.destroy=function(){this.cancelAuto();this.core.$outer.find(".lg-progress-bar").remove()};c.fn.lightGallery.modules.autoplay=d})(jQuery,window,document);