/** * jquery lightbox plugin * this jquery plugin was inspired and based on lightbox 2 by lokesh dhakar (http://www.huddletogether.com/projects/lightbox2/) * and adapted to me for use like a plugin from jquery. * @name jquery-lightbox-0.5.js * @author leandro vieira pinho - http://leandrovieira.com * @version 0.5 * @date april 11, 2008 * @category jquery plugin * @copyright (c) 2008 leandro vieira pinho (leandrovieira.com) * @license cc attribution-no derivative works 2.5 brazil - http://creativecommons.org/licenses/by-nd/2.5/br/deed.en_us * @example visit http://leandrovieira.com/projects/jquery/lightbox/ for more informations about this jquery plugin */ (function($){$.fn.lightbox=function(settings){settings=jquery.extend({overlaybgcolor:'#000',overlayopacity:0.8,fixednavigation:false,imageloading:'../../style/global/lightbox-images/lightbox-ico-loading.gif',imagebtnprev:'../../style/global/lightbox-images/lightbox-btn-prev.gif',imagebtnnext:'../../style/global/lightbox-images/lightbox-btn-next.gif',imagebtnclose:'../../style/global/lightbox-images/lightbox-btn-close.gif',imageblank:'../../style/global/lightbox-images/lightbox-blank.gif',containerbordersize:10,containerresizespeed:400,txtimage:'image',txtof:'of',keytoclose:'c',keytoprev:'p',keytonext:'n',imagearray:[],activeimage:0},settings);var jquerymatchedobj=this;function _initialize(){_start(this,jquerymatchedobj);return false;} function _start(objclicked,jquerymatchedobj){$('embed, object, select').css({'visibility':'hidden'});_set_interface();settings.imagearray.length=0;settings.activeimage=0;if(jquerymatchedobj.length==1){settings.imagearray.push(new array(objclicked.getattribute('href'),objclicked.getattribute('title')));}else{for(var i=0;i
');var arrpagesizes=___getpagesize();$('#jquery-overlay').css({backgroundcolor:settings.overlaybgcolor,opacity:settings.overlayopacity,width:arrpagesizes[0],height:arrpagesizes[1]}).fadein();var arrpagescroll=___getpagescroll();$('#jquery-lightbox').css({top:arrpagescroll[1]+(arrpagesizes[3]/10),left:arrpagescroll[0]}).show();$('#jquery-overlay,#jquery-lightbox').click(function(){_finish();});$('#lightbox-loading-link,#lightbox-secnav-btnclose').click(function(){_finish();return false;});$(window).resize(function(){var arrpagesizes=___getpagesize();$('#jquery-overlay').css({width:arrpagesizes[0],height:arrpagesizes[1]});var arrpagescroll=___getpagescroll();$('#jquery-lightbox').css({top:arrpagescroll[1]+(arrpagesizes[3]/10),left:arrpagescroll[0]});});} function _set_image_to_view(){$('#lightbox-loading').show();if(settings.fixednavigation){$('#lightbox-image,#lightbox-container-image-data-box,#lightbox-image-details-currentnumber').hide();}else{$('#lightbox-image,#lightbox-nav,#lightbox-nav-btnprev,#lightbox-nav-btnnext,#lightbox-container-image-data-box,#lightbox-image-details-currentnumber').hide();} var objimagepreloader=new image();objimagepreloader.onload=function(){$('#lightbox-image').attr('src',settings.imagearray[settings.activeimage][0]);_resize_container_image_box(objimagepreloader.width,objimagepreloader.height);objimagepreloader.onload=function(){};};objimagepreloader.src=settings.imagearray[settings.activeimage][0];};function _resize_container_image_box(intimagewidth,intimageheight){var intcurrentwidth=$('#lightbox-container-image-box').width();var intcurrentheight=$('#lightbox-container-image-box').height();var intwidth=(intimagewidth+(settings.containerbordersize*2));var intheight=(intimageheight+(settings.containerbordersize*2));var intdiffw=intcurrentwidth-intwidth;var intdiffh=intcurrentheight-intheight;$('#lightbox-container-image-box').animate({width:intwidth,height:intheight},settings.containerresizespeed,function(){_show_image();});if((intdiffw==0)&&(intdiffh==0)){if($.browser.msie){___pause(250);}else{___pause(100);}} $('#lightbox-container-image-data-box').css({width:intimagewidth});$('#lightbox-nav-btnprev,#lightbox-nav-btnnext').css({height:intimageheight+(settings.containerbordersize*2)});};function _show_image(){$('#lightbox-loading').hide();$('#lightbox-image').fadein(function(){_show_image_data();_set_navigation();});_preload_neighbor_images();};function _show_image_data(){$('#lightbox-container-image-data-box').slidedown('fast');$('#lightbox-image-details-caption').hide();if(settings.imagearray[settings.activeimage][1]){$('#lightbox-image-details-caption').html(settings.imagearray[settings.activeimage][1]).show();} if(settings.imagearray.length>1){$('#lightbox-image-details-currentnumber').html(settings.txtimage+' '+(settings.activeimage+1)+' '+settings.txtof+' '+settings.imagearray.length).show();}} function _set_navigation(){$('#lightbox-nav').show();$('#lightbox-nav-btnprev,#lightbox-nav-btnnext').css({'background':'transparent url('+settings.imageblank+') no-repeat'});if(settings.activeimage!=0){if(settings.fixednavigation){$('#lightbox-nav-btnprev').css({'background':'url('+settings.imagebtnprev+') left 15% no-repeat'}).unbind().bind('click',function(){settings.activeimage=settings.activeimage-1;_set_image_to_view();return false;});}else{$('#lightbox-nav-btnprev').unbind().hover(function(){$(this).css({'background':'url('+settings.imagebtnprev+') left 15% no-repeat'});},function(){$(this).css({'background':'transparent url('+settings.imageblank+') no-repeat'});}).show().bind('click',function(){settings.activeimage=settings.activeimage-1;_set_image_to_view();return false;});}} if(settings.activeimage!=(settings.imagearray.length-1)){if(settings.fixednavigation){$('#lightbox-nav-btnnext').css({'background':'url('+settings.imagebtnnext+') right 15% no-repeat'}).unbind().bind('click',function(){settings.activeimage=settings.activeimage+1;_set_image_to_view();return false;});}else{$('#lightbox-nav-btnnext').unbind().hover(function(){$(this).css({'background':'url('+settings.imagebtnnext+') right 15% no-repeat'});},function(){$(this).css({'background':'transparent url('+settings.imageblank+') no-repeat'});}).show().bind('click',function(){settings.activeimage=settings.activeimage+1;_set_image_to_view();return false;});}} _enable_keyboard_navigation();} function _enable_keyboard_navigation(){$(document).keydown(function(objevent){_keyboard_action(objevent);});} function _disable_keyboard_navigation(){$(document).unbind();} function _keyboard_action(objevent){if(objevent==null){keycode=event.keycode;escapekey=27;}else{keycode=objevent.keycode;escapekey=objevent.dom_vk_escape;} key=string.fromcharcode(keycode).tolowercase();if((key==settings.keytoclose)||(key=='x')||(keycode==escapekey)){_finish();} if((key==settings.keytoprev)||(keycode==37)){if(settings.activeimage!=0){settings.activeimage=settings.activeimage-1;_set_image_to_view();_disable_keyboard_navigation();}} if((key==settings.keytonext)||(keycode==39)){if(settings.activeimage!=(settings.imagearray.length-1)){settings.activeimage=settings.activeimage+1;_set_image_to_view();_disable_keyboard_navigation();}}} function _preload_neighbor_images(){if((settings.imagearray.length-1)>settings.activeimage){objnext=new image();objnext.src=settings.imagearray[settings.activeimage+1][0];} if(settings.activeimage>0){objprev=new image();objprev.src=settings.imagearray[settings.activeimage-1][0];}} function _finish(){$('#jquery-lightbox').remove();$('#jquery-overlay').fadeout(function(){$('#jquery-overlay').remove();});$('embed, object, select').css({'visibility':'visible'});} function ___getpagesize(){var xscroll,yscroll;if(window.innerheight&&window.scrollmaxy){xscroll=window.innerwidth+window.scrollmaxx;yscroll=window.innerheight+window.scrollmaxy;}else if(document.body.scrollheight>document.body.offsetheight){xscroll=document.body.scrollwidth;yscroll=document.body.scrollheight;}else{xscroll=document.body.offsetwidth;yscroll=document.body.offsetheight;} var windowwidth,windowheight;if(self.innerheight){if(document.documentelement.clientwidth){windowwidth=document.documentelement.clientwidth;}else{windowwidth=self.innerwidth;} windowheight=self.innerheight;}else if(document.documentelement&&document.documentelement.clientheight){windowwidth=document.documentelement.clientwidth;windowheight=document.documentelement.clientheight;}else if(document.body){windowwidth=document.body.clientwidth;windowheight=document.body.clientheight;} if(yscroll