author | Madhusudan.C.S <madhusudancs@gmail.com> |
Fri, 07 Aug 2009 01:03:56 +0530 | |
changeset 12 | aac4944aca52 |
parent 8 | 294ff7ac9cb6 |
permissions | -rw-r--r-- |
8
294ff7ac9cb6
Added new set of files.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
1 |
// ColorBox v1.2.7 - a full featured, light-weight, customizable lightbox based on jQuery 1.3 |
294ff7ac9cb6
Added new set of files.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
2 |
|
294ff7ac9cb6
Added new set of files.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
3 |
(function(B){var G,V,W,d,z,k,b,F,c,Q,D,e,s,j,m,P,l,H,t;var X,i,g,a,p,A,T,w,I,q="colorbox",o="hover";var y,f,R,L,K,J,r,M;var x="cbox_open",O="cbox_load",u="cbox_complete",h="cbox_close",n="cbox_closed";var C={transition:"elastic",speed:350,width:false,height:false,initialWidth:"400",initialHeight:"400",maxWidth:false,maxHeight:false,resize:true,inline:false,html:false,iframe:false,photo:false,href:false,title:false,rel:false,opacity:0.9,preloading:true,current:"image {current} of {total}",previous:"previous",next:"next",close:"close",open:false,overlayClose:true,slideshow:false,slideshowAuto:true,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow"};B(function(){R()});function N(Y){if(Y.keyCode==37){Y.preventDefault();H.click()}else{if(Y.keyCode==39){Y.preventDefault();l.click()}}}function E(Y,Z){Z=Z=="x"?document.documentElement.clientWidth:document.documentElement.clientHeight;return(typeof Y=="string")?(Y.match(/%/)?(Z/100)*parseInt(Y,10):parseInt(Y,10)):Y}function v(Y){return T.photo?true:Y.match(/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(.*))?$/i)}function U(){for(var Y in T){if(typeof(T[Y])=="function"){T[Y]=T[Y].call(p)}}}B.fn.colorbox=function(Z,Y){if(this.length){this.each(function(){var aa=B(this).data(q)?B.extend({},B(this).data(q),Z):B.extend({},C,Z);B(this).data(q,aa).addClass("cboxelement")})}else{B(this).data(q,B.extend({},C,Z))}B(this).unbind("click.colorbox").bind("click.colorbox",function(ab){p=this;T=B(p).data(q);U();B().bind("keydown.cbox_close",function(ac){if(ac.keyCode==27){ac.preventDefault();t.click()}});if(T.overlayClose===true){G.css({cursor:"pointer"}).one("click",M)}p.blur();I=Y||false;var aa=T.rel||p.rel;if(aa&&aa!="nofollow"){c=B(".cboxelement").filter(function(){var ac=B(this).data(q).rel||this.rel;return(ac==aa)});A=c.index(p);if(A<0){c=c.add(p);A=c.length-1}}else{c=B(p);A=0}if(!w){B.event.trigger(x);t.html(T.close);G.css({opacity:T.opacity}).show();w=true;K(E(T.initialWidth,"x"),E(T.initialHeight,"y"),0);if(B.browser.msie&&B.browser.version<7){Q.bind("resize.cboxie6 scroll.cboxie6",function(){G.css({width:Q.width(),height:Q.height(),top:Q.scrollTop(),left:Q.scrollLeft()})})}}r();L();ab.preventDefault()});if(Z&&Z.open){B(this).triggerHandler("click.colorbox")}return this};R=function(){function Y(Z){return B('<div id="cbox'+Z+'"/>')}Q=B(window);V=B('<div id="colorbox"/>');G=Y("Overlay").hide();W=Y("Wrapper");d=Y("Content").append(D=Y("LoadedContent").css({width:0,height:0}),e=Y("LoadingOverlay"),s=Y("LoadingGraphic"),j=Y("Title"),m=Y("Current"),P=Y("Slideshow"),l=Y("Next"),H=Y("Previous"),t=Y("Close"));W.append(B("<div/>").append(Y("TopLeft"),z=Y("TopCenter"),Y("TopRight")),B("<div/>").append(k=Y("MiddleLeft"),d,b=Y("MiddleRight")),B("<div/>").append(Y("BottomLeft"),F=Y("BottomCenter"),Y("BottomRight"))).children().children().css({"float":"left"});B("body").prepend(G,V.append(W));if(B.browser.msie&&B.browser.version<7){G.css("position","absolute")}d.children().addClass(o).mouseover(function(){B(this).addClass(o)}).mouseout(function(){B(this).removeClass(o)}).hide();X=z.height()+F.height()+d.outerHeight(true)-d.height();i=k.width()+b.width()+d.outerWidth(true)-d.width();g=D.outerHeight(true);a=D.outerWidth(true);V.css({"padding-bottom":X,"padding-right":i}).hide();l.click(f);H.click(y);t.click(M);d.children().removeClass(o)};K=function(ab,aa,Z,ac){var ad=document.documentElement.clientHeight;var af=ad/2-aa/2;var ae=document.documentElement.clientWidth/2-ab/2;if(aa>ad){af-=(aa-ad)}if(af<0){af=0}if(ae<0){ae=0}af+=Q.scrollTop();ae+=Q.scrollLeft();ab=ab-i;aa=aa-X;W[0].style.width=W[0].style.height="9999px";function ag(ah){z[0].style.width=F[0].style.width=d[0].style.width=ah.style.width;s[0].style.height=e[0].style.height=d[0].style.height=k[0].style.height=b[0].style.height=ah.style.height}var Y=(V.width()===ab&&V.height()===aa)?0:Z;V.dequeue().animate({height:aa,width:ab,top:af,left:ae},{duration:Y,complete:function(){ag(this);W[0].style.width=(ab+i)+"px";W[0].style.height=(aa+X)+"px";if(ac){ac()}},step:function(){ag(this)}})};J=function(ad){if(!w){return}Q.unbind("resize.cbox_resize");var ab=T.transition=="none"?0:T.speed;D.remove();D=B(ad);var Z;var aj;function ah(){if(T.width){Z=maxWidth}else{Z=maxWidth&&maxWidth<D.width()?maxWidth:D.width()}return Z}function ag(){if(T.height){aj=maxHeight}else{aj=maxHeight&&maxHeight<D.height()?maxHeight:D.height()}return aj}D.hide().appendTo("body").attr({id:"cboxLoadedContent"}).css({width:ah()}).css({height:ag()}).prependTo(d);if(B.browser.msie&&B.browser.version<7){B("select").not(B("#colorbox select")).filter(function(){return B(this).css("visibility")!="hidden"}).css({visibility:"hidden"}).one(h,function(){B(this).css({visibility:"inherit"})})}var Y=B("#cboxPhoto")[0];if(Y&&T.height){var ae=(aj-parseInt(Y.style.height,10))/2;Y.style.marginTop=(ae>0?ae:0)+"px"}function ai(am){var al=Z+a+i;var an=aj+g+X;K(al,an,am,function(){if(!w){return}if(B.browser.msie){if(Y){D.fadeIn(100)}V.css("filter","")}d.children().show();B("#cboxIframeTemp").after("<iframe id='cboxIframe' name='iframe_"+new Date().getTime()+"' frameborder=0 src='"+(T.href||p.href)+"' />").remove();e.hide();s.hide();P.hide();if(c.length>1){m.html(T.current.replace(/\{current\}/,A+1).replace(/\{total\}/,c.length));l.html(T.next);H.html(T.previous);B().unbind("keydown",N).one("keydown",N);if(T.slideshow){P.show()}}else{m.hide();l.hide();H.hide()}j.html(T.title||p.title);B.event.trigger(u);if(I){I.call(p)}if(T.transition==="fade"){V.fadeTo(ab,1,function(){if(B.browser.msie){d.css("filter","")}})}Q.bind("resize.cbox_resize",function(){K(al,an,0)})})}if(T.transition=="fade"){V.fadeTo(ab,0,function(){ai(0)})}else{ai(ab)}if(T.preloading&&c.length>1){var ac=A>0?c[A-1]:c[c.length-1];var af=A<c.length-1?c[A+1]:c[0];var ak=B(af).data(q).href||af.href;var aa=B(ac).data(q).href||ac.href;if(v(ak)){B("<img />").attr("src",ak)}if(v(aa)){B("<img />").attr("src",aa)}}};L=function(){p=c[A];T=B(p).data(q);U();B.event.trigger(O);e.show();s.show();t.show();var Y=T.height?E(T.height,"y")-g-X:false;var ab=T.width?E(T.width,"x")-a-i:false;if(T.maxHeight){maxHeight=T.maxHeight?E(T.maxHeight,"y")-g-X:false;Y=Y&&Y<maxHeight?Y:maxHeight}if(T.maxWidth){maxWidth=T.maxWidth?E(T.maxWidth,"x")-a-i:false;ab=ab&&ab<maxWidth?ab:maxWidth}maxHeight=Y;maxWidth=ab;var Z=T.href||p.href;if(T.inline){B('<div id="cboxInlineTemp" />').hide().insertBefore(B(Z)[0]).bind(O+" "+h,function(){D.children().insertBefore(this);B(this).remove()});J(B(Z).wrapAll("<div/>").parent())}else{if(T.iframe){J(B("<div><div id='cboxIframeTemp' /></div>"))}else{if(T.html){J(B("<div/>").html(T.html))}else{if(v(Z)){var aa=new Image();aa.onload=function(){aa.onload=null;if((maxHeight||maxWidth)&&T.resize){var ae=this.width;var ac=this.height;var ag=0;var af=this;var ad=function(){ac+=ac*ag;ae+=ae*ag;af.height=ac;af.width=ae};if(maxWidth&&ae>maxWidth){ag=(maxWidth-ae)/ae;ad()}if(maxHeight&&ac>maxHeight){ag=(maxHeight-ac)/ac;ad()}}J(B("<div />").css({width:this.width,height:this.height}).append(B(this).css({width:this.width,height:this.height,display:"block",margin:"auto",border:0}).attr("id","cboxPhoto")));if(c.length>1){B(this).css({cursor:"pointer"}).click(f)}if(B.browser.msie&&B.browser.version==7){this.style.msInterpolationMode="bicubic"}};aa.src=Z}else{B("<div />").load(Z,function(ac,ad){if(ad=="success"){J(B(this))}else{J(B("<p>Request unsuccessful.</p>"))}})}}}}};f=function(){A=A<c.length-1?A+1:0;L()};y=function(){A=A>0?A-1:c.length-1;L()};r=function(){var Z,Y,aa="cboxSlideshow_";P.bind(h,function(){clearTimeout(Y);P.unbind()});function ab(){P.text(T.slideshowStop).bind(u,function(){Y=setTimeout(f,T.slideshowSpeed)}).bind(O,function(){clearTimeout(Y)}).one("click",function(){Z();B(this).removeClass(o)});V.removeClass(aa+"off").addClass(aa+"on")}Z=function(){clearTimeout(Y);P.text(T.slideshowStart).unbind(u+" "+O).one("click",function(){ab();Y=setTimeout(f,T.slideshowSpeed);B(this).removeClass(o)});V.removeClass(aa+"on").addClass(aa+"off")};if(T.slideshow&&c.length>1){if(T.slideshowAuto){ab()}else{Z()}}};M=function(){B.event.trigger(h);w=false;B().unbind("keydown",N).unbind("keydown.cbox_close");Q.unbind("resize.cbox_resize resize.cboxie6 scroll.cboxie6");G.css({cursor:"auto"}).fadeOut("fast");d.children().hide();V.stop(true,false).removeClass().fadeOut("fast",function(){p.focus();D.remove();V.css({opacity:1});B.event.trigger(n)})};var S=B.fn.colorbox;S.init=R;S.next=f;S.prev=y;S.close=M;S.load=L;S.position=K;S.dimensions=J;S.element=function(){return p};S.settings=C})(jQuery); |