simplelightbox
Advanced tools
Comparing version 1.17.0 to 1.17.1
{ | ||
"name": "simplelightbox", | ||
"version": "1.17.0", | ||
"version": "1.17.1", | ||
"homepage": "http://simplelightbox.com/", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -5,3 +5,3 @@ /*! | ||
Available for use under the MIT License | ||
1.17.0 | ||
1.17.1 | ||
*/ | ||
@@ -32,3 +32,3 @@ ;( function( $, window, document, undefined ) | ||
showCounter: true, | ||
fileExt: 'png|jpg|jpeg|gif', | ||
fileExt: 'png|jpg|jpeg|gif|webp', | ||
animationSlide: true, | ||
@@ -93,2 +93,3 @@ animationSpeed: 250, | ||
objects = (options.rel && options.rel !== false) ? getRelated(options.rel, $(this)) : this, | ||
tagname = objects.get()[0].tagName, | ||
transPrefix = transPrefix(), | ||
@@ -167,3 +168,3 @@ globalScrollbarwidth = 0, | ||
var testExt = $( element ).attr( options.sourceAttr ).match(filEext); | ||
return testExt && $( element ).prop( 'tagName' ).toLowerCase() == 'a' && ( new RegExp( '\.(' + options.fileExt + ')$', 'i' ) ).test( testExt ); | ||
return testExt && $( element ).prop( 'tagName' ).toUpperCase() == tagname && ( new RegExp( '\.(' + options.fileExt + ')$', 'i' ) ).test( testExt ); | ||
}, | ||
@@ -170,0 +171,0 @@ setup = function(){ |
@@ -5,4 +5,4 @@ /* | ||
Available for use under the MIT License | ||
1.17.0 | ||
1.17.1 | ||
*/ | ||
!function(st,lt,rt,t){"use strict";st.fn.simpleLightbox=function(P){P=st.extend({sourceAttr:"href",overlay:!0,spinner:!0,nav:!0,navText:["‹","›"],captions:!0,captionDelay:0,captionSelector:"img",captionType:"attr",captionsData:"title",captionPosition:"bottom",captionClass:"",close:!0,closeText:"×",swipeClose:!0,showCounter:!0,fileExt:"png|jpg|jpeg|gif",animationSlide:!0,animationSpeed:250,preloading:!0,enableKeyboard:!0,loop:!0,rel:!1,docClose:!0,swipeTolerance:50,className:"simple-lightbox",widthRatio:.8,heightRatio:.9,scaleImageToRatio:!1,disableRightClick:!1,disableScroll:!0,alertError:!0,alertErrorMessage:"Image not found, next image will be loaded",additionalHtml:!1,history:!0,throttleInterval:0,doubleTapZoom:2,maxZoom:10,htmlClass:"has-lightbox"},P);var h,t,Z="ontouchstart"in lt,z=(lt.navigator.pointerEnabled||lt.navigator.msPointerEnabled,0),H=0,L=st(),i=function(){var t=rt.body||rt.documentElement;return""===(t=t.style).WebkitTransition?"-webkit-":""===t.MozTransition?"-moz-":""===t.OTransition?"-o-":""===t.transition&&""},N=!1,p=[],j=P.rel&&!1!==P.rel?(t=P.rel,st(this).filter(function(){return st(this).attr("rel")===t})):this,d=(i=i(),0),K=!1!==i,a="pushState"in history,u=!1,n=lt.location,$=function(){return n.hash.substring(1)},B=$(),f=function(){$();var t="pid="+(J+1),e=n.href.split("#")[0]+"#"+t;a?history[u?"replaceState":"pushState"]("",rt.title,e):u?n.replace(e):n.hash=t,u=!0},Q=function(e,a){var n;return function(){var t=arguments;n||(e.apply(this,t),n=!0,setTimeout(function(){return n=!1},a))}},U="simplelb",e=st("<div>").addClass("sl-overlay"),o=st("<button>").addClass("sl-close").html(P.closeText),g=st("<div>").addClass("sl-spinner").html("<div></div>"),G=st("<div>").addClass("sl-navigation").html('<button class="sl-prev">'+P.navText[0]+'</button><button class="sl-next">'+P.navText[1]+"</button>"),s=st("<div>").addClass("sl-counter").html('<span class="sl-current"></span>/<span class="sl-total"></span>'),m=!1,J=0,v=0,l=st("<div>").addClass("sl-caption "+P.captionClass+" pos-"+P.captionPosition),V=st("<div>").addClass("sl-image"),r=st("<div>").addClass("sl-wrapper").addClass(P.className),c=function(t){t.trigger(st.Event("show.simplelightbox")),P.disableScroll&&(d=C("hide")),P.htmlClass&&""!=P.htmlClass&&st("html").addClass(P.htmlClass),r.appendTo("body"),V.appendTo(r),P.overlay&&e.appendTo(st("body")),m=!0,J=j.index(t),L=st("<img/>").hide().attr("src",t.attr(P.sourceAttr)).attr("data-scale",1).attr("data-translate-x",0).attr("data-translate-y",0),-1==p.indexOf(t.attr(P.sourceAttr))&&p.push(t.attr(P.sourceAttr)),V.html("").attr("style",""),L.appendTo(V),b(),e.fadeIn("fast"),st(".sl-close").fadeIn("fast"),g.show(),G.fadeIn("fast"),st(".sl-wrapper .sl-counter .sl-current").text(J+1),s.fadeIn("fast"),_(),P.preloading&&y(),setTimeout(function(){t.trigger(st.Event("shown.simplelightbox"))},P.animationSpeed)},_=function(s){if(L.length){var l=new Image,r=lt.innerWidth*P.widthRatio,c=lt.innerHeight*P.heightRatio;l.src=L.attr("src"),L.data("scale",1),L.data("translate-x",0),L.data("translate-y",0),et(0,0,1),st(l).on("error",function(t){j.eq(J).trigger(st.Event("error.simplelightbox")),N=!(m=!1),g.hide();var e=1==s||-1==s;v===J&&e?ot():(P.alertError&&alert(P.alertErrorMessage),it(e?s:1))}),l.onload=function(){void 0!==s&&j.eq(J).trigger(st.Event("changed.simplelightbox")).trigger(st.Event((1===s?"nextDone":"prevDone")+".simplelightbox")),P.history&&(u?h=setTimeout(f,800):f()),-1==p.indexOf(L.attr("src"))&&p.push(L.attr("src"));var t=l.width,e=l.height;if(P.scaleImageToRatio||r<t||c<e){var a=r/c<t/e?t/r:e/c;t/=a,e/=a}st(".sl-image").css({top:(lt.innerHeight-e)/2+"px",left:(lt.innerWidth-t-d)/2+"px",width:t+"px",height:e+"px"}),g.hide(),L.fadeIn("fast"),N=!0;var n,i="self"==P.captionSelector?j.eq(J):j.eq(J).find(P.captionSelector);if(n="data"==P.captionType?i.data(P.captionsData):"text"==P.captionType?i.html():i.prop(P.captionsData),P.loop||(0===J&&st(".sl-prev").hide(),J>=j.length-1&&st(".sl-next").hide(),0<J&&st(".sl-prev").show(),J<j.length-1&&st(".sl-next").show()),1==j.length&&st(".sl-prev, .sl-next").hide(),1==s||-1==s){var o={opacity:1};P.animationSlide&&(K?(tt(0,100*s+"px"),setTimeout(function(){tt(P.animationSpeed/1e3,"0px")},50)):o.left=parseInt(st(".sl-image").css("left"))+100*s+"px"),st(".sl-image").animate(o,P.animationSpeed,function(){m=!1,x(n,t)})}else m=!1,x(n,t);P.additionalHtml&&0===st(".sl-additional-html").length&&st("<div>").html(P.additionalHtml).addClass("sl-additional-html").appendTo(st(".sl-image"))}}},x=function(t,e){""!==t&&void 0!==t&&P.captions&&l.html(t).css({width:e+"px"}).hide().appendTo(st(".sl-image")).delay(P.captionDelay).fadeIn("fast")},tt=function(t,e){var a={};a[i+"transform"]="translateX("+e+")",a[i+"transition"]=i+"transform "+t+"s linear",st(".sl-image").css(a)},et=function(t,e,a){var n={};n[i+"transform"]="translate("+t+","+e+") scale("+a+")",L.css(n)},at=function(t,e,a){return t<e?e:a<t?a:t},nt=function(t,e,a){L.data("scale",t),L.data("translate-x",e),L.data("translate-y",a)},b=function(){st(lt).on("resize."+U,_),st(rt).on("click."+U+" touchstart."+U,".sl-close",function(t){t.preventDefault(),N&&ot()}),P.history&&setTimeout(function(){st(lt).on("hashchange."+U,function(){N&&$()===B&&ot()})},40),G.on("click."+U,"button",Q(function(t){t.preventDefault(),z=0,it(st(this).hasClass("sl-next")?1:-1)},P.throttleInterval));var e,a,n,i,o,s,l,r,c,h,p,d,u,f,g,m,v,x,b,y,C,w,T,E,S,M,I,k=0,q=0,X=0,D=0,Y=!1,A=!1,O=0,R=!1,W=at(1,1,P.maxZoom),F=!1;V.on("touchstart."+U+" mousedown."+U,function(t){if("A"===t.target.tagName&&"touchstart"==t.type)return!0;if("mousedown"==(t=t.originalEvent).type)c=t.clientX,h=t.clientY,e=V.height(),a=V.width(),o=L.height(),s=L.width(),n=V.position().left,i=V.position().top,l=parseFloat(L.data("translate-x")),r=parseFloat(L.data("translate-y")),R=!0;else{if(I=t.touches.length,c=t.touches[0].clientX,h=t.touches[0].clientY,e=V.height(),a=V.width(),o=L.height(),s=L.width(),n=V.position().left,i=V.position().top,1===I){if(F)return L.addClass("sl-transition"),Y=Y?(nt(0,0,W=1),et("0px","0px",W),!1):(W=P.doubleTapZoom,nt(0,0,W),et("0px","0px",W),st(".sl-caption").fadeOut(200),!0),setTimeout(function(){L.removeClass("sl-transition")},200),!1;F=!0,setTimeout(function(){F=!1},300),l=parseFloat(L.data("translate-x")),r=parseFloat(L.data("translate-y"))}else 2===I&&(p=t.touches[1].clientX,d=t.touches[1].clientY,l=parseFloat(L.data("translate-x")),r=parseFloat(L.data("translate-y")),C=(c+p)/2,w=(h+d)/2,u=Math.sqrt((c-p)*(c-p)+(h-d)*(h-d)));R=!0}return!!A||(K&&(O=parseInt(V.css("left"))),A=!0,H=z=0,k=t.pageX||t.touches[0].pageX,X=t.pageY||t.touches[0].pageY,!1)}).on("touchmove."+U+" mousemove."+U+" MSPointerMove",function(t){if(!A)return!0;if(t.preventDefault(),"touchmove"==(t=t.originalEvent).type){if(!1===R)return!1;f=t.touches[0].clientX,g=t.touches[0].clientY,I=t.touches.length,0,1<I?(m=t.touches[1].clientX,v=t.touches[1].clientY,M=Math.sqrt((f-m)*(f-m)+(g-v)*(g-v)),null===u&&(u=M),1<=Math.abs(u-M)&&(y=at(M/u*W,1,P.maxZoom),T=(s*y-a)/2,E=(o*y-e)/2,S=y-W,x=s*y<=a?0:at(l-(C-n-a/2-l)/(y-S)*S,-1*T,T),b=o*y<=e?0:at(r-(w-i-e/2-r)/(y-S)*S,-1*E,E),et(x+"px",b+"px",y),1<y&&(Y=!0,st(".sl-caption").fadeOut(200)),u=M,W=y,l=x,r=b)):(T=(s*(y=W)-a)/2,E=(o*y-e)/2,x=s*y<=a?0:at(f-(c-l),-1*T,T),b=o*y<=e?0:at(g-(h-r),-1*E,E),Math.abs(x)===Math.abs(T)&&(l=x,c=f),Math.abs(b)===Math.abs(E)&&(r=b,h=g),nt(W,x,b),et(x+"px",b+"px",y))}if("mousemove"==t.type&&A){if("touchmove"==t.type)return!0;if(!1===R)return!1;f=t.clientX,g=t.clientY,T=(s*(y=W)-a)/2,E=(o*y-e)/2,x=s*y<=a?0:at(f-(c-l),-1*T,T),b=o*y<=e?0:at(g-(h-r),-1*E,E),Math.abs(x)===Math.abs(T)&&(l=x,c=f),Math.abs(b)===Math.abs(E)&&(r=b,h=g),nt(W,x,b),et(x+"px",b+"px",y)}Y||(q=t.pageX||t.touches[0].pageX,D=t.pageY||t.touches[0].pageY,z=k-q,H=X-D,P.animationSlide&&(K?tt(0,-z+"px"):V.css("left",O-z+"px")))}).on("touchend."+U+" mouseup."+U+" touchcancel."+U+" mouseleave."+U+" pointerup pointercancel MSPointerUp MSPointerCancel",function(t){if(t=t.originalEvent,Z&&"touchend"==t.type&&(0===(I=t.touches.length)?(nt(W,x,b),1==W&&(Y=!1,st(".sl-caption").fadeIn(200)),u=null,R=!1):1===I?(c=t.touches[0].clientX,h=t.touches[0].clientY):1<I&&(u=null)),A){var e=!(A=!1);P.loop||(0===J&&z<0&&(e=!1),J>=j.length-1&&0<z&&(e=!1)),Math.abs(z)>P.swipeTolerance&&e?it(0<z?1:-1):P.animationSlide&&(K?tt(P.animationSpeed/1e3,"0px"):V.animate({left:O+"px"},P.animationSpeed/2)),P.swipeClose&&50<Math.abs(H)&&Math.abs(z)<P.swipeTolerance&&ot()}}).on("dblclick",function(t){return c=t.clientX,h=t.clientY,e=V.height(),a=V.width(),o=L.height(),s=L.width(),n=V.position().left,i=V.position().top,L.addClass("sl-transition"),Y=Y?(nt(0,0,W=1),et("0px","0px",W),!1):(W=P.doubleTapZoom,nt(0,0,W),et("0px","0px",W),st(".sl-caption").fadeOut(200),!0),setTimeout(function(){L.removeClass("sl-transition")},200),!(R=!0)})},y=function(){var t=J+1<0?j.length-1:J+1>=j.length-1?0:J+1,e=J-1<0?j.length-1:J-1>=j.length-1?0:J-1;st("<img />").attr("src",j.eq(t).attr(P.sourceAttr)).on("load",function(){-1==p.indexOf(st(this).attr("src"))&&p.push(st(this).attr("src")),j.eq(J).trigger(st.Event("nextImageLoaded.simplelightbox"))}),st("<img />").attr("src",j.eq(e).attr(P.sourceAttr)).on("load",function(){-1==p.indexOf(st(this).attr("src"))&&p.push(st(this).attr("src")),j.eq(J).trigger(st.Event("prevImageLoaded.simplelightbox"))})},it=function(e){j.eq(J).trigger(st.Event("change.simplelightbox")).trigger(st.Event((1===e?"next":"prev")+".simplelightbox"));var t=J+e;if(!(m||(t<0||t>=j.length)&&!1===P.loop)){J=t<0?j.length-1:t>j.length-1?0:t,st(".sl-wrapper .sl-counter .sl-current").text(J+1);var a={opacity:0};P.animationSlide&&(K?tt(P.animationSpeed/1e3,-100*e-z+"px"):a.left=parseInt(st(".sl-image").css("left"))+-100*e+"px"),st(".sl-image").animate(a,P.animationSpeed,function(){setTimeout(function(){var t=j.eq(J);L.attr("src",t.attr(P.sourceAttr)),-1==p.indexOf(t.attr(P.sourceAttr))&&g.show(),st(".sl-caption").remove(),_(e),P.preloading&&y()},100)})}},ot=function(){if(!m){var t=j.eq(J),e=!1;t.trigger(st.Event("close.simplelightbox")),P.history&&(a?history.pushState("",rt.title,n.pathname+n.search):n.hash="",clearTimeout(h)),st(".sl-image img, .sl-overlay, .sl-close, .sl-navigation, .sl-image .sl-caption, .sl-counter").fadeOut("fast",function(){P.disableScroll&&C("show"),P.htmlClass&&""!=P.htmlClass&&st("html").removeClass(P.htmlClass),st(".sl-wrapper, .sl-overlay").remove(),G.off("click","button"),st(rt).off("click."+U,".sl-close"),st(lt).off("resize."+U),st(lt).off("hashchange."+U),e||t.trigger(st.Event("closed.simplelightbox")),e=!0}),L=st(),m=N=!1}},C=function(t){var e=0;if("hide"==t){var a=lt.innerWidth;if(!a){var n=rt.documentElement.getBoundingClientRect();a=n.right-Math.abs(n.left)}if(rt.body.clientWidth<a){var i=rt.createElement("div"),o=parseInt(st("body").css("padding-right"),10);i.className="sl-scrollbar-measure",st("body").append(i),e=i.offsetWidth-i.clientWidth,st(rt.body)[0].removeChild(i),st("body").data("padding",o),0<e&&st("body").addClass("hidden-scroll").css({"padding-right":o+e})}}else st("body").removeClass("hidden-scroll").css({"padding-right":st("body").data("padding")});return e};return P.close&&o.appendTo(r),P.showCounter&&1<j.length&&(s.appendTo(r),s.find(".sl-total").text(j.length)),P.nav&&G.appendTo(r),P.spinner&&g.appendTo(r),j.on("click."+U,function(t){if(function(t){if(!P.fileExt)return!0;var e=st(t).attr(P.sourceAttr).match(/\.([0-9a-z]+)(?=[?#])|(\.)(?:[\w]+)$/gim);return e&&"a"==st(t).prop("tagName").toLowerCase()&&new RegExp(".("+P.fileExt+")$","i").test(e)}(this)){if(t.preventDefault(),m)return!1;var e=st(this);v=j.index(e),c(e)}}),st(rt).on("click."+U+" touchstart."+U,function(t){N&&P.docClose&&0===st(t.target).closest(".sl-image").length&&0===st(t.target).closest(".sl-navigation").length&&ot()}),P.disableRightClick&&st(rt).on("contextmenu",".sl-image img",function(t){return!1}),P.enableKeyboard&&st(rt).on("keyup."+U,Q(function(t){z=0;var e=t.keyCode;m&&27==e&&(L.attr("src",""),m=!1,ot()),N&&(t.preventDefault(),27==e&&ot(),37!=e&&39!=t.keyCode||it(39==t.keyCode?1:-1))},P.throttleInterval)),this.open=function(t){t=t||st(this[0]),v=j.index(t),c(t)},this.next=function(){it(1)},this.prev=function(){it(-1)},this.close=function(){ot()},this.destroy=function(){st(rt).off("click."+U).off("keyup."+U),ot(),st(".sl-overlay, .sl-wrapper").remove(),this.off("click")},this.refresh=function(){this.destroy(),st(this).simpleLightbox(P)},this}}(jQuery,window,document); | ||
!function(st,lt,rt,t){"use strict";st.fn.simpleLightbox=function(N){N=st.extend({sourceAttr:"href",overlay:!0,spinner:!0,nav:!0,navText:["‹","›"],captions:!0,captionDelay:0,captionSelector:"img",captionType:"attr",captionsData:"title",captionPosition:"bottom",captionClass:"",close:!0,closeText:"×",swipeClose:!0,showCounter:!0,fileExt:"png|jpg|jpeg|gif|webp",animationSlide:!0,animationSpeed:250,preloading:!0,enableKeyboard:!0,loop:!0,rel:!1,docClose:!0,swipeTolerance:50,className:"simple-lightbox",widthRatio:.8,heightRatio:.9,scaleImageToRatio:!1,disableRightClick:!1,disableScroll:!0,alertError:!0,alertErrorMessage:"Image not found, next image will be loaded",additionalHtml:!1,history:!0,throttleInterval:0,doubleTapZoom:2,maxZoom:10,htmlClass:"has-lightbox"},N);var h,t,P="ontouchstart"in lt,Z=(lt.navigator.pointerEnabled||lt.navigator.msPointerEnabled,0),z=0,H=st(),i=function(){var t=rt.body||rt.documentElement;return""===(t=t.style).WebkitTransition?"-webkit-":""===t.MozTransition?"-moz-":""===t.OTransition?"-o-":""===t.transition&&""},L=!1,p=[],j=N.rel&&!1!==N.rel?(t=N.rel,st(this).filter(function(){return st(this).attr("rel")===t})):this,a=j.get()[0].tagName,d=(i=i(),0),K=!1!==i,n="pushState"in history,u=!1,o=lt.location,U=function(){return o.hash.substring(1)},$=U(),f=function(){U();var t="pid="+(J+1),e=o.href.split("#")[0]+"#"+t;n?history[u?"replaceState":"pushState"]("",rt.title,e):u?o.replace(e):o.hash=t,u=!0},B=function(e,a){var n;return function(){var t=arguments;n||(e.apply(this,t),n=!0,setTimeout(function(){return n=!1},a))}},Q="simplelb",e=st("<div>").addClass("sl-overlay"),s=st("<button>").addClass("sl-close").html(N.closeText),g=st("<div>").addClass("sl-spinner").html("<div></div>"),G=st("<div>").addClass("sl-navigation").html('<button class="sl-prev">'+N.navText[0]+'</button><button class="sl-next">'+N.navText[1]+"</button>"),l=st("<div>").addClass("sl-counter").html('<span class="sl-current"></span>/<span class="sl-total"></span>'),m=!1,J=0,v=0,r=st("<div>").addClass("sl-caption "+N.captionClass+" pos-"+N.captionPosition),V=st("<div>").addClass("sl-image"),c=st("<div>").addClass("sl-wrapper").addClass(N.className),x=function(t){t.trigger(st.Event("show.simplelightbox")),N.disableScroll&&(d=w("hide")),N.htmlClass&&""!=N.htmlClass&&st("html").addClass(N.htmlClass),c.appendTo("body"),V.appendTo(c),N.overlay&&e.appendTo(st("body")),m=!0,J=j.index(t),H=st("<img/>").hide().attr("src",t.attr(N.sourceAttr)).attr("data-scale",1).attr("data-translate-x",0).attr("data-translate-y",0),-1==p.indexOf(t.attr(N.sourceAttr))&&p.push(t.attr(N.sourceAttr)),V.html("").attr("style",""),H.appendTo(V),y(),e.fadeIn("fast"),st(".sl-close").fadeIn("fast"),g.show(),G.fadeIn("fast"),st(".sl-wrapper .sl-counter .sl-current").text(J+1),l.fadeIn("fast"),_(),N.preloading&&C(),setTimeout(function(){t.trigger(st.Event("shown.simplelightbox"))},N.animationSpeed)},_=function(s){if(H.length){var l=new Image,r=lt.innerWidth*N.widthRatio,c=lt.innerHeight*N.heightRatio;l.src=H.attr("src"),H.data("scale",1),H.data("translate-x",0),H.data("translate-y",0),et(0,0,1),st(l).on("error",function(t){j.eq(J).trigger(st.Event("error.simplelightbox")),L=!(m=!1),g.hide();var e=1==s||-1==s;v===J&&e?ot():(N.alertError&&alert(N.alertErrorMessage),it(e?s:1))}),l.onload=function(){void 0!==s&&j.eq(J).trigger(st.Event("changed.simplelightbox")).trigger(st.Event((1===s?"nextDone":"prevDone")+".simplelightbox")),N.history&&(u?h=setTimeout(f,800):f()),-1==p.indexOf(H.attr("src"))&&p.push(H.attr("src"));var t=l.width,e=l.height;if(N.scaleImageToRatio||r<t||c<e){var a=r/c<t/e?t/r:e/c;t/=a,e/=a}st(".sl-image").css({top:(lt.innerHeight-e)/2+"px",left:(lt.innerWidth-t-d)/2+"px",width:t+"px",height:e+"px"}),g.hide(),H.fadeIn("fast"),L=!0;var n,i="self"==N.captionSelector?j.eq(J):j.eq(J).find(N.captionSelector);if(n="data"==N.captionType?i.data(N.captionsData):"text"==N.captionType?i.html():i.prop(N.captionsData),N.loop||(0===J&&st(".sl-prev").hide(),J>=j.length-1&&st(".sl-next").hide(),0<J&&st(".sl-prev").show(),J<j.length-1&&st(".sl-next").show()),1==j.length&&st(".sl-prev, .sl-next").hide(),1==s||-1==s){var o={opacity:1};N.animationSlide&&(K?(tt(0,100*s+"px"),setTimeout(function(){tt(N.animationSpeed/1e3,"0px")},50)):o.left=parseInt(st(".sl-image").css("left"))+100*s+"px"),st(".sl-image").animate(o,N.animationSpeed,function(){m=!1,b(n,t)})}else m=!1,b(n,t);N.additionalHtml&&0===st(".sl-additional-html").length&&st("<div>").html(N.additionalHtml).addClass("sl-additional-html").appendTo(st(".sl-image"))}}},b=function(t,e){""!==t&&void 0!==t&&N.captions&&r.html(t).css({width:e+"px"}).hide().appendTo(st(".sl-image")).delay(N.captionDelay).fadeIn("fast")},tt=function(t,e){var a={};a[i+"transform"]="translateX("+e+")",a[i+"transition"]=i+"transform "+t+"s linear",st(".sl-image").css(a)},et=function(t,e,a){var n={};n[i+"transform"]="translate("+t+","+e+") scale("+a+")",H.css(n)},at=function(t,e,a){return t<e?e:a<t?a:t},nt=function(t,e,a){H.data("scale",t),H.data("translate-x",e),H.data("translate-y",a)},y=function(){st(lt).on("resize."+Q,_),st(rt).on("click."+Q+" touchstart."+Q,".sl-close",function(t){t.preventDefault(),L&&ot()}),N.history&&setTimeout(function(){st(lt).on("hashchange."+Q,function(){L&&U()===$&&ot()})},40),G.on("click."+Q,"button",B(function(t){t.preventDefault(),Z=0,it(st(this).hasClass("sl-next")?1:-1)},N.throttleInterval));var e,a,n,i,o,s,l,r,c,h,p,d,u,f,g,m,v,x,b,y,C,w,T,E,S,M,I,k=0,q=0,X=0,D=0,Y=!1,A=!1,O=0,R=!1,W=at(1,1,N.maxZoom),F=!1;V.on("touchstart."+Q+" mousedown."+Q,function(t){if("A"===t.target.tagName&&"touchstart"==t.type)return!0;if("mousedown"==(t=t.originalEvent).type)c=t.clientX,h=t.clientY,e=V.height(),a=V.width(),o=H.height(),s=H.width(),n=V.position().left,i=V.position().top,l=parseFloat(H.data("translate-x")),r=parseFloat(H.data("translate-y")),R=!0;else{if(I=t.touches.length,c=t.touches[0].clientX,h=t.touches[0].clientY,e=V.height(),a=V.width(),o=H.height(),s=H.width(),n=V.position().left,i=V.position().top,1===I){if(F)return H.addClass("sl-transition"),Y=Y?(nt(0,0,W=1),et("0px","0px",W),!1):(W=N.doubleTapZoom,nt(0,0,W),et("0px","0px",W),st(".sl-caption").fadeOut(200),!0),setTimeout(function(){H.removeClass("sl-transition")},200),!1;F=!0,setTimeout(function(){F=!1},300),l=parseFloat(H.data("translate-x")),r=parseFloat(H.data("translate-y"))}else 2===I&&(p=t.touches[1].clientX,d=t.touches[1].clientY,l=parseFloat(H.data("translate-x")),r=parseFloat(H.data("translate-y")),C=(c+p)/2,w=(h+d)/2,u=Math.sqrt((c-p)*(c-p)+(h-d)*(h-d)));R=!0}return!!A||(K&&(O=parseInt(V.css("left"))),A=!0,z=Z=0,k=t.pageX||t.touches[0].pageX,X=t.pageY||t.touches[0].pageY,!1)}).on("touchmove."+Q+" mousemove."+Q+" MSPointerMove",function(t){if(!A)return!0;if(t.preventDefault(),"touchmove"==(t=t.originalEvent).type){if(!1===R)return!1;f=t.touches[0].clientX,g=t.touches[0].clientY,I=t.touches.length,0,1<I?(m=t.touches[1].clientX,v=t.touches[1].clientY,M=Math.sqrt((f-m)*(f-m)+(g-v)*(g-v)),null===u&&(u=M),1<=Math.abs(u-M)&&(y=at(M/u*W,1,N.maxZoom),T=(s*y-a)/2,E=(o*y-e)/2,S=y-W,x=s*y<=a?0:at(l-(C-n-a/2-l)/(y-S)*S,-1*T,T),b=o*y<=e?0:at(r-(w-i-e/2-r)/(y-S)*S,-1*E,E),et(x+"px",b+"px",y),1<y&&(Y=!0,st(".sl-caption").fadeOut(200)),u=M,W=y,l=x,r=b)):(T=(s*(y=W)-a)/2,E=(o*y-e)/2,x=s*y<=a?0:at(f-(c-l),-1*T,T),b=o*y<=e?0:at(g-(h-r),-1*E,E),Math.abs(x)===Math.abs(T)&&(l=x,c=f),Math.abs(b)===Math.abs(E)&&(r=b,h=g),nt(W,x,b),et(x+"px",b+"px",y))}if("mousemove"==t.type&&A){if("touchmove"==t.type)return!0;if(!1===R)return!1;f=t.clientX,g=t.clientY,T=(s*(y=W)-a)/2,E=(o*y-e)/2,x=s*y<=a?0:at(f-(c-l),-1*T,T),b=o*y<=e?0:at(g-(h-r),-1*E,E),Math.abs(x)===Math.abs(T)&&(l=x,c=f),Math.abs(b)===Math.abs(E)&&(r=b,h=g),nt(W,x,b),et(x+"px",b+"px",y)}Y||(q=t.pageX||t.touches[0].pageX,D=t.pageY||t.touches[0].pageY,Z=k-q,z=X-D,N.animationSlide&&(K?tt(0,-Z+"px"):V.css("left",O-Z+"px")))}).on("touchend."+Q+" mouseup."+Q+" touchcancel."+Q+" mouseleave."+Q+" pointerup pointercancel MSPointerUp MSPointerCancel",function(t){if(t=t.originalEvent,P&&"touchend"==t.type&&(0===(I=t.touches.length)?(nt(W,x,b),1==W&&(Y=!1,st(".sl-caption").fadeIn(200)),u=null,R=!1):1===I?(c=t.touches[0].clientX,h=t.touches[0].clientY):1<I&&(u=null)),A){var e=!(A=!1);N.loop||(0===J&&Z<0&&(e=!1),J>=j.length-1&&0<Z&&(e=!1)),Math.abs(Z)>N.swipeTolerance&&e?it(0<Z?1:-1):N.animationSlide&&(K?tt(N.animationSpeed/1e3,"0px"):V.animate({left:O+"px"},N.animationSpeed/2)),N.swipeClose&&50<Math.abs(z)&&Math.abs(Z)<N.swipeTolerance&&ot()}}).on("dblclick",function(t){return c=t.clientX,h=t.clientY,e=V.height(),a=V.width(),o=H.height(),s=H.width(),n=V.position().left,i=V.position().top,H.addClass("sl-transition"),Y=Y?(nt(0,0,W=1),et("0px","0px",W),!1):(W=N.doubleTapZoom,nt(0,0,W),et("0px","0px",W),st(".sl-caption").fadeOut(200),!0),setTimeout(function(){H.removeClass("sl-transition")},200),!(R=!0)})},C=function(){var t=J+1<0?j.length-1:J+1>=j.length-1?0:J+1,e=J-1<0?j.length-1:J-1>=j.length-1?0:J-1;st("<img />").attr("src",j.eq(t).attr(N.sourceAttr)).on("load",function(){-1==p.indexOf(st(this).attr("src"))&&p.push(st(this).attr("src")),j.eq(J).trigger(st.Event("nextImageLoaded.simplelightbox"))}),st("<img />").attr("src",j.eq(e).attr(N.sourceAttr)).on("load",function(){-1==p.indexOf(st(this).attr("src"))&&p.push(st(this).attr("src")),j.eq(J).trigger(st.Event("prevImageLoaded.simplelightbox"))})},it=function(e){j.eq(J).trigger(st.Event("change.simplelightbox")).trigger(st.Event((1===e?"next":"prev")+".simplelightbox"));var t=J+e;if(!(m||(t<0||t>=j.length)&&!1===N.loop)){J=t<0?j.length-1:t>j.length-1?0:t,st(".sl-wrapper .sl-counter .sl-current").text(J+1);var a={opacity:0};N.animationSlide&&(K?tt(N.animationSpeed/1e3,-100*e-Z+"px"):a.left=parseInt(st(".sl-image").css("left"))+-100*e+"px"),st(".sl-image").animate(a,N.animationSpeed,function(){setTimeout(function(){var t=j.eq(J);H.attr("src",t.attr(N.sourceAttr)),-1==p.indexOf(t.attr(N.sourceAttr))&&g.show(),st(".sl-caption").remove(),_(e),N.preloading&&C()},100)})}},ot=function(){if(!m){var t=j.eq(J),e=!1;t.trigger(st.Event("close.simplelightbox")),N.history&&(n?history.pushState("",rt.title,o.pathname+o.search):o.hash="",clearTimeout(h)),st(".sl-image img, .sl-overlay, .sl-close, .sl-navigation, .sl-image .sl-caption, .sl-counter").fadeOut("fast",function(){N.disableScroll&&w("show"),N.htmlClass&&""!=N.htmlClass&&st("html").removeClass(N.htmlClass),st(".sl-wrapper, .sl-overlay").remove(),G.off("click","button"),st(rt).off("click."+Q,".sl-close"),st(lt).off("resize."+Q),st(lt).off("hashchange."+Q),e||t.trigger(st.Event("closed.simplelightbox")),e=!0}),H=st(),m=L=!1}},w=function(t){var e=0;if("hide"==t){var a=lt.innerWidth;if(!a){var n=rt.documentElement.getBoundingClientRect();a=n.right-Math.abs(n.left)}if(rt.body.clientWidth<a){var i=rt.createElement("div"),o=parseInt(st("body").css("padding-right"),10);i.className="sl-scrollbar-measure",st("body").append(i),e=i.offsetWidth-i.clientWidth,st(rt.body)[0].removeChild(i),st("body").data("padding",o),0<e&&st("body").addClass("hidden-scroll").css({"padding-right":o+e})}}else st("body").removeClass("hidden-scroll").css({"padding-right":st("body").data("padding")});return e};return N.close&&s.appendTo(c),N.showCounter&&1<j.length&&(l.appendTo(c),l.find(".sl-total").text(j.length)),N.nav&&G.appendTo(c),N.spinner&&g.appendTo(c),j.on("click."+Q,function(t){if(function(t){if(!N.fileExt)return!0;var e=st(t).attr(N.sourceAttr).match(/\.([0-9a-z]+)(?=[?#])|(\.)(?:[\w]+)$/gim);return e&&st(t).prop("tagName").toUpperCase()==a&&new RegExp(".("+N.fileExt+")$","i").test(e)}(this)){if(t.preventDefault(),m)return!1;var e=st(this);v=j.index(e),x(e)}}),st(rt).on("click."+Q+" touchstart."+Q,function(t){L&&N.docClose&&0===st(t.target).closest(".sl-image").length&&0===st(t.target).closest(".sl-navigation").length&&ot()}),N.disableRightClick&&st(rt).on("contextmenu",".sl-image img",function(t){return!1}),N.enableKeyboard&&st(rt).on("keyup."+Q,B(function(t){Z=0;var e=t.keyCode;m&&27==e&&(H.attr("src",""),m=!1,ot()),L&&(t.preventDefault(),27==e&&ot(),37!=e&&39!=t.keyCode||it(39==t.keyCode?1:-1))},N.throttleInterval)),this.open=function(t){t=t||st(this[0]),v=j.index(t),x(t)},this.next=function(){it(1)},this.prev=function(){it(-1)},this.close=function(){ot()},this.destroy=function(){st(rt).off("click."+Q).off("keyup."+Q),ot(),st(".sl-overlay, .sl-wrapper").remove(),this.off("click")},this.refresh=function(){this.destroy(),st(this).simpleLightbox(N)},this}}(jQuery,window,document); |
{ | ||
"name": "simplelightbox", | ||
"version": "1.17.0", | ||
"version": "1.17.1", | ||
"description": "Touch-friendly image lightbox for mobile and desktop with jQuery", | ||
@@ -5,0 +5,0 @@ "main": "dist/simple-lightbox.js", |
@@ -169,2 +169,3 @@ # simplelightbox | ||
### Changelog | ||
**1.17.1 - Added webp in fileExt list #135, removed hardcoded a-tag in isValidLink function #134** | ||
**1.17.0 - Merged pull request #132. Added double click to zoom for desktop browsers - Thanks to coderkan** | ||
@@ -171,0 +172,0 @@ **1.16.3 - Merged pull request #126,#127 - Thanks to jieter** |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7352808
1178
232