mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-14 00:53:57 -07:00
this should cover it!
This commit is contained in:
parent
7f5136120d
commit
c090b3efa1
15 changed files with 166 additions and 331 deletions
|
@ -3,10 +3,12 @@ define(
|
|||
[
|
||||
'Commands/CommandModel',
|
||||
'Commands/CommandCollection',
|
||||
'underscore'
|
||||
'underscore',
|
||||
'jQuery/jquery.spin'
|
||||
], function (CommandModel, CommandCollection, _) {
|
||||
|
||||
return{
|
||||
|
||||
Execute: function (name, properties) {
|
||||
|
||||
var attr = _.extend({name: name.toLocaleLowerCase()}, properties);
|
||||
|
@ -16,6 +18,39 @@ define(
|
|||
return commandModel.save().success(function () {
|
||||
CommandCollection.add(commandModel);
|
||||
});
|
||||
},
|
||||
|
||||
bindToCommand: function (options) {
|
||||
|
||||
var self = this;
|
||||
|
||||
var existingCommand = CommandCollection.findCommand(options.command);
|
||||
|
||||
if (existingCommand) {
|
||||
this._bindToCommandModel.call(this, existingCommand, options);
|
||||
}
|
||||
|
||||
CommandCollection.bind('add sync', function (model) {
|
||||
if (model.isSameCommand(options.command)) {
|
||||
self._bindToCommandModel.call(self, model, options);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_bindToCommandModel: function bindToCommand(model, options) {
|
||||
|
||||
if (!model.isActive()) {
|
||||
options.element.stopSpin();
|
||||
return;
|
||||
}
|
||||
|
||||
model.bind('change:state', function (model) {
|
||||
if (!model.isActive()) {
|
||||
options.element.stopSpin();
|
||||
}
|
||||
});
|
||||
|
||||
options.element.startSpin();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue