/* Slimbox v2.01 - The ultimate lightweight Lightbox clone for jQuery (c) 2007-2009 Christophe Beyls MIT-style license. */ (function(v){var D=v(window),t,g,E=-1,w,C,u,x,K,r,n=!window.XMLHttpRequest,e=window.opera&&(document.compatMode=="CSS1Compat")&&(v.browser.version>=9.3),m=document.documentElement,l={},s=new Image(),I=new Image(),G,a,h,p,H,d,F,c,z,J;v(function(){v("body").append(v([G=v('
')[0],a=v('
')[0],F=v('
')[0]]).css("display","none"));h=v('
').appendTo(a).append(p=v('
').append([H=v('').click(A)[0],d=v('').click(f)[0]])[0])[0];c=v('
').appendTo(F).append([v('').add(G).click(B)[0],z=v('
')[0],J=v('
')[0],v('
')[0]])[0]});v.slimbox=function(N,M,L){t=v.extend({loop:false,overlayOpacity:0.8,overlayFadeDuration:400,resizeDuration:400,resizeEasing:"swing",initialWidth:250,initialHeight:250,imageFadeDuration:400,captionAnimationDuration:400,counterText:"Image {x} of {y}",closeKeys:[27,88,67],previousKeys:[37,80],nextKeys:[39,78]},L);if(typeof N=="string"){N=[[N,M]];M=0}x=D.scrollTop()+((e?m.clientHeight:D.height())/2);K=t.initialWidth;r=t.initialHeight;v(a).css({top:Math.max(0,x-(r/2)),width:K,height:r,marginLeft:-K/2}).show();u=n||(G.currentStyle&&(G.currentStyle.position!="fixed"));if(u){G.style.position="absolute"}v(G).css("opacity",t.overlayOpacity).fadeIn(t.overlayFadeDuration);y();k(1);g=N;t.loop=t.loop&&(g.length>1);return b(M)};v.fn.slimbox=function(L,O,N){O=O||function(P){return[P.href,P.title]};N=N||function(){return true};var M=this;return M.unbind("click").click(function(){var R=this,T=0,S,P=0,Q;S=v.grep(M,function(V,U){return N.call(R,V,U)});for(Q=S.length;P=0)?B():(L(M,t.nextKeys)>=0)?f():(L(M,t.previousKeys)>=0)?A():false}function A(){return b(w)}function f(){return b(C)}function b(L){if(L>=0){E=L;w=(E||(t.loop?g.length:0))-1;C=((E+1)%g.length)||(t.loop?0:-1);q();a.className="lbLoading";l=new Image();l.onload=j;l.src=g[E][0]}return false}function j(){a.className="";v(h).css({backgroundImage:"url("+l.src+")",visibility:"hidden",display:""});v(p).width(l.width);v([p,H,d]).height(l.height);v(z).html(g[E][1]||"");v(J).html((((g.length>1)&&t.counterText)||"").replace(/{x}/,E+1).replace(/{y}/,g.length));if(w>=0){s.src=g[w][0]}if(C>=0){I.src=g[C][0]}K=h.offsetWidth;r=h.offsetHeight;var L=Math.max(0,x-(r/2));if(a.offsetHeight!=r){v(a).animate({height:r,top:L},t.resizeDuration,t.resizeEasing)}if(a.offsetWidth!=K){v(a).animate({width:K,marginLeft:-K/2},t.resizeDuration,t.resizeEasing)}v(a).queue(function(){v(F).css({width:K,top:L+r,marginLeft:-K/2,visibility:"hidden",display:""});v(h).css({display:"none",visibility:"",opacity:""}).fadeIn(t.imageFadeDuration,i)})}function i(){if(w>=0){v(H).show()}if(C>=0){v(d).show()}v(c).css("marginTop",-c.offsetHeight).animate({marginTop:0},t.captionAnimationDuration);F.style.visibility=""}function q(){l.onload=null;l.src=s.src=I.src="";v([a,h,c]).stop(true);v([H,d,h,F]).hide()}function B(){if(E>=0){q();E=w=C=-1;v(a).hide();v(G).stop().fadeOut(t.overlayFadeDuration,k)}return false}})(jQuery); $(document).ready(function() { // remove those common links var links = [ "http://www.fotosik.pl", "http://imageshack.us" ]; // set max-height asap var maxh = Math.round($(window).height() * 0.9); $(".entry-content .postimg img").css("max-height", maxh); $(".entry-content .postimg img").not(".done").mouseover(function () { //exclude already done if ($(this).is(".done")) { // do nothing } else { // get original img size $(this).css("max-width", "9999px"); $(this).css("max-height", "9999px"); var orgw = $(this).width(); var orgh = $(this).height(); // get resized img size $(this).css("max-width", "80%"); $(this).css("max-height", maxh); var neww = $(this).width(); var newh = $(this).height(); // check resize scale (show slimbox only if more than +10% change) var scalex = orgw / neww; var scaley = orgh / newh; var scale = Math.max(scalex, scaley); var slim = false; if (scale > 1.1) { slim = true; } // remove common links if ($(this).parent().parent().is("a")) { var linkurl = $(this).parent().parent().attr("href"); if (jQuery.inArray(linkurl, links) != -1) { $(this).parent().parent().removeAttr("href"); // if link removed - set slim if (slim) { $(this).addClass("slimbox"); var res = linkurl+" - "+orgw+"x"+orgh; $(this).attr("title", res); } else { $(this).attr("title", linkurl); } } } else { // if not link - set slim if (slim) { $(this).addClass("slimbox"); var res = orgw+"x"+orgh; $(this).attr("title", res); } } // "mark" as done $(this).addClass("done"); } }); $("img.slimbox").live("click", function () { var imgurl = $(this).attr("src"); jQuery.slimbox(imgurl); }); });