/** * jQuery Lightbox Plugin (balupton edition) - Lightboxes for jQuery * Copyright (C) 2008 Benjamin Arthur Lupton * http://jquery.com/plugins/project/jquerylightbox_bal * * This file is part of jQuery Lightbox (balupton edition). * * You should have received a copy of the GNU Affero General Public License * along with jQuery Lightbox (balupton edition). If not, see . */ (function($){if(typeof $.log==="undefined"){if(typeof window.console!=="undefined"&&typeof window.console.log==="function"){$.log=function(){var args=[];for(var i=0;i0){image.description=image.title.substring(s+2)||image.description;image.title=image.title.substring(0,s)||image.title}}else{image=false}}else{image=false}}if(!image){$.console.error("Spróbuj pu¼niej:",obj);return false}return image},get:function(image){if(typeof image==="undefined"||image===null){return this.active()}else{if(typeof image==="number"){image=this.list[image]||false}else{image=this.create(image);if(!image){return false}var f=false;for(var i=0;i=0){this.ie6=true}else{this.ie6=false}if(domReady||typeof options.download_link!=="undefined"||typeof options.colorBlend!=="undefined"||typeof options.files==="object"||typeof options.text==="object"||typeof options.show_linkback!=="undefined"||typeof options.scroll_with!=="undefined"){$(function(){$.Lightbox.domReady()})}return true},domReady:function(){var bodyEl=document.getElementsByTagName("body")[0];var stylesheets=this.files.css;var scripts=this.files.js;if(this.ie6&&this.ie6_upgrade){scripts.ie6=""}if(this.colorBlend===true&&typeof $.colorBlend==="undefined"){this.colorBlend=true}else{this.colorBlend=typeof $.colorBlend!=="undefined";delete scripts.colorBlend}for(stylesheet in stylesheets){var linkEl=document.createElement("link");linkEl.type="text/css";linkEl.rel="stylesheet";linkEl.media="screen";linkEl.href=stylesheets[stylesheet];linkEl.id="lightbox-stylesheet-"+stylesheet.replace(/[^a-zA-Z0-9]/g,"");$("#"+linkEl.id).remove();bodyEl.appendChild(linkEl)}for(script in scripts){var scriptEl=document.createElement("script");scriptEl.type="text/javascript";scriptEl.src=scripts[script];scriptEl.id="lightbox-script-"+script.replace(/[^a-zA-Z0-9]/g,"");$("#"+scriptEl.id).remove();bodyEl.appendChild(scriptEl)}delete scripts;delete stylesheets;delete bodyEl;$("#lightbox,#lightbox-overlay").remove();$("body").append('');this.resizeBoxes();this.repositionBoxes();$("#lightbox,#lightbox-overlay,#lightbox-overlay-text-interact").hide();if(this.ie6&&this.ie6_support){$("#lightbox-overlay").css({position:"absolute",top:"0px",left:"0px"})}$.each(this.files.images,function(){var preloader=new Image();preloader.onload=function(){preloader.onload=null;preloader=null};preloader.src=this});$(window).unbind("resize").resize(function(){$.Lightbox.resizeBoxes("resized")});if(this.scroll==="follow"){$(window).scroll(function(){$.Lightbox.repositionBoxes()})}$("#lightbox-nav-btnPrev").unbind().hover(function(){$(this).css({background:"url("+$.Lightbox.files.images.prev+") left 45% no-repeat"})},function(){$(this).css({background:"transparent url("+$.Lightbox.files.images.blank+") no-repeat"})}).click(function(){$.Lightbox.showImage($.Lightbox.images.prev());return false});$("#lightbox-nav-btnNext").unbind().hover(function(){$(this).css({background:"url("+$.Lightbox.files.images.next+") right 45% no-repeat"})},function(){$(this).css({background:"transparent url("+$.Lightbox.files.images.blank+") no-repeat"})}).click(function(){$.Lightbox.showImage($.Lightbox.images.next());return false});if(this.show_linkback){$("#lightbox-overlay-text-about a").click(function(){window.open($.Lightbox.text.about.link);return false})}$("#lightbox-overlay-text-close").unbind().hover(function(){$("#lightbox-overlay-text-interact").fadeIn()},function(){$("#lightbox-overlay-text-interact").fadeOut()});$("#lightbox-caption-title").click(function(){window.open($(this).attr("href"));return false});$("#lightbox-overlay, #lightbox, #lightbox-loading-link, #lightbox-btnClose").unbind().click(function(){$.Lightbox.finish();return false});if(this.auto_relify){this.relify()}return true},relify:function(){var groups={};var groups_n=0;var orig_rel=this.rel;$.each($("[rel*="+orig_rel+"]"),function(index,obj){var rel=$(obj).attr("rel");if(rel===orig_rel){rel=groups_n}if(typeof groups[rel]==="undefined"){groups[rel]=[];groups_n++}groups[rel].push(obj)});$.each(groups,function(index,group){$(group).lightbox()});return true},init:function(image,images){if(typeof images==="undefined"){images=image;image=0}this.images.clear();if(!this.images.add(images)){return false}if(this.images.empty()){$.console.warn("WARNING","Lightbox started, but no images: ",image,images);return false}if(!this.images.active(image)){return false}return true},start:function(){this.visible=true;if(this.scroll==="disable"){$(document.body).css("overflow","hidden")}$("embed, object, select").css("visibility","hidden");this.resizeBoxes("general");this.repositionBoxes({speed:0});$("#lightbox-infoFooter").hide();$("#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-infoBox").hide();$("#lightbox-overlay").css("opacity",this.opacity).fadeIn(400,function(){$("#lightbox").fadeIn(300);if(!$.Lightbox.showImage($.Lightbox.images.active())){$.Lightbox.finish();return false}});return true},finish:function(){$("#lightbox").hide();$("#lightbox-overlay").fadeOut(function(){$("#lightbox-overlay").hide()});$("embed, object, select").css({visibility:"visible"});this.images.active(false);if(this.scroll==="disable"){$(document.body).css("overflow","visible")}this.visible=false},resizeBoxes:function(type){if(type!=="transition"){var $body=$(this.ie6?document.body:document);$("#lightbox-overlay").css({width:$body.width(),height:$(document).height()});delete $body}switch(type){case"general":return true;break;case"resized":if(this.auto_resize===false){this.repositionBoxes({nHeight:nHeight,speed:this.speed});return true}case"transition":default:break}var image=this.images.active();if(!image||!image.width||!this.visible){return false}var iWidth=image.width;var iHeight=image.height;var wWidth=$(window).width();var wHeight=$(window).height();if(this.auto_resize!==false){var maxWidth=Math.floor(wWidth*(4/5));var maxHeight=Math.floor(wHeight*(4/5));var resizeRatio;while(iWidth>maxWidth||iHeight>maxHeight){if(iWidth>maxWidth){resizeRatio=maxWidth/iWidth;iWidth=maxWidth;iHeight=Math.floor(iHeight*resizeRatio)}if(iHeight>maxHeight){resizeRatio=maxHeight/iHeight;iHeight=maxHeight;iWidth=Math.floor(iWidth*resizeRatio)}}}var cWidth=$("#lightbox-imageBox").width();var cHeight=$("#lightbox-imageBox").height();var nWidth=(iWidth+(this.padding*2));var nHeight=(iHeight+(this.padding*2));var dWidth=cWidth-nWidth;var dHeight=cHeight-nHeight;$("#lightbox-nav-btnPrev,#lightbox-nav-btnNext").css("height",nHeight);$("#lightbox-infoBox").css("width",nWidth);if(type==="transition"){if(dWidth===0&&dHeight===0){this.pause(this.speed/3);this.showImage(null,3)}else{$("#lightbox-image").width(iWidth).height(iHeight);$("#lightbox-imageBox").animate({width:nWidth,height:nHeight},this.speed,function(){$.Lightbox.showImage(null,3)})}}else{$("#lightbox-image").animate({width:iWidth,height:iHeight},this.speed);$("#lightbox-imageBox").animate({width:nWidth,height:nHeight},this.speed)}this.repositionBoxes({nHeight:nHeight,speed:this.speed});return true},repositioning:false,reposition_failsafe:false,repositionBoxes:function(options){if(this.repositioning){this.reposition_failsafe=true;return null}this.repositioning=true;options=$.extend({},options);options.callback=options.callback||null;options.speed=options.speed||"slow";var pageScroll=this.getPageScroll();var nHeight=options.nHeight||parseInt($("#lightbox").height(),10);var nTop=pageScroll.yScroll+($(window).height()-nHeight)/2.5;var nLeft=pageScroll.xScroll;var css={left:nLeft,top:nTop};if(options.speed){$("#lightbox").animate(css,"slow",function(){if($.Lightbox.reposition_failsafe){$.Lightbox.repositioning=$.Lightbox.reposition_failsafe=false;$.Lightbox.repositionBoxes(options)}else{$.Lightbox.repositioning=false;if(options.callback){options.callback()}}})}else{$("#lightbox").css(css);if(this.reposition_failsafe){this.repositioning=this.reposition_failsafe=false;this.repositionBoxes(options)}else{this.repositioning=false}}return true},visible:false,showImage:function(image,step){image=this.images.get(image);if(!image){return image}step=step||1;var skipped_step_1=step>1&&this.images.active().src!==image.src;var skipped_step_2=step>2&&$("#lightbox-image").attr("src")!==image.src;if(skipped_step_1||skipped_step_2){$.console.info("We wanted to skip a few steps: ",image,step,skipped_step_1,skipped_step_2);step=1}switch(step){case 1:this.KeyboardNav_Disable();$("#lightbox-loading").show();$("#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-infoBox").hide();$("#lightbox-imageBox").unbind();if(!this.images.active(image)){return false}if(image.width&&image.height){this.showImage(null,2)}else{var preloader=new Image();preloader.onload=function(){image.width=preloader.width;image.height=preloader.height;$.Lightbox.showImage(null,2);preloader.onload=null;preloader=null};preloader.src=image.src}break;case 2:$("#lightbox-image").attr("src",image.src);if(typeof this.padding==="undefined"||this.padding===null||isNaN(this.padding)){this.padding=parseInt($("#lightbox-imageContainer").css("padding-left"),10)||parseInt($("#lightbox-imageContainer").css("padding"),10)||0}if(this.colorBlend){$("#lightbox-overlay").animate({backgroundColor:image.color},this.speed*2);$("#lightbox-imageBox").css("borderColor",image.color)}this.resizeBoxes("transition");break;case 3:$("#lightbox-loading").hide();$("#lightbox-image").fadeIn(this.speed*1.5,function(){$.Lightbox.showImage(null,4)});this.preloadNeighbours();if(this.handlers.show!==null){this.handlers.show(image)}break;case 4:var $title=$("#lightbox-caption-title").html(image.title||"");if(this.download_link){$title.attr("href",this.download_link?image.src:"")}delete $title;$("#lightbox-caption-seperator").html(image.description?": ":"");$("#lightbox-caption-description").html(image.description||" ");if(this.images.size()>1){$("#lightbox-currentNumber").html(this.text.image+" "+(image.index+1)+" "+this.text.of+" "+this.images.size())}else{$("#lightbox-currentNumber").html(" ")}$("#lightbox-imageBox").unbind("mouseover").mouseover(function(){$("#lightbox-infoBox:not(:visible)").stop().slideDown("fast")});$("#lightbox-infoBox").unbind("mouseover").mouseover(function(){$("#lightbox-infoFooter:not(:visible)").stop().slideDown("fast")});if(this.show_extended_info===true){$("#lightbox-imageBox").trigger("mouseover");$("#lightbox-infoBox").trigger("mouseover")}else{if(this.show_info===true){$("#lightbox-imageBox").trigger("mouseover")}}$("#lightbox-nav-btnPrev, #lightbox-nav-btnNext").css({background:"transparent url("+this.files.images.blank+") no-repeat"});if(!this.images.first(image)){$("#lightbox-nav-btnPrev").show()}if(!this.images.last(image)){$("#lightbox-nav-btnNext").show()}$("#lightbox-nav").show();this.KeyboardNav_Enable();break;default:$.console.error("Don't know what to do: ",image,step);return this.showImage(image,1)}return true},preloadNeighbours:function(){if(this.images.single()||this.images.empty()){return true}var image=this.images.active();if(!image){return image}var prev=this.images.prev(image);var objNext;if(prev){objNext=new Image();objNext.src=prev.src}var next=this.images.next(image);if(next){objNext=new Image();objNext.src=next.src}},KeyboardNav_Enable:function(){$(document).keydown(function(objEvent){$.Lightbox.KeyboardNav_Action(objEvent)})},KeyboardNav_Disable:function(){$(document).unbind("keydown")},KeyboardNav_Action:function(objEvent){objEvent=objEvent||window.event;var keycode=objEvent.keyCode;var escapeKey=objEvent.DOM_VK_ESCAPE||27;var key=String.fromCharCode(keycode).toLowerCase();if(key===this.keys.close||keycode===escapeKey){return $.Lightbox.finish()}if(key===this.keys.prev||keycode===37){return $.Lightbox.showImage($.Lightbox.images.prev())}if(key===this.keys.next||keycode===39){return $.Lightbox.showImage($.Lightbox.images.next())}return true},getPageScroll:function(){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}}}var arrayPageScroll={xScroll:xScroll,yScroll:yScroll};return arrayPageScroll},pause:function(ms){var date=new Date();var curDate=null;do{curDate=new Date()}while(curDate-date