-
-
Save AABoyles/5399427 to your computer and use it in GitHub Desktop.
A simpler, slightly more efficient, less customizable jQuery Spinner plugin.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
You can create a spinner using either of the variants below: | |
$("#el").spin(true); //Starts the spinner. | |
$("#el").spin(false); // Kills the spinner. | |
*/ | |
(function($) { | |
$.fn.spin = function(opts) { | |
if (Spinner) { | |
if (opts !== false) { | |
return this.each(function() { | |
var $this = $(this), data = $this.data(); | |
if (!data.spinner) { | |
data.spinner = new Spinner(); | |
} | |
data.spinner.spin(this) | |
}); | |
} else { | |
return this.each(function() { | |
var $this = $(this), data = $this.data(); | |
if (data.spinner) { | |
data.spinner.stop(); | |
} | |
}); | |
} | |
} else { | |
throw("Spinner Class not Available!"); | |
} | |
} | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment