Template:HarvardFancybox

From 2010.igem.org

(Difference between revisions)
Line 383: Line 383:
<script type="text/javascript">
<script type="text/javascript">
-
(function(b){var m,u,x,g,D,i,z,A,B,p=0,e={},q=[],n=0,c={},j=[],E=null,s=new Image,G=/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i,S=/[^\.]\.(swf)\s*$/i,H,I=1,k,l,h=false,y=b.extend(b("<div/>")[0],{prop:0}),v=0,O=!b.support.opacity&&!window.XMLHttpRequest,J=function(){u.hide();s.onerror=s.onload=null;E&&E.abort();m.empty()},P=function(){b.fancybox('<p id="fancybox_error">The requested content cannot be loaded.<br />Please try again later.</p>',{scrolling:"no",padding:20,transitionIn:"none",transitionOut:"none"})},
+
/*
-
K=function(){return[b(window).width(),b(window).height(),b(document).scrollLeft(),b(document).scrollTop()]},T=function(){var a=K(),d={},f=c.margin,o=c.autoScale,t=(20+f)*2,w=(20+f)*2,r=c.padding*2;if(c.width.toString().indexOf("%")>-1){d.width=a[0]*parseFloat(c.width)/100-40;o=false}else d.width=c.width+r;if(c.height.toString().indexOf("%")>-1){d.height=a[1]*parseFloat(c.height)/100-40;o=false}else d.height=c.height+r;if(o&&(d.width>a[0]-t||d.height>a[1]-w))if(e.type=="image"||e.type=="swf"){t+=r;
+
* FancyBox - jQuery Plugin
-
w+=r;o=Math.min(Math.min(a[0]-t,c.width)/c.width,Math.min(a[1]-w,c.height)/c.height);d.width=Math.round(o*(d.width-r))+r;d.height=Math.round(o*(d.height-r))+r}else{d.width=Math.min(d.width,a[0]-t);d.height=Math.min(d.height,a[1]-w)}d.top=a[3]+(a[1]-(d.height+40))*0.5;d.left=a[2]+(a[0]-(d.width+40))*0.5;if(c.autoScale===false){d.top=Math.max(a[3]+f,d.top);d.left=Math.max(a[2]+f,d.left)}return d},U=function(a){if(a&&a.length)switch(c.titlePosition){case "inside":return a;case "over":return'<span id="fancybox-title-over">'+
+
* Simple and fancy lightbox alternative
-
a+"</span>";default:return'<span id="fancybox-title-wrap"><span id="fancybox-title-left"></span><span id="fancybox-title-main">'+a+'</span><span id="fancybox-title-right"></span></span>'}return false},V=function(){var a=c.title,d=l.width-c.padding*2,f="fancybox-title-"+c.titlePosition;b("#fancybox-title").remove();v=0;if(c.titleShow!==false){a=b.isFunction(c.titleFormat)?c.titleFormat(a,j,n,c):U(a);if(!(!a||a==="")){b('<div id="fancybox-title" class="'+f+'" />').css({width:d,paddingLeft:c.padding,
+
*
-
paddingRight:c.padding}).html(a).appendTo("body");switch(c.titlePosition){case "inside":v=b("#fancybox-title").outerHeight(true)-c.padding;l.height+=v;break;case "over":b("#fancybox-title").css("bottom",c.padding);break;default:b("#fancybox-title").css("bottom",b("#fancybox-title").outerHeight(true)*-1);break}b("#fancybox-title").appendTo(D).hide()}}},W=function(){b(document).unbind("keydown.fb").bind("keydown.fb",function(a){if(a.keyCode==27&&c.enableEscapeButton){a.preventDefault();b.fancybox.close()}else if(a.keyCode==
+
* Examples and documentation at: http://fancybox.net
-
37){a.preventDefault();b.fancybox.prev()}else if(a.keyCode==39){a.preventDefault();b.fancybox.next()}});if(b.fn.mousewheel){g.unbind("mousewheel.fb");j.length>1&&g.bind("mousewheel.fb",function(a,d){a.preventDefault();h||d===0||(d>0?b.fancybox.prev():b.fancybox.next())})}if(c.showNavArrows){if(c.cyclic&&j.length>1||n!==0)A.show();if(c.cyclic&&j.length>1||n!=j.length-1)B.show()}},X=function(){var a,d;if(j.length-1>n){a=j[n+1].href;if(typeof a!=="undefined"&&a.match(G)){d=new Image;d.src=a}}if(n>0){a=
+
*
-
j[n-1].href;if(typeof a!=="undefined"&&a.match(G)){d=new Image;d.src=a}}},L=function(){i.css("overflow",c.scrolling=="auto"?c.type=="image"||c.type=="iframe"||c.type=="swf"?"hidden":"auto":c.scrolling=="yes"?"auto":"visible");if(!b.support.opacity){i.get(0).style.removeAttribute("filter");g.get(0).style.removeAttribute("filter")}b("#fancybox-title").show();c.hideOnContentClick&&i.one("click",b.fancybox.close);c.hideOnOverlayClick&&x.one("click",b.fancybox.close);c.showCloseButton&&z.show();W();b(window).bind("resize.fb",
+
* Copyright (c) 2008 - 2010 Janis Skarnelis
-
b.fancybox.center);c.centerOnScroll?b(window).bind("scroll.fb",b.fancybox.center):b(window).unbind("scroll.fb");b.isFunction(c.onComplete)&&c.onComplete(j,n,c);h=false;X()},M=function(a){var d=Math.round(k.width+(l.width-k.width)*a),f=Math.round(k.height+(l.height-k.height)*a),o=Math.round(k.top+(l.top-k.top)*a),t=Math.round(k.left+(l.left-k.left)*a);g.css({width:d+"px",height:f+"px",top:o+"px",left:t+"px"});d=Math.max(d-c.padding*2,0);f=Math.max(f-(c.padding*2+v*a),0);i.css({width:d+"px",height:f+
+
*
-
"px"});if(typeof l.opacity!=="undefined")g.css("opacity",a<0.5?0.5:a)},Y=function(a){var d=a.offset();d.top+=parseFloat(a.css("paddingTop"))||0;d.left+=parseFloat(a.css("paddingLeft"))||0;d.top+=parseFloat(a.css("border-top-width"))||0;d.left+=parseFloat(a.css("border-left-width"))||0;d.width=a.width();d.height=a.height();return d},Q=function(){var a=e.orig?b(e.orig):false,d={};if(a&&a.length){a=Y(a);d={width:a.width+c.padding*2,height:a.height+c.padding*2,top:a.top-c.padding-20,left:a.left-c.padding-
+
* Version: 1.3.1 (05/03/2010)
-
20}}else{a=K();d={width:1,height:1,top:a[3]+a[1]*0.5,left:a[2]+a[0]*0.5}}return d},N=function(){u.hide();if(g.is(":visible")&&b.isFunction(c.onCleanup))if(c.onCleanup(j,n,c)===false){b.event.trigger("fancybox-cancel");h=false;return}j=q;n=p;c=e;i.get(0).scrollTop=0;i.get(0).scrollLeft=0;if(c.overlayShow){O&&b("select:not(#fancybox-tmp select)").filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one("fancybox-cleanup",function(){this.style.visibility="inherit"});
+
* Requires: jQuery v1.3+
-
x.css({"background-color":c.overlayColor,opacity:c.overlayOpacity}).unbind().show()}l=T();V();if(g.is(":visible")){b(z.add(A).add(B)).hide();var a=g.position(),d;k={top:a.top,left:a.left,width:g.width(),height:g.height()};d=k.width==l.width&&k.height==l.height;i.fadeOut(c.changeFade,function(){var f=function(){i.html(m.contents()).fadeIn(c.changeFade,L)};b.event.trigger("fancybox-change");i.empty().css("overflow","hidden");if(d){i.css({top:c.padding,left:c.padding,width:Math.max(l.width-c.padding*
+
*
-
2,1),height:Math.max(l.height-c.padding*2-v,1)});f()}else{i.css({top:c.padding,left:c.padding,width:Math.max(k.width-c.padding*2,1),height:Math.max(k.height-c.padding*2,1)});y.prop=0;b(y).animate({prop:1},{duration:c.changeSpeed,easing:c.easingChange,step:M,complete:f})}})}else{g.css("opacity",1);if(c.transitionIn=="elastic"){k=Q();i.css({top:c.padding,left:c.padding,width:Math.max(k.width-c.padding*2,1),height:Math.max(k.height-c.padding*2,1)}).html(m.contents());g.css(k).show();if(c.opacity)l.opacity=
+
* Dual licensed under the MIT and GPL licenses:
-
0;y.prop=0;b(y).animate({prop:1},{duration:c.speedIn,easing:c.easingIn,step:M,complete:L})}else{i.css({top:c.padding,left:c.padding,width:Math.max(l.width-c.padding*2,1),height:Math.max(l.height-c.padding*2-v,1)}).html(m.contents());g.css(l).fadeIn(c.transitionIn=="none"?0:c.speedIn,L)}}},F=function(){m.width(e.width);m.height(e.height);if(e.width=="auto")e.width=m.width();if(e.height=="auto")e.height=m.height();N()},Z=function(){h=true;e.width=s.width;e.height=s.height;b("<img />").attr({id:"fancybox-img",
+
*  http://www.opensource.org/licenses/mit-license.php
-
src:s.src,alt:e.title}).appendTo(m);N()},C=function(){J();var a=q[p],d,f,o,t,w;e=b.extend({},b.fn.fancybox.defaults,typeof b(a).data("fancybox")=="undefined"?e:b(a).data("fancybox"));o=a.title||b(a).title||e.title||"";if(a.nodeName&&!e.orig)e.orig=b(a).children("img:first").length?b(a).children("img:first"):b(a);if(o===""&&e.orig)o=e.orig.attr("alt");d=a.nodeName&&/^(?:javascript|#)/i.test(a.href)?e.href||null:e.href||a.href||null;if(e.type){f=e.type;if(!d)d=e.content}else if(e.content)f="html";else if(d)if(d.match(G))f=
+
*  http://www.gnu.org/licenses/gpl.html
-
"image";else if(d.match(S))f="swf";else if(b(a).hasClass("iframe"))f="iframe";else if(d.match(/#/)){a=d.substr(d.indexOf("#"));f=b(a).length>0?"inline":"ajax"}else f="ajax";else f="inline";e.type=f;e.href=d;e.title=o;if(e.autoDimensions&&e.type!=="iframe"&&e.type!=="swf"){e.width="auto";e.height="auto"}if(e.modal){e.overlayShow=true;e.hideOnOverlayClick=false;e.hideOnContentClick=false;e.enableEscapeButton=false;e.showCloseButton=false}if(b.isFunction(e.onStart))if(e.onStart(q,p,e)===false){h=false;
+
*/
-
return}m.css("padding",20+e.padding+e.margin);b(".fancybox-inline-tmp").unbind("fancybox-cancel").bind("fancybox-change",function(){b(this).replaceWith(i.children())});switch(f){case "html":m.html(e.content);F();break;case "inline":b('<div class="fancybox-inline-tmp" />').hide().insertBefore(b(a)).bind("fancybox-cleanup",function(){b(this).replaceWith(i.children())}).bind("fancybox-cancel",function(){b(this).replaceWith(m.children())});b(a).appendTo(m);F();break;case "image":h=false;b.fancybox.showActivity();
+
 
-
s=new Image;s.onerror=function(){P()};s.onload=function(){s.onerror=null;s.onload=null;Z()};s.src=d;break;case "swf":t='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+e.width+'" height="'+e.height+'"><param name="movie" value="'+d+'"></param>';w="";b.each(e.swf,function(r,R){t+='<param name="'+r+'" value="'+R+'"></param>';w+=" "+r+'="'+R+'"'});t+='<embed src="'+d+'" type="application/x-shockwave-flash" width="'+e.width+'" height="'+e.height+'"'+w+"></embed></object>";m.html(t);
+
(function($) {
-
F();break;case "ajax":a=d.split("#",2);f=e.ajax.data||{};if(a.length>1){d=a[0];if(typeof f=="string")f+="&selector="+a[1];else f.selector=a[1]}h=false;b.fancybox.showActivity();E=b.ajax(b.extend(e.ajax,{url:d,data:f,error:P,success:function(r){if(E.status==200){m.html(r);F()}}}));break;case "iframe":b('<iframe id="fancybox-frame" name="fancybox-frame'+(new Date).getTime()+'" frameborder="0" hspace="0" scrolling="'+e.scrolling+'" src="'+e.href+'"></iframe>').appendTo(m);N();break}},$=function(){if(u.is(":visible")){b("div",
+
 
-
u).css("top",I*-40+"px");I=(I+1)%12}else clearInterval(H)},aa=function(){if(!b("#fancybox-wrap").length){b("body").append(m=b('<div id="fancybox-tmp"></div>'),u=b('<div id="fancybox-loading"><div></div></div>'),x=b('<div id="fancybox-overlay"></div>'),g=b('<div id="fancybox-wrap"></div>'));if(!b.support.opacity){g.addClass("fancybox-ie");u.addClass("fancybox-ie")}D=b('<div id="fancybox-outer"></div>').append('<div class="fancy-bg" id="fancy-bg-n"></div><div class="fancy-bg" id="fancy-bg-ne"></div><div class="fancy-bg" id="fancy-bg-e"></div><div class="fancy-bg" id="fancy-bg-se"></div><div class="fancy-bg" id="fancy-bg-s"></div><div class="fancy-bg" id="fancy-bg-sw"></div><div class="fancy-bg" id="fancy-bg-w"></div><div class="fancy-bg" id="fancy-bg-nw"></div>').appendTo(g);
+
var tmp, loading, overlay, wrap, outer, inner, close, nav_left, nav_right,
-
D.append(i=b('<div id="fancybox-inner"></div>'),z=b('<a id="fancybox-close"></a>'),A=b('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'),B=b('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>'));z.click(b.fancybox.close);u.click(b.fancybox.cancel);A.click(function(a){a.preventDefault();b.fancybox.prev()});B.click(function(a){a.preventDefault();b.fancybox.next()});if(O){x.get(0).style.setExpression("height",
+
 
-
"document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'");u.get(0).style.setExpression("top","(-20 + (document.documentElement.clientHeight ? document.documentElement.clientHeight/2 : document.body.clientHeight/2 ) + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop )) + 'px'");D.prepend('<iframe id="fancybox-hide-sel-frame" src="javascript:\'\';" scrolling="no" frameborder="0" ></iframe>')}}};
+
selectedIndex = 0, selectedOpts = {}, selectedArray = [], currentIndex = 0, currentOpts = {}, currentArray = [],
-
b.fn.fancybox=function(a){b(this).data("fancybox",b.extend({},a,b.metadata?b(this).metadata():{})).unbind("click.fb").bind("click.fb",function(d){d.preventDefault();if(!h){h=true;b(this).blur();q=[];p=0;d=b(this).attr("rel")||"";if(!d||d==""||d==="nofollow")q.push(this);else{q=b("a[rel="+d+"], area[rel="+d+"]");p=q.index(this)}C();return false}});return this};b.fancybox=function(a,d){if(!h){h=true;d=typeof d!=="undefined"?d:{};q=[];p=d.index||0;if(b.isArray(a)){for(var f=0,o=a.length;f<o;f++)if(typeof a[f]==
+
 
-
"object")b(a[f]).data("fancybox",b.extend({},d,a[f]));else a[f]=b({}).data("fancybox",b.extend({content:a[f]},d));q=jQuery.merge(q,a)}else{if(typeof a=="object")b(a).data("fancybox",b.extend({},d,a));else a=b({}).data("fancybox",b.extend({content:a},d));q.push(a)}if(p>q.length||p<0)p=0;C()}};b.fancybox.showActivity=function(){clearInterval(H);u.show();H=setInterval($,66)};b.fancybox.hideActivity=function(){u.hide()};b.fancybox.next=function(){return b.fancybox.pos(n+1)};b.fancybox.prev=function(){return b.fancybox.pos(n-
+
ajaxLoader = null, imgPreloader = new Image(), imgRegExp = /\.(jpg|gif|png|bmp|jpeg)(.*)?$/i, swfRegExp = /[^\.]\.(swf)\s*$/i,
-
1)};b.fancybox.pos=function(a){if(!h){a=parseInt(a,10);if(a>-1&&j.length>a){p=a;C()}if(c.cyclic&&j.length>1&&a<0){p=j.length-1;C()}if(c.cyclic&&j.length>1&&a>=j.length){p=0;C()}}};b.fancybox.cancel=function(){if(!h){h=true;b.event.trigger("fancybox-cancel");J();e&&b.isFunction(e.onCancel)&&e.onCancel(q,p,e);h=false}};b.fancybox.close=function(){function a(){x.fadeOut("fast");g.hide();b.event.trigger("fancybox-cleanup");i.empty();b.isFunction(c.onClosed)&&c.onClosed(j,n,c);j=e=[];n=p=0;c=e={};h=false}
+
 
-
if(!(h||g.is(":hidden"))){h=true;if(c&&b.isFunction(c.onCleanup))if(c.onCleanup(j,n,c)===false){h=false;return}J();b(z.add(A).add(B)).hide();b("#fancybox-title").remove();g.add(i).add(x).unbind();b(window).unbind("resize.fb scroll.fb");b(document).unbind("keydown.fb");i.css("overflow","hidden");if(c.transitionOut=="elastic"){k=Q();var d=g.position();l={top:d.top,left:d.left,width:g.width(),height:g.height()};if(c.opacity)l.opacity=1;y.prop=1;b(y).animate({prop:0},{duration:c.speedOut,easing:c.easingOut,
+
loadingTimer, loadingFrame = 1,
-
step:M,complete:a})}else g.fadeOut(c.transitionOut=="none"?0:c.speedOut,a)}};b.fancybox.resize=function(){var a,d;if(!(h||g.is(":hidden"))){h=true;a=i.wrapInner("<div style='overflow:auto'></div>").children();d=a.height();g.css({height:d+c.padding*2+v});i.css({height:d});a.replaceWith(a.children());b.fancybox.center()}};b.fancybox.center=function(){h=true;var a=K(),d=c.margin,f={};f.top=a[3]+(a[1]-(g.height()-v+40))*0.5;f.left=a[2]+(a[0]-(g.width()+40))*0.5;f.top=Math.max(a[3]+d,f.top);f.left=Math.max(a[2]+
+
 
-
d,f.left);g.css(f);h=false};b.fn.fancybox.defaults={padding:10,margin:20,opacity:false,modal:false,cyclic:false,scrolling:"auto",width:560,height:340,autoScale:true,autoDimensions:true,centerOnScroll:false,ajax:{},swf:{wmode:"transparent"},hideOnOverlayClick:true,hideOnContentClick:false,overlayShow:true,overlayOpacity:0.3,overlayColor:"#666",titleShow:true,titlePosition:"outside",titleFormat:null,transitionIn:"fade",transitionOut:"fade",speedIn:300,speedOut:300,changeSpeed:300,changeFade:"fast",
+
start_pos, final_pos, busy = false, shadow = 20, fx = $.extend($('<div/>')[0], { prop: 0 }), titleh = 0,  
-
easingIn:"swing",easingOut:"swing",showCloseButton:true,showNavArrows:true,enableEscapeButton:true,onStart:null,onCancel:null,onComplete:null,onCleanup:null,onClosed:null};b(document).ready(function(){aa()})})(jQuery);
+
 
 +
