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