/* by andre knieriem, www.andreknieriem.de available for use under the mit license */ !function(e,t,n){"use strict";e.fn.simplelightbox=function(i){var i=e.extend({overlay:!0,spinner:!0,nav:!0,navtext:["←","→"],captions:!0,captionsdata:"title",close:!0,closetext:"x",fileext:"png|jpg|jpeg|gif",animationspeed:250,preloading:!0,enablekeyboard:!0,loop:!0,docclose:!0,swipetolerance:50,classname:"simple-lightbox",widthratio:.8,heightratio:.9},i),a=(t.navigator.pointerenabled||t.navigator.mspointerenabled,0),o=e(),s=function(){var e=n.body||n.documentelement,e=e.style;return""==e.webkittransition?"-webkit-":""==e.moztransition?"-moz-":""==e.otransition?"-o-":""==e.transition?"":!1},l=!1,r=this.selector,s=s(),p=s!==!1?!0:!1,c="simplelb",d=e("
").addclass("sl-overlay"),g=e(""),h=!1,m=0,v=e(),x=e("
").addclass("sl-caption"),b=function(t){return"a"==e(t).prop("tagname").tolowercase()&&new regexp(".("+i.fileext+")$","i").test(e(t).attr("href"))},w=function(){i.overlay&&d.appendto(e("body")),e("
").addclass("sl-wrapper").addclass(i.classname).html('
').appendto("body"),v=e(".sl-image"),i.close&&g.appendto(e(".sl-wrapper")),i.nav&&u.appendto(e(".sl-wrapper")),i.spinner&&f.appendto(e(".sl-wrapper"))},y=function(t){t.trigger(e.event("show.simplelightbox")),h=!0,m=e(r).index(t),o=e("").hide().attr("src",t.attr("href")),e(".sl-image").html(""),o.appendto(e(".sl-image")),d.fadein("fast"),e(".sl-close").fadein("fast"),f.show(),u.fadein("fast"),t(),i.preloading&&k(),settimeout(function(){t.trigger(e.event("shown.simplelightbox"))},i.animationspeed)},t=function(n){if(o.length){var a=new image,s=e(t).width()*i.widthratio,c=e(t).height()*i.heightratio;a.src=o.attr("src"),a.onload=function(){var d=a.width,g=a.height;if(d>s||g>c){var u=d/g>s/c?d/s:g/c;d/=u,g/=u}e(".sl-image").css({top:(e(t).height()-g)/2+"px",left:(e(t).width()-d)/2+"px"}),f.hide(),o.css({width:d+"px",height:g+"px"}).fadein("fast"),l=!0;var v="title"==i.captionsdata?e(r).eq(m).find("img").prop("title"):e(r).eq(m).find("img").data("title");if(1==n||-1==n){var x={opacity:1};p?(e(0,100*n+"px"),settimeout(function(){e(i.animationspeed/1e3,"0px"),50})):x.left=parseint(e(".sl-image").css("left"))+100*n+"px",e(".sl-image").animate(x,i.animationspeed,function(){h=!1,c(v)})}else h=!1,c(v)}}},c=function(t){""!=t&&i.captions&&x.html(t).hide().appendto(e(".sl-image")).fadein("fast")},e=function(t,n){var i={};i[s+"transform"]="translatex("+n+")",i[s+"transition"]=s+"transform "+t+"s linear",e(".sl-image").css(i)},k=function(){var t=0>m+1?e(r).length-1:m+1>=e(r).length-1?0:m+1,n=0>m-1?e(r).length-1:m-1>=e(r).length-1?0:m-1;e("").attr("src",e(r).eq(t).attr("href")).load(),e("").attr("src",e(r).eq(n).attr("href")).load()},s=function(t){f.show();var n=m+t;if(!(h||(0>n||n>=e(r).length)&&0==i.loop)){h=!0,m=0>n?e(r).length-1:n>e(r).length-1?0:n;var s={opacity:0};p?e(i.animationspeed/1e3,-100*t-a+"px"):s.left=parseint(e(".sl-image").css("left"))+-100*t+"px",e(".sl-image").animate(s,i.animationspeed,function(){settimeout(function(){var n=e(r).eq(m);o.attr("src",n.attr("href")),e(".sl-caption").remove(),t(t),i.preloading&&k()},100)})}},i=function(){var t=e(r).eq(m),n=!1;t.trigger(e.event("close.simplelightbox")),e(".sl-image img, .sl-overlay, .sl-close, .sl-navigation, .sl-image .sl-caption").fadeout("fast",function(){n||t.trigger(e.event("closed.simplelightbox")),n=!0}),o=e(),l=!1};w(),e(t).on("resize",t),e(n).on("click."+c,this.selector,function(t){if(b(this)){if(t.preventdefault(),h)return!1;y(e(this))}}),e(n).on("click",".sl-close",function(e){e.preventdefault(),l&&i()}),e(n).click(function(t){l&&i.docclose&&0==e(t.target).closest(".sl-image").length&&0==e(t.target).closest(".sl-navigation").length&&i()}),e(n).on("click",".sl-navigation button",function(t){t.preventdefault(),a=0,s(e(this).hasclass("sl-next")?1:-1)}),i.enablekeyboard&&e(n).on("keyup."+c,function(e){e.preventdefault(),a=0;var t=e.keycode;27==t&&i(),(37==t||39==e.keycode)&&s(39==e.keycode?1:-1)});var d=0,m=0,q=!1,x=0;return e(n).on("touchstart mousedown pointerdown mspointerdown",".sl-image",function(e){return q?!0:(p&&(x=parseint(v.css("left"))),q=!0,void(d=e.originalevent.pagex||e.originalevent.touches[0].pagex))}).on("touchmove mousemove pointermove mspointermove",".sl-image",function(e){return q?(e.preventdefault(),m=e.originalevent.pagex||e.originalevent.touches[0].pagex,a=d-m,void(p?e(0,-a+"px"):v.css("left",x-a+"px"))):!0}).on("touchend mouseup touchcancel pointerup pointercancel mspointerup mspointercancel",".sl-image",function(){q=!1,math.abs(a)>i.swipetolerance?s(a>0?1:-1):p?e(i.animationspeed/1e3,"0px"):v.animate({left:x+"px"},i.animationspeed/2)}),this.open=function(e){y(e)},this.next=function(){s(1)},this.prev=function(){s(-1)},this.close=function(){i()},this.destroy=function(){e(n).unbind("click."+c).unbind("keyup."+c),i(),e(".sl-overlay, .sl-wrapper").remove()},this}}(jquery,window,document);