// jBoxed Lightbox // by Tanner Hildebrand // and BenchSketch.com // (function($){ $.fn.extend({ jboxed : function(options) { // options var opts = $.extend({}, $.fn.jboxed.defaults, options); var wS=$(window).height(); $("body").append("
"); $("body").append("
Закрыть
Bottom Info here
«»
"); // Fix Initial Position jMod=$("#jbModal"),full=$("#jbModal, #jbInterface"); jMod.css({"opacity":opts.modal}); iFace=$("#jbInterface"),iBox=$("#jbImageBox"),jImg=$("#jbImage"); aR="#jbRight",aL="#jbLeft"; iFace.css({"height":150,"width":150}); iBox.css({"height":"100%","width":"100%"}); iFace.css({"marginTop":-75,"marginLeft":-75}); $(aR).css("marginLeft",157); full.hide(); jSrc="#jbImage img"; bInfo=$("#jbInfoBottom"),tInfo=$("#jbInfoTop"); jLnk=$("#jbLink"); // And boom goes the dynamite // Close $("#jbModal, #jbClose").click(function(){ full.fadeOut(opts.speed); }) // // work gallery links $("#jbLink a, #jbRight, #jbLeft").live("click",function(){ hr=$(this),hTtl=hr.attr("title"),hRel=hr.attr("Rel"),hRef=hr.attr("href"); imageChange( hRef , hTtl , hRel ); return false; }) // // so we know what we are clicking... return this.each(function(){ t=$(this); //when click show box t.click(function(){ rel=$(this).attr("rel"),title=$(this).attr("title"),href=$(this).attr("href"); showBoxed( rel , title , href ); return false; }) })//end each // Initial click function showBoxed ( rel , title , href ) { setGallery ( rel ); imageChange ( href , title , rel ); full.fadeIn(opts.speed); } // // Apply the changes function imageChange ( src , info , gal ) { iImg=iBox.children("img"); iImg.fadeOut(opts.speed).remove(); iBox.append(""); iImg=iBox.children("img"); iImg.hide(); setInfo( info ); setNext ( gal , iImg ); imageLoad( iImg ); } // // When image is loaded realign function imageLoad ( image ) { $("#jbImage").css({"height":"100%"}),iBox.css({"height":"100%"}); image.load(function(){ // when image is loaded raBox(image); }) } // // realign box function raBox ( ) { img=iBox.children("img"); imageFit(img); iH=img.height(); iW=img.width(); iFace.animate({"height":iH,"width":iW,"marginTop":-iH*.5-20,"marginLeft":-iW*.5},opts.speed,function(){ img.fadeIn(opts.speed); // when animate is done, show the image bInfo.slideDown(opts.speed); // and slide in the info }) $(aR).css("marginLeft",iW+7); } // // fit the image to the window function imageFit ( image ) { iHt=image.height(); if(iHt+40>wS){ iFdif=iHt-wS+80; image.css({"height":iHt-iFdif}); } } // // Set the info // don't know why I made this a whole funtion function setInfo ( info ) { bInfo.fadeOut(opts.speed).html(""+info+""); } // // function to set the gallery links function setGallery ( gallery ) { rCount=0,rString=""; $("a[rel="+gallery+"]").each(function(){ rCount+=1; var hr=$(this),gRef=hr.attr("href"),fTtl=hr.attr("title"); rString+=""+rCount+"  " }) jLnk.html(rString); } // // Set the next and previous buttons function setNext ( gal , img ) { lnk=jLnk.children("a"); iSrc=img.attr("src"); lngt=lnk.length; nCount=0; // Set the count to zero lnk.each(function(){ // go thru all h=$(this); nCount+=1; if(nCount==1){ frst=$(this); } // that was find the first element if(h.attr("href")==iSrc){ // matched links if(nCount==1){ // matched is first n=h.next("a"); p=false; } else if (nCount==lngt) { // matched is last p=h.prev("a"); n=frst; } else { // matched is anything else p=h.prev("a"); n=h.next("a"); } } lst=$(this); }) // if we don't have a previous link yet if(!p){ p=lst; } // and assign our variables pL=p.attr("href"),pT=p.attr("title"); nL=n.attr("href"),nT=n.attr("title"); $(aR).attr({"href":nL,"title":nT}); $(aL).attr({"href":pL,"title":pT}); } // } // end jBoxed }); // end extend // Plugin Defaults $.fn.jboxed.defaults = { modal:.9, speed:"slow", fit:true, border:1 }; })(jQuery); // end all