-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjquery.fancybox.js
1 lines (1 loc) · 23.4 KB
/
jquery.fancybox.js
1
(function(e,t,i,n){"use strict";var a=i("html"),o=i(e),r=i(t),s=i.fancybox=function(){s.open.apply(this,arguments)},l=navigator.userAgent.match(/msie/i),f=null,c=t.createTouch!==n,d=function(e){return e&&e.hasOwnProperty&&e instanceof i},p=function(e){return e&&i.type(e)==="string"},u=function(e){return p(e)&&e.indexOf("%")>0},h=function(e){return e&&!(e.style.overflow&&e.style.overflow==="hidden")&&(e.clientWidth&&e.scrollWidth>e.clientWidth||e.clientHeight&&e.scrollHeight>e.clientHeight)},g=function(e,t){var i=parseInt(e,10)||0;if(t&&u(e)){i=s.getViewport()[t]/100*i}return Math.ceil(i)},m=function(e,t){return g(e,t)+"px"};i.extend(s,{version:"2.1.5",defaults:{padding:15,margin:20,width:800,height:600,minWidth:100,minHeight:100,maxWidth:9999,maxHeight:9999,pixelRatio:1,autoSize:true,autoHeight:false,autoWidth:false,autoResize:true,autoCenter:!c,fitToView:true,aspectRatio:false,topRatio:.5,leftRatio:.5,scrolling:"auto",wrapCSS:"",arrows:true,closeBtn:true,closeClick:false,nextClick:false,mouseWheel:true,autoPlay:false,playSpeed:3e3,preload:3,modal:false,loop:true,ajax:{dataType:"html",headers:{"X-fancyBox":true}},iframe:{scrolling:"auto",preload:true},swf:{wmode:"transparent",allowfullscreen:"true",allowscriptaccess:"always"},keys:{next:{13:"left",34:"up",39:"left",40:"up"},prev:{8:"right",33:"down",37:"right",38:"down"},close:[27],play:[32],toggle:[70]},direction:{next:"left",prev:"right"},scrollOutside:true,index:0,type:null,href:null,content:null,title:null,tpl:{wrap:'<div class="fancybox-wrap" tabIndex="-1"><div class="fancybox-skin"><div class="fancybox-outer"><div class="fancybox-inner"></div></div></div></div>',image:'<img class="fancybox-image" src="{href}" alt="" />',iframe:'<iframe id="fancybox-frame{rnd}" name="fancybox-frame{rnd}" class="fancybox-iframe" frameborder="0" vspace="0" hspace="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen'+(l?' allowtransparency="true"':"")+"></iframe>",error:'<p class="fancybox-error">The requested content cannot be loaded.<br/>Please try again later.</p>',closeBtn:'<a title="Close" class="fancybox-item fancybox-close" href="javascript:;"></a>',next:'<a title="Next" class="fancybox-nav fancybox-next" href="javascript:;"><span></span></a>',prev:'<a title="Previous" class="fancybox-nav fancybox-prev" href="javascript:;"><span></span></a>'},openEffect:"fade",openSpeed:250,openEasing:"swing",openOpacity:true,openMethod:"zoomIn",closeEffect:"fade",closeSpeed:250,closeEasing:"swing",closeOpacity:true,closeMethod:"zoomOut",nextEffect:"elastic",nextSpeed:250,nextEasing:"swing",nextMethod:"changeIn",prevEffect:"elastic",prevSpeed:250,prevEasing:"swing",prevMethod:"changeOut",helpers:{overlay:true,title:true},onCancel:i.noop,beforeLoad:i.noop,afterLoad:i.noop,beforeShow:i.noop,afterShow:i.noop,beforeChange:i.noop,beforeClose:i.noop,afterClose:i.noop},group:{},opts:{},previous:null,coming:null,current:null,isActive:false,isOpen:false,isOpened:false,wrap:null,skin:null,outer:null,inner:null,player:{timer:null,isActive:false},ajaxLoad:null,imgPreload:null,transitions:{},helpers:{},open:function(e,t){if(!e){return}if(!i.isPlainObject(t)){t={}}if(false===s.close(true)){return}if(!i.isArray(e)){e=d(e)?i(e).get():[e]}i.each(e,function(a,o){var r={},l,f,c,u,h,g,m;if(i.type(o)==="object"){if(o.nodeType){o=i(o)}if(d(o)){r={href:o.data("fancybox-href")||o.attr("href"),title:o.data("fancybox-title")||o.attr("title"),isDom:true,element:o};if(i.metadata){i.extend(true,r,o.metadata())}}else{r=o}}l=t.href||r.href||(p(o)?o:null);f=t.title!==n?t.title:r.title||"";c=t.content||r.content;u=c?"html":t.type||r.type;if(!u&&r.isDom){u=o.data("fancybox-type");if(!u){h=o.prop("class").match(/fancybox\.(\w+)/);u=h?h[1]:null}}if(p(l)){if(!u){if(s.isImage(l)){u="image"}else if(s.isSWF(l)){u="swf"}else if(l.charAt(0)==="#"){u="inline"}else if(p(o)){u="html";c=o}}if(u==="ajax"){g=l.split(/\s+/,2);l=g.shift();m=g.shift()}}if(!c){if(u==="inline"){if(l){c=i(p(l)?l.replace(/.*(?=#[^\s]+$)/,""):l)}else if(r.isDom){c=o}}else if(u==="html"){c=l}else if(!u&&!l&&r.isDom){u="inline";c=o}}i.extend(r,{href:l,type:u,content:c,title:f,selector:m});e[a]=r});s.opts=i.extend(true,{},s.defaults,t);if(t.keys!==n){s.opts.keys=t.keys?i.extend({},s.defaults.keys,t.keys):false}s.group=e;return s._start(s.opts.index)},cancel:function(){var e=s.coming;if(!e||false===s.trigger("onCancel")){return}s.hideLoading();if(s.ajaxLoad){s.ajaxLoad.abort()}s.ajaxLoad=null;if(s.imgPreload){s.imgPreload.onload=s.imgPreload.onerror=null}if(e.wrap){e.wrap.stop(true,true).trigger("onReset").remove()}s.coming=null;if(!s.current){s._afterZoomOut(e)}},close:function(e){s.cancel();if(false===s.trigger("beforeClose")){return}s.unbindEvents();if(!s.isActive){return}if(!s.isOpen||e===true){i(".fancybox-wrap").stop(true).trigger("onReset").remove();s._afterZoomOut()}else{s.isOpen=s.isOpened=false;s.isClosing=true;i(".fancybox-item, .fancybox-nav").remove();s.wrap.stop(true,true).removeClass("fancybox-opened");s.transitions[s.current.closeMethod]()}},play:function(e){var t=function(){clearTimeout(s.player.timer)},i=function(){t();if(s.current&&s.player.isActive){s.player.timer=setTimeout(s.next,s.current.playSpeed)}},n=function(){t();r.unbind(".player");s.player.isActive=false;s.trigger("onPlayEnd")},a=function(){if(s.current&&(s.current.loop||s.current.index<s.group.length-1)){s.player.isActive=true;r.bind({"onCancel.player beforeClose.player":n,"onUpdate.player":i,"beforeLoad.player":t});i();s.trigger("onPlayStart")}};if(e===true||!s.player.isActive&&e!==false){a()}else{n()}},next:function(e){var t=s.current;if(t){if(!p(e)){e=t.direction.next}s.jumpto(t.index+1,e,"next")}},prev:function(e){var t=s.current;if(t){if(!p(e)){e=t.direction.prev}s.jumpto(t.index-1,e,"prev")}},jumpto:function(e,t,i){var a=s.current;if(!a){return}e=g(e);s.direction=t||a.direction[e>=a.index?"next":"prev"];s.router=i||"jumpto";if(a.loop){if(e<0){e=a.group.length+e%a.group.length}e=e%a.group.length}if(a.group[e]!==n){s.cancel();s._start(e)}},reposition:function(e,t){var n=s.current,a=n?n.wrap:null,o;if(a){o=s._getPosition(t);if(e&&e.type==="scroll"){delete o.position;a.stop(true,true).animate(o,200)}else{a.css(o);n.pos=i.extend({},n.dim,o)}}},update:function(e){var t=e&&e.type,i=!t||t==="orientationchange";if(i){clearTimeout(f);f=null}if(!s.isOpen||f){return}f=setTimeout(function(){var n=s.current;if(!n||s.isClosing){return}s.wrap.removeClass("fancybox-tmp");if(i||t==="load"||t==="resize"&&n.autoResize){s._setDimension()}if(!(t==="scroll"&&n.canShrink)){s.reposition(e)}s.trigger("onUpdate");f=null},i&&!c?0:300)},toggle:function(e){if(s.isOpen){s.current.fitToView=i.type(e)==="boolean"?e:!s.current.fitToView;if(c){s.wrap.removeAttr("style").addClass("fancybox-tmp");s.trigger("onUpdate")}s.update()}},hideLoading:function(){r.unbind(".loading");i("#fancybox-loading").remove()},showLoading:function(){var e,t;s.hideLoading();e=i('<div id="fancybox-loading"><div></div></div>').click(s.cancel).appendTo("body");r.bind("keydown.loading",function(e){if((e.which||e.keyCode)===27){e.preventDefault();s.cancel()}});if(!s.defaults.fixed){t=s.getViewport();e.css({position:"absolute",top:t.h*.5+t.y,left:t.w*.5+t.x})}},getViewport:function(){var t=s.current&&s.current.locked||false,i={x:o.scrollLeft(),y:o.scrollTop()};if(t){i.w=t[0].clientWidth;i.h=t[0].clientHeight}else{i.w=c&&e.innerWidth?e.innerWidth:o.width();i.h=c&&e.innerHeight?e.innerHeight:o.height()}return i},unbindEvents:function(){if(s.wrap&&d(s.wrap)){s.wrap.unbind(".fb")}r.unbind(".fb");o.unbind(".fb")},bindEvents:function(){var e=s.current,t;if(!e){return}o.bind("orientationchange.fb"+(c?"":" resize.fb")+(e.autoCenter&&!e.locked?" scroll.fb":""),s.update);t=e.keys;if(t){r.bind("keydown.fb",function(a){var o=a.which||a.keyCode,r=a.target||a.srcElement;if(o===27&&s.coming){return false}if(!a.ctrlKey&&!a.altKey&&!a.shiftKey&&!a.metaKey&&!(r&&(r.type||i(r).is("[contenteditable]")))){i.each(t,function(t,r){if(e.group.length>1&&r[o]!==n){s[t](r[o]);a.preventDefault();return false}if(i.inArray(o,r)>-1){s[t]();a.preventDefault();return false}})}})}if(i.fn.mousewheel&&e.mouseWheel){s.wrap.bind("mousewheel.fb",function(t,n,a,o){var r=t.target||null,l=i(r),f=false;while(l.length){if(f||l.is(".fancybox-skin")||l.is(".fancybox-wrap")){break}f=h(l[0]);l=i(l).parent()}if(n!==0&&!f){if(s.group.length>1&&!e.canShrink){if(o>0||a>0){s.prev(o>0?"down":"left")}else if(o<0||a<0){s.next(o<0?"up":"right")}t.preventDefault()}}})}},trigger:function(e,t){var n,a=t||s.coming||s.current;if(!a){return}if(i.isFunction(a[e])){n=a[e].apply(a,Array.prototype.slice.call(arguments,1))}if(n===false){return false}if(a.helpers){i.each(a.helpers,function(t,n){if(n&&s.helpers[t]&&i.isFunction(s.helpers[t][e])){s.helpers[t][e](i.extend(true,{},s.helpers[t].defaults,n),a)}})}r.trigger(e)},isImage:function(e){return p(e)&&e.match(/(^data:image\/.*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp|svg)((\?|#).*)?$)/i)},isSWF:function(e){return p(e)&&e.match(/\.(swf)((\?|#).*)?$/i)},_start:function(e){var t={},n,a,o,r,l;e=g(e);n=s.group[e]||null;if(!n){return false}t=i.extend(true,{},s.opts,n);r=t.margin;l=t.padding;if(i.type(r)==="number"){t.margin=[r,r,r,r]}if(i.type(l)==="number"){t.padding=[l,l,l,l]}if(t.modal){i.extend(true,t,{closeBtn:false,closeClick:false,nextClick:false,arrows:false,mouseWheel:false,keys:null,helpers:{overlay:{closeClick:false}}})}if(t.autoSize){t.autoWidth=t.autoHeight=true}if(t.width==="auto"){t.autoWidth=true}if(t.height==="auto"){t.autoHeight=true}t.group=s.group;t.index=e;s.coming=t;if(false===s.trigger("beforeLoad")){s.coming=null;return}o=t.type;a=t.href;if(!o){s.coming=null;if(s.current&&s.router&&s.router!=="jumpto"){s.current.index=e;return s[s.router](s.direction)}return false}s.isActive=true;if(o==="image"||o==="swf"){t.autoHeight=t.autoWidth=false;t.scrolling="visible"}if(o==="image"){t.aspectRatio=true}if(o==="iframe"&&c){t.scrolling="scroll"}t.wrap=i(t.tpl.wrap).addClass("fancybox-"+(c?"mobile":"desktop")+" fancybox-type-"+o+" fancybox-tmp "+t.wrapCSS).appendTo(t.parent||"body");i.extend(t,{skin:i(".fancybox-skin",t.wrap),outer:i(".fancybox-outer",t.wrap),inner:i(".fancybox-inner",t.wrap)});i.each(["Top","Right","Bottom","Left"],function(e,i){t.skin.css("padding"+i,m(t.padding[e]))});s.trigger("onReady");if(o==="inline"||o==="html"){if(!t.content||!t.content.length){return s._error("content")}}else if(!a){return s._error("href")}if(o==="image"){s._loadImage()}else if(o==="ajax"){s._loadAjax()}else if(o==="iframe"){s._loadIframe()}else{s._afterLoad()}},_error:function(e){i.extend(s.coming,{type:"html",autoWidth:true,autoHeight:true,minWidth:0,minHeight:0,scrolling:"no",hasError:e,content:s.coming.tpl.error});s._afterLoad()},_loadImage:function(){var e=s.imgPreload=new Image;e.onload=function(){this.onload=this.onerror=null;s.coming.width=this.width/s.opts.pixelRatio;s.coming.height=this.height/s.opts.pixelRatio;s._afterLoad()};e.onerror=function(){this.onload=this.onerror=null;s._error("image")};e.src=s.coming.href;if(e.complete!==true){s.showLoading()}},_loadAjax:function(){var e=s.coming;s.showLoading();s.ajaxLoad=i.ajax(i.extend({},e.ajax,{url:e.href,error:function(e,t){if(s.coming&&t!=="abort"){s._error("ajax",e)}else{s.hideLoading()}},success:function(t,i){if(i==="success"){e.content=t;s._afterLoad()}}}))},_loadIframe:function(){var e=s.coming,t=i(e.tpl.iframe.replace(/\{rnd\}/g,(new Date).getTime())).attr("scrolling",c?"auto":e.iframe.scrolling).attr("src",e.href);i(e.wrap).bind("onReset",function(){try{i(this).find("iframe").hide().attr("src","//about:blank").end().empty()}catch(e){}});if(e.iframe.preload){s.showLoading();t.one("load",function(){i(this).data("ready",1);if(!c){i(this).bind("load.fb",s.update)}i(this).parents(".fancybox-wrap").width("100%").removeClass("fancybox-tmp").show();s._afterLoad()})}e.content=t.appendTo(e.inner);if(!e.iframe.preload){s._afterLoad()}},_preloadImages:function(){var e=s.group,t=s.current,i=e.length,n=t.preload?Math.min(t.preload,i-1):0,a,o;for(o=1;o<=n;o+=1){a=e[(t.index+o)%i];if(a.type==="image"&&a.href){(new Image).src=a.href}}},_afterLoad:function(){var e=s.coming,t=s.current,n="fancybox-placeholder",a,o,r,l,f,c;s.hideLoading();if(!e||s.isActive===false){return}if(false===s.trigger("afterLoad",e,t)){e.wrap.stop(true).trigger("onReset").remove();s.coming=null;return}if(t){s.trigger("beforeChange",t);t.wrap.stop(true).removeClass("fancybox-opened").find(".fancybox-item, .fancybox-nav").remove()}s.unbindEvents();a=e;o=e.content;r=e.type;l=e.scrolling;i.extend(s,{wrap:a.wrap,skin:a.skin,outer:a.outer,inner:a.inner,current:a,previous:t});f=a.href;switch(r){case"inline":case"ajax":case"html":if(a.selector){o=i("<div>").html(o).find(a.selector)}else if(d(o)){if(!o.data(n)){o.data(n,i('<div class="'+n+'"></div>').insertAfter(o).hide())}o=o.show().detach();a.wrap.bind("onReset",function(){if(i(this).find(o).length){o.hide().replaceAll(o.data(n)).data(n,false)}})}break;case"image":o=a.tpl.image.replace("{href}",f);break;case"swf":o='<object id="fancybox-swf" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%"><param name="movie" value="'+f+'"></param>';c="";i.each(a.swf,function(e,t){o+='<param name="'+e+'" value="'+t+'"></param>';c+=" "+e+'="'+t+'"'});o+='<embed src="'+f+'" type="application/x-shockwave-flash" width="100%" height="100%"'+c+"></embed></object>";break}if(!(d(o)&&o.parent().is(a.inner))){a.inner.append(o)}s.trigger("beforeShow");a.inner.css("overflow",l==="yes"?"scroll":l==="no"?"hidden":l);s._setDimension();s.reposition();s.isOpen=false;s.coming=null;s.bindEvents();if(!s.isOpened){i(".fancybox-wrap").not(a.wrap).stop(true).trigger("onReset").remove()}else if(t.prevMethod){s.transitions[t.prevMethod]()}s.transitions[s.isOpened?a.nextMethod:a.openMethod]();s._preloadImages()},_setDimension:function(){var e=s.getViewport(),t=0,n=false,a=false,o=s.wrap,r=s.skin,l=s.inner,f=s.current,c=f.width,d=f.height,p=f.minWidth,h=f.minHeight,y=f.maxWidth,x=f.maxHeight,v=f.scrolling,w=f.scrollOutside?f.scrollbarWidth:0,b=f.margin,k=g(b[1]+b[3]),C=g(b[0]+b[2]),O,W,_,S,T,L,E,R,j,P,H,M,A,I,D;o.add(r).add(l).width("auto").height("auto").removeClass("fancybox-tmp");O=g(r.outerWidth(true)-r.width());W=g(r.outerHeight(true)-r.height());_=k+O;S=C+W;T=u(c)?(e.w-_)*g(c)/100:c;L=u(d)?(e.h-S)*g(d)/100:d;if(f.type==="iframe"){I=f.content;if(f.autoHeight&&I.data("ready")===1){try{if(I[0].contentWindow.document.location){l.width(T).height(9999);D=I.contents().find("body");if(w){D.css("overflow-x","hidden")}L=D.outerHeight(true)}}catch(z){}}}else if(f.autoWidth||f.autoHeight){l.addClass("fancybox-tmp");if(!f.autoWidth){l.width(T)}if(!f.autoHeight){l.height(L)}if(f.autoWidth){T=l.width()}if(f.autoHeight){L=l.height()}l.removeClass("fancybox-tmp")}c=g(T);d=g(L);j=T/L;p=g(u(p)?g(p,"w")-_:p);y=g(u(y)?g(y,"w")-_:y);h=g(u(h)?g(h,"h")-S:h);x=g(u(x)?g(x,"h")-S:x);E=y;R=x;if(f.fitToView){y=Math.min(e.w-_,y);x=Math.min(e.h-S,x)}M=e.w-k;A=e.h-C;if(f.aspectRatio){if(c>y){c=y;d=g(c/j)}if(d>x){d=x;c=g(d*j)}if(c<p){c=p;d=g(c/j)}if(d<h){d=h;c=g(d*j)}}else{c=Math.max(p,Math.min(c,y));if(f.autoHeight&&f.type!=="iframe"){l.width(c);d=l.height()}d=Math.max(h,Math.min(d,x))}if(f.fitToView){l.width(c).height(d);o.width(c+O);P=o.width();H=o.height();if(f.aspectRatio){while((P>M||H>A)&&c>p&&d>h){if(t++>19){break}d=Math.max(h,Math.min(x,d-10));c=g(d*j);if(c<p){c=p;d=g(c/j)}if(c>y){c=y;d=g(c/j)}l.width(c).height(d);o.width(c+O);P=o.width();H=o.height()}}else{c=Math.max(p,Math.min(c,c-(P-M)));d=Math.max(h,Math.min(d,d-(H-A)))}}if(w&&v==="auto"&&d<L&&c+O+w<M){c+=w}l.width(c).height(d);o.width(c+O);P=o.width();H=o.height();n=(P>M||H>A)&&c>p&&d>h;a=f.aspectRatio?c<E&&d<R&&c<T&&d<L:(c<E||d<R)&&(c<T||d<L);i.extend(f,{dim:{width:m(P),height:m(H)},origWidth:T,origHeight:L,canShrink:n,canExpand:a,wPadding:O,hPadding:W,wrapSpace:H-r.outerHeight(true),skinSpace:r.height()-d});if(!I&&f.autoHeight&&d>h&&d<x&&!a){l.height("auto")}},_getPosition:function(e){var t=s.current,i=s.getViewport(),n=t.margin,a=s.wrap.width()+n[1]+n[3],o=s.wrap.height()+n[0]+n[2],r={position:"absolute",top:n[0],left:n[3]};if(t.autoCenter&&t.fixed&&!e&&o<=i.h&&a<=i.w){r.position="fixed"}else if(!t.locked){r.top+=i.y;r.left+=i.x}r.top=m(Math.max(r.top,r.top+(i.h-o)*t.topRatio));r.left=m(Math.max(r.left,r.left+(i.w-a)*t.leftRatio));return r},_afterZoomIn:function(){var e=s.current;if(!e){return}s.isOpen=s.isOpened=true;s.wrap.css("overflow","visible").addClass("fancybox-opened");s.update();if(e.closeClick||e.nextClick&&s.group.length>1){s.inner.css("cursor","pointer").bind("click.fb",function(t){if(!i(t.target).is("a")&&!i(t.target).parent().is("a")){t.preventDefault();s[e.closeClick?"close":"next"]()}})}if(e.closeBtn){i(e.tpl.closeBtn).appendTo(s.skin).bind("click.fb",function(e){e.preventDefault();s.close()})}if(e.arrows&&s.group.length>1){if(e.loop||e.index>0){i(e.tpl.prev).appendTo(s.outer).bind("click.fb",s.prev)}if(e.loop||e.index<s.group.length-1){i(e.tpl.next).appendTo(s.outer).bind("click.fb",s.next)}}s.trigger("afterShow");if(!e.loop&&e.index===e.group.length-1){s.play(false)}else if(s.opts.autoPlay&&!s.player.isActive){s.opts.autoPlay=false;s.play()}},_afterZoomOut:function(e){e=e||s.current;i(".fancybox-wrap").trigger("onReset").remove();i.extend(s,{group:{},opts:{},router:false,current:null,isActive:false,isOpened:false,isOpen:false,isClosing:false,wrap:null,skin:null,outer:null,inner:null});s.trigger("afterClose",e)}});s.transitions={getOrigPosition:function(){var e=s.current,t=e.element,i=e.orig,n={},a=50,o=50,r=e.hPadding,l=e.wPadding,f=s.getViewport();if(!i&&e.isDom&&t.is(":visible")){i=t.find("img:first");if(!i.length){i=t}}if(d(i)){n=i.offset();if(i.is("img")){a=i.outerWidth();o=i.outerHeight()}}else{n.top=f.y+(f.h-o)*e.topRatio;n.left=f.x+(f.w-a)*e.leftRatio}if(s.wrap.css("position")==="fixed"||e.locked){n.top-=f.y;n.left-=f.x}n={top:m(n.top-r*e.topRatio),left:m(n.left-l*e.leftRatio),width:m(a+l),height:m(o+r)};return n},step:function(e,t){var i,n,a,o=t.prop,r=s.current,l=r.wrapSpace,f=r.skinSpace;if(o==="width"||o==="height"){i=t.end===t.start?1:(e-t.start)/(t.end-t.start);if(s.isClosing){i=1-i}n=o==="width"?r.wPadding:r.hPadding;a=e-n;s.skin[o](g(o==="width"?a:a-l*i));s.inner[o](g(o==="width"?a:a-l*i-f*i))}},zoomIn:function(){var e=s.current,t=e.pos,n=e.openEffect,a=n==="elastic",o=i.extend({opacity:1},t);delete o.position;if(a){t=this.getOrigPosition();if(e.openOpacity){t.opacity=.1}}else if(n==="fade"){t.opacity=.1}s.wrap.css(t).animate(o,{duration:n==="none"?0:e.openSpeed,easing:e.openEasing,step:a?this.step:null,complete:s._afterZoomIn})},zoomOut:function(){var e=s.current,t=e.closeEffect,i=t==="elastic",n={opacity:.1};if(i){n=this.getOrigPosition();if(e.closeOpacity){n.opacity=.1}}s.wrap.animate(n,{duration:t==="none"?0:e.closeSpeed,easing:e.closeEasing,step:i?this.step:null,complete:s._afterZoomOut})},changeIn:function(){var e=s.current,t=e.nextEffect,i=e.pos,n={opacity:1},a=s.direction,o=200,r;i.opacity=.1;if(t==="elastic"){r=a==="down"||a==="up"?"top":"left";if(a==="down"||a==="right"){i[r]=m(g(i[r])-o);n[r]="+="+o+"px"}else{i[r]=m(g(i[r])+o);n[r]="-="+o+"px"}}if(t==="none"){s._afterZoomIn()}else{s.wrap.css(i).animate(n,{duration:e.nextSpeed,easing:e.nextEasing,complete:s._afterZoomIn})}},changeOut:function(){var e=s.previous,t=e.prevEffect,n={opacity:.1},a=s.direction,o=200;if(t==="elastic"){n[a==="down"||a==="up"?"top":"left"]=(a==="up"||a==="left"?"-":"+")+"="+o+"px"}e.wrap.animate(n,{duration:t==="none"?0:e.prevSpeed,easing:e.prevEasing,complete:function(){i(this).trigger("onReset").remove()}})}};s.helpers.overlay={defaults:{closeClick:true,speedOut:200,showEarly:true,css:{},locked:!c,fixed:true},overlay:null,fixed:false,el:i("html"),create:function(e){e=i.extend({},this.defaults,e);if(this.overlay){this.close()}this.overlay=i('<div class="fancybox-overlay"></div>').appendTo(s.coming?s.coming.parent:e.parent);this.fixed=false;if(e.fixed&&s.defaults.fixed){this.overlay.addClass("fancybox-overlay-fixed");this.fixed=true}},open:function(e){var t=this;e=i.extend({},this.defaults,e);if(this.overlay){this.overlay.unbind(".overlay").width("auto").height("auto")}else{this.create(e)}if(!this.fixed){o.bind("resize.overlay",i.proxy(this.update,this));this.update()}if(e.closeClick){this.overlay.bind("click.overlay",function(e){if(i(e.target).hasClass("fancybox-overlay")){if(s.isActive){s.close()}else{t.close()}return false}})}this.overlay.css(e.css).show()},close:function(){var e,t;o.unbind("resize.overlay");if(this.el.hasClass("fancybox-lock")){i(".fancybox-margin").removeClass("fancybox-margin");e=o.scrollTop();t=o.scrollLeft();this.el.removeClass("fancybox-lock");o.scrollTop(e).scrollLeft(t)}i(".fancybox-overlay").remove().hide();i.extend(this,{overlay:null,fixed:false})},update:function(){var e="100%",i;this.overlay.width(e).height("100%");if(l){i=Math.max(t.documentElement.offsetWidth,t.body.offsetWidth);if(r.width()>i){e=r.width()}}else if(r.width()>o.width()){e=r.width()}this.overlay.width(e).height(r.height())},onReady:function(e,t){var n=this.overlay;i(".fancybox-overlay").stop(true,true);if(!n){this.create(e)}if(e.locked&&this.fixed&&t.fixed){if(!n){this.margin=r.height()>o.height()?i("html").css("margin-right").replace("px",""):false}t.locked=this.overlay.append(t.wrap);t.fixed=false}if(e.showEarly===true){this.beforeShow.apply(this,arguments)}},beforeShow:function(e,t){var n,a;if(t.locked){if(this.margin!==false){i("*").filter(function(){return i(this).css("position")==="fixed"&&!i(this).hasClass("fancybox-overlay")&&!i(this).hasClass("fancybox-wrap")}).addClass("fancybox-margin");this.el.addClass("fancybox-margin")}n=o.scrollTop();a=o.scrollLeft();this.el.addClass("fancybox-lock");o.scrollTop(n).scrollLeft(a)}this.open(e)},onUpdate:function(){if(!this.fixed){this.update()}},afterClose:function(e){if(this.overlay&&!s.coming){this.overlay.fadeOut(e.speedOut,i.proxy(this.close,this))}}};s.helpers.title={defaults:{type:"float",position:"bottom"},beforeShow:function(e){var t=s.current,n=t.title,a=e.type,o,r;if(i.isFunction(n)){n=n.call(t.element,t)}if(!p(n)||i.trim(n)===""){return}o=i('<div class="fancybox-title fancybox-title-'+a+'-wrap">'+n+"</div>");switch(a){case"inside":r=s.skin;break;case"outside":r=s.wrap;break;case"over":r=s.inner;break;default:r=s.skin;o.appendTo("body");if(l){o.width(o.width())}o.wrapInner('<span class="child"></span>');s.current.margin[2]+=Math.abs(g(o.css("margin-bottom")));break}o[e.position==="top"?"prependTo":"appendTo"](r)}};i.fn.fancybox=function(e){var t,n=i(this),a=this.selector||"",o=function(o){var r=i(this).blur(),l=t,f,c;if(!(o.ctrlKey||o.altKey||o.shiftKey||o.metaKey)&&!r.is(".fancybox-wrap")){f=e.groupAttr||"data-fancybox-group";c=r.attr(f);if(!c){f="rel";c=r.get(0)[f]}if(c&&c!==""&&c!=="nofollow"){r=a.length?i(a):n;r=r.filter("["+f+'="'+c+'"]');l=r.index(this)}e.index=l;if(s.open(r,e)!==false){o.preventDefault()}}};e=e||{};t=e.index||0;if(!a||e.live===false){n.unbind("click.fb-start").bind("click.fb-start",o)}else{r.undelegate(a,"click.fb-start").delegate(a+":not('.fancybox-item, .fancybox-nav')","click.fb-start",o)}this.filter("[data-fancybox-start=1]").trigger("click");return this};r.ready(function(){var t,o;if(i.scrollbarWidth===n){i.scrollbarWidth=function(){var e=i('<div style="width:50px;height:50px;overflow:auto"><div/></div>').appendTo("body"),t=e.children(),n=t.innerWidth()-t.height(99).innerWidth();e.remove();return n}}if(i.support.fixedPosition===n){i.support.fixedPosition=function(){var e=i('<div style="position:fixed;top:20px;"></div>').appendTo("body"),t=e[0].offsetTop===20||e[0].offsetTop===15;e.remove();return t}()}i.extend(s.defaults,{scrollbarWidth:i.scrollbarWidth(),fixed:i.support.fixedPosition,parent:i("body")});t=i(e).width();a.addClass("fancybox-lock-test");o=i(e).width();a.removeClass("fancybox-lock-test");i("<style type='text/css'>.fancybox-margin{margin-right:"+(o-t)+"px;}</style>").appendTo("head")})})(window,document,jQuery);