mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-14 00:53:57 -07:00
signalr cleanup
This commit is contained in:
parent
feda4a9b67
commit
25e2c98c45
219 changed files with 2035 additions and 1495 deletions
|
@ -3,17 +3,55 @@ define(
|
|||
[
|
||||
'Commands/CommandController',
|
||||
'Commands/CommandCollection',
|
||||
'Shared/Messenger'],
|
||||
function(CommandController, CommandCollection, Messenger) {
|
||||
'Shared/Messenger',
|
||||
'jQuery/jquery.spin'
|
||||
], function (CommandController, CommandCollection, Messenger) {
|
||||
|
||||
var actioneer = Marionette.AppRouter.extend({
|
||||
|
||||
initialize: function () {
|
||||
this.trackedCommands = [];
|
||||
this.trackedCommands =
|
||||
[
|
||||
];
|
||||
CommandCollection.fetch();
|
||||
this.listenTo(CommandCollection, 'sync', this._handleCommands);
|
||||
},
|
||||
|
||||
|
||||
bindToCommand: function (options) {
|
||||
|
||||
var self = this;
|
||||
options.idleIcon = this._getIconClass(options.element);
|
||||
|
||||
var existingCommand = CommandCollection.findCommand(options.command);
|
||||
|
||||
if (existingCommand) {
|
||||
this._bindToCommandModel.call(this, existingCommand, options);
|
||||
}
|
||||
|
||||
this.listenTo(CommandCollection, '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;
|
||||
}
|
||||
|
||||
this.listenTo(model, 'change:state', function (model) {
|
||||
if (!model.isActive()) {
|
||||
options.element.stopSpin();
|
||||
}
|
||||
});
|
||||
|
||||
options.element.startSpin();
|
||||
},
|
||||
|
||||
ExecuteCommand: function (options) {
|
||||
options.iconClass = this._getIconClass(options.element);
|
||||
|
||||
|
@ -62,7 +100,7 @@ define(
|
|||
_handleCommands: function () {
|
||||
var self = this;
|
||||
|
||||
_.each(this.trackedCommands, function (trackedCommand){
|
||||
_.each(this.trackedCommands, function (trackedCommand) {
|
||||
if (trackedCommand.completed === true) {
|
||||
return;
|
||||
}
|
||||
|
@ -95,12 +133,12 @@ define(
|
|||
});
|
||||
},
|
||||
|
||||
_getIconClass: function(element) {
|
||||
_getIconClass: function (element) {
|
||||
if (!element) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return element.attr('class').match(/(?:^|\s)icon\-.+?(?:$|\s)/)[0];
|
||||
return element.find('i').attr('class').match(/(?:^|\s)icon\-.+?(?:$|\s)/)[0];
|
||||
},
|
||||
|
||||
_setSpinnerOnElement: function (options) {
|
||||
|
@ -195,4 +233,4 @@ define(
|
|||
});
|
||||
|
||||
return new actioneer();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue