summaryrefslogtreecommitdiff
blob: d0ce09791d476a3354ece0b386425bb729e39f1e (plain)
1
2
3
4
5
6
7
/* Do not modify this file directly. It is compiled from other files. */
//fgnass.github.com/spin.js#v1.3
/**
 * Copyright (c) 2011-2013 Felix Gnass
 * Licensed under the MIT license
 */
!function(t,e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):t.Spinner=e()}(this,function(){"use strict";var t,e=["webkit","Moz","ms","O"],i={};function o(t,e){var i,o=document.createElement(t||"div");for(i in e)o[i]=e[i];return o}function r(t){for(var e=1,i=arguments.length;e<i;e++)t.appendChild(arguments[e]);return t}var n,s=(n=o("style",{type:"text/css"}),r(document.getElementsByTagName("head")[0],n),n.sheet||n.styleSheet);function a(e,o,r,n){var a=["opacity",o,~~(100*e),r,n].join("-"),l=.01+r/n*100,f=Math.max(1-(1-e)/o*(100-l),e),p=t.substring(0,t.indexOf("Animation")).toLowerCase(),d=p&&"-"+p+"-"||"";return i[a]||(s.insertRule("@"+d+"keyframes "+a+"{0%{opacity:"+f+"}"+l+"%{opacity:"+e+"}"+(l+.01)+"%{opacity:1}"+(l+o)%100+"%{opacity:"+e+"}100%{opacity:"+f+"}}",s.cssRules.length),i[a]=1),a}function l(t,i){var o,r,n=t.style;if(void 0!==n[i])return i;for(i=i.charAt(0).toUpperCase()+i.slice(1),r=0;r<e.length;r++)if(void 0!==n[o=e[r]+i])return o}function f(t,e){for(var i in e)t.style[l(t,i)||i]=e[i];return t}function p(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var o in i)void 0===t[o]&&(t[o]=i[o])}return t}function d(t){for(var e={x:t.offsetLeft,y:t.offsetTop};t=t.offsetParent;)e.x+=t.offsetLeft,e.y+=t.offsetTop;return e}var c={lines:12,length:7,width:5,radius:10,rotate:0,corners:1,color:"#000",direction:1,speed:1,trail:100,opacity:.25,fps:20,zIndex:2e9,className:"spinner",top:"auto",left:"auto",position:"relative"};function u(t){if(void 0===this)return new u(t);this.opts=p(t||{},u.defaults,c)}u.defaults={},p(u.prototype,{spin:function(e){this.stop();var i,r,n=this,s=n.opts,a=n.el=f(o(0,{className:s.className}),{position:s.position,width:0,zIndex:s.zIndex}),l=s.radius+s.length+s.width;if(e&&(e.insertBefore(a,e.firstChild||null),r=d(e),i=d(a),f(a,{left:("auto"==s.left?r.x-i.x+(e.offsetWidth>>1):parseInt(s.left,10)+l)+"px",top:("auto"==s.top?r.y-i.y+(e.offsetHeight>>1):parseInt(s.top,10)+l)+"px"})),a.setAttribute("role","progressbar"),n.lines(a,n.opts),!t){var p,c=0,u=(s.lines-1)*(1-s.direction)/2,h=s.fps,y=h/s.speed,m=(1-s.opacity)/(y*s.trail/100),v=y/s.lines;!function t(){c++;for(var e=0;e<s.lines;e++)p=Math.max(1-(c+(s.lines-e)*v)%y*m,s.opacity),n.opacity(a,e*s.direction+u,p,s);n.timeout=n.el&&setTimeout(t,~~(1e3/h))}()}return n},stop:function(){var t=this.el;return t&&(clearTimeout(this.timeout),t.parentNode&&t.parentNode.removeChild(t),this.el=void 0),this},lines:function(e,i){var n,s=0,l=(i.lines-1)*(1-i.direction)/2;function p(t,e){return f(o(),{position:"absolute",width:i.length+i.width+"px",height:i.width+"px",background:t,boxShadow:e,transformOrigin:"left",transform:"rotate("+~~(360/i.lines*s+i.rotate)+"deg) translate("+i.radius+"px,0)",borderRadius:(i.corners*i.width>>1)+"px"})}for(;s<i.lines;s++)n=f(o(),{position:"absolute",top:1+~(i.width/2)+"px",transform:i.hwaccel?"translate3d(0,0,0)":"",opacity:i.opacity,animation:t&&a(i.opacity,i.trail,l+s*i.direction,i.lines)+" "+1/i.speed+"s linear infinite"}),i.shadow&&r(n,f(p("#000","0 0 4px #000"),{top:"2px"})),r(e,r(n,p(i.color,"0 0 1px rgba(0,0,0,.1)")));return e},opacity:function(t,e,i){e<t.childNodes.length&&(t.childNodes[e].style.opacity=i)}});var h=f(o("group"),{behavior:"url(#default#VML)"});return!l(h,"transform")&&h.adj?function(){function t(t,e){return o("<"+t+' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">',e)}s.addRule(".spin-vml","behavior:url(#default#VML)"),u.prototype.lines=function(e,i){var o=i.length+i.width,n=2*o;function s(){return f(t("group",{coordsize:n+" "+n,coordorigin:-o+" "+-o}),{width:n,height:n})}var a,l=2*-(i.width+i.length)+"px",p=f(s(),{position:"absolute",top:l,left:l});function d(e,n,a){r(p,r(f(s(),{rotation:360/i.lines*e+"deg",left:~~n}),r(f(t("roundrect",{arcsize:i.corners}),{width:o,height:i.width,left:i.radius,top:-i.width>>1,filter:a}),t("fill",{color:i.color,opacity:i.opacity}),t("stroke",{opacity:0}))))}if(i.shadow)for(a=1;a<=i.lines;a++)d(a,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)");for(a=1;a<=i.lines;a++)d(a);return r(e,p)},u.prototype.opacity=function(t,e,i,o){var r=t.firstChild;o=o.shadow&&o.lines||0,r&&e+o<r.childNodes.length&&(r=(r=(r=r.childNodes[e+o])&&r.firstChild)&&r.firstChild)&&(r.opacity=i)}}():t=l(h,"animation"),u});