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