Skip to content

Instantly share code, notes, and snippets.

@monkeymonk
Last active August 29, 2015 13:57
Show Gist options
  • Save monkeymonk/9763071 to your computer and use it in GitHub Desktop.
Save monkeymonk/9763071 to your computer and use it in GitHub Desktop.
$.extend($.fn, {
spin: function (opts, callback) {
this.each(function() {
var $this = $(this),
data = $this.data();
if (opts !== false) {
data.spinner = new Spinner(opts).spin(this);
$this.trigger('spin');
callback.call($this);
}
});
return this;
}, // spin (depend from spin.js)
unspin: function (callback) {
this.each(function () {
var $this = $(this),
data = $this.data();
if (data.spinner) {
data.spinner.stop();
$this.trigger('unspin');
callback.call($this);
delete data.spinner;
}
});
return this;
} // unspin (depend from spin.js)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment