From 823762d8285fe8f7c847d9a0e5a161c38d0a46ea Mon Sep 17 00:00:00 2001 From: Leif Johansson Date: Thu, 9 Feb 2012 22:19:02 +0100 Subject: increase the pool a bit slower --- src/site-media/js/jquery.spin.js | 48 ++++++++++++++++++++++++++++++++++++++++ src/site-media/js/spin.min.js | 2 ++ 2 files changed, 50 insertions(+) create mode 100644 src/site-media/js/jquery.spin.js create mode 100644 src/site-media/js/spin.min.js (limited to 'src/site-media/js') diff --git a/src/site-media/js/jquery.spin.js b/src/site-media/js/jquery.spin.js new file mode 100644 index 0000000..0a7c2b5 --- /dev/null +++ b/src/site-media/js/jquery.spin.js @@ -0,0 +1,48 @@ +/* + +You can now create a spinner using any of the variants below: + +$("#el").spin(); // Produces default Spinner using the text color of #el. +$("#el").spin("small"); // Produces a 'small' Spinner using the text color of #el. +$("#el").spin("large", "white"); // Produces a 'large' Spinner in white (or any valid CSS color). +$("#el").spin({ ... }); // Produces a Spinner using your custom settings. + +$("#el").spin(false); // Kills the spinner. + +*/ +(function($) { + $.fn.spin = function(opts, color) { + var presets = { + "custom": { lines: 7, length: 2, width: 2, radius: 2}, + "tiny": { lines: 8, length: 2, width: 2, radius: 3 }, + "small": { lines: 8, length: 4, width: 3, radius: 5 }, + "large": { lines: 10, length: 8, width: 4, radius: 8 } + }; + if (Spinner) { + return this.each(function() { + var $this = $(this), + data = $this.data(); + + if (data.spinner) { + data.spinner.stop(); + delete data.spinner; + } + if (opts !== false) { + if (typeof opts === "string") { + if (opts in presets) { + opts = presets[opts]; + } else { + opts = {}; + } + if (color) { + opts.color = color; + } + } + data.spinner = new Spinner($.extend({color: $this.css('color')}, opts)).spin(this); + } + }); + } else { + throw "Spinner class not available."; + } + }; +})(jQuery); diff --git a/src/site-media/js/spin.min.js b/src/site-media/js/spin.min.js new file mode 100644 index 0000000..c7c01c6 --- /dev/null +++ b/src/site-media/js/spin.min.js @@ -0,0 +1,2 @@ +//fgnass.github.com/spin.js#v1.2.3 +(function(a,b,c){function n(a){var b={x:a.offsetLeft,y:a.offsetTop};while(a=a.offsetParent)b.x+=a.offsetLeft,b.y+=a.offsetTop;return b}function m(a){for(var b=1;b>1)-d.x+e.x+"px",top:(a.offsetHeight>>1)-d.y+e.y+"px"})),c.setAttribute("aria-role","progressbar"),b.lines(c,b.opts);if(!f){var i=b.opts,j=0,k=i.fps,m=k/i.speed,o=(1-i.opacity)/(m*i.trail/100),p=m/i.lines;(function q(){j++;for(var a=i.lines;a;a--){var d=Math.max(1-(j+a*p)%m*o,i.opacity);b.opacity(c,i.lines-a,d,i)}b.timeout=b.el&&setTimeout(q,~~(1e3/k))})()}return b},stop:function(){var a=this.el;a&&(clearTimeout(this.timeout),a.parentNode&&a.parentNode.removeChild(a),this.el=c);return this}};q.lines=function(a,b){function e(a,d){return l(g(),{position:"absolute",width:b.length+b.width+"px",height:b.width+"px",background:a,boxShadow:d,transformOrigin:"left",transform:"rotate("+~~(360/b.lines*c)+"deg) translate("+b.radius+"px"+",0)",borderRadius:(b.width>>1)+"px"})}var c=0,d;for(;c>1,filter:i}),g("fill",{color:b.color,opacity:b.opacity}),g("stroke",{opacity:0}))))}function e(){return l(g("group",{coordsize:d+" "+d,coordorigin:-c+" "+ -c}),{width:d,height:d})}var c=b.length+b.width,d=2*c,f=e(),i=~(b.length+b.radius+b.width)+"px",j;if(b.shadow)for(j=1;j<=b.lines;j++)k(j,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)");for(j=1;j<=b.lines;j++)k(j);return h(l(a,{margin:i+" 0 0 "+i,zoom:1}),f)},q.opacity=function(a,b,c,d){var e=a.firstChild;d=d.shadow&&d.lines||0,e&&b+d