/** * zbox - lightbox and zoomer combo for jQuery * * Copyright 2013 Arcitus Solutions Ltd. * http://www.arcitus.co.uk/ * Not to be used without permission. * * Version 1.0.0 - 26th August 2013 * * Developed for jQuery 1.8.2 * */ ;!function(e,t,n){"use strict";var i={margin:10},r={c:null,o:{},s:function(i){r.cin=r.cn.index(this),r.sd=!1,r.r=!0,e(this).blur(),e(n).on("keydown.zbox",function(e){27==e.which||13==e.which?(r.sdn(),e.preventDefault()):37==e.which||38==e.which||8==e.which?(r.p(),e.preventDefault()):(39==e.which||40==e.which||32==e.which)&&(r.n(),e.preventDefault())}),e(t).resize(function(){r.rf(!1)}),r.window=e(t),r.so(),r.li(),i.preventDefault()},so:function(){var t='
';r.ov=e(t).appendTo("body"),r.ov.click(r.sdn),r.ov.animate({opacity:.7},{duration:250,easing:"swing"})},sdn:function(){r.sd=!0,r.sp&&(r.sp.remove(),r.sp=null),r.c&&r.c.animate({opacity:.1},{duration:250,easing:"swing"}),r.ov?r.ov.animate({opacity:.1},{duration:250,easing:"swing",complete:r.sdf}):r.sdf()},sdf:function(){r.sd=!0,r.ov&&(r.ov.remove(),r.ov=null),r.c&&(r.c.remove(),r.c=null),r.sp&&(r.sp.remove(),r.sp=null),r.i=null,r.nil=0,r.ail=!1,e(".zbox-screen").unbind(".zbox"),e(n).off(".zbox")},li:function(){r.i=new Array,r.nil=0,r.ail=!1,r.cn.each(function(){var t=new Image;t.onload=function(){r.sd||(r.nil++,r.nil==r.cn.length&&(r.ail=!0,r.hs(),r.bi(),r.si(),r.sm()))},t.onerror=function(){console&&console.warn("Error loading image "+t.src),r.hs(),r.sdf()};var n=e(this).attr("href"),i=e(this).attr("title");t.src=n,r.i.push({img:t,href:n,title:i})}),r.ail||r.ss()},ss:function(){if(!r.sd){var t='
Loading...
';r.sp=e(t),r.sp.css("left",r.window.scrollLeft()-16+r.window.width()/2),r.sp.css("top",r.window.scrollTop()-16+r.window.height()/2),r.ail||r.sp.appendTo("body")}},hs:function(){r.sp&&(r.sp.remove(),r.sp=null)},bi:function(){var t='
';r.c=e(t);var n=r.i[r.cin].href,i=r.i[r.cin].title,o=r.i[r.cin].img,a=''+i+'';r.im=e(a);var s=o.width,l=o.height,c=r.window.width()-2*r.o.margin,u=r.window.height()-2*r.o.margin,d=c-80,p=u-20,f=d/p,h=s/l,g=d,m=p;h>f?s>d?m=Math.ceil(d/h):(g=s,m=l):l>p?g=Math.ceil(p*h):(g=s,m=l),r.im.width(g),r.im.height(m),r.c.css("left",Math.ceil(r.o.margin+(c-(g+80))/2)+"px"),r.c.css("top",Math.ceil(r.o.margin+(u-(m+20))/2)+"px"),r.i.length>1&&(e('
').css("top",Math.ceil((m+20)/2-6)+"px").appendTo(r.c).click(r.p),e('
').css("top",Math.ceil((m+20)/2-6)+"px").appendTo(r.c).click(r.n)),e('
').appendTo(r.c).click(r.sdn),r.d={iw:s,ih:l,ww:c,wh:u,nw:g,nh:m}},si:function(e){r.im.appendTo(r.c),r.c.appendTo("body"),e?r.c.animate({opacity:1},{duration:250,easing:"swing",complete:function(){r.r=!1}}):(r.c.css("opacity",1),r.r=!1)},mon:function(){r.showingMag=!0,r.mag&&r.mag.css("display","block")},moff:function(){r.showingMag=!1,r.mag&&r.mag.css("display","none")},sm:function(){function t(e,t,n,i){var o=l.left,a=l.top,s=e-o;"undefined"!=typeof zoom_offset&&(s-=zoom_offset);var c=t-a,u=s/r.d.nw,d=c/r.d.nh,p=u*r.d.iw,f=d*r.d.ih,h=100-p,g=100-f,m=100,y=100;jQuery("#zbox-magnifier").css("left",n-m).css("top",i-y).css("background-position",h+"px "+g+"px")}if(r.d.nw