2 lines
No EOL
8.8 KiB
JavaScript
2 lines
No EOL
8.8 KiB
JavaScript
/* jquery.poptrox.js v2.4 | (c) n33 | n33.co | MIT licensed */
|
|
(function(e){var t="height",n="width",r="trigger",i="css",s="stopPropagation",o="position",u=!1,a="poptrox_close",f="fadeSpeed",l="length",c="text-align",h="popupNavPreviousSelector",p="poptrox_switch",d="stopSpinning",v="click",m="popupNavNextSelector",g="popupHeight",y="popupCaptionSelector",b=!0,w="popupCloserSelector",E="popupLoaderSelector",S=null,x="none",T="font-size",N="poptrox_previous",C="popupCaptionHeight",k="preventDefault",L="cursor",A="center",O="line-height",M="poptrox_reset",_="overflow",D="poptrox_next",P="popupTextColor",H="text-indent",B="fadeIn",j="pointer",F="object",I="poptrox_disableSelection",q="auto",R="color",U="absolute",z="load",W="#000000",X="px",V="usePopupNav",$="100%",J="relative",K="</div>",Q="0",G="popupWidth",Y='<div class="',Z="z-index",et="outline",tt="background",nt="startSpinning",rt="left",it="poptrox_open",st="40px",ot="popupLoaderText",ut="poptrox",at="popupCloserText",ft="update",lt="ignore",ct="usePopupEasyClose",ht="popupSelector",pt="soundcloud",dt="#FFFFFF",vt="display",mt="image",gt="hide",yt="useBodyOverflow",bt="overlayOpacity",wt="xfin",Et="type",St="youtube";e.fn[I]=function(){return e(this)[i]("user-select",x)[i]("-khtml-user-select",x)[i]("-moz-user-select",x)[i]("-o-user-select",x)[i]("-webkit-user-select",x)},e.fn[ut]=function(Mt){function tn(){var r,s,o,u,a,f;Ft=e(window)[n](),It=e(window)[t]()+Dt.windowHeightPad,r=Math.abs(Wt[n]()-Wt.outerWidth()),s=Math.abs(Wt[t]()-Wt.outerHeight()),o=Vt[n](),u=Vt[t](),a=Ft-Dt.windowMargin*2-r,f=It-Dt.windowMargin*2-s,Wt[i]("min-width",Dt[G])[i]("min-height",Dt[g]),Xt.children()[i]("max-width",a)[i]("max-height",f)}var _t,Dt,Pt,Ht,Bt,jt,Ft,It,qt,Rt,Ut,zt,Wt,Xt,Vt,$t,Jt,Kt,Qt,Gt,Yt,Zt,en;if(this[l]==0)return e(this);if(this[l]>1){for(_t=0;_t<this[l];_t++)e(this[_t])[ut](Mt);return e(this)}return Dt=e.extend({preload:u,baseZIndex:1e3,fadeSpeed:300,overlayColor:W,overlayOpacity:.6,overlayClass:"poptrox-overlay",windowMargin:50,windowHeightPad:0,selector:"a",parent:"body",popupSpeed:300,popupWidth:200,popupHeight:100,popupIsFixed:u,useBodyOverflow:u,usePopupEasyClose:b,usePopupLoader:b,usePopupCloser:b,usePopupCaption:u,usePopupNav:u,usePopupDefaultStyling:b,popupBackgroundColor:dt,popupTextColor:W,popupLoaderTextSize:"2em",popupCloserBackgroundColor:W,popupCloserTextColor:dt,popupCloserTextSize:"20px",popupPadding:10,popupCaptionHeight:60,popupCaptionTextSize:S,popupBlankCaptionText:"(untitled)",popupCloserText:"×",popupLoaderText:"••••",popupClass:"poptrox-popup",popupSelector:S,popupLoaderSelector:".loader",popupCloserSelector:".closer",popupCaptionSelector:".caption",popupNavPreviousSelector:".nav-previous",popupNavNextSelector:".nav-next",onPopupClose:S,onPopupOpen:S},Mt),Pt=e(this),Ht=e("body"),Bt=e(Y+Dt.overlayClass+'"></div>'),jt=e(window),qt=[],Rt=0,Ut=u,zt=new Array,Dt.usePopupLoader||(Dt[E]=S),Dt.usePopupCloser||(Dt[w]=S),Dt.usePopupCaption||(Dt[y]=S),Dt[V]||(Dt[h]=S,Dt[m]=S),Dt[ht]?Wt=e(Dt[ht]):Wt=e(Y+Dt.popupClass+'">'+(Dt[E]?'<div class="loader">'+Dt[ot]+K:"")+'<div class="pic"></div>'+(Dt[y]?'<div class="caption"></div>':"")+(Dt[w]?'<span class="closer">'+Dt[at]+"</span>":"")+(Dt[h]?'<div class="nav-previous"></div>':"")+(Dt[m]?'<div class="nav-next"></div>':"")+K),Xt=Wt.find(".pic"),Vt=e(),$t=Wt.find(Dt[E]),Jt=Wt.find(Dt[y]),Kt=Wt.find(Dt[w]),Qt=Wt.find(Dt[m]),Gt=Wt.find(Dt[h]),Yt=Qt.add(Gt),Dt.usePopupDefaultStyling&&(Wt[i](tt,Dt.popupBackgroundColor)[i](R,Dt[P])[i]("padding",Dt.popupPadding+X),Jt[l]>0&&(Wt[i]("padding-bottom",Dt[C]+X),Jt[i](o,U)[i](rt,Q)[i]("bottom",Q)[i](n,$)[i](c,A)[i](t,Dt[C]+X)[i](O,Dt[C]+X),Dt.popupCaptionTextSize&&Jt[i](T,popupCaptionTextSize)),Kt[l]>0&&Kt.html(Dt[at])[i](T,Dt.popupCloserTextSize)[i](tt,Dt.popupCloserBackgroundColor)[i](R,Dt.popupCloserTextColor)[i](vt,"block")[i](n,st)[i](t,st)[i](O,st)[i](c,A)[i](o,U)[i]("text-decoration",x)[i](et,Q)[i]("top",Q)[i]("right","-40px"),$t[l]>0&&$t.html("")[i](o,J)[i](T,Dt.popupLoaderTextSize).on(nt,function(){var n=e("<div>"+Dt[ot]+K);n[i](t,Math.floor(Dt[g]/2)+X)[i](_,"hidden")[i](O,Math.floor(Dt[g]/2)+X)[i](c,A)[i]("margin-top",Math.floor((Wt[t]()-n[t]()+(Jt[l]>0?Jt[t]():0))/2))[i](R,Dt[P]?Dt[P]:"").on(wt,function(){n.fadeTo(300,.5,function(){n[r]("xfout")})}).on("xfout",function(){n.fadeTo(300,.05,function(){n[r](wt)})})[r](wt),$t.append(n)}).on(d,function(){var e=$t.find("div");e.remove()}),Yt[l]==2&&(Yt[i](T,"75px")[i](c,A)[i](R,"#fff")[i]("text-shadow",x)[i](t,$)[i](o,U)[i]("top",Q)[i]("opacity","0.35")[i](L,j)[i]("box-shadow","inset 0px 0px 10px 0px rgba(0,0,0,0)")[I](),Dt[ct]?(Zt="100px",en="100px"):(Zt="75%",en="25%"),Qt[i]("right",Q)[i](n,Zt).html('<div style="position: absolute; height: 100px; width: 125px; top: 50%; right: 0; margin-top: -50px;">></div>'),Gt[i](rt,Q)[i](n,en).html('<div style="position: absolute; height: 100px; width: 125px; top: 50%; left: 0; margin-top: -50px;"><</div>'))),jt.on("resize orientationchange",function(){tn()}),Jt.on(ft,function(e,t){if(!t||t[l]==0)t=Dt.popupBlankCaptionText;Jt.html(t)}),Kt[i](L,j).on(v,function(e){return e[k](),e[s](),Wt[r](a),b}),Qt.on(v,function(){Wt[r](D)}),Gt.on(v,function(){Wt[r](N)}),Bt[i](o,"fixed")[i](rt,0)[i]("top",0)[i](Z,Dt.baseZIndex)[i](n,$)[i](t,$)[i](c,A)[i](L,j).appendTo(Dt.parent).prepend('<div style="display:inline-block;height:100%;vertical-align:middle;"></div>').append('<div style="position:absolute;left:0;top:0;width:100%;height:100%;background:'+Dt.overlayColor+";opacity:"+Dt[bt]+";filter:alpha(opacity="+Dt[bt]*100+');"></div>')[gt]().on("touchmove",function(){return u}).on(v,function(e){e[k](),e[s](),Wt[r](a)}),Dt[ct]&&Xt[i](L,j).on(v,function(e){e[k](),e[s](),Wt[r](a)}),Wt[i](vt,"inline-block")[i]("vertical-align","middle")[i](o,J)[i](Z,1).appendTo(Bt)[gt]().on(D,function(){var e=Rt+1;e>=qt[l]&&(e=0),Wt[r](p,[e])}).on(N,function(){var e=Rt-1;e<0&&(e=qt[l]-1),Wt[r](p,[e])}).on(M,function(){tn(),Wt.data(n,Dt[G]).data(t,Dt[g]),$t[gt]()[r](d),Jt[gt](),Kt[gt](),Yt[gt](),Xt[gt](),Vt.detach()}).on(it,function(e,t){if(Ut)return b;Ut=b,Dt[yt]&&Ht[i](_,"hidden"),Dt.onPopupOpen&&Dt.onPopupOpen(),Bt.fadeTo(Dt[f],1,function(){Wt[r](p,[t,b])})}).on(p,function(s,a,l){var c;if(!l&&Ut)return b;Ut=b,Wt[i](n,Wt.data(n))[i](t,Wt.data(t)),Jt[gt](),Vt.attr("src")&&Vt.attr("src",""),Vt.detach(),c=qt[a],Vt=c[F],Vt.off(z),Xt[i](H,"-9999px").show().append(Vt),c[Et]=="ajax"?e.get(c.src,function(e){Vt.html(e),Vt[r](z)}):Vt.attr("src",c.src),c[Et]!=mt&&Vt[i](o,J)[i](et,Q)[i](Z,Dt.baseZIndex+100)[n](c[n])[t](c[t]),$t[r](nt)[B](300),Wt.show(),Dt.popupIsFixed?(Wt[n](Dt[G])[t](Dt[g]),Vt[z](function(){Vt.off(z),$t[gt]()[r](d),Jt[r](ft,[c.captionText])[B](Dt[f]),Kt[B](Dt[f]),Xt[i](H,0)[gt]()[B](Dt[f],function(){Ut=u}),Rt=a,Yt[B](Dt[f])})):Vt[z](function(){var e,s,o;tn(),Vt.off(z),$t[gt]()[r](d),e=Vt[n](),s=Vt[t](),o=function(){Jt[r](ft,[c.captionText])[B](Dt[f]),Kt[B](Dt[f]),Xt[i](H,0)[gt]()[B](Dt[f],function(){Ut=u}),Rt=a,Yt[B](Dt[f]),Wt.data(n,e).data(t,s)[i](n,q)[i](t,q)},e==Wt.data(n)&&s==Wt.data(t)?o():Wt.animate({width:e,height:s},Dt.popupSpeed,"swing",o)}),c[Et]!=mt&&Vt[r](z)}).on(a,function(){if(Ut)return b;Ut=b,Wt[gt]()[r](M),Dt.onPopupClose&&Dt.onPopupClose(),Bt.fadeOut(Dt[f],function(){Dt[yt]&&Ht[i](_,q),Ut=u})})[r](M),jt.keydown(function(e){if(Wt.is(":visible"))switch(e.keyCode){case 37:case 32:if(Dt[V])return Wt[r](N),u;break;case 39:if(Dt[V])return Wt[r](D),u;break;case 27:return Wt[r](a),u}}),Pt.find(Dt.selector).each(function(o){var a,f,c,h=e(this),p=h.find("img"),d=h.data(ut),m={src:h.attr("href"),captionText:p.attr("title"),width:h.attr(n),height:h.attr(t),type:S,object:S};if(d){c=d.split(",");for(f in c)a=c[f].match(/([0-9]+)x([0-9]+)/),a&&a[l]==3?(m[n]=a[1],m[t]=a[2]):m[Et]=c[f]}if(!m[Et]){a=m.src.match(/http[s]?:\/\/([a-z0-9\.]+)\/.*/);if(!a||a[l]<3)a=[u];switch(a[1]){case"api.soundcloud.com":m[Et]=pt;break;case"youtu.be":m[Et]=St;break;case"vimeo.com":m[Et]="vimeo";break;default:m[Et]=mt}}a=m.src.match(/http([s]?):\/\/[a-z0-9\.]+\/(.*)/),a&&(m.prefix="http"+(a[1]=="s"?"s":""));switch(m[Et]){case lt:break;case"iframe":m[F]=e('<iframe src="" frameborder="0"></iframe>'),m[F].on(v,function(e){e[s]()})[i](L,q);break;case"ajax":m[F]=e('<div class="poptrox-ajax"></div>'),m[F].on(v,function(e){e[s]()})[i](L,q)[i](_,q);break;case pt:m[F]=e('<iframe scrolling="no" frameborder="no" src=""></iframe>'),m.src=m.prefix+"://w.soundcloud.com/player/?url="+escape(m.src),m[n]="600",m[t]="166";break;case St:m[F]=e('<iframe src="" frameborder="0" allowfullscreen="1"></iframe>'),m.src=m.prefix+"://www.youtube.com/embed/"+a[2];break;case"vimeo":m[F]=e('<iframe src="" frameborder="0" allowFullScreen="1"></iframe>'),m.src=m.prefix+"://player.vimeo.com/video/"+a[2];break;default:m[F]=e('<img src="" alt="" style="vertical-align:bottom" />'),Dt.preload&&(a=document.createElement("img"),a.src=m.src,zt.push(a))}m[Et]!=lt&&qt.push(m),p.attr("title",""),m[Et]!=lt&&h.attr("href","")[i](et,0).on(v,function(e){e[k](),e[s](),Wt[r](it,[o])})}),e(this)}})(jQuery); |