Skip to content

Instantly share code, notes, and snippets.

@AABoyles
Forked from tsgautier/jquery.spin.js
Last active December 16, 2015 07:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AABoyles/5399427 to your computer and use it in GitHub Desktop.
Save AABoyles/5399427 to your computer and use it in GitHub Desktop.
A simpler, slightly more efficient, less customizable jQuery Spinner plugin.
/*
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