woocommerce/assets/js/fancybox.min.js

16 lines
15 KiB
JavaScript
Raw Normal View History

/*
* FancyBox - jQuery Plugin
* Simple and fancy lightbox alternative
*
* Examples and documentation at: http://fancybox.net
*
* Copyright © 2008 - 2010 Janis Skarnelis
* That said, it is hardly a one-person project. Many people have submitted bugs, code, and offered their advice freely. Their support is greatly appreciated.
*
* Version: 1.3.4 (11/11/2010)
* Requires: jQuery v1.3+
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
2012-02-14 15:14:07 +00:00
*/(function(a){var b,c,d,e,f,g,h,i,j,k,l=0,m={},n=[],o=0,p={},q=[],r=null,s=new Image,t=/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i,u=/[^\.]\.(swf)\s*$/i,v,w=1,x=0,y="",z,A,B=!1,C=a.extend(a("<div/>")[0],{prop:0}),D=a.browser.msie&&a.browser.version<7&&!window.XMLHttpRequest,E=function(){c.hide();s.onerror=s.onload=null;r&&r.abort();b.empty()},F=function(){if(!1===m.onError(n,l,m)){c.hide();B=!1;return}m.titleShow=!1;m.width="auto";m.height="auto";b.html('<p id="fancybox-error">The requested content cannot be loaded.<br />Please try again later.</p>');H()},G=function(){var d=n[l],e,f,h,i,j,k;E();m=a.extend({},a.fn.fancybox.defaults,typeof a(d).data("fancybox")=="undefined"?m:a(d).data("fancybox"));k=m.onStart(n,l,m);if(k===!1){B=!1;return}typeof k=="object"&&(m=a.extend(m,k));h=m.title||(d.nodeName?a(d).attr("title"):d.title)||"";d.nodeName&&!m.orig&&(m.orig=a(d).children("img:first").length?a(d).children("img:first"):a(d));h===""&&m.orig&&m.titleFromAlt&&(h=m.orig.attr("alt"));e=m.href||(d.nodeName?a(d).attr("href"):d.href)||null;if(/^(?:javascript)/i.test(e)||e=="#")e=null;if(m.type){f=m.type;e||(e=m.content)}else m.content?f="html":e&&(e.match(t)?f="image":e.match(u)?f="swf":a(d).hasClass("iframe")?f="iframe":e.indexOf("#")===0?f="inline":f="ajax");if(!f){F();return}if(f=="inline"){d=e.substr(e.indexOf("#"));f=a(d).length>0?"inline":"ajax"}m.type=f;m.href=e;m.title=h;if(m.autoDimensions)if(m.type=="html"||m.type=="inline"||m.type=="ajax"){m.width="auto";m.height="auto"}else m.autoDimensions=!1;if(m.modal){m.overlayShow=!0;m.hideOnOverlayClick=!1;m.hideOnContentClick=!1;m.enableEscapeButton=!1;m.showCloseButton=!1}m.padding=parseInt(m.padding,10);m.margin=parseInt(m.margin,10);b.css("padding",m.padding+m.margin);a(".fancybox-inline-tmp").unbind("fancybox-cancel").bind("fancybox-change",function(){a(this).replaceWith(g.children())});switch(f){case"html":b.html(m.content);H();break;case"inline":if(a(d).parent().is("#fancybox-content")===!0){B=!1;return}a('<div class="fancybox-inline-tmp" />').hide().insertBefore(a(d)).bind("fancybox-cleanup",function(){a(this).replaceWith(g.children())}).bind("fancybox-cancel",function(){a(this).replaceWith(b.children())});a(d).appendTo(b);H();break;case"image":B=!1;a.fancybox.showActivity();s=new Image;s.onerror=function(){F()};s.onload=function(){B=!0;s.onerror=s.onload=null;I()};s.src=e;break;case"swf":m.scrolling="no";i='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+m.width+'" height="'+m.height+'"><param name="movie" value="'+e+'"></param>';j="";a.each(m.swf,function(a,b){i+='<param name="'+a+'" value="'+b+'"></param>';j+=" "+a+'="'+b+'"'});i+='<embed src="'+e+'" type="application/x-shockwave-flash" width="'+m.width+'" height="'+m.height+'"'+j+"></embed></object>";b.html(i);H();break;case"ajax":B=!1;a.fancybox.showActivity();m.ajax.win=m.ajax.success;r=a.ajax(a.extend({},m.ajax,{url:e,data:m.ajax.data||{},error:function(a,b,c){a.status>0&&F()},success:function(a,d,f){var g=typeof f=="object"?f:r;if(g.status==200){if(typeof m.ajax.win=="function"){k=m.ajax.win(e,a,d,f);if(k===!1){c.hide();return}if(typeof k=="string"||typeof k=="object")a=k}b.html(a);H()}}}));break;case"iframe":J()}},H=function(){var c=m.width,d=m.height;c.toString().indexOf("%")>-1?c=parseInt((a(window).width()-m.margin*2)*parseFloat(c)/100,10)+"px":c=c=="auto"?"auto":c+"px";d.toString().indexOf("%")>-1?d=parseInt((a(window).height()-m.margin*2)*parseFloat(d)/100,10)+"px":d=d=="auto"?"auto":d+"px";b.wrapInner('<div style="width:'+c+";height:"+d+";overflow: "+(m.scrolling=="auto"?"auto":m.scrolling=="yes"?"scroll":"hidden")+';position:relative;"></div>');m.width=b.width();m.height=b.height();J()},I=function(){m.width=s.width;m.height=s.height;a("<img />").attr({id:"fancybox-img",src:s.src,alt:m.title}).appendTo(b);J()},J=function(){var f,r;c.hide();if(e.is(":visible")&&!1===p.onCleanup(q,o,p)){a.event.trigger("fancybox-cancel");B=!1;return}B=!0;a(g.add(d)).unbind();a(window).unbind("resize.fb scroll.fb");a(document).unbind("keydown.fb");e.is(":visible")&&p.titlePosition!=="outside"&&e.css("height",e.h