////////////////////////////////////////////////////////////////////////////////// // cloud zoom v1.0.1 // (c) 2010 by r cecco. // mit license // // please retain this copyright header in all versions of the software ////////////////////////////////////////////////////////////////////////////////// (function($){$(document).ready(function(){$('.cloud-zoom, .cloud-zoom-gallery').cloudzoom()});function format(a){for(var i=1;iloading...',w/3,(w/2)-(w/6))).find(':last').css('opacity',0.5)}},200);var f=function(){if(r!==null){r.remove();r=null}};this.removebits=function(){if(o){o.remove();o=null}if(p){p.remove();p=null}if(q){q.remove();q=null}f();$('.cloud-zoom-loading',g.parent()).remove()};this.destroy=function(){g.data('zoom',null);if(n){n.unbind();n.remove();n=null}if(m){m.remove();m=null}this.removebits()};this.fadedout=function(){if(m){m.remove();m=null}this.removebits()};this.controlloop=function(){if(o){var x=(d-j.offset().left-(u*0.5))>>0;var y=(my-j.offset().top-(ch*0.5))>>0;if(x<0){x=0}else if(x>(j.outerwidth()-u)){x=(j.outerwidth()-u)}if(y<0){y=0}else if(y>(j.outerheight()-ch)){y=(j.outerheight()-ch)}o.css({left:x,top:y});o.css('background-position',(-x)+'px '+(-y)+'px');v=(((x)/j.outerwidth())*s.width)>>0;z=(((y)/j.outerheight())*s.height)>>0;b+=(v-b)/i.smoothmove;a+=(z-a)/i.smoothmove;m.css('background-position',(-(b>>0)+'px ')+(-(a>>0)+'px'))}t=settimeout(function(){e.controlloop()},30)};this.init2=function(a,b){c++;if(b===1){s=a}if(c===2){this.init()}};this.init=function(){$('.cloud-zoom-loading',g.parent()).remove();n=g.parent().append(format("
",j.outerwidth(),j.outerheight(),0,0)).find(':last');n.bind('mousemove',this,function(a){d=a.pagex;my=a.pagey});n.bind('mouseleave',this,function(a){cleartimeout(t);if(o){o.fadeout(299)}if(p){p.fadeout(299)}if(q){q.fadeout(299)}m.fadeout(300,function(){e.fadedout()});return false});n.bind('mouseenter',this,function(a){d=a.pagex;my=a.pagey;zw=a.data;if(m){m.stop(true,false);m.remove()}var b=i.adjustx,ypos=i.adjusty;var c=j.outerwidth();var d=j.outerheight();var w=i.zoomwidth;var h=i.zoomheight;if(i.zoomwidth=='auto'){w=c}if(i.zoomheight=='auto'){h=d}var e=g.parent();switch(i.position){case'top':ypos-=h;break;case'right':b+=c;break;case'bottom':ypos+=d;break;case'left':b-=w;break;case'inside':w=c;h=d;break;default:e=$('#'+i.position);if(!e.length){e=g;b+=c;ypos+=d}else{w=e.innerwidth();h=e.innerheight()}}m=e.append(format('',b,ypos,w,h,s.src)).find(':last');if($.browser.msie&&$.browser.version<7){r=$('').css({position:"absolute",left:b,top:ypos,zindex:99,width:w,height:h}).insertbefore(m)}m.fadein(500);if(o){o.remove();o=null}u=(j.outerwidth()/s.width)*m.width();ch=(j.outerheight()/s.height)*m.height();o=g.append(format("",u,ch)).find(':last');n.css('cursor',o.css('cursor'));var f=false;if(i.tint){o.css('background','url("'+j.attr('src')+'")');p=g.append(format('
',j.outerwidth(),j.outerheight(),i.tint)).find(':last');p.css('opacity',i.tintopacity);f=true;p.fadein(500)}if(i.softfocus){o.css('background','url("'+j.attr('src')+'")');q=g.append(format('
',j.outerwidth()-2,j.outerheight()-2,i.tint)).find(':last');q.css('background','url("'+j.attr('src')+'")');q.css('opacity',0.5);f=true;q.fadein(500)}if(!f){o.css('opacity',i.lensopacity)}if(i.position!=='inside'){o.fadein(500)}zw.controlloop();return})};k=new image();$(k).load(function(){e.init2(this,0)});k.src=j.attr('src');l=new image();$(l).load(function(){e.init2(this,1)});l.src=g.attr('href')}$.fn.cloudzoom=function(d){try{document.execcommand("backgroundimagecache",false,true)}catch(e){}this.each(function(){var c,opts;eval('var a = {'+$(this).attr('rel')+'}');c=a;if($(this).is('.cloud-zoom')){$(this).css({'position':'relative','display':'block'});$('img',$(this)).css({'display':'block'});if($(this).parent().attr('id')!='wrap'){$(this).wrap('
')}opts=$.extend({},$.fn.cloudzoom.defaults,d);opts=$.extend({},opts,c);$(this).data('zoom',new cloudzoom($(this),opts))}else if($(this).is('.cloud-zoom-gallery')){opts=$.extend({},c,d);$(this).data('relopts',opts);$(this).bind('mouseenter',$(this),function(a){$('.cloud-zoom-gallery').removeclass("hover");$(this).addclass("hover");var b=a.data.data('relopts');$('#'+b.usezoom).data('zoom').destroy();$('#'+b.usezoom).attr('href',a.data.attr('href'));$('#'+b.usezoom+' img').attr('src',a.data.data('relopts').smallimage);$('#'+a.data.data('relopts').usezoom).cloudzoom();return false})}});return this};$.fn.cloudzoom.defaults={zoomwidth:'auto',zoomheight:'auto',position:'right',tint:false,tintopacity:0.5,lensopacity:0.5,softfocus:false,smoothmove:3,showtitle:true,titleopacity:0.3,adjustx:0,adjusty:0}})(jquery);