jquery - Set max width 800px on Lightbox plugin -


hello use lightbox plugin 1 of website , when picture open have max width 800px, because i'm beginner in jquery have no idea suppose set here :

/**  * jquery lightbox plugin  * jquery plugin inspired , based on lightbox 2 lokesh dhakar (http://www.huddletogether.com/projects/lightbox2/)  * , adapted me use plugin 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 ccattribution-sharealike 2.5 brazil - http://creativecommons.org/licenses/by-sa/2.5/br/deed.en_us  * @example visit http://leandrovieira.com/projects/jquery/lightbox/ more informations jquery plugin  */ (function($){$.fn.lightbox=function(settings){settings=jquery.extend({overlaybgcolor:'#000',overlayopacity:0.8,fixednavigation:false,imageloading:'css/images/lightbox-ico-loading.gif',imagebtnprev:'css/images/lightbox-btn-prev.gif',imagebtnnext:'css/images/lightbox-btn-next.gif',imagebtnclose:'css/images/lightbox-btn-close.gif',imageblank:'css/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<jquerymatchedobj.length;i++){settings.imagearray.push(new array(jquerymatchedobj[i].getattribute('href'),jquerymatchedobj[i].getattribute('title')))}}while(settings.imagearray[settings.activeimage][0]!=objclicked.getattribute('href')){settings.activeimage++}_set_image_to_view()}function _set_interface(){$('body').append('<div id="jquery-overlay"></div><div id="jquery-lightbox"><div id="lightbox-container-image-box"><div id="lightbox-container-image"><img id="lightbox-image"><div style="" id="lightbox-nav"><a href="#" id="lightbox-nav-btnprev"></a><a href="#" id="lightbox-nav-btnnext"></a></div><div id="lightbox-loading"><a href="#" id="lightbox-loading-link"><img src="'+settings.imageloading+'"></a></div></div></div><div id="lightbox-container-image-data-box"><div id="lightbox-container-image-data"><div id="lightbox-image-details"><span id="lightbox-image-details-caption"></span><span id="lightbox-image-details-currentnumber"></span></div><div id="lightbox-secnav"><a href="#" id="lightbox-secnav-btnclose"><img src="'+settings.imagebtnclose+'"></a></div></div></div></div>');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<windowheight){pageheight=windowheight}else{pageheight=yscroll}if(xscroll<windowwidth){pagewidth=xscroll}else{pagewidth=windowwidth}arraypagesize=new array(pagewidth,pageheight,windowwidth,windowheight);return arraypagesize};function ___getpagescroll(){var xscroll,yscroll;if(self.pageyoffset){yscroll=self.pageyoffset;xscroll=self.pagexoffset}else if(document.documentelement&&document.documentelement.scrolltop){yscroll=document.documentelement.scrolltop;xscroll=document.documentelement.scrollleft}else if(document.body){yscroll=document.body.scrolltop;xscroll=document.body.scrollleft}arraypagescroll=new array(xscroll,yscroll);return arraypagescroll};function ___pause(ms){var date=new date();curdate=null;do{var curdate=new date()}while(curdate-date<ms)};return this.unbind('click').click(_initialize)}})(jquery); 

if had problem or know how fix appreciated,

thank you

i modified jquery.lightbox-0.5.js file leandro vieira pinho. modified javascript file is, check each image , if width or height exceeds screen (viewport area), image resized while preserving aspect ratio.

to use file, have copy , paste entire contents of javascript file in existing jquery.lightbox-0.5.js file or have replace old file this.

i have given 2 links: first 1 let down load entire javascript file , second display source code can copy , paste existing jquery.lightbox-0.5.js.

download javascript file: http://turboupload.com/081zwttawcb6

source code : http://www.sourcepod.com/twhbtf88-5047


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -