woocommerce/assets/js/fancybox/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-11-08 11:39:01 +00:00
*/(function(e){var t,n,r,i,s,o,u,a,f,l,c=0,h={},p=[],d=0,v={},m=[],g=null,y=new Image,b=/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i,w=/[^\.]\.(swf)\s*$/i,E,S=1,x=0,T="",N,C,k=!1,L=e.extend(e("<div/>")[0],{prop:0}),A=e.browser.msie&&e.browser.version<7&&!window.XMLHttpRequest,O=function(){n.hide();y.onerror=y.onload=null;g&&g.abort();t.empty()},M=function(){if(!1===h.onError(p,c,h)){n.hide();k=!1;return}h.titleShow=!1;h.width="auto";h.height="auto";t.html('<p id="fancybox-error">The requested content cannot be loaded.<br />Please try again later.</p>');D()},_=function(){var r=p[c],i,s,u,a,f,l;O();h=e.extend({},e.fn.fancybox.defaults,typeof e(r).data("fancybox")=="undefined"?h:e(r).data("fancybox"));l=h.onStart(p,c,h);if(l===!1){k=!1;return}typeof l=="object"&&(h=e.extend(h,l));u=h.title||(r.nodeName?e(r).attr("title"):r.title)||"";r.nodeName&&!h.orig&&(h.orig=e(r).children("img:first").length?e(r).children("img:first"):e(r));u===""&&h.orig&&h.titleFromAlt&&(u=h.orig.attr("alt"));i=h.href||(r.nodeName?e(r).attr("href"):r.href)||null;if(/^(?:javascript)/i.test(i)||i=="#")i=null;if(h.type){s=h.type;i||(i=h.content)}else h.content?s="html":i&&(i.match(b)?s="image":i.match(w)?s="swf":e(r).hasClass("iframe")?s="iframe":i.indexOf("#")===0?s="inline":s="ajax");if(!s){M();return}if(s=="inline"){r=i.substr(i.indexOf("#"));s=e(r).length>0?"inline":"ajax"}h.type=s;h.href=i;h.title=u;if(h.autoDimensions)if(h.type=="html"||h.type=="inline"||h.type=="ajax"){h.width="auto";h.height="auto"}else h.autoDimensions=!1;if(h.modal){h.overlayShow=!0;h.hideOnOverlayClick=!1;h.hideOnContentClick=!1;h.enableEscapeButton=!1;h.showCloseButton=!1}h.padding=parseInt(h.padding,10);h.margin=parseInt(h.margin,10);t.css("padding",h.padding+h.margin);e(".fancybox-inline-tmp").unbind("fancybox-cancel").bind("fancybox-change",function(){e(this).replaceWith(o.children())});switch(s){case"html":t.html(h.content);D();break;case"inline":if(e(r).parent().is("#fancybox-content")===!0){k=!1;return}e('<div class="fancybox-inline-tmp" />').hide().insertBefore(e(r)).bind("fancybox-cleanup",function(){e(this).replaceWith(o.children())}).bind("fancybox-cancel",function(){e(this).replaceWith(t.children())});e(r).appendTo(t);D();break;case"image":k=!1;e.fancybox.showActivity();y=new Image;y.onerror=function(){M()};y.onload=function(){k=!0;y.onerror=y.onload=null;P()};y.src=i;break;case"swf":h.scrolling="no";a='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+h.width+'" height="'+h.height+'"><param name="movie" value="'+i+'"></param>';f="";e.each(h.swf,function(e,t){a+='<param name="'+e+'" value="'+t+'"></param>';f+=" "+e+'="'+t+'"'});a+='<embed src="'+i+'" type="application/x-shockwave-flash" width="'+h.width+'" height="'+h.height+'"'+f+"></embed></object>";t.html(a);D();break;case"ajax":k=!1;e.fancybox.showActivity();h.ajax.win=h.ajax.success;g=e.ajax(e.extend({},h.ajax,{url:i,data:h.ajax.data||{},error:function(e,t,n){e.status>0&&M()},success:function(e,r,s){var o=typeof s=="object"?s:g;if(o.status==200){if(typeof h.ajax.win=="function"){l=h.ajax.win(i,e,r,s);if(l===!1){n.hide();return}if(typeof l=="string"||typeof l=="object")e=l}t.html(e);D()}}}));break;case"iframe":H()}},D=function(){var n=h.width,r=h.height;n.toString().indexOf("%")>-1?n=parseInt((e(window).width()-h.margin*2)*parseFloat(n)/100,10)+"px":n=n=="auto"?"auto":n+"px";r.toString().indexOf("%")>-1?r=parseInt((e(window).height()-h.margin*2)*parseFloat(r)/100,10)+"px":r=r=="auto"?"auto":r+"px";t.wrapInner('<div style="width:'+n+";height:"+r+";overflow: "+(h.scrolling=="auto"?"auto":h.scrolling=="yes"?"scroll":"hidden")+';position:relative;"></div>');h.width=t.width();h.height=t.height();H()},P=function(){h.width=y.width;h.height=y.height;e("<img />").attr({id:"fancybox-img",src:y.src,alt:h.title}).appendTo(t);H()},H=function(){var s,g;n.hide();if(i.is(":visible")&&!1===v.onCleanup(m,d,v)){e.event.trigger("fancybox-cancel");k=!1;return}k=!0;e(o.add(r)).unbind();e(window).unbind("resize.fb scroll.fb");e(document).unbind("keydown.fb");i.is(":visible")&&v.titlePosition!=="outside"&&i.css("height",i.h