!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||f>n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.12",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b),d=c["offsetParent"in a.fn?"offsetParent":"parent"]();return d.length||(d=a("body")),parseInt(d.css("fontSize"),10)||parseInt(c.css("fontSize"),10)||16},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})}); !function(a,b,c,d){"use strict";function e(b,d){if(this.el=b,this.$el=a(b),this.s=a.extend({},f,d),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 c.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=a(this.s.selectWithin).find(this.s.selector):this.$items=this.$el.find(a(this.s.selector)):this.$items=this.$el.children(),this.$slide="",this.$outer="",this.init(),this}var f={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",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};e.prototype.init=function(){var c=this;c.s.preload>c.$items.length&&(c.s.preload=c.$items.length);var d=b.location.hash;d.indexOf("lg="+this.s.galleryId)>0&&(c.index=parseInt(d.split("&slide=")[1],10),a("body").addClass("lg-from-hash"),a("body").hasClass("lg-on")||setTimeout(function(){c.build(c.index),a("body").addClass("lg-on")})),c.s.dynamic?(c.$el.trigger("onBeforeOpen.lg"),c.index=c.s.index||0,a("body").hasClass("lg-on")||setTimeout(function(){c.build(c.index),a("body").addClass("lg-on")})):c.$items.on("click.lgcustom",function(b){try{b.preventDefault(),b.preventDefault()}catch(d){b.returnValue=!1}c.$el.trigger("onBeforeOpen.lg"),c.index=c.s.index||c.$items.index(this),a("body").hasClass("lg-on")||(c.build(c.index),a("body").addClass("lg-on"))})},e.prototype.build=function(b){var c=this;c.structure(),a.each(a.fn.lightGallery.modules,function(b){c.modules[b]=new a.fn.lightGallery.modules[b](c.el)}),c.slide(b,!1,!1),c.s.keyPress&&c.keyPress(),c.$items.length>1&&(c.arrow(),setTimeout(function(){c.enableDrag(),c.enableSwipe()},50),c.s.mousewheel&&c.mousewheel()),c.counter(),c.closeGallery(),c.$el.trigger("onAfterOpen.lg"),c.$outer.on("mousemove.lg click.lg touchstart.lg",function(){c.$outer.removeClass("lg-hide-items"),clearTimeout(c.hideBartimeout),c.hideBartimeout=setTimeout(function(){c.$outer.addClass("lg-hide-items")},c.s.hideBarsDelay)})},e.prototype.structure=function(){var c,d="",e="",f=0,g="",h=this;for(a("body").append('
'),a(".lg-backdrop").css("transition-duration",this.s.backdropDuration+"ms"),f=0;f';if(this.s.controls&&this.$items.length>1&&(e='
'+this.s.prevHtml+'
'+this.s.nextHtml+"
"),".lg-sub-html"===this.s.appendSubHtmlTo&&(g='
'),c='
'+d+'
'+e+g+"
",a("body").append(c),this.$outer=a(".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"),h.setTop(),a(b).on("resize.lg orientationchange.lg",function(){setTimeout(function(){h.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 i=this.$outer.find(".lg-inner");i.css("transition-timing-function",this.s.cssEasing),i.css("transition-duration",this.s.speed+"ms")}a(".lg-backdrop").addClass("in"),setTimeout(function(){h.$outer.addClass("lg-visible")},this.s.backdropDuration),this.s.download&&this.$outer.find(".lg-toolbar").append(''),this.prevScrollTop=a(b).scrollTop()},e.prototype.setTop=function(){if("100%"!==this.s.height){var c=a(b).height(),d=(c-parseInt(this.s.height,10))/2,e=this.$outer.find(".lg");c>=parseInt(this.s.height,10)?e.css("top",d+"px"):e.css("top","0px")}},e.prototype.doCss=function(){var a=function(){var a=["transition","MozTransition","WebkitTransition","OTransition","msTransition","KhtmlTransition"],b=c.documentElement,d=0;for(d=0;d'+(parseInt(this.index,10)+1)+' / '+this.$items.length+"")},e.prototype.addHtml=function(b){var c,d=null;if(this.s.dynamic?this.s.dynamicEl[b].subHtmlUrl?c=this.s.dynamicEl[b].subHtmlUrl:d=this.s.dynamicEl[b].subHtml:this.$items.eq(b).attr("data-sub-html-url")?c=this.$items.eq(b).attr("data-sub-html-url"):(d=this.$items.eq(b).attr("data-sub-html"),this.s.getCaptionFromTitleOrAlt&&!d&&(d=this.$items.eq(b).attr("title")||this.$items.eq(b).find("img").first().attr("alt"))),!c)if("undefined"!=typeof d&&null!==d){var e=d.substring(0,1);"."!==e&&"#"!==e||(d=a(d).html())}else d="";".lg-sub-html"===this.s.appendSubHtmlTo?c?this.$outer.find(this.s.appendSubHtmlTo).load(c):this.$outer.find(this.s.appendSubHtmlTo).html(d):c?this.$slide.eq(b).load(c):this.$slide.eq(b).append(d),"undefined"!=typeof d&&null!==d&&(""===d?this.$outer.find(this.s.appendSubHtmlTo).addClass("lg-empty-html"):this.$outer.find(this.s.appendSubHtmlTo).removeClass("lg-empty-html")),this.$el.trigger("onAfterAppendSubHtml.lg",[b])},e.prototype.preload=function(a){var b=1,c=1;for(b=1;b<=this.s.preload&&!(b>=this.$items.length-a);b++)this.loadContent(a+b,!1,0);for(c=1;c<=this.s.preload&&!(0>a-c);c++)this.loadContent(a-c,!1,0)},e.prototype.loadContent=function(c,d,e){var f,g,h,i,j,k,l=this,m=!1,n=function(c){for(var d=[],e=[],f=0;fi){g=e[j];break}};if(l.s.dynamic){if(l.s.dynamicEl[c].poster&&(m=!0,h=l.s.dynamicEl[c].poster),k=l.s.dynamicEl[c].html,g=l.s.dynamicEl[c].src,l.s.dynamicEl[c].responsive){var o=l.s.dynamicEl[c].responsive.split(",");n(o)}i=l.s.dynamicEl[c].srcset,j=l.s.dynamicEl[c].sizes}else{if(l.$items.eq(c).attr("data-poster")&&(m=!0,h=l.$items.eq(c).attr("data-poster")),k=l.$items.eq(c).attr("data-html"),g=l.$items.eq(c).attr("href")||l.$items.eq(c).attr("data-src"),l.$items.eq(c).attr("data-responsive")){var p=l.$items.eq(c).attr("data-responsive").split(",");n(p)}i=l.$items.eq(c).attr("data-srcset"),j=l.$items.eq(c).attr("data-sizes")}var q=!1;l.s.dynamic?l.s.dynamicEl[c].iframe&&(q=!0):"true"===l.$items.eq(c).attr("data-iframe")&&(q=!0);var r=l.isVideo(g,c);if(!l.$slide.eq(c).hasClass("lg-loaded")){if(q)l.$slide.eq(c).prepend('
');else if(m){var s="";s=r&&r.youtube?"lg-has-youtube":r&&r.vimeo?"lg-has-vimeo":"lg-has-html5",l.$slide.eq(c).prepend('
')}else r?(l.$slide.eq(c).prepend('
'),l.$el.trigger("hasVideo.lg",[c,g,k])):l.$slide.eq(c).prepend('
');if(l.$el.trigger("onAferAppendSlide.lg",[c]),f=l.$slide.eq(c).find(".lg-object"),j&&f.attr("sizes",j),i){f.attr("srcset",i);try{picturefill({elements:[f[0]]})}catch(t){console.error("Make sure you have included Picturefill version 2")}}".lg-sub-html"!==this.s.appendSubHtmlTo&&l.addHtml(c),l.$slide.eq(c).addClass("lg-loaded")}l.$slide.eq(c).find(".lg-object").on("load.lg error.lg",function(){var b=0;e&&!a("body").hasClass("lg-from-hash")&&(b=e),setTimeout(function(){l.$slide.eq(c).addClass("lg-complete"),l.$el.trigger("onSlideItemLoad.lg",[c,e||0])},b)}),r&&r.html5&&!m&&l.$slide.eq(c).addClass("lg-complete"),d===!0&&(l.$slide.eq(c).hasClass("lg-complete")?l.preload(c):l.$slide.eq(c).find(".lg-object").on("load.lg error.lg",function(){l.preload(c)}))},e.prototype.slide=function(b,c,d){var e=this.$outer.find(".lg-current").index(),f=this;if(!f.lGalleryOn||e!==b){var g=this.$slide.length,h=f.lGalleryOn?this.s.speed:0,i=!1,j=!1;if(!f.lgBusy){if(this.s.download){var k;k=f.s.dynamic?f.s.dynamicEl[b].downloadUrl!==!1&&(f.s.dynamicEl[b].downloadUrl||f.s.dynamicEl[b].src):"false"!==f.$items.eq(b).attr("data-download-url")&&(f.$items.eq(b).attr("data-download-url")||f.$items.eq(b).attr("href")||f.$items.eq(b).attr("data-src")),k?(a("#lg-download").attr("href",k),f.$outer.removeClass("lg-hide-download")):f.$outer.addClass("lg-hide-download")}if(this.$el.trigger("onBeforeSlide.lg",[e,b,c,d]),f.lgBusy=!0,clearTimeout(f.hideBartimeout),".lg-sub-html"===this.s.appendSubHtmlTo&&setTimeout(function(){f.addHtml(b)},h),this.arrowDisable(b),c){var l=b-1,m=b+1;0===b&&e===g-1?(m=0,l=g-1):b===g-1&&0===e&&(m=0,l=g-1),this.$slide.removeClass("lg-prev-slide lg-current lg-next-slide"),f.$slide.eq(l).addClass("lg-prev-slide"),f.$slide.eq(m).addClass("lg-next-slide"),f.$slide.eq(b).addClass("lg-current")}else f.$outer.addClass("lg-no-trans"),this.$slide.removeClass("lg-prev-slide lg-next-slide"),e>b?(j=!0,0!==b||e!==g-1||d||(j=!1,i=!0)):b>e&&(i=!0,b!==g-1||0!==e||d||(j=!0,i=!1)),j?(this.$slide.eq(b).addClass("lg-prev-slide"),this.$slide.eq(e).addClass("lg-next-slide")):i&&(this.$slide.eq(b).addClass("lg-next-slide"),this.$slide.eq(e).addClass("lg-prev-slide")),setTimeout(function(){f.$slide.removeClass("lg-current"),f.$slide.eq(b).addClass("lg-current"),f.$outer.removeClass("lg-no-trans")},50);f.lGalleryOn?(setTimeout(function(){f.loadContent(b,!0,0)},this.s.speed+50),setTimeout(function(){f.lgBusy=!1,f.$el.trigger("onAfterSlide.lg",[e,b,c,d])},this.s.speed)):(f.loadContent(b,!0,f.s.backdropDuration),f.lgBusy=!1,f.$el.trigger("onAfterSlide.lg",[e,b,c,d])),f.lGalleryOn=!0,this.s.counter&&a("#lg-counter-current").text(b+1)}}},e.prototype.goToNextSlide=function(a){var b=this;b.lgBusy||(b.index+10?(b.index--,b.$el.trigger("onBeforePrevSlide.lg",[b.index,a]),b.slide(b.index,a,!1)):b.s.loop?(b.index=b.$items.length-1,b.$el.trigger("onBeforePrevSlide.lg",[b.index,a]),b.slide(b.index,a,!1)):b.s.slideEndAnimatoin&&(b.$outer.addClass("lg-left-end"),setTimeout(function(){b.$outer.removeClass("lg-left-end")},400)))},e.prototype.keyPress=function(){var c=this;this.$items.length>1&&a(b).on("keyup.lg",function(a){c.$items.length>1&&(37===a.keyCode&&(a.preventDefault(),c.goToPrevSlide()),39===a.keyCode&&(a.preventDefault(),c.goToNextSlide()))}),a(b).on("keydown.lg",function(a){c.s.escKey===!0&&27===a.keyCode&&(a.preventDefault(),c.$outer.hasClass("lg-thumb-open")?c.$outer.removeClass("lg-thumb-open"):c.destroy())})},e.prototype.arrow=function(){var a=this;this.$outer.find(".lg-prev").on("click.lg",function(){a.goToPrevSlide()}),this.$outer.find(".lg-next").on("click.lg",function(){a.goToNextSlide()})},e.prototype.arrowDisable=function(a){!this.s.loop&&this.s.hideControlOnEnd&&(a+10?this.$outer.find(".lg-prev").removeAttr("disabled").removeClass("disabled"):this.$outer.find(".lg-prev").attr("disabled","disabled").addClass("disabled"))},e.prototype.setTranslate=function(a,b,c){this.s.useLeft?a.css("left",b):a.css({transform:"translate3d("+b+"px, "+c+"px, 0px)"})},e.prototype.touchMove=function(b,c){var d=c-b;Math.abs(d)>15&&(this.$outer.addClass("lg-dragging"),this.setTranslate(this.$slide.eq(this.index),d,0),this.setTranslate(a(".lg-prev-slide"),-this.$slide.eq(this.index).width()+d,0),this.setTranslate(a(".lg-next-slide"),this.$slide.eq(this.index).width()+d,0))},e.prototype.touchEnd=function(a){var b=this;"lg-slide"!==b.s.mode&&b.$outer.addClass("lg-slide"),this.$slide.not(".lg-current, .lg-prev-slide, .lg-next-slide").css("opacity","0"),setTimeout(function(){b.$outer.removeClass("lg-dragging"),0>a&&Math.abs(a)>b.s.swipeThreshold?b.goToNextSlide(!0):a>0&&Math.abs(a)>b.s.swipeThreshold?b.goToPrevSlide(!0):Math.abs(a)<5&&b.$el.trigger("onSlideClick.lg"),b.$slide.removeAttr("style")}),setTimeout(function(){b.$outer.hasClass("lg-dragging")||"lg-slide"===b.s.mode||b.$outer.removeClass("lg-slide")},b.s.speed+100)},e.prototype.enableSwipe=function(){var a=this,b=0,c=0,d=!1;a.s.enableSwipe&&a.isTouch&&a.doCss()&&(a.$slide.on("touchstart.lg",function(c){a.$outer.hasClass("lg-zoomed")||a.lgBusy||(c.preventDefault(),a.manageSwipeClass(),b=c.originalEvent.targetTouches[0].pageX)}),a.$slide.on("touchmove.lg",function(e){a.$outer.hasClass("lg-zoomed")||(e.preventDefault(),c=e.originalEvent.targetTouches[0].pageX,a.touchMove(b,c),d=!0)}),a.$slide.on("touchend.lg",function(){a.$outer.hasClass("lg-zoomed")||(d?(d=!1,a.touchEnd(c-b)):a.$el.trigger("onSlideClick.lg"))}))},e.prototype.enableDrag=function(){var c=this,d=0,e=0,f=!1,g=!1;c.s.enableDrag&&!c.isTouch&&c.doCss()&&(c.$slide.on("mousedown.lg",function(b){c.$outer.hasClass("lg-zoomed")||(a(b.target).hasClass("lg-object")||a(b.target).hasClass("lg-video-play"))&&(b.preventDefault(),c.lgBusy||(c.manageSwipeClass(),d=b.pageX,f=!0,c.$outer.scrollLeft+=1,c.$outer.scrollLeft-=1,c.$outer.removeClass("lg-grab").addClass("lg-grabbing"),c.$el.trigger("onDragstart.lg")))}),a(b).on("mousemove.lg",function(a){f&&(g=!0,e=a.pageX,c.touchMove(d,e),c.$el.trigger("onDragmove.lg"))}),a(b).on("mouseup.lg",function(b){g?(g=!1,c.touchEnd(e-d),c.$el.trigger("onDragend.lg")):(a(b.target).hasClass("lg-object")||a(b.target).hasClass("lg-video-play"))&&c.$el.trigger("onSlideClick.lg"),f&&(f=!1,c.$outer.removeClass("lg-grabbing").addClass("lg-grab"))}))},e.prototype.manageSwipeClass=function(){var a=this.index+1,b=this.index-1,c=this.$slide.length;this.s.loop&&(0===this.index?b=c-1:this.index===c-1&&(a=0)),this.$slide.removeClass("lg-next-slide lg-prev-slide"),b>-1&&this.$slide.eq(b).addClass("lg-prev-slide"),this.$slide.eq(a).addClass("lg-next-slide")},e.prototype.mousewheel=function(){var a=this;a.$outer.on("mousewheel.lg",function(b){b.deltaY&&(b.deltaY>0?a.goToPrevSlide():a.goToNextSlide(),b.preventDefault())})},e.prototype.closeGallery=function(){var b=this,c=!1;this.$outer.find(".lg-close").on("click.lg",function(){b.destroy(),$('body').removeClass('overflow-full')}),b.s.closable&&(b.$outer.on("mousedown.lg",function(b){c=!!(a(b.target).is(".lg-outer")||a(b.target).is(".lg-item ")||a(b.target).is(".lg-img-wrap"))}),b.$outer.on("mouseup.lg",function(d){(a(d.target).is(".lg-outer")||a(d.target).is(".lg-item ")||a(d.target).is(".lg-img-wrap")&&c)&&(b.$outer.hasClass("lg-dragging")||b.destroy())}))},e.prototype.destroy=function(c){var d=this;c||d.$el.trigger("onBeforeClose.lg"),a(b).scrollTop(d.prevScrollTop),c&&(d.s.dynamic||this.$items.off("click.lg click.lgcustom"),a.removeData(d.el,"lightGallery")),this.$el.off(".lg.tm"),a.each(a.fn.lightGallery.modules,function(a){d.modules[a]&&d.modules[a].destroy()}),this.lGalleryOn=!1,clearTimeout(d.hideBartimeout),this.hideBartimeout=!1,a(b).off(".lg"),a("body").removeClass("lg-on lg-from-hash"),d.$outer&&d.$outer.removeClass("lg-visible"),a(".lg-backdrop").removeClass("in"),setTimeout(function(){d.$outer&&d.$outer.remove(),a(".lg-backdrop").remove(),c||d.$el.trigger("onCloseAfter.lg")},d.s.backdropDuration+50)},a.fn.lightGallery=function(b){return this.each(function(){if(a.data(this,"lightGallery"))try{a(this).data("lightGallery").init()}catch(c){console.error("lightGallery has not initiated properly")}else a.data(this,"lightGallery",new e(this,b))})},a.fn.lightGallery.modules={}}(jQuery,window,document); !function(a,b,c,d){"use strict";var e={fullScreen:!0},f=function(b){return this.core=a(b).data("lightGallery"),this.$el=a(b),this.core.s=a.extend({},e,this.core.s),this.init(),this};f.prototype.init=function(){var a="";if(this.core.s.fullScreen){if(!(c.fullscreenEnabled||c.webkitFullscreenEnabled||c.mozFullScreenEnabled||c.msFullscreenEnabled))return;a='',this.core.$outer.find(".lg-toolbar").append(a),this.fullScreen()}},f.prototype.requestFullscreen=function(){var a=c.documentElement;a.requestFullscreen?a.requestFullscreen():a.msRequestFullscreen?a.msRequestFullscreen():a.mozRequestFullScreen?a.mozRequestFullScreen():a.webkitRequestFullscreen&&a.webkitRequestFullscreen()},f.prototype.exitFullscreen=function(){c.exitFullscreen?c.exitFullscreen():c.msExitFullscreen?c.msExitFullscreen():c.mozCancelFullScreen?c.mozCancelFullScreen():c.webkitExitFullscreen&&c.webkitExitFullscreen()},f.prototype.fullScreen=function(){var b=this;a(c).on("fullscreenchange.lg webkitfullscreenchange.lg mozfullscreenchange.lg MSFullscreenChange.lg",function(){b.core.$outer.toggleClass("lg-fullscreen-on")}),this.core.$outer.find(".lg-fullscreen").on("click.lg",function(){c.fullscreenElement||c.mozFullScreenElement||c.webkitFullscreenElement||c.msFullscreenElement?b.exitFullscreen():b.requestFullscreen()})},f.prototype.destroy=function(){this.exitFullscreen(),a(c).off("fullscreenchange.lg webkitfullscreenchange.lg mozfullscreenchange.lg MSFullscreenChange.lg")},a.fn.lightGallery.modules.fullscreen=f}(jQuery,window,document); !function(a,b,c,d){"use strict";var e={scale:1,zoom:!0,actualSize:!0,enableZoomAfter:300},f=function(c){return this.core=a(c).data("lightGallery"),this.core.s=a.extend({},e,this.core.s),this.core.s.zoom&&this.core.doCss()&&(this.init(),this.zoomabletimeout=!1,this.pageX=a(b).width()/2,this.pageY=a(b).height()/2+a(b).scrollTop()),this};f.prototype.init=function(){var c=this,d='';c.core.s.actualSize&&(d+=''),this.core.$outer.find(".lg-toolbar").append(d),c.core.$el.on("onSlideItemLoad.lg.tm.zoom",function(b,d,e){var f=c.core.s.enableZoomAfter+e;a("body").hasClass("lg-from-hash")&&e?f=0:a("body").removeClass("lg-from-hash"),c.zoomabletimeout=setTimeout(function(){c.core.$slide.eq(d).addClass("lg-zoomable")},f+30)});var e=1,f=function(d){var e,f,g=c.core.$outer.find(".lg-current .lg-image"),h=(a(b).width()-g.width())/2,i=(a(b).height()-g.height())/2+a(b).scrollTop();e=c.pageX-h,f=c.pageY-i;var j=(d-1)*e,k=(d-1)*f;g.css("transform","scale3d("+d+", "+d+", 1)").attr("data-scale",d),g.parent().css({left:-j+"px",top:-k+"px"}).attr("data-x",j).attr("data-y",k)},g=function(){e>1?c.core.$outer.addClass("lg-zoomed"):c.resetZoom(),1>e&&(e=1),f(e)},h=function(d,f,h,i){var j,k=f.width();j=c.core.s.dynamic?c.core.s.dynamicEl[h].width||f[0].naturalWidth||k:c.core.$items.eq(h).attr("data-width")||f[0].naturalWidth||k;var l;c.core.$outer.hasClass("lg-zoomed")?e=1:j>k&&(l=j/k,e=l||2),i?(c.pageX=a(b).width()/2,c.pageY=a(b).height()/2+a(b).scrollTop()):(c.pageX=d.pageX||d.originalEvent.targetTouches[0].pageX,c.pageY=d.pageY||d.originalEvent.targetTouches[0].pageY),g(),setTimeout(function(){c.core.$outer.removeClass("lg-grabbing").addClass("lg-grab")},10)},i=!1;c.core.$el.on("onAferAppendSlide.lg.tm.zoom",function(a,b){var d=c.core.$slide.eq(b).find(".lg-image");d.on("dblclick",function(a){h(a,d,b)}),d.on("touchstart",function(a){i?(clearTimeout(i),i=null,h(a,d,b)):i=setTimeout(function(){i=null},300),a.preventDefault()})}),a(b).on("resize.lg.zoom scroll.lg.zoom orientationchange.lg.zoom",function(){c.pageX=a(b).width()/2,c.pageY=a(b).height()/2+a(b).scrollTop(),f(e)}),a("#lg-zoom-out").on("click.lg",function(){c.core.$outer.find(".lg-current .lg-image").length&&(e-=c.core.s.scale,g())}),a("#lg-zoom-in").on("click.lg",function(){c.core.$outer.find(".lg-current .lg-image").length&&(e+=c.core.s.scale,g())}),a("#lg-actual-size").on("click.lg",function(a){h(a,c.core.$slide.eq(c.core.index).find(".lg-image"),c.core.index,!0)}),c.core.$el.on("onBeforeSlide.lg.tm",function(){e=1,c.resetZoom()}),c.core.isTouch||c.zoomDrag(),c.core.isTouch&&c.zoomSwipe()},f.prototype.resetZoom=function(){this.core.$outer.removeClass("lg-zoomed"),this.core.$slide.find(".lg-img-wrap").removeAttr("style data-x data-y"),this.core.$slide.find(".lg-image").removeAttr("style data-scale"),this.pageX=a(b).width()/2,this.pageY=a(b).height()/2+a(b).scrollTop()},f.prototype.zoomSwipe=function(){var a=this,b={},c={},d=!1,e=!1,f=!1;a.core.$slide.on("touchstart.lg",function(c){if(a.core.$outer.hasClass("lg-zoomed")){var d=a.core.$slide.eq(a.core.index).find(".lg-object");f=d.outerHeight()*d.attr("data-scale")>a.core.$outer.find(".lg").height(),e=d.outerWidth()*d.attr("data-scale")>a.core.$outer.find(".lg").width(),(e||f)&&(c.preventDefault(),b={x:c.originalEvent.targetTouches[0].pageX,y:c.originalEvent.targetTouches[0].pageY})}}),a.core.$slide.on("touchmove.lg",function(g){if(a.core.$outer.hasClass("lg-zoomed")){var h,i,j=a.core.$slide.eq(a.core.index).find(".lg-img-wrap");g.preventDefault(),d=!0,c={x:g.originalEvent.targetTouches[0].pageX,y:g.originalEvent.targetTouches[0].pageY},a.core.$outer.addClass("lg-zoom-dragging"),i=f?-Math.abs(j.attr("data-y"))+(c.y-b.y):-Math.abs(j.attr("data-y")),h=e?-Math.abs(j.attr("data-x"))+(c.x-b.x):-Math.abs(j.attr("data-x")),(Math.abs(c.x-b.x)>15||Math.abs(c.y-b.y)>15)&&j.css({left:h+"px",top:i+"px"})}}),a.core.$slide.on("touchend.lg",function(){a.core.$outer.hasClass("lg-zoomed")&&d&&(d=!1,a.core.$outer.removeClass("lg-zoom-dragging"),a.touchendZoom(b,c,e,f))})},f.prototype.zoomDrag=function(){var c=this,d={},e={},f=!1,g=!1,h=!1,i=!1;c.core.$slide.on("mousedown.lg.zoom",function(b){var e=c.core.$slide.eq(c.core.index).find(".lg-object");i=e.outerHeight()*e.attr("data-scale")>c.core.$outer.find(".lg").height(),h=e.outerWidth()*e.attr("data-scale")>c.core.$outer.find(".lg").width(),c.core.$outer.hasClass("lg-zoomed")&&a(b.target).hasClass("lg-object")&&(h||i)&&(b.preventDefault(),d={x:b.pageX,y:b.pageY},f=!0,c.core.$outer.scrollLeft+=1,c.core.$outer.scrollLeft-=1,c.core.$outer.removeClass("lg-grab").addClass("lg-grabbing"))}),a(b).on("mousemove.lg.zoom",function(a){if(f){var b,j,k=c.core.$slide.eq(c.core.index).find(".lg-img-wrap");g=!0,e={x:a.pageX,y:a.pageY},c.core.$outer.addClass("lg-zoom-dragging"),j=i?-Math.abs(k.attr("data-y"))+(e.y-d.y):-Math.abs(k.attr("data-y")),b=h?-Math.abs(k.attr("data-x"))+(e.x-d.x):-Math.abs(k.attr("data-x")),k.css({left:b+"px",top:j+"px"})}}),a(b).on("mouseup.lg.zoom",function(a){f&&(f=!1,c.core.$outer.removeClass("lg-zoom-dragging"),!g||d.x===e.x&&d.y===e.y||(e={x:a.pageX,y:a.pageY},c.touchendZoom(d,e,h,i)),g=!1),c.core.$outer.removeClass("lg-grabbing").addClass("lg-grab")})},f.prototype.touchendZoom=function(a,b,c,d){var e=this,f=e.core.$slide.eq(e.core.index).find(".lg-img-wrap"),g=e.core.$slide.eq(e.core.index).find(".lg-object"),h=-Math.abs(f.attr("data-x"))+(b.x-a.x),i=-Math.abs(f.attr("data-y"))+(b.y-a.y),j=(e.core.$outer.find(".lg").height()-g.outerHeight())/2,k=Math.abs(g.outerHeight()*Math.abs(g.attr("data-scale"))-e.core.$outer.find(".lg").height()+j),l=(e.core.$outer.find(".lg").width()-g.outerWidth())/2,m=Math.abs(g.outerWidth()*Math.abs(g.attr("data-scale"))-e.core.$outer.find(".lg").width()+l);(Math.abs(b.x-a.x)>15||Math.abs(b.y-a.y)>15)&&(d&&(-k>=i?i=-k:i>=-j&&(i=-j)),c&&(-m>=h?h=-m:h>=-l&&(h=-l)),d?f.attr("data-y",Math.abs(i)):i=-Math.abs(f.attr("data-y")),c?f.attr("data-x",Math.abs(h)):h=-Math.abs(f.attr("data-x")),f.css({left:h+"px",top:i+"px"}))},f.prototype.destroy=function(){var c=this;c.core.$el.off(".lg.zoom"),a(b).off(".lg.zoom"),c.core.$slide.off(".lg.zoom"),c.core.$el.off(".lg.tm.zoom"),c.resetZoom(),clearTimeout(c.zoomabletimeout),c.zoomabletimeout=!1},a.fn.lightGallery.modules.zoom=f}(jQuery,window,document); (function($){ function hasScrollBar(){ return $("body").height() > $(window).height(); } var JustifiedGallery=function ($gallery, settings){ this.settings=settings; this.checkSettings(); this.imgAnalyzerTimeout=null; this.entries=null; this.buildingRow={ entriesBuff:[], width:0, height:0, aspectRatio:0 }; this.lastAnalyzedIndex=-1; this.yield={ every:2, flushed:0 }; this.border=settings.border >=0 ? settings.border:settings.margins; this.maxRowHeight=this.retrieveMaxRowHeight(); this.suffixRanges=this.retrieveSuffixRanges(); this.offY=this.border; this.spinner={ phase:0, timeSlot:150, $el:$('
'), intervalId:null }; this.checkWidthIntervalId=null; this.galleryWidth=$gallery.width(); this.$gallery=$gallery; }; JustifiedGallery.prototype.getSuffix=function (width, height){ var longestSide, i; longestSide=(width > height) ? width:height; for (i=0; i < this.suffixRanges.length; i++){ if(longestSide <=this.suffixRanges[i]){ return this.settings.sizeRangeSuffixes[this.suffixRanges[i]]; }} return this.settings.sizeRangeSuffixes[this.suffixRanges[i - 1]]; }; JustifiedGallery.prototype.removeSuffix=function (str, suffix){ return str.substring(0, str.length - suffix.length); }; JustifiedGallery.prototype.endsWith=function (str, suffix){ return str.indexOf(suffix, str.length - suffix.length)!==-1; }; JustifiedGallery.prototype.getUsedSuffix=function (str){ for (var si in this.settings.sizeRangeSuffixes){ if(this.settings.sizeRangeSuffixes.hasOwnProperty(si)){ if(this.settings.sizeRangeSuffixes[si].length===0) continue; if(this.endsWith(str, this.settings.sizeRangeSuffixes[si])) return this.settings.sizeRangeSuffixes[si]; }} return ''; }; JustifiedGallery.prototype.newSrc=function (imageSrc, imgWidth, imgHeight, $image){ var newImageSrc; if(this.settings.thumbnailPath){ newImageSrc=this.settings.thumbnailPath(imageSrc, imgWidth, imgHeight, $image); }else{ var matchRes=imageSrc.match(this.settings.extension); var ext=(matchRes!==null) ? matchRes[0]:''; newImageSrc=imageSrc.replace(this.settings.extension, ''); newImageSrc=this.removeSuffix(newImageSrc, this.getUsedSuffix(newImageSrc)); newImageSrc +=this.getSuffix(imgWidth, imgHeight) + ext; } return newImageSrc; }; JustifiedGallery.prototype.showImg=function ($entry, callback){ if(this.settings.cssAnimation){ $entry.addClass('entry-visible'); if(callback) callback(); }else{ $entry.stop().fadeTo(this.settings.imagesAnimationDuration, 1.0, callback); }}; JustifiedGallery.prototype.extractImgSrcFromImage=function ($image){ var imageSrc=(typeof $image.data('safe-src')!=='undefined') ? $image.data('safe-src'):$image.attr('src'); $image.data('jg.originalSrc', imageSrc); return imageSrc; }; JustifiedGallery.prototype.imgFromEntry=function ($entry){ var $img=$entry.find('> img'); if($img.length===0) $img=$entry.find('> a > img'); return $img.length===0 ? null:$img; }; JustifiedGallery.prototype.captionFromEntry=function ($entry){ var $caption=$entry.find('> .caption'); return $caption.length===0 ? null:$caption; }; JustifiedGallery.prototype.displayEntry=function ($entry, x, y, imgWidth, imgHeight, rowHeight){ $entry.width(imgWidth); $entry.height(rowHeight); $entry.css('top', y); $entry.css('left', x); var $image=this.imgFromEntry($entry); if($image!==null){ $image.css('width', imgWidth); $image.css('height', imgHeight); $image.css('margin-left', - imgWidth / 2); $image.css('margin-top', - imgHeight / 2); var imageSrc=$image.attr('src'); var newImageSrc=this.newSrc(imageSrc, imgWidth, imgHeight, $image); $image.one('error', function (){ $image.attr('src', $image.data('jg.originalSrc')); }); var loadNewImage=function (){ if(imageSrc!==newImageSrc){ $image.attr('src', newImageSrc); }}; if($entry.data('jg.loaded')==='skipped'){ this.onImageEvent(imageSrc, $.proxy(function(){ this.showImg($entry, loadNewImage); $entry.data('jg.loaded', true); }, this)); }else{ this.showImg($entry, loadNewImage); }}else{ this.showImg($entry); } this.displayEntryCaption($entry); }; JustifiedGallery.prototype.displayEntryCaption=function ($entry){ var $image=this.imgFromEntry($entry); if($image!==null&&this.settings.captions){ var $imgCaption=this.captionFromEntry($entry); if($imgCaption===null){ var caption=$image.attr('alt'); if(!this.isValidCaption(caption)) caption=$entry.attr('title'); if(this.isValidCaption(caption)){ $imgCaption=$('
' + caption + '
'); $entry.append($imgCaption); $entry.data('jg.createdCaption', true); }} if($imgCaption!==null){ if(!this.settings.cssAnimation) $imgCaption.stop().fadeTo(0, this.settings.captionSettings.nonVisibleOpacity); this.addCaptionEventsHandlers($entry); }}else{ this.removeCaptionEventsHandlers($entry); }}; JustifiedGallery.prototype.isValidCaption=function (caption){ return (typeof caption!=='undefined'&&caption.length > 0); }; JustifiedGallery.prototype.onEntryMouseEnterForCaption=function (eventObject){ var $caption=this.captionFromEntry($(eventObject.currentTarget)); if(this.settings.cssAnimation){ $caption.addClass('caption-visible').removeClass('caption-hidden'); }else{ $caption.stop().fadeTo(this.settings.captionSettings.animationDuration, this.settings.captionSettings.visibleOpacity); }}; JustifiedGallery.prototype.onEntryMouseLeaveForCaption=function (eventObject){ var $caption=this.captionFromEntry($(eventObject.currentTarget)); if(this.settings.cssAnimation){ $caption.removeClass('caption-visible').removeClass('caption-hidden'); }else{ $caption.stop().fadeTo(this.settings.captionSettings.animationDuration, this.settings.captionSettings.nonVisibleOpacity); }}; JustifiedGallery.prototype.addCaptionEventsHandlers=function ($entry){ var captionMouseEvents=$entry.data('jg.captionMouseEvents'); if(typeof captionMouseEvents==='undefined'){ captionMouseEvents={ mouseenter: $.proxy(this.onEntryMouseEnterForCaption, this), mouseleave: $.proxy(this.onEntryMouseLeaveForCaption, this) }; $entry.on('mouseenter', undefined, undefined, captionMouseEvents.mouseenter); $entry.on('mouseleave', undefined, undefined, captionMouseEvents.mouseleave); $entry.data('jg.captionMouseEvents', captionMouseEvents); }}; JustifiedGallery.prototype.removeCaptionEventsHandlers=function ($entry){ var captionMouseEvents=$entry.data('jg.captionMouseEvents'); if(typeof captionMouseEvents!=='undefined'){ $entry.off('mouseenter', undefined, captionMouseEvents.mouseenter); $entry.off('mouseleave', undefined, captionMouseEvents.mouseleave); $entry.removeData('jg.captionMouseEvents'); }}; JustifiedGallery.prototype.prepareBuildingRow=function (isLastRow){ var i, $entry, imgAspectRatio, newImgW, newImgH, justify=true; var minHeight=0; var availableWidth=this.galleryWidth - 2 * this.border - ( (this.buildingRow.entriesBuff.length - 1) * this.settings.margins); var rowHeight=availableWidth / this.buildingRow.aspectRatio; var justifiable=this.buildingRow.width / availableWidth > this.settings.justifyThreshold; if(isLastRow&&this.settings.lastRow==='hide'&&!justifiable){ for (i=0; i < this.buildingRow.entriesBuff.length; i++){ $entry=this.buildingRow.entriesBuff[i]; if(this.settings.cssAnimation) $entry.removeClass('entry-visible'); else $entry.stop().fadeTo(0, 0); } return -1; } if(isLastRow&&!justifiable&&this.settings.lastRow!=='justify'&&this.settings.lastRow!=='hide') justify=false; for (i=0; i < this.buildingRow.entriesBuff.length; i++){ $entry=this.buildingRow.entriesBuff[i]; imgAspectRatio=$entry.data('jg.width') / $entry.data('jg.height'); if(justify){ newImgW=(i===this.buildingRow.entriesBuff.length - 1) ? availableWidth:rowHeight * imgAspectRatio; newImgH=this.settings.rowHeight; }else{ newImgW=this.settings.rowHeight * imgAspectRatio; newImgH=this.settings.rowHeight; } availableWidth -=Math.round(newImgW); $entry.data('jg.jwidth', Math.round(newImgW)); $entry.data('jg.jheight', Math.ceil(newImgH)); if(i===0||minHeight > newImgH) minHeight=newImgH; } if(this.settings.fixedHeight&&minHeight > this.settings.rowHeight) minHeight=this.settings.rowHeight; this.buildingRow.height=minHeight; return justify; }; JustifiedGallery.prototype.clearBuildingRow=function (){ this.buildingRow.entriesBuff=[]; this.buildingRow.aspectRatio=0; this.buildingRow.width=0; }; JustifiedGallery.prototype.flushRow=function (isLastRow){ var settings=this.settings; var $entry, buildingRowRes, offX=this.border, i; buildingRowRes=this.prepareBuildingRow(isLastRow); if(isLastRow&&settings.lastRow==='hide'&&this.buildingRow.height===-1){ this.clearBuildingRow(); return; } if(this.maxRowHeight.isPercentage){ if(this.maxRowHeight.value * settings.rowHeight < this.buildingRow.height){ this.buildingRow.height=this.maxRowHeight.value * settings.rowHeight; }}else{ if(this.maxRowHeight.value > 0&&this.maxRowHeight.value < this.buildingRow.height){ this.buildingRow.height=this.maxRowHeight.value; }} if(settings.lastRow==='center'||settings.lastRow==='right'){ var availableWidth=this.galleryWidth - 2 * this.border - (this.buildingRow.entriesBuff.length - 1) * settings.margins; for (i=0; i < this.buildingRow.entriesBuff.length; i++){ $entry=this.buildingRow.entriesBuff[i]; availableWidth -=$entry.data('jg.jwidth'); } if(settings.lastRow==='center') offX +=availableWidth / 2; else if(settings.lastRow==='right') offX +=availableWidth; } for (i=0; i < this.buildingRow.entriesBuff.length; i++){ $entry=this.buildingRow.entriesBuff[i]; this.displayEntry($entry, offX, this.offY, $entry.data('jg.jwidth'), $entry.data('jg.jheight'), this.buildingRow.height); offX +=$entry.data('jg.jwidth') + settings.margins; } this.galleryHeightToSet=this.offY + this.buildingRow.height + this.border; if(!isLastRow||(this.buildingRow.height <=settings.rowHeight&&buildingRowRes)){ this.offY +=this.buildingRow.height + settings.margins; this.clearBuildingRow(); this.$gallery.trigger('jg.rowflush'); }}; var scrollBarOn=false; JustifiedGallery.prototype.checkWidth=function (){ this.checkWidthIntervalId=setInterval($.proxy(function (){ var galleryWidth=parseFloat(this.$gallery.width()); if(hasScrollBar()===scrollBarOn){ if(Math.abs(galleryWidth - this.galleryWidth) > this.settings.refreshSensitivity){ this.galleryWidth=galleryWidth; this.rewind(); this.startImgAnalyzer(true); }}else{ scrollBarOn=hasScrollBar(); this.galleryWidth=galleryWidth; }}, this), this.settings.refreshTime); }; JustifiedGallery.prototype.isSpinnerActive=function (){ return this.spinner.intervalId!==null; }; JustifiedGallery.prototype.getSpinnerHeight=function (){ return this.spinner.$el.innerHeight(); }; JustifiedGallery.prototype.stopLoadingSpinnerAnimation=function (){ clearInterval(this.spinner.intervalId); this.spinner.intervalId=null; this.$gallery.height(this.$gallery.height() - this.getSpinnerHeight()); this.spinner.$el.detach(); }; JustifiedGallery.prototype.startLoadingSpinnerAnimation=function (){ var spinnerContext=this.spinner; var $spinnerPoints=spinnerContext.$el.find('span'); clearInterval(spinnerContext.intervalId); this.$gallery.append(spinnerContext.$el); this.$gallery.height(this.offY + this.buildingRow.height + this.getSpinnerHeight()); spinnerContext.intervalId=setInterval(function (){ if(spinnerContext.phase < $spinnerPoints.length){ $spinnerPoints.eq(spinnerContext.phase).fadeTo(spinnerContext.timeSlot, 1); }else{ $spinnerPoints.eq(spinnerContext.phase - $spinnerPoints.length).fadeTo(spinnerContext.timeSlot, 0); } spinnerContext.phase=(spinnerContext.phase + 1) % ($spinnerPoints.length * 2); }, spinnerContext.timeSlot); }; JustifiedGallery.prototype.rewind=function (){ this.lastAnalyzedIndex=-1; this.offY=this.border; this.clearBuildingRow(); }; JustifiedGallery.prototype.updateEntries=function (norewind){ this.entries=this.$gallery.find(this.settings.selector).toArray(); if(this.entries.length===0) return false; if(this.settings.filter){ this.modifyEntries(this.filterArray, norewind); }else{ this.modifyEntries(this.resetFilters, norewind); } if($.isFunction(this.settings.sort)){ this.modifyEntries(this.sortArray, norewind); }else if(this.settings.randomize){ this.modifyEntries(this.shuffleArray, norewind); } return true; }; JustifiedGallery.prototype.insertToGallery=function (entries){ var that=this; $.each(entries, function (){ $(this).appendTo(that.$gallery); }); }; JustifiedGallery.prototype.shuffleArray=function (a){ var i, j, temp; for (i=a.length - 1; i > 0; i--){ j=Math.floor(Math.random() * (i + 1)); temp=a[i]; a[i]=a[j]; a[j]=temp; } this.insertToGallery(a); return a; }; JustifiedGallery.prototype.sortArray=function (a){ a.sort(this.settings.sort); this.insertToGallery(a); return a; }; JustifiedGallery.prototype.resetFilters=function (a){ for (var i=0; i < a.length; i++) $(a[i]).removeClass('jg-filtered'); return a; }; JustifiedGallery.prototype.filterArray=function (a){ var settings=this.settings; if($.type(settings.filter)==='string'){ return a.filter(function (el){ var $el=$(el); if($el.is(settings.filter)){ $el.removeClass('jg-filtered'); return true; }else{ $el.addClass('jg-filtered'); return false; }}); }else if($.isFunction(settings.filter)){ return a.filter(settings.filter); }}; JustifiedGallery.prototype.modifyEntries=function (functionToApply, norewind){ var lastEntries=norewind ? this.entries.splice(this.lastAnalyzedIndex + 1, this.entries.length - this.lastAnalyzedIndex - 1) : this.entries; lastEntries=functionToApply.call(this, lastEntries); this.entries=norewind ? this.entries.concat(lastEntries):lastEntries; }; JustifiedGallery.prototype.destroy=function (){ clearInterval(this.checkWidthIntervalId); $.each(this.entries, $.proxy(function(_, entry){ var $entry=$(entry); $entry.css('width', ''); $entry.css('height', ''); $entry.css('top', ''); $entry.css('left', ''); $entry.data('jg.loaded', undefined); $entry.removeClass('jg-entry'); var $img=this.imgFromEntry($entry); $img.css('width', ''); $img.css('height', ''); $img.css('margin-left', ''); $img.css('margin-top', ''); $img.attr('src', $img.data('jg.originalSrc')); $img.data('jg.originalSrc', undefined); this.removeCaptionEventsHandlers($entry); var $caption=this.captionFromEntry($entry); if($entry.data('jg.createdCaption')){ $entry.data('jg.createdCaption', undefined); if($caption!==null) $caption.remove(); }else{ if($caption!==null) $caption.fadeTo(0, 1); }}, this)); this.$gallery.css('height', ''); this.$gallery.removeClass('justified-gallery'); this.$gallery.data('jg.controller', undefined); }; JustifiedGallery.prototype.analyzeImages=function (isForResize){ for (var i=this.lastAnalyzedIndex + 1; i < this.entries.length; i++){ var $entry=$(this.entries[i]); if($entry.data('jg.loaded')===true||$entry.data('jg.loaded')==='skipped'){ var availableWidth=this.galleryWidth - 2 * this.border - ( (this.buildingRow.entriesBuff.length - 1) * this.settings.margins); var imgAspectRatio=$entry.data('jg.width') / $entry.data('jg.height'); if(availableWidth / (this.buildingRow.aspectRatio + imgAspectRatio) < this.settings.rowHeight){ this.flushRow(false); if(++this.yield.flushed >=this.yield.every){ this.startImgAnalyzer(isForResize); return; }} this.buildingRow.entriesBuff.push($entry); this.buildingRow.aspectRatio +=imgAspectRatio; this.buildingRow.width +=imgAspectRatio * this.settings.rowHeight; this.lastAnalyzedIndex=i; }else if($entry.data('jg.loaded')!=='error'){ return; }} if(this.buildingRow.entriesBuff.length > 0) this.flushRow(true); if(this.isSpinnerActive()){ this.stopLoadingSpinnerAnimation(); } this.stopImgAnalyzerStarter(); this.$gallery.trigger(isForResize ? 'jg.resize':'jg.complete'); this.$gallery.height(this.galleryHeightToSet); }; JustifiedGallery.prototype.stopImgAnalyzerStarter=function (){ this.yield.flushed=0; if(this.imgAnalyzerTimeout!==null) clearTimeout(this.imgAnalyzerTimeout); }; JustifiedGallery.prototype.startImgAnalyzer=function (isForResize){ var that=this; this.stopImgAnalyzerStarter(); this.imgAnalyzerTimeout=setTimeout(function (){ that.analyzeImages(isForResize); }, 0.001); }; JustifiedGallery.prototype.onImageEvent=function (imageSrc, onLoad, onError){ if(!onLoad&&!onError) return; var memImage=new Image(); var $memImage=$(memImage); if(onLoad){ $memImage.one('load', function (){ $memImage.off('load error'); onLoad(memImage); }); } if(onError){ $memImage.one('error', function(){ $memImage.off('load error'); onError(memImage); }); } memImage.src=imageSrc; }; JustifiedGallery.prototype.init=function (){ var imagesToLoad=false, skippedImages=false, that=this; $.each(this.entries, function (index, entry){ var $entry=$(entry); var $image=that.imgFromEntry($entry); $entry.addClass('jg-entry'); if($entry.data('jg.loaded')!==true&&$entry.data('jg.loaded')!=='skipped'){ if(that.settings.rel!==null) $entry.attr('rel', that.settings.rel); if(that.settings.target!==null) $entry.attr('target', that.settings.target); if($image!==null){ var imageSrc=that.extractImgSrcFromImage($image); $image.attr('src', imageSrc); if(that.settings.waitThumbnailsLoad===false){ var width=parseFloat($image.attr('width')); var height=parseFloat($image.attr('height')); if(!isNaN(width)&&!isNaN(height)){ $entry.data('jg.width', width); $entry.data('jg.height', height); $entry.data('jg.loaded', 'skipped'); skippedImages=true; that.startImgAnalyzer(false); return true; }} $entry.data('jg.loaded', false); imagesToLoad=true; if(!that.isSpinnerActive()) that.startLoadingSpinnerAnimation(); that.onImageEvent(imageSrc, function (loadImg){ $entry.data('jg.width', loadImg.width); $entry.data('jg.height', loadImg.height); $entry.data('jg.loaded', true); that.startImgAnalyzer(false); }, function (){ $entry.data('jg.loaded', 'error'); that.startImgAnalyzer(false); }); }else{ $entry.data('jg.loaded', true); $entry.data('jg.width', $entry.width() | parseFloat($entry.css('width')) | 1); $entry.data('jg.height', $entry.height() | parseFloat($entry.css('height')) | 1); }} }); if(!imagesToLoad&&!skippedImages) this.startImgAnalyzer(false); this.checkWidth(); }; JustifiedGallery.prototype.checkOrConvertNumber=function (settingContainer, settingName){ if($.type(settingContainer[settingName])==='string'){ settingContainer[settingName]=parseFloat(settingContainer[settingName]); } if($.type(settingContainer[settingName])==='number'){ if(isNaN(settingContainer[settingName])) throw 'invalid number for ' + settingName; }else{ throw settingName + ' must be a number'; }}; JustifiedGallery.prototype.checkSizeRangesSuffixes=function (){ if($.type(this.settings.sizeRangeSuffixes)!=='object'){ throw 'sizeRangeSuffixes must be defined and must be an object'; } var suffixRanges=[]; for (var rangeIdx in this.settings.sizeRangeSuffixes){ if(this.settings.sizeRangeSuffixes.hasOwnProperty(rangeIdx)) suffixRanges.push(rangeIdx); } var newSizeRngSuffixes={0: ''}; for (var i=0; i < suffixRanges.length; i++){ if($.type(suffixRanges[i])==='string'){ try { var numIdx=parseInt(suffixRanges[i].replace(/^[a-z]+/, ''), 10); newSizeRngSuffixes[numIdx]=this.settings.sizeRangeSuffixes[suffixRanges[i]]; } catch (e){ throw 'sizeRangeSuffixes keys must contains correct numbers (' + e + ')'; }}else{ newSizeRngSuffixes[suffixRanges[i]]=this.settings.sizeRangeSuffixes[suffixRanges[i]]; }} this.settings.sizeRangeSuffixes=newSizeRngSuffixes; }; JustifiedGallery.prototype.retrieveMaxRowHeight=function (){ var newMaxRowHeight={ }; if($.type(this.settings.maxRowHeight)==='string'){ if(this.settings.maxRowHeight.match(/^[0-9]+%$/)){ newMaxRowHeight.value=parseFloat(this.settings.maxRowHeight.match(/^([0-9]+)%$/)[1]) / 100; newMaxRowHeight.isPercentage=false; }else{ newMaxRowHeight.value=parseFloat(this.settings.maxRowHeight); newMaxRowHeight.isPercentage=true; }}else if($.type(this.settings.maxRowHeight)==='number'){ newMaxRowHeight.value=this.settings.maxRowHeight; newMaxRowHeight.isPercentage=false; }else{ throw 'maxRowHeight must be a number or a percentage'; } if(isNaN(newMaxRowHeight.value)) throw 'invalid number for maxRowHeight'; if(newMaxRowHeight.isPercentage){ if(newMaxRowHeight.value < 100) newMaxRowHeight.value=100; }else{ if(newMaxRowHeight.value > 0&&newMaxRowHeight.value < this.settings.rowHeight){ newMaxRowHeight.value=this.settings.rowHeight; }} return newMaxRowHeight; }; JustifiedGallery.prototype.checkSettings=function (){ this.checkSizeRangesSuffixes(); this.checkOrConvertNumber(this.settings, 'rowHeight'); this.checkOrConvertNumber(this.settings, 'margins'); this.checkOrConvertNumber(this.settings, 'border'); if(this.settings.lastRow!=='justify' && this.settings.lastRow!=='nojustify'&&this.settings.lastRow!=='left' && this.settings.lastRow!=='center' && this.settings.lastRow!=='right' && this.settings.lastRow!=='hide'){ throw 'lastRow must be "justify", "nojustify", "left", "center", "right" or "hide"'; } this.checkOrConvertNumber(this.settings, 'justifyThreshold'); if(this.settings.justifyThreshold < 0||this.settings.justifyThreshold > 1){ throw 'justifyThreshold must be in the interval [0,1]'; } if($.type(this.settings.cssAnimation)!=='boolean'){ throw 'cssAnimation must be a boolean'; } if($.type(this.settings.captions)!=='boolean') throw 'captions must be a boolean'; this.checkOrConvertNumber(this.settings.captionSettings, 'animationDuration'); this.checkOrConvertNumber(this.settings.captionSettings, 'visibleOpacity'); if(this.settings.captionSettings.visibleOpacity < 0 || this.settings.captionSettings.visibleOpacity > 1){ throw 'captionSettings.visibleOpacity must be in the interval [0, 1]'; } this.checkOrConvertNumber(this.settings.captionSettings, 'nonVisibleOpacity'); if(this.settings.captionSettings.nonVisibleOpacity < 0 || this.settings.captionSettings.nonVisibleOpacity > 1){ throw 'captionSettings.nonVisibleOpacity must be in the interval [0, 1]'; } if($.type(this.settings.fixedHeight)!=='boolean') throw 'fixedHeight must be a boolean'; this.checkOrConvertNumber(this.settings, 'imagesAnimationDuration'); this.checkOrConvertNumber(this.settings, 'refreshTime'); this.checkOrConvertNumber(this.settings, 'refreshSensitivity'); if($.type(this.settings.randomize)!=='boolean') throw 'randomize must be a boolean'; if($.type(this.settings.selector)!=='string') throw 'selector must be a string'; if(this.settings.sort!==false&&!$.isFunction(this.settings.sort)){ throw 'sort must be false or a comparison function'; } if(this.settings.filter!==false&&!$.isFunction(this.settings.filter) && $.type(this.settings.filter)!=='string'){ throw 'filter must be false, a string or a filter function'; }}; JustifiedGallery.prototype.retrieveSuffixRanges=function (){ var suffixRanges=[]; for (var rangeIdx in this.settings.sizeRangeSuffixes){ if(this.settings.sizeRangeSuffixes.hasOwnProperty(rangeIdx)) suffixRanges.push(parseInt(rangeIdx, 10)); } suffixRanges.sort(function (a, b){ return a > b ? 1:a < b ? -1:0; }); return suffixRanges; }; JustifiedGallery.prototype.updateSettings=function (newSettings){ this.settings=$.extend({}, this.settings, newSettings); this.checkSettings(); this.border=this.settings.border >=0 ? this.settings.border:this.settings.margins; this.maxRowHeight=this.retrieveMaxRowHeight(); this.suffixRanges=this.retrieveSuffixRanges(); }; $.fn.justifiedGallery=function (arg){ return this.each(function (index, gallery){ var $gallery=$(gallery); $gallery.addClass('justified-gallery'); var controller=$gallery.data('jg.controller'); if(typeof controller==='undefined'){ if(typeof arg!=='undefined'&&arg!==null&&$.type(arg)!=='object'){ if(arg==='destroy') return; throw 'The argument must be an object'; } controller=new JustifiedGallery($gallery, $.extend({}, $.fn.justifiedGallery.defaults, arg)); $gallery.data('jg.controller', controller); }else if(arg==='norewind'){ }else if(arg==='destroy'){ controller.destroy(); return; }else{ controller.updateSettings(arg); controller.rewind(); } if(!controller.updateEntries(arg==='norewind')) return; controller.init(); }); }; $.fn.justifiedGallery.defaults={ sizeRangeSuffixes: { }, thumbnailPath: undefined, rowHeight: 120, maxRowHeight: -1, margins: 1, border: -1, lastRow: 'nojustify', justifyThreshold: 0.75, fixedHeight: false, waitThumbnailsLoad: true, captions: true, cssAnimation: false, imagesAnimationDuration: 500, captionSettings: { animationDuration: 500, visibleOpacity: 0.7, nonVisibleOpacity: 0.0 }, rel: null, target: null, extension: /\.[^.\\/]+$/, refreshTime: 200, refreshSensitivity: 0, randomize: false, sort: false, filter: false, selector: '> a, > div:not(.spinner)' };}(jQuery)); (function ($){ !function(t,e){"function"==typeof define&&define.amd?define("jquery-bridget/jquery-bridget",["jquery"],function(i){return e(t,i)}):"object"==typeof module&&module.exports?module.exports=e(t,require("jquery")):t.jQueryBridget=e(t,t.jQuery)}(window,function(t,e){"use strict";function i(i,s,a){function u(t,e,o){var n,s="$()."+i+'("'+e+'")';return t.each(function(t,u){var h=a.data(u,i);if(!h)return void r(i+" not initialized. Cannot call methods, i.e. "+s);var d=h[e];if(!d||"_"==e.charAt(0))return void r(s+" is not a valid method");var l=d.apply(h,o);n=void 0===n?l:n}),void 0!==n?n:t}function h(t,e){t.each(function(t,o){var n=a.data(o,i);n?(n.option(e),n._init()):(n=new s(o,e),a.data(o,i,n))})}a=a||e||t.jQuery,a&&(s.prototype.option||(s.prototype.option=function(t){a.isPlainObject(t)&&(this.options=a.extend(!0,this.options,t))}),a.fn[i]=function(t){if("string"==typeof t){var e=n.call(arguments,1);return u(this,t,e)}return h(this,t),this},o(a))}function o(t){!t||t&&t.bridget||(t.bridget=i)}var n=Array.prototype.slice,s=t.console,r="undefined"==typeof s?function(){}:function(t){s.error(t)};return o(e||t.jQuery),i}),function(t,e){"function"==typeof define&&define.amd?define("ev-emitter/ev-emitter",e):"object"==typeof module&&module.exports?module.exports=e():t.EvEmitter=e()}("undefined"!=typeof window?window:this,function(){function t(){}var e=t.prototype;return e.on=function(t,e){if(t&&e){var i=this._events=this._events||{},o=i[t]=i[t]||[];return o.indexOf(e)==-1&&o.push(e),this}},e.once=function(t,e){if(t&&e){this.on(t,e);var i=this._onceEvents=this._onceEvents||{},o=i[t]=i[t]||{};return o[e]=!0,this}},e.off=function(t,e){var i=this._events&&this._events[t];if(i&&i.length){var o=i.indexOf(e);return o!=-1&&i.splice(o,1),this}},e.emitEvent=function(t,e){var i=this._events&&this._events[t];if(i&&i.length){var o=0,n=i[o];e=e||[];for(var s=this._onceEvents&&this._onceEvents[t];n;){var r=s&&s[n];r&&(this.off(t,n),delete s[n]),n.apply(this,e),o+=r?0:1,n=i[o]}return this}},t}),function(t,e){"use strict";"function"==typeof define&&define.amd?define("get-size/get-size",[],function(){return e()}):"object"==typeof module&&module.exports?module.exports=e():t.getSize=e()}(window,function(){"use strict";function t(t){var e=parseFloat(t),i=t.indexOf("%")==-1&&!isNaN(e);return i&&e}function e(){}function i(){for(var t={width:0,height:0,innerWidth:0,innerHeight:0,outerWidth:0,outerHeight:0},e=0;e