Datatables (hazelnut) added a link on the hrn to look at a single resource
[myslice.git] / third-party / spin-1.3.0 / jquery.spin.js
1 // https://gist.github.com/its-florida/1290439/raw/ce7face0309bdb265244e8483ce91dcf86e8cb14/jquery.spin.js
2 /*
3
4 You can now create a spinner using any of the variants below:
5
6 $("#el").spin(); // Produces default Spinner using the text color of #el.
7 $("#el").spin("small"); // Produces a 'small' Spinner using the text color of #el.
8 $("#el").spin("large", "white"); // Produces a 'large' Spinner in white (or any valid CSS color).
9 $("#el").spin({ ... }); // Produces a Spinner using your custom settings.
10
11 $("#el").spin(false); // Kills the spinner.
12
13 */
14 (function($) {
15         $.fn.spin = function(opts, color) {
16                 var presets = {
17                         "tiny": { lines: 8, length: 2, width: 2, radius: 3 },
18                         "small": { lines: 8, length: 4, width: 3, radius: 5 },
19                         "large": { lines: 10, length: 8, width: 4, radius: 8 }
20                 };
21                 if (Spinner) {
22                         return this.each(function() {
23                                 var $this = $(this),
24                                         data = $this.data();
25                                 
26                                 if (data.spinner) {
27                                         data.spinner.stop();
28                                         delete data.spinner;
29                                 }
30                                 if (opts !== false) {
31                                         if (typeof opts === "string") {
32                                                 if (opts in presets) {
33                                                         opts = presets[opts];
34                                                 } else {
35                                                         opts = {};
36                                                 }
37                                                 if (color) {
38                                                         opts.color = color;
39                                                 }
40                                         }
41                                         data.spinner = new Spinner($.extend({color: $this.css('color')}, opts)).spin(this);
42                                 }
43                         });
44                 } else {
45                         throw "Spinner class not available.";
46                 }
47         };
48 })(jQuery);