isIE6 = !$.support.opacity && !window.XMLHttpRequest,
 +
 
 +
/*
 +
* Private methods
 +
*/
 +
 
 +
fancybox_abort = function() {
 +
loading.hide();
 +
 
 +
imgPreloader.onerror = imgPreloader.onload = null;
 +
 
 +
if (ajaxLoader) {
 +
ajaxLoader.abort();
 +
}
 +
 
 +
tmp.empty();
 +
},
 +
 
 +
fancybox_error = function() {
 +
$.fancybox('<p id="fancybox_error">The requested content cannot be loaded.<br />Please try again later.</p>', {
 +
'scrolling' : 'no',
 +
'padding' : 20,
 +
'transitionIn' : 'none',
 +
'transitionOut' : 'none'
 +
});
 +
},
 +
 
 +
fancybox_get_viewport = function() {
 +
return [ $(window).width(), $(window).height(), $(document).scrollLeft(), $(document).scrollTop() ];
 +
},
 +
 
 +
fancybox_get_zoom_to = function () {
 +
var view = fancybox_get_viewport(),
 +
to = {},
 +
 
 +
margin = currentOpts.margin,
 +
resize = currentOpts.autoScale,
 +
 
 +
horizontal_space = (shadow + margin) * 2,
 +
vertical_space = (shadow + margin) * 2,
 +
double_padding = (currentOpts.padding * 2),
 +
 +
ratio;
 +
 
 +
if (currentOpts.width.toString().indexOf('%') > -1) {
 +
to.width = ((view[0] * parseFloat(currentOpts.width)) / 100) - (shadow * 2) ;
 +
resize = false;
 +
 
 +
} else {
 +
to.width = currentOpts.width + double_padding;
 +
}
 +
 
 +
if (currentOpts.height.toString().indexOf('%') > -1) {
 +
to.height = ((view[1] * parseFloat(currentOpts.height)) / 100) - (shadow * 2);
 +
resize = false;
 +
 
 +
} else {
 +
to.height = currentOpts.height + double_padding;
 +
}
 +
 
 +
if (resize && (to.width > (view[0] - horizontal_space) || to.height > (view[1] - vertical_space))) {
 +
if (selectedOpts.type == 'image' || selectedOpts.type == 'swf') {
 +
horizontal_space += double_padding;
 +
vertical_space += double_padding;
 +
 
 +
ratio = Math.min(Math.min( view[0] - horizontal_space, currentOpts.width) / currentOpts.width, Math.min( view[1] - vertical_space, currentOpts.height) / currentOpts.height);
 +
 
 +
to.width = Math.round(ratio * (to.width - double_padding)) + double_padding;
 +
to.height = Math.round(ratio * (to.height - double_padding)) + double_padding;
 +
 
 +
} else {
 +
to.width = Math.min(to.width, (view[0] - horizontal_space));
 +
to.height = Math.min(to.height, (view[1] - vertical_space));
 +
}
 +
}
 +
 
 +
to.top = view[3] + ((view[1] - (to.height + (shadow * 2 ))) * 0.5);
 +
to.left = view[2] + ((view[0] - (to.width + (shadow * 2 ))) * 0.5);
 +
 
 +
if (currentOpts.autoScale === false) {
 +
to.top = Math.max(view[3] + margin, to.top);
 +
to.left = Math.max(view[2] + margin, to.left);
 +
}
 +
 
 +
return to;
 +
},
 +
 
 +
