-
Notifications
You must be signed in to change notification settings - Fork 1
/
jquery.colorbox-min.js
executable file
·7 lines (7 loc) · 10.7 KB
/
jquery.colorbox-min.js
1
2
3
4
5
6
7
/*!
Colorbox v1.4.29 - 2013-09-10
jQuery lightbox and modal window plugin
(c) 2013 Jack Moore - http://www.jacklmoore.com/colorbox
license: http://www.opensource.org/licenses/mit-license.php
*/
(function(t,e,i){function o(i,o,n){var r=e.createElement(i);return o&&(r.id=Z+o),n&&(r.style.cssText=n),t(r)}function n(){return i.innerHeight?i.innerHeight:t(i).height()}function r(t){var e=k.length,i=(A+t)%e;return 0>i?e+i:i}function h(t,e){return Math.round((/%/.test(t)?("x"===e?E.width():n())/100:1)*parseInt(t,10))}function l(t,e){return t.photo||t.photoRegex.test(e)}function s(t,e){return t.retinaUrl&&i.devicePixelRatio>1?e.replace(t.photoRegex,t.retinaSuffix):e}function a(t){"contains"in g[0]&&!g[0].contains(t.target)&&(t.stopPropagation(),g.focus())}function d(){var e,i=t.data(z,Y);null==i?(B=t.extend({},X),console&&console.log&&console.log("Error: cboxElement missing settings object")):B=t.extend({},i);for(e in B)t.isFunction(B[e])&&"on"!==e.slice(0,2)&&(B[e]=B[e].call(z));B.rel=B.rel||z.rel||t(z).data("rel")||"nofollow",B.href=B.href||t(z).attr("href"),B.title=B.title||z.title,"string"==typeof B.href&&(B.href=t.trim(B.href))}function c(i,o){t(e).trigger(i),le.trigger(i),t.isFunction(o)&&o.call(z)}function u(i){q||(z=i,d(),k=t(z),A=0,"nofollow"!==B.rel&&(k=t("."+te).filter(function(){var e,i=t.data(this,Y);return i&&(e=t(this).data("rel")||i.rel||this.rel),e===B.rel}),A=k.index(z),-1===A&&(k=k.add(z),A=k.length-1)),w.css({opacity:parseFloat(B.opacity),cursor:B.overlayClose?"pointer":"auto",visibility:"visible"}).show(),J&&g.add(w).removeClass(J),B.className&&g.add(w).addClass(B.className),J=B.className,B.closeButton?K.html(B.close).appendTo(y):K.appendTo("<div/>"),U||(U=$=!0,g.css({visibility:"hidden",display:"block"}),H=o(se,"LoadedContent","width:0; height:0; overflow:hidden"),y.css({width:"",height:""}).append(H),O=x.height()+C.height()+y.outerHeight(!0)-y.height(),_=b.width()+T.width()+y.outerWidth(!0)-y.width(),D=H.outerHeight(!0),N=H.outerWidth(!0),B.w=h(B.initialWidth,"x"),B.h=h(B.initialHeight,"y"),H.css({width:"",height:B.h}),Q.position(),c(ee,B.onOpen),P.add(L).hide(),g.focus(),B.trapFocus&&e.addEventListener&&(e.addEventListener("focus",a,!0),le.one(re,function(){e.removeEventListener("focus",a,!0)})),B.returnFocus&&le.one(re,function(){t(z).focus()})),m())}function f(){!g&&e.body&&(V=!1,E=t(i),g=o(se).attr({id:Y,"class":t.support.opacity===!1?Z+"IE":"",role:"dialog",tabindex:"-1"}).hide(),w=o(se,"Overlay").hide(),F=t([o(se,"LoadingOverlay")[0],o(se,"LoadingGraphic")[0]]),v=o(se,"Wrapper"),y=o(se,"Content").append(L=o(se,"Title"),S=o(se,"Current"),I=t('<button type="button"/>').attr({id:Z+"Previous"}),R=t('<button type="button"/>').attr({id:Z+"Next"}),M=o("button","Slideshow"),F),K=t('<button type="button"/>').attr({id:Z+"Close"}),v.append(o(se).append(o(se,"TopLeft"),x=o(se,"TopCenter"),o(se,"TopRight")),o(se,!1,"clear:left").append(b=o(se,"MiddleLeft"),y,T=o(se,"MiddleRight")),o(se,!1,"clear:left").append(o(se,"BottomLeft"),C=o(se,"BottomCenter"),o(se,"BottomRight"))).find("div div").css({"float":"left"}),W=o(se,!1,"position:absolute; width:9999px; visibility:hidden; display:none"),P=R.add(I).add(S).add(M),t(e.body).append(w,g.append(v,W)))}function p(){function i(t){t.which>1||t.shiftKey||t.altKey||t.metaKey||t.ctrlKey||(t.preventDefault(),u(this))}return g?(V||(V=!0,R.click(function(){Q.next()}),I.click(function(){Q.prev()}),K.click(function(){Q.close()}),w.click(function(){B.overlayClose&&Q.close()}),t(e).bind("keydown."+Z,function(t){var e=t.keyCode;U&&B.escKey&&27===e&&(t.preventDefault(),Q.close()),U&&B.arrowKey&&k[1]&&!t.altKey&&(37===e?(t.preventDefault(),I.click()):39===e&&(t.preventDefault(),R.click()))}),t.isFunction(t.fn.on)?t(e).on("click."+Z,"."+te,i):t("."+te).live("click."+Z,i)),!0):!1}function m(){var n,r,a,u=Q.prep,f=++ae;$=!0,j=!1,z=k[A],d(),c(he),c(ie,B.onLoad),B.h=B.height?h(B.height,"y")-D-O:B.innerHeight&&h(B.innerHeight,"y"),B.w=B.width?h(B.width,"x")-N-_:B.innerWidth&&h(B.innerWidth,"x"),B.mw=B.w,B.mh=B.h,B.maxWidth&&(B.mw=h(B.maxWidth,"x")-N-_,B.mw=B.w&&B.w<B.mw?B.w:B.mw),B.maxHeight&&(B.mh=h(B.maxHeight,"y")-D-O,B.mh=B.h&&B.h<B.mh?B.h:B.mh),n=B.href,G=setTimeout(function(){F.show()},100),B.inline?(a=o(se).hide().insertBefore(t(n)[0]),le.one(he,function(){a.replaceWith(H.children())}),u(t(n))):B.iframe?u(" "):B.html?u(B.html):l(B,n)?(n=s(B,n),j=e.createElement("img"),t(j).addClass(Z+"Photo").bind("error",function(){B.title=!1,u(o(se,"Error").html(B.imgError))}).one("load",function(){var e;f===ae&&(j.alt=t(z).attr("alt")||t(z).attr("data-alt")||"",B.retinaImage&&i.devicePixelRatio>1&&(j.height=j.height/i.devicePixelRatio,j.width=j.width/i.devicePixelRatio),B.scalePhotos&&(r=function(){j.height-=j.height*e,j.width-=j.width*e},B.mw&&j.width>B.mw&&(e=(j.width-B.mw)/j.width,r()),B.mh&&j.height>B.mh&&(e=(j.height-B.mh)/j.height,r())),B.h&&(j.style.marginTop=Math.max(B.mh-j.height,0)/2+"px"),k[1]&&(B.loop||k[A+1])&&(j.style.cursor="pointer",j.onclick=function(){Q.next()}),j.style.width=j.width+"px",j.style.height=j.height+"px",setTimeout(function(){u(j)},1))}),setTimeout(function(){j.src=n},1)):n&&W.load(n,B.data,function(e,i){f===ae&&u("error"===i?o(se,"Error").html(B.xhrError):t(this).contents())})}var w,g,v,y,x,b,T,C,k,E,H,W,F,L,S,M,R,I,K,P,B,O,_,D,N,z,A,j,U,$,q,G,Q,J,V,X={transition:"elastic",speed:300,fadeOut:300,width:!1,initialWidth:"600",innerWidth:!1,maxWidth:!1,height:!1,initialHeight:"450",innerHeight:!1,maxHeight:!1,scalePhotos:!0,scrolling:!0,inline:!1,html:!1,iframe:!1,fastIframe:!0,photo:!1,href:!1,title:!1,rel:!1,opacity:.9,preloading:!0,className:!1,retinaImage:!1,retinaUrl:!1,retinaSuffix:"@2x.$1",current:"image {current} of {total}",previous:"previous",next:"next",close:"close",xhrError:"This content failed to load.",imgError:"This image failed to load.",open:!1,returnFocus:!0,trapFocus:!0,reposition:!0,loop:!0,slideshow:!1,slideshowAuto:!0,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",photoRegex:/\.(gif|png|jp(e|g|eg)|bmp|ico|webp)((#|\?).*)?$/i,onOpen:!1,onLoad:!1,onComplete:!1,onCleanup:!1,onClosed:!1,overlayClose:!0,escKey:!0,arrowKey:!0,top:!1,bottom:!1,left:!1,right:!1,fixed:!1,data:void 0,closeButton:!0},Y="colorbox",Z="cbox",te=Z+"Element",ee=Z+"_open",ie=Z+"_load",oe=Z+"_complete",ne=Z+"_cleanup",re=Z+"_closed",he=Z+"_purge",le=t("<a/>"),se="div",ae=0,de={},ce=function(){function t(){clearTimeout(h)}function e(){(B.loop||k[A+1])&&(t(),h=setTimeout(Q.next,B.slideshowSpeed))}function i(){M.html(B.slideshowStop).unbind(s).one(s,o),le.bind(oe,e).bind(ie,t),g.removeClass(l+"off").addClass(l+"on")}function o(){t(),le.unbind(oe,e).unbind(ie,t),M.html(B.slideshowStart).unbind(s).one(s,function(){Q.next(),i()}),g.removeClass(l+"on").addClass(l+"off")}function n(){r=!1,M.hide(),t(),le.unbind(oe,e).unbind(ie,t),g.removeClass(l+"off "+l+"on")}var r,h,l=Z+"Slideshow_",s="click."+Z;return function(){r?B.slideshow||(le.unbind(ne,n),n()):B.slideshow&&k[1]&&(r=!0,le.one(ne,n),B.slideshowAuto?i():o(),M.show())}}();t.colorbox||(t(f),Q=t.fn[Y]=t[Y]=function(e,i){var o=this;if(e=e||{},f(),p()){if(t.isFunction(o))o=t("<a/>"),e.open=!0;else if(!o[0])return o;i&&(e.onComplete=i),o.each(function(){t.data(this,Y,t.extend({},t.data(this,Y)||X,e))}).addClass(te),(t.isFunction(e.open)&&e.open.call(o)||e.open)&&u(o[0])}return o},Q.position=function(e,i){function o(){x[0].style.width=C[0].style.width=y[0].style.width=parseInt(g[0].style.width,10)-_+"px",y[0].style.height=b[0].style.height=T[0].style.height=parseInt(g[0].style.height,10)-O+"px"}var r,l,s,a=0,d=0,c=g.offset();if(E.unbind("resize."+Z),g.css({top:-9e4,left:-9e4}),l=E.scrollTop(),s=E.scrollLeft(),B.fixed?(c.top-=l,c.left-=s,g.css({position:"fixed"})):(a=l,d=s,g.css({position:"absolute"})),d+=B.right!==!1?Math.max(E.width()-B.w-N-_-h(B.right,"x"),0):B.left!==!1?h(B.left,"x"):Math.round(Math.max(E.width()-B.w-N-_,0)/2),a+=B.bottom!==!1?Math.max(n()-B.h-D-O-h(B.bottom,"y"),0):B.top!==!1?h(B.top,"y"):Math.round(Math.max(n()-B.h-D-O,0)/2),g.css({top:c.top,left:c.left,visibility:"visible"}),v[0].style.width=v[0].style.height="9999px",r={width:B.w+N+_,height:B.h+D+O,top:a,left:d},e){var u=0;t.each(r,function(t){return r[t]!==de[t]?(u=e,void 0):void 0}),e=u}de=r,e||g.css(r),g.dequeue().animate(r,{duration:e||0,complete:function(){o(),$=!1,v[0].style.width=B.w+N+_+"px",v[0].style.height=B.h+D+O+"px",B.reposition&&setTimeout(function(){E.bind("resize."+Z,Q.position)},1),i&&i()},step:o})},Q.resize=function(t){var e;U&&(t=t||{},t.width&&(B.w=h(t.width,"x")-N-_),t.innerWidth&&(B.w=h(t.innerWidth,"x")),H.css({width:B.w}),t.height&&(B.h=h(t.height,"y")-D-O),t.innerHeight&&(B.h=h(t.innerHeight,"y")),t.innerHeight||t.height||(e=H.scrollTop(),H.css({height:"auto"}),B.h=H.height()),H.css({height:B.h}),e&&H.scrollTop(e),Q.position("none"===B.transition?0:B.speed))},Q.prep=function(i){function n(){return B.w=B.w||H.width(),B.w=B.mw&&B.mw<B.w?B.mw:B.w,B.w}function h(){return B.h=B.h||H.height(),B.h=B.mh&&B.mh<B.h?B.mh:B.h,B.h}if(U){var a,d="none"===B.transition?0:B.speed;H.empty().remove(),H=o(se,"LoadedContent").append(i),H.hide().appendTo(W.show()).css({width:n(),overflow:B.scrolling?"auto":"hidden"}).css({height:h()}).prependTo(y),W.hide(),t(j).css({"float":"none"}),a=function(){function i(){t.support.opacity===!1&&g[0].style.removeAttribute("filter")}var n,h,a=k.length,u="frameBorder",f="allowTransparency";U&&(h=function(){clearTimeout(G),F.hide(),c(oe,B.onComplete)},L.html(B.title).add(H).show(),a>1?("string"==typeof B.current&&S.html(B.current.replace("{current}",A+1).replace("{total}",a)).show(),R[B.loop||a-1>A?"show":"hide"]().html(B.next),I[B.loop||A?"show":"hide"]().html(B.previous),ce(),B.preloading&&t.each([r(-1),r(1)],function(){var i,o,n=k[this],r=t.data(n,Y);r&&r.href?(i=r.href,t.isFunction(i)&&(i=i.call(n))):i=t(n).attr("href"),i&&l(r,i)&&(i=s(r,i),o=e.createElement("img"),o.src=i)})):P.hide(),B.iframe?(n=o("iframe")[0],u in n&&(n[u]=0),f in n&&(n[f]="true"),B.scrolling||(n.scrolling="no"),t(n).attr({src:B.href,name:(new Date).getTime(),"class":Z+"Iframe",allowFullScreen:!0,webkitAllowFullScreen:!0,mozallowfullscreen:!0}).one("load",h).appendTo(H),le.one(he,function(){n.src="//about:blank"}),B.fastIframe&&t(n).trigger("load")):h(),"fade"===B.transition?g.fadeTo(d,1,i):i())},"fade"===B.transition?g.fadeTo(d,0,function(){Q.position(0,a)}):Q.position(d,a)}},Q.next=function(){!$&&k[1]&&(B.loop||k[A+1])&&(A=r(1),u(k[A]))},Q.prev=function(){!$&&k[1]&&(B.loop||A)&&(A=r(-1),u(k[A]))},Q.close=function(){U&&!q&&(q=!0,U=!1,c(ne,B.onCleanup),E.unbind("."+Z),w.fadeTo(B.fadeOut||0,0),g.stop().fadeTo(B.fadeOut||0,0,function(){g.add(w).css({opacity:1,cursor:"auto"}).hide(),c(he),H.empty().remove(),setTimeout(function(){q=!1,c(re,B.onClosed)},1)}))},Q.remove=function(){g&&(g.stop(),t.colorbox.close(),g.stop().remove(),w.remove(),q=!1,g=null,t("."+te).removeData(Y).removeClass(te),t(e).unbind("click."+Z))},Q.element=function(){return t(z)},Q.settings=X)})(jQuery,document,window);