1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-25 17:17:02 +00:00

jquery plugin to attach a promise to a spinning icon

This commit is contained in:
Keivan Beigi 2013-09-11 16:34:04 -07:00
parent bb518ca19b
commit 578808ecd3

View file

@ -4,9 +4,22 @@ define(
], function ($) {
'use strict';
$.fn.spinForPromise = function (promise) {
var self = this;
if (!promise || promise.state() !== 'pending') {
return this;
}
promise.always(function () {
self.stopSpin();
});
return this.startSpin();
};
$.fn.startSpin = function () {
var icon = this.find('i');
var icon = this.find('i').andSelf('i');
var iconClasses = icon.attr('class').match(/(?:^|\s)icon\-.+?(?:$|\s)/);
@ -31,7 +44,7 @@ define(
};
$.fn.stopSpin = function () {
var icon = this.find('i');
var icon = this.find('i').andSelf('i');
this.removeClass('disabled');
icon.removeClass('icon-spin icon-nd-spinner');