fancybox_format_title = function(title) {
 +
if (title && title.length) {
 +
switch (currentOpts.titlePosition) {
 +
case 'inside':
 +
return title;
 +
case 'over':
 +
return '<span id="fancybox-title-over">' + title + '</span>';
 +
default:
 +
return '<span id="fancybox-title-wrap"><span id="fancybox-title-left"></span><span id="fancybox-title-main">' + title + '</span><span id="fancybox-title-right"></span></span>';
 +
}
 +
}
 +
 
 +
return false;
 +
},
 +
 
 +
fancybox_process_title = function() {
 +
var title = currentOpts.title,
 +
width = final_pos.width - (currentOpts.padding * 2),
 +
titlec = 'fancybox-title-' + currentOpts.titlePosition;
 +
 +
$('#fancybox-title').remove();
 +
 
 +
titleh = 0;
 +
 
 +
if (currentOpts.titleShow === false) {
 +
return;
 +
}
 +
 
 +
title = $.isFunction(currentOpts.titleFormat) ? currentOpts.titleFormat(title, currentArray, currentIndex, currentOpts) : fancybox_format_title(title);
 +
 
 +
if (!title || title === '') {
 +
return;
 +
}
 +
 
 +
$('<div id="fancybox-title" class="' + titlec + '" />').css({
 +
'width' : width,
 +
'paddingLeft' : currentOpts.padding,
 +
'paddingRight' : currentOpts.padding
 +
}).html(title).appendTo('body');
 +
 
 +
switch (currentOpts.titlePosition) {
 +
case 'inside':
 +
titleh = $("#fancybox-title").outerHeight(true) - currentOpts.padding;
 +
final_pos.height += titleh;
 +
break;
 +
 
 +
case 'over':
 +
$('#fancybox-title').css('bottom', currentOpts.padding);
 +
break;
 +
 
 +
default:
 +
$('#fancybox-title').css('bottom', $("#fancybox-title").outerHeight(true) * -1);
 +
break;
 +
}
 +
 
 +
$('#fancybox-title').appendTo( outer ).hide();
 +
},
 +
 
 +
fancybox_set_navigation = function() {
 +
$(document).unbind('keydown.fb').bind('keydown.fb', function(e) {
 +
if (e.keyCode == 27 && currentOpts.enableEscapeButton) {
 +
e.preventDefault();
 +
$.fancybox.close();
 +
 
 +
} else if (e.keyCode == 37) {
 +
e.preventDefault();
 +
$.fancybox.prev();
 +
 
 +
} else if (e.keyCode == 39) {
 +
e.preventDefault();
 +
$.fancybox.next();
 +
}
 +
});
 +
 
 +
if ($.fn.mousewheel) {
 +
wrap.unbind('mousewheel.fb');
 +
 
 +
if (currentArray.length > 1) {
 +
wrap.bind('mousewheel.fb', function(e, delta) {
 +
e.preventDefault();
 +
 
 +
if (busy || delta === 0) {
 +
return;
 +
}
 +
 
 +
if (delta > 0) {
 +
$.fancybox.prev();
 +
} else {
 +
$.fancybox.next();
 +
}
 +
});
 +
}
 +
}
 +
 
 +
if (!currentOpts.showNavArrows) { return; }
 +
 
 +
if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex !== 0) {
 +
nav_left.show();
 +
}
 +
 
 +
if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex != (currentArray.length -1)) {
 +
nav_right.show();
 +
}
 +
},
 +
 
 +
fancybox_preload_images = function() {
 +
var href,  
 +
objNext;
 +
 +
if ((currentArray.length -1) > currentIndex) {
 +
href = currentArray[ currentIndex + 1 ].href;
 +
 
 +
if (typeof href !== 'undefined' && href.match(imgRegExp)) {
 +
objNext = new Image();
 +
objNext.src = href;
 +
}
 +
}
 +
 
 +
if (currentIndex > 0) {
 +
href = currentArray[ currentIndex - 1 ].href;
 +
 
 +
if (typeof href !== 'undefined' && href.match(imgRegExp)) {
 +
objNext = new Image();
 +
objNext.src = href;
 +
}
 +
}
 +
},
 +
 
 +
_finish = function () {
 +
inner.css('overflow', (currentOpts.scrolling == 'auto' ? (currentOpts.type == 'image' || currentOpts.type == 'iframe' || currentOpts.type == 'swf' ? 'hidden' : 'auto') : (currentOpts.scrolling == 'yes' ? 'auto' : 'visible')));
 +
 
 +
if (!$.support.opacity) {
 +
inner.get(0).style.removeAttribute('filter');
 +
wrap.get(0).style.removeAttribute('filter');
 +
}
 +
 
 +
$('#fancybox-title').show();
 +
 
 +
if (currentOpts.hideOnContentClick) {
 +
inner.one('click', $.fancybox.close);
 +
}
 +
if (currentOpts.hideOnOverlayClick) {
 +
overlay.one('click', $.fancybox.close);
 +
}
 +
 
 +
if (currentOpts.showCloseButton) {
 +
close.show();
 +
}
 +
 
 +
fancybox_set_navigation();
 +
 
 +
$(window).bind("resize.fb", $.fancybox.center);
 +
 
 +
if (currentOpts.centerOnScroll) {
 +
$(window).bind("scroll.fb", $.fancybox.center);
 +
} else {
 +
$(window).unbind("scroll.fb");
 +
}
 +
 
 +
if ($.isFunction(currentOpts.onComplete)) {
 +
currentOpts.onComplete(currentArray, currentIndex, currentOpts);
 +
}
 +
 
 +
busy = false;
 +
 
 +
fancybox_preload_images();
 +
},
 +
 
 +
fancybox_draw = function(pos) {
 +
var width = Math.round(start_pos.width + (final_pos.width - start_pos.width) * pos),
 +
height = Math.round(start_pos.height + (final_pos.height - start_pos.height) * pos),
 +
 
 +
top = Math.round(start_pos.top + (final_pos.top - start_pos.top) * pos),
 +
left = Math.round(start_pos.left + (final_pos.left - start_pos.left) * pos);
 +
 
 +
wrap.css({
 +
'width' : width + 'px',
 +
'height' : height + 'px',
 +
'top' : top + 'px',
 +
'left' : left + 'px'
 +
});
 +
 
 +
width = Math.max(width - currentOpts.padding * 2, 0);
 +
height = Math.max(height - (currentOpts.padding * 2 + (titleh * pos)), 0);
 +
 
 +
inner.css({
 +
'width' : width + 'px',
 +
'height' : height + 'px'
 +
});
 +
 
 +
if (typeof final_pos.opacity !== 'undefined') {
 +
wrap.css('opacity', (pos < 0.5 ? 0.5 : pos));
 +
}
 +
},
 +
 
 +
fancybox_get_obj_pos = function(obj) {
 +
var pos = obj.offset();
 +
 
 +
pos.top += parseFloat( obj.css('paddingTop') ) || 0;
 +
pos.left += parseFloat( obj.css('paddingLeft') ) || 0;
 +
 
 +
pos.top += parseFloat( obj.css('border-top-width') ) || 0;
 +
pos.left += parseFloat( obj.css('border-left-width') ) || 0;
 +
 
 +
pos.width = obj.width();
 +
pos.height = obj.height();
 +
 
 +
return pos;
 +
},
 +
 
 +
fancybox_get_zoom_from = function() {
 +
var orig = selectedOpts.orig ? $(selectedOpts.orig) : false,
 +
from = {},
 +
pos,
 +
view;
 +
 
 +
if (orig && orig.length) {
 +
pos = fancybox_get_obj_pos(orig);
 +
 
 +
from = {
 +
width : (pos.width + (currentOpts.padding * 2)),
 +
height : (pos.height + (currentOpts.padding * 2)),
 +
top : (pos.top - currentOpts.padding - shadow),
 +
left : (pos.left - currentOpts.padding - shadow)
 +
};
 +
 +
} else {
 +
view = fancybox_get_viewport();
 +
 
 +
from = {
 +
width : 1,
 +
height : 1,
 +
top : view[3] + view[1] * 0.5,
 +
left : view[2] + view[0] * 0.5
 +
};
 +
}
 +
 
 +
return from;
 +
},
 +
 
 +
fancybox_show = function() {
 +
loading.hide();
 +
 
 +
if (wrap.is(":visible") && $.isFunction(currentOpts.onCleanup)) {
 +
if (currentOpts.onCleanup(currentArray, currentIndex, currentOpts) === false) {
 +
$.event.trigger('fancybox-cancel');
 +
 
 +
busy = false;
 +
return;
 +
}
 +
}
 +
 
 +
currentArray = selectedArray;
 +
currentIndex = selectedIndex;
 +
currentOpts = selectedOpts;
 +
 
 +
inner.get(0).scrollTop = 0;
 +
inner.get(0).scrollLeft = 0;
 +
 
 +
if (currentOpts.overlayShow) {
 +
if (isIE6) {
 +
$('select:not(#fancybox-tmp select)').filter(function() {
 +
return this.style.visibility !== 'hidden';
 +
}).css({'visibility':'hidden'}).one('fancybox-cleanup', function() {
 +
this.style.visibility = 'inherit';
 +
});
 +
}
 +
 
 +
overlay.css({
 +
'background-color' : currentOpts.overlayColor,
 +
'opacity' : currentOpts.overlayOpacity
 +
}).unbind().show();
 +
}
 +
 
 +
final_pos = fancybox_get_zoom_to();
 +
 
 +
fancybox_process_title();
 +
 
 +
if (wrap.is(":visible")) {
 +
$( close.add( nav_left ).add( nav_right ) ).hide();
 +
 
 +
var pos = wrap.position(),
 +
equal;
 +
 
 +
start_pos = {
 +
top : pos.top ,
 +
left : pos.left,
 +
width : wrap.width(),
 +
height : wrap.height()
 +
};
 +
 
 +
equal = (start_pos.width == final_pos.width && start_pos.height == final_pos.height);
 +
 
 +
inner.fadeOut(currentOpts.changeFade, function() {
 +
var finish_resizing = function() {
 +
inner.html( tmp.contents() ).fadeIn(currentOpts.changeFade, _finish);
 +
};
 +
 +
$.event.trigger('fancybox-change');
 +
 
 +
inner.empty().css('overflow', 'hidden');
 +
 
 +
if (equal) {
 +
inner.css({
 +
top : currentOpts.padding,
 +
left : currentOpts.padding,
 +
width : Math.max(final_pos.width - (currentOpts.padding * 2), 1),
 +
height : Math.max(final_pos.height - (currentOpts.padding * 2) - titleh, 1)
 +
});
 +
 +
finish_resizing();
 +
 
 +
} else {
 +
inner.css({
 +
top : currentOpts.padding,
 +
left : currentOpts.padding,
 +
width : Math.max(start_pos.width - (currentOpts.padding * 2), 1),
 +
height : Math.max(start_pos.height - (currentOpts.padding * 2), 1)
 +
});
 +
 +
fx.prop = 0;
 +
 
 +
$(fx).animate({ prop: 1 }, {
 +
duration : currentOpts.changeSpeed,
 +
easing : currentOpts.easingChange,
 +
step : fancybox_draw,
 +
complete : finish_resizing
 +
});
 +
}
 +
});
 +
 
 +
return;
 +
}
 +
 
 +
wrap.css('opacity', 1);
 +
 
 +
if (currentOpts.transitionIn == 'elastic') {
 +
start_pos = fancybox_get_zoom_from();
 +
 
 +
inner.css({
 +
top : currentOpts.padding,
 +
left : currentOpts.padding,
 +
width : Math.max(start_pos.width - (currentOpts.padding * 2), 1),
 +
height : Math.max(start_pos.height - (currentOpts.padding * 2), 1)
 +
})
 +
.html( tmp.contents() );
 +
 
 +
wrap.css(start_pos).show();
 +
 
 +
if (currentOpts.opacity) {
 +
final_pos.opacity = 0;
 +
}
 +
 
 +
fx.prop = 0;
 +
 
 +
$(fx).animate({ prop: 1 }, {
 +
duration : currentOpts.speedIn,
 +
easing : currentOpts.easingIn,
 +
step : fancybox_draw,
 +
complete : _finish
 +
});
 +
 
 +
} else {
 +
inner.css({
 +
top : currentOpts.padding,
 +
left : currentOpts.padding,
 +
width : Math.max(final_pos.width - (currentOpts.padding * 2), 1),
 +
height : Math.max(final_pos.height - (currentOpts.padding * 2) - titleh, 1)
 +
})
 +
.html( tmp.contents() );
 +
 
 +
wrap.css( final_pos ).fadeIn( currentOpts.transitionIn == 'none' ? 0 : currentOpts.speedIn, _finish );
 +
}
 +
},
 +
 
 +
fancybox_process_inline = function() {
 +
tmp.width( selectedOpts.width );
 +
tmp.height( selectedOpts.height );
 +
 
 +
if (selectedOpts.width == 'auto') {
 +
selectedOpts.width = tmp.width();
 +
}
 +
if (selectedOpts.height == 'auto') {
 +
selectedOpts.height = tmp.height();
 +
}
 +
 
 +
fancybox_show();
 +
},
 +
 +
fancybox_process_image = function() {
 +
busy = true;
 +
 
 +
selectedOpts.width = imgPreloader.width;
 +
selectedOpts.height = imgPreloader.height;
 +
 
 +
$("<img />").attr({
 +
'id' : 'fancybox-img',
 +
'src' : imgPreloader.src,
 +
'alt' : selectedOpts.title
 +
}).appendTo( tmp );
 +
 
 +
fancybox_show();
 +
},
 +
 
 +
fancybox_start = function() {
 +
fancybox_abort();
 +
 
 +
var obj = selectedArray[ selectedIndex ],
 +
href,  
 +
type,  
 +
title,
 +
str,
 +
emb,
 +
selector,
 +
data;
 +
 
 +
selectedOpts = $.extend({}, $.fn.fancybox.defaults, (typeof $(obj).data('fancybox') == 'undefined' ? selectedOpts : $(obj).data('fancybox')));
 +
title = obj.title || $(obj).title || selectedOpts.title || '';
 +
 +
if (obj.nodeName && !selectedOpts.orig) {
 +
selectedOpts.orig = $(obj).children("img:first").length ? $(obj).children("img:first") : $(obj);
 +
}
 +
 
 +
if (title === '' && selectedOpts.orig) {
 +
title = selectedOpts.orig.attr('alt');
 +
}
 +
 
 +
if (obj.nodeName && (/^(?:javascript|#)/i).test(obj.href)) {
 +
href = selectedOpts.href || null;
 +
} else {
 +
href = selectedOpts.href || obj.href || null;
 +
}
 +
 
 +
if (selectedOpts.type) {
 +
type = selectedOpts.type;
 +
 
 +
if (!href) {
 +
href = selectedOpts.content;
 +
}
 +
 +
} else if (selectedOpts.content) {
 +
type = 'html';
 +
 
 +
} else if (href) {
 +
if (href.match(imgRegExp)) {
 +
type = 'image';
 +
 
 +
} else if (href.match(swfRegExp)) {
 +
type = 'swf';
 +
 
 +
} else if ($(obj).hasClass("iframe")) {
 +
type = 'iframe';
 +
 
 +
} else if (href.match(/#/)) {
 +
obj = href.substr(href.indexOf("#"));
 +
 
 +
type = $(obj).length > 0 ? 'inline' : 'ajax';
 +
} else {
 +
type = 'ajax';
 +
}
 +
} else {
 +
type = 'inline';
 +
}
 +
 
 +
selectedOpts.type = type;
 +
selectedOpts.href = href;
 +
selectedOpts.title = title;
 +
 
 +
if (selectedOpts.autoDimensions && selectedOpts.type !== 'iframe' && selectedOpts.type !== 'swf') {
 +
selectedOpts.width = 'auto';
 +
selectedOpts.height = 'auto';
 +
}
 +
 
 +
if (selectedOpts.modal) {
 +
selectedOpts.overlayShow = true;
 +
selectedOpts.hideOnOverlayClick = false;
 +
selectedOpts.hideOnContentClick = false;
 +
selectedOpts.enableEscapeButton = false;
 +
selectedOpts.showCloseButton = false;
 +
}
 +
 
 +
if ($.isFunction(selectedOpts.onStart)) {
 +
if (selectedOpts.onStart(selectedArray, selectedIndex, selectedOpts) === false) {
 +
busy = false;
 +
return;
 +
}
 +
}
 +
 
 +
tmp.css('padding', (shadow + selectedOpts.padding + selectedOpts.margin));
 +
 
 +
$('.fancybox-inline-tmp').unbind('fancybox-cancel').bind('fancybox-change', function() {
 +
$(this).replaceWith(inner.children());
 +
});
 +
 
 +
switch (type) {
 +
case 'html' :
 +
tmp.html( selectedOpts.content );
 +
fancybox_process_inline();
 +
break;
 +
 
 +
case 'inline' :
 +
$('<div class="fancybox-inline-tmp" />').hide().insertBefore( $(obj) ).bind('fancybox-cleanup', function() {
 +
$(this).replaceWith(inner.children());
 +
}).bind('fancybox-cancel', function() {
 +
$(this).replaceWith(tmp.children());
 +
});
 +
 
 +
$(obj).appendTo(tmp);
 +
 
 +
fancybox_process_inline();
 +
break;
 +
 
 +
case 'image':
 +
busy = false;
 +
 
 +
$.fancybox.showActivity();
 +
 
 +
imgPreloader = new Image();
 +
 
 +
imgPreloader.onerror = function() {
 +
fancybox_error();
 +
};
 +
 
 +
imgPreloader.onload = function() {
 +
imgPreloader.onerror = null;
 +
imgPreloader.onload = null;
 +
fancybox_process_image();
 +
};
 +
 
 +
imgPreloader.src = href;
 +
 +
break;
 +
 
 +
case 'swf':
 +
str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"><param name="movie" value="' + href + '"></param>';
 +
emb = '';
 +
 +
$.each(selectedOpts.swf, function(name, val) {
 +
str += '<param name="' + name + '" value="' + val + '"></param>';
 +
emb += ' ' + name + '="' + val + '"';
 +
});
 +
 
 +
str += '<embed src="' + href + '" type="application/x-shockwave-flash" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"' + emb + '></embed></object>';
 +
 
 +
tmp.html(str);
 +
 
 +
fancybox_process_inline();
 +
break;
 +
 
 +
case 'ajax':
 +
selector = href.split('#', 2);
 +
data = selectedOpts.ajax.data || {};
 +
 
 +
if (selector.length > 1) {
 +
href = selector[0];
 +
 
 +
if (typeof data == "string") {
 +
data += '&selector=' + selector[1];
 +
} else {
 +
data.selector = selector[1];
 +
}
 +
}
 +
 
 +
busy = false;
 +
$.fancybox.showActivity();
 +
 
 +
ajaxLoader = $.ajax($.extend(selectedOpts.ajax, {
 +
url : href,
 +
data : data,
 +
error : fancybox_error,
 +
success : function(data, textStatus, XMLHttpRequest) {
 +
if (ajaxLoader.status == 200) {
 +
tmp.html( data );
 +
fancybox_process_inline();
 +
}
 +
}
 +
}));
 +
 
 +
break;
 +
 
 +
case 'iframe' :
 +
$('<iframe id="fancybox-frame" name="fancybox-frame' + new Date().getTime() + '" frameborder="0" hspace="0" scrolling="' + selectedOpts.scrolling + '" src="' + selectedOpts.href + '"></iframe>').appendTo(tmp);
 +
fancybox_show();
 +
break;
 +
}
 +
},
 +
 
 +
fancybox_animate_loading = function() {
 +
if (!loading.is(':visible')){
 +
clearInterval(loadingTimer);
 +
return;
 +
}
 +
 
 +
$('div', loading).css('top', (loadingFrame * -40) + 'px');
 +
 
 +
loadingFrame = (loadingFrame + 1) % 12;
 +
},
 +
 
 +
fancybox_init = function() {
 +
if ($("#fancybox-wrap").length) {
 +
return;
 +
}
 +
 
 +
$('body').append(
 +
tmp = $('<div id="fancybox-tmp"></div>'),
 +
loading = $('<div id="fancybox-loading"><div></div></div>'),
 +
overlay = $('<div id="fancybox-overlay"></div>'),
 +
wrap = $('<div id="fancybox-wrap"></div>')
 +
);
 +
 
 +
if (!$.support.opacity) {
 +
wrap.addClass('fancybox-ie');
 +
loading.addClass('fancybox-ie');
 +
}
 +
 
 +
outer = $('<div id="fancybox-outer"></div>')
 +
.append('<div class="fancy-bg" id="fancy-bg-n"></div><div class="fancy-bg" id="fancy-bg-ne"></div><div class="fancy-bg" id="fancy-bg-e"></div><div class="fancy-bg" id="fancy-bg-se"></div><div class="fancy-bg" id="fancy-bg-s"></div><div class="fancy-bg" id="fancy-bg-sw"></div><div class="fancy-bg" id="fancy-bg-w"></div><div class="fancy-bg" id="fancy-bg-nw"></div>')
 +
.appendTo( wrap );
 +
 
 +
outer.append(
 +
inner = $('<div id="fancybox-inner"></div>'),
 +
close = $('<a id="fancybox-close"></a>'),
 +
 
 +
nav_left = $('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'),
 +
nav_right = $('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>')
 +
);
 +
 
 +
close.click($.fancybox.close);
 +
loading.click($.fancybox.cancel);
 +
 
 +
nav_left.click(function(e) {
 +
e.preventDefault();
 +
$.fancybox.prev();
 +
});
 +
 
 +
nav_right.click(function(e) {
 +
e.preventDefault();
 +
$.fancybox.next();
 +
});
 +
 
 +
if (isIE6) {
 +
overlay.get(0).style.setExpression('height', "document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'");
 +
loading.get(0).style.setExpression('top', "(-20 + (document.documentElement.clientHeight ? document.documentElement.clientHeight/2 : document.body.clientHeight/2 ) + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop )) + 'px'");
 +
 
 +
outer.prepend('<iframe id="fancybox-hide-sel-frame" src="javascript:\'\';" scrolling="no" frameborder="0" ></iframe>');
 +
}
 +
};
 +
 
 +
/*
 +
* Public methods
 +
*/
 +
 
 +
$.fn.fancybox = function(options) {
 +
$(this)
 +
.data('fancybox', $.extend({}, options, ($.metadata ? $(this).metadata() : {})))
 +
.unbind('click.fb').bind('click.fb', function(e) {
 +
e.preventDefault();
 +
 
 +
if (busy) {
 +
return;
 +
}
 +
 
 +
busy = true;
 +
 
 +
$(this).blur();
 +
 
 +
selectedArray = [];
 +
selectedIndex = 0;
 +
 
 +
var rel = $(this).attr('rel') || '';
 +
 
 +
if (!rel || rel == '' || rel === 'nofollow') {
 +
selectedArray.push(this);
 +
 
 +
} else {
 +
selectedArray = $("a[rel=" + rel + "], area[rel=" + rel + "]");
 +
selectedIndex = selectedArray.index( this );
 +
}
 +
 
 +
fancybox_start();
 +
 
 +
return false;
 +
});
 +
 
 +
return this;
 +
};
 +
 
 +
$.fancybox = function(obj) {
 +
if (busy) {
 +
return;
 +
}
 +
 
 +
busy = true;
 +
 
 +
var opts = typeof arguments[1] !== 'undefined' ? arguments[1] : {};
 +
 
 +
selectedArray = [];
 +
selectedIndex = opts.index || 0;
 +
 
 +
if ($.isArray(obj)) {
 +
for (var i = 0, j = obj.length; i < j; i++) {
 +
if (typeof obj[i] == 'object') {
 +
$(obj[i]).data('fancybox', $.extend({}, opts, obj[i]));
 +
} else {
 +
obj[i] = $({}).data('fancybox', $.extend({content : obj[i]}, opts));
 +
}
 +
}
 +
 
 +
selectedArray = jQuery.merge(selectedArray, obj);
 +
 
 +
} else {
 +
if (typeof obj == 'object') {
 +
$(obj).data('fancybox', $.extend({}, opts, obj));
 +
} else {
 +
obj = $({}).data('fancybox', $.extend({content : obj}, opts));
 +
}
 +
 
 +
selectedArray.push(obj);
 +
}
 +
 
 +
if (selectedIndex > selectedArray.length || selectedIndex < 0) {
 +
selectedIndex = 0;
 +
}
 +
 
 +
fancybox_start();
 +
};
 +
 
 +
$.fancybox.showActivity = function() {
 +
clearInterval(loadingTimer);
 +
 
 +
loading.show();
 +
loadingTimer = setInterval(fancybox_animate_loading, 66);
 +
};
 +
 
 +
$.fancybox.hideActivity = function() {
 +
loading.hide();
 +
};
 +
 
 +
$.fancybox.next = function() {
 +
return $.fancybox.pos( currentIndex + 1);
 +
};
 +
 +
$.fancybox.prev = function() {
 +
return $.fancybox.pos( currentIndex - 1);
 +
};
 +
 
 +
$.fancybox.pos = function(pos) {
 +
if (busy) {
 +
return;
 +
}
 +
 
 +
pos = parseInt(pos, 10);
 +
 
 +
if (pos > -1 && currentArray.length > pos) {
 +
selectedIndex = pos;
 +
fancybox_start();
 +
}
 +
 
 +
if (currentOpts.cyclic && currentArray.length > 1 && pos < 0) {
 +
selectedIndex = currentArray.length - 1;
 +
fancybox_start();
 +
}
 +
 
 +
if (currentOpts.cyclic && currentArray.length > 1 && pos >= currentArray.length) {
 +
selectedIndex = 0;
 +
fancybox_start();
 +
}
 +
 
 +
return;
 +
};
 +
 
 +
$.fancybox.cancel = function() {
 +
if (busy) {
 +
return;
 +
}
 +
 
 +
busy = true;
 +
 
 +
$.event.trigger('fancybox-cancel');
 +
 
 +
fancybox_abort();
 +
 
 +
if (selectedOpts && $.isFunction(selectedOpts.onCancel)) {
 +
selectedOpts.onCancel(selectedArray, selectedIndex, selectedOpts);
 +
}
 +
 
 +
busy = false;
 +
};
 +
 
 +
// Note: within an iframe use - parent.$.fancybox.close();
 +
$.fancybox.close = function() {
 +
if (busy || wrap.is(':hidden')) {
 +
return;
 +
}
 +
 
 +
busy = true;
 +
 
 +
if (currentOpts && $.isFunction(currentOpts.onCleanup)) {
 +
if (currentOpts.onCleanup(currentArray, currentIndex, currentOpts) === false) {
 +
busy = false;
 +
return;
 +
}
 +
}
 +
 
 +
fancybox_abort();
 +
 
 +
$(close.add( nav_left ).add( nav_right )).hide();
 +
 
 +
$('#fancybox-title').remove();
 +
 
 +
wrap.add(inner).add(overlay).unbind();
 +
 
 +
$(window).unbind("resize.fb scroll.fb");
 +
$(document).unbind('keydown.fb');
 +
 
 +
function _cleanup() {
 +
overlay.fadeOut('fast');
 +
 
 +
wrap.hide();
 +
 
 +
$.event.trigger('fancybox-cleanup');
 +
 
 +
inner.empty();
 +
 
 +
if ($.isFunction(currentOpts.onClosed)) {
 +
currentOpts.onClosed(currentArray, currentIndex, currentOpts);
 +
}
 +
 
 +
currentArray = selectedOpts = [];
 +
currentIndex = selectedIndex = 0;
 +
currentOpts = selectedOpts = {};
 +
 
 +
busy = false;
 +
}
 +
 
 +
inner.css('overflow', 'hidden');
 +
 
 +
if (currentOpts.transitionOut == 'elastic') {
 +
start_pos = fancybox_get_zoom_from();
 +
 
 +
var pos = wrap.position();
 +
 
 +
final_pos = {
 +
top : pos.top ,
 +
left : pos.left,
 +
width : wrap.width(),
 +
height : wrap.height()
 +
};
 +
 
 +
if (currentOpts.opacity) {
 +
final_pos.opacity = 1;
 +
}
 +
 
 +
fx.prop = 1;
 +
 
 +
$(fx).animate({ prop: 0 }, {
 +
duration : currentOpts.speedOut,
 +
easing : currentOpts.easingOut,
 +
step : fancybox_draw,
 +
complete : _cleanup
 +
});
 +
 
 +
} else {
 +
wrap.fadeOut( currentOpts.transitionOut == 'none' ? 0 : currentOpts.speedOut, _cleanup);
 +
}
 +
};
 +
 
 +
$.fancybox.resize = function() {
 +
var c, h;
 +
 +
if (busy || wrap.is(':hidden')) {
 +
return;
 +
}
 +
 
 +
busy = true;
 +
 
 +
c = inner.wrapInner("<div style='overflow:auto'></div>").children();
 +
h = c.height();
 +
 
 +
wrap.css({height: h + (currentOpts.padding * 2) + titleh});
 +
inner.css({height: h});
 +
 
 +
c.replaceWith(c.children());
 +
 
 +
$.fancybox.center();
 +
};
 +
 
 +
$.fancybox.center = function() {
 +
busy = true;
 +
 
 +
var view = fancybox_get_viewport(),
 +
margin = currentOpts.margin,
 +
to = {};
 +
 
 +
to.top = view[3] + ((view[1] - ((wrap.height() - titleh) + (shadow * 2 ))) * 0.5);
 +
to.left = view[2] + ((view[0] - (wrap.width() + (shadow * 2 ))) * 0.5);
 +
 
 +
to.top = Math.max(view[3] + margin, to.top);
 +
to.left = Math.max(view[2] + margin, to.left);
 +
 
 +
wrap.css(to);
 +
 
 +
busy = false;
 +
};
 +
 
 +
$.fn.fancybox.defaults = {
 +
padding : 10,
 +
margin : 20,
 +
opacity : false,
 +
modal : false,
 +
cyclic : false,
 +
scrolling : 'auto', // 'auto', 'yes' or 'no'
 +
 
 +
width : 560,
 +
height : 340,
 +
 
 +
autoScale : true,
 +
autoDimensions : true,
 +
centerOnScroll : false,
 +
 
 +
ajax : {},
 +
swf : { wmode: 'transparent' },
 +
 
 +
hideOnOverlayClick : true,
 +
hideOnContentClick : false,
 +
 
 +
overlayShow : true,
 +
overlayOpacity : 0.3,
 +
overlayColor : '#666',
 +
 
 +
titleShow : true,
 +
titlePosition : 'outside', // 'outside', 'inside' or 'over'
 +
titleFormat : null,
 +
 
 +
transitionIn : 'fade', // 'elastic', 'fade' or 'none'
 +
transitionOut : 'fade', // 'elastic', 'fade' or 'none'
 +
 
 +
speedIn : 300,
 +
speedOut : 300,
 +
 
 +
changeSpeed : 300,
 +
changeFade : 'fast',
 +
 
 +
easingIn : 'swing',
 +
easingOut : 'swing',
 +
 
 +
showCloseButton : true,
 +
showNavArrows : true,
 +
enableEscapeButton : true,
 +
 
 +
onStart : null,
 +
onCancel : null,
 +
onComplete : null,
 +
onCleanup : null,
 +
onClosed : null
 +
};
 +
 
 +
$(document).ready(function() {
 +
fancybox_init();
 +
});
 +
 
 +
})(jQuery);
</script>
</script>
</head>
</head>
</html>
</html>

Revision as of 14:53, 14 July 2010