mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 21:43:33 -07:00
removed NzbDrone. namespace, everything is done using require.
This commit is contained in:
parent
ef62af75df
commit
b0bd3f34f1
121 changed files with 2570 additions and 2587 deletions
|
@ -1,9 +1,13 @@
|
|||
'use strict';
|
||||
define(['app', 'Shared/Toolbar/Button/ButtonView', 'Config'], function (App, ButtonView, Config) {
|
||||
return Backbone.Marionette.CollectionView.extend({
|
||||
className: 'btn-group',
|
||||
itemView : ButtonView
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'Shared/Toolbar/Button/ButtonView'
|
||||
], function (Marionette, ButtonView) {
|
||||
return Marionette.CollectionView.extend({
|
||||
className: 'btn-group',
|
||||
itemView : ButtonView
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -1,102 +1,113 @@
|
|||
'use strict';
|
||||
define(['app', 'Config', 'Commands/CommandController', 'Shared/Messenger'],
|
||||
function (App,
|
||||
Config,
|
||||
CommandController,
|
||||
Messenger) {
|
||||
define(
|
||||
[
|
||||
'app',
|
||||
'marionette',
|
||||
'Commands/CommandController',
|
||||
'Shared/Messenger'
|
||||
], function (App, Marionette, CommandController, Messenger) {
|
||||
|
||||
return Backbone.Marionette.ItemView.extend({
|
||||
template : 'Shared/Toolbar/ButtonTemplate',
|
||||
className: 'btn',
|
||||
return Marionette.ItemView.extend({
|
||||
template : 'Shared/Toolbar/ButtonTemplate',
|
||||
className: 'btn',
|
||||
|
||||
events: {
|
||||
'click': 'onClick'
|
||||
},
|
||||
events: {
|
||||
'click': 'onClick'
|
||||
},
|
||||
|
||||
ui: {
|
||||
icon: '.x-icon'
|
||||
},
|
||||
ui: {
|
||||
icon: '.x-icon'
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
this.storageKey = this.model.get('menuKey') + ':' + this.model.get('key');
|
||||
this.idle = true;
|
||||
},
|
||||
|
||||
onRender: function () {
|
||||
if (this.model.get('active')) {
|
||||
this.$el.addClass('active');
|
||||
this.invokeCallback();
|
||||
}
|
||||
},
|
||||
initialize: function () {
|
||||
this.storageKey = this.model.get('menuKey') + ':' + this.model.get('key');
|
||||
this.idle = true;
|
||||
},
|
||||
|
||||
onClick: function () {
|
||||
if (this.idle) {
|
||||
this.invokeCallback();
|
||||
this.invokeRoute();
|
||||
this.invokeCommand();
|
||||
}
|
||||
},
|
||||
onRender: function () {
|
||||
if (this.model.get('active')) {
|
||||
this.$el.addClass('active');
|
||||
this.invokeCallback();
|
||||
}
|
||||
},
|
||||
|
||||
invokeCommand: function () {
|
||||
var command = this.model.get('command');
|
||||
if (command) {
|
||||
this.idle = false;
|
||||
this.$el.addClass('disabled');
|
||||
this.ui.icon.addClass('icon-spinner icon-spin');
|
||||
onClick: function () {
|
||||
if (this.idle) {
|
||||
this.invokeCallback();
|
||||
this.invokeRoute();
|
||||
this.invokeCommand();
|
||||
}
|
||||
},
|
||||
|
||||
var self = this;
|
||||
var commandPromise = CommandController.Execute(command);
|
||||
commandPromise.done(function () {
|
||||
if (self.model.get('successMessage')) {
|
||||
Messenger.show({
|
||||
message: self.model.get('successMessage')
|
||||
|
||||
invokeCommand: function () {
|
||||
var command = this.model.get('command');
|
||||
if (command) {
|
||||
this.idle = false;
|
||||
this.$el.addClass('disabled');
|
||||
this.ui.icon.addClass('icon-spinner icon-spin');
|
||||
|
||||
var self = this;
|
||||
var commandPromise = CommandController.Execute(command);
|
||||
commandPromise.done(function () {
|
||||
if (self.model.get('successMessage')) {
|
||||
Messenger.show({
|
||||
message: self.model.get('successMessage')
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
commandPromise.fail(function (options) {
|
||||
if (options.readyState === 0 || options.status === 0) {
|
||||
return;
|
||||
}
|
||||
if (self.model.get('errorMessage')) {
|
||||
Messenger.show({
|
||||
message: self.model.get('errorMessage'),
|
||||
type : 'error'
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
commandPromise.always(function () {
|
||||
if (!self.isClosed) {
|
||||
self.$el.removeClass('disabled');
|
||||
self.ui.icon.removeClass('icon-spinner icon-spin');
|
||||
self.idle = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
invokeRoute: function () {
|
||||
var route = this.model.get('route');
|
||||
if (route) {
|
||||
|
||||
require(
|
||||
[
|
||||
'Router'
|
||||
], function () {
|
||||
App.Router.navigate(route, {trigger: true});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
commandPromise.fail(function (options) {
|
||||
if (options.readyState === 0 || options.status === 0) {
|
||||
return;
|
||||
}
|
||||
if (self.model.get('errorMessage')) {
|
||||
Messenger.show({
|
||||
message: self.model.get('errorMessage'),
|
||||
type : 'error'
|
||||
});
|
||||
}
|
||||
});
|
||||
invokeCallback: function () {
|
||||
|
||||
commandPromise.always(function () {
|
||||
if (!self.isClosed) {
|
||||
self.$el.removeClass('disabled');
|
||||
self.ui.icon.removeClass('icon-spinner icon-spin');
|
||||
self.idle = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
if (!this.model.ownerContext) {
|
||||
throw 'ownerContext must be set.';
|
||||
}
|
||||
|
||||
invokeRoute: function () {
|
||||
var route = this.model.get('route');
|
||||
if (route) {
|
||||
NzbDrone.Router.navigate(route, {trigger: true});
|
||||
}
|
||||
},
|
||||
|
||||
invokeCallback: function () {
|
||||
|
||||
if (!this.model.ownerContext) {
|
||||
throw 'ownerContext must be set.';
|
||||
var callback = this.model.get('callback');
|
||||
if (callback) {
|
||||
callback.call(this.model.ownerContext);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var callback = this.model.get('callback');
|
||||
if (callback) {
|
||||
callback.call(this.model.ownerContext);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
'use strict';
|
||||
define(['app', 'Shared/Toolbar/ButtonModel'], function () {
|
||||
return Backbone.Collection.extend({
|
||||
model: NzbDrone.Shared.Toolbar.ButtonModel
|
||||
define(
|
||||
[
|
||||
'backbone',
|
||||
'Shared/Toolbar/ButtonModel'
|
||||
], function (Backbone, ButtonModel) {
|
||||
return Backbone.Collection.extend({
|
||||
model: ButtonModel
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -1,17 +1,13 @@
|
|||
'use strict';
|
||||
define(['app'], function () {
|
||||
|
||||
NzbDrone.Shared.Toolbar.ActionTypes =
|
||||
{
|
||||
RouteTrigger: 'RouteTrigger',
|
||||
CallBack : 'CallBack'
|
||||
};
|
||||
|
||||
return Backbone.Model.extend({
|
||||
defaults: {
|
||||
'target' : '/nzbdrone/route',
|
||||
'title' : '',
|
||||
'active' : false,
|
||||
'tooltip': undefined }
|
||||
define(
|
||||
[
|
||||
'backbone'
|
||||
], function (Backbone) {
|
||||
return Backbone.Model.extend({
|
||||
defaults: {
|
||||
'target' : '/nzbdrone/route',
|
||||
'title' : '',
|
||||
'active' : false,
|
||||
'tooltip': undefined }
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
'use strict';
|
||||
define(
|
||||
[
|
||||
'app',
|
||||
'marionette',
|
||||
'Shared/Toolbar/Radio/RadioButtonView',
|
||||
'Config'
|
||||
], function (App, RadioButtonView, Config) {
|
||||
return Backbone.Marionette.CollectionView.extend({
|
||||
], function (Marionette, RadioButtonView, Config) {
|
||||
return Marionette.CollectionView.extend({
|
||||
className: 'btn-group',
|
||||
itemView : NzbDrone.Shared.Toolbar.RadioButtonView,
|
||||
itemView : RadioButtonView,
|
||||
|
||||
attributes: {
|
||||
'data-toggle': 'buttons-radio'
|
||||
|
|
|
@ -1,48 +1,52 @@
|
|||
'use strict';
|
||||
define(['app', 'Config'], function () {
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'Config'
|
||||
], function (Marionette, Config) {
|
||||
|
||||
NzbDrone.Shared.Toolbar.RadioButtonView = Backbone.Marionette.ItemView.extend({
|
||||
template : 'Shared/Toolbar/ButtonTemplate',
|
||||
className: 'btn',
|
||||
return Marionette.ItemView.extend({
|
||||
template : 'Shared/Toolbar/ButtonTemplate',
|
||||
className: 'btn',
|
||||
|
||||
events: {
|
||||
'click': 'onClick'
|
||||
},
|
||||
events: {
|
||||
'click': 'onClick'
|
||||
},
|
||||
|
||||
|
||||
initialize: function () {
|
||||
initialize: function () {
|
||||
|
||||
this.storageKey = this.model.get('menuKey') + ':' + this.model.get('key');
|
||||
},
|
||||
this.storageKey = this.model.get('menuKey') + ':' + this.model.get('key');
|
||||
},
|
||||
|
||||
onRender: function () {
|
||||
if (this.model.get('active')) {
|
||||
this.$el.addClass('active');
|
||||
onRender: function () {
|
||||
if (this.model.get('active')) {
|
||||
this.$el.addClass('active');
|
||||
this.invokeCallback();
|
||||
}
|
||||
},
|
||||
|
||||
onClick: function () {
|
||||
|
||||
Config.SetValue(this.model.get('menuKey'), this.model.get('key'));
|
||||
this.invokeCallback();
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
onClick: function () {
|
||||
invokeCallback: function () {
|
||||
|
||||
NzbDrone.Config.SetValue(this.model.get('menuKey'), this.model.get('key'));
|
||||
this.invokeCallback();
|
||||
},
|
||||
if (!this.model.ownerContext) {
|
||||
throw 'ownerContext must be set.';
|
||||
}
|
||||
|
||||
invokeCallback: function () {
|
||||
|
||||
if (!this.model.ownerContext) {
|
||||
throw 'ownerContext must be set.';
|
||||
var callback = this.model.get('callback');
|
||||
if (callback) {
|
||||
callback.call(this.model.ownerContext);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var callback = this.model.get('callback');
|
||||
if (callback) {
|
||||
callback.call(this.model.ownerContext);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,18 +1,13 @@
|
|||
'use strict';
|
||||
define(
|
||||
[
|
||||
'app',
|
||||
'Shared/Toolbar/Radio/RadioButtonCollectionView',
|
||||
'Shared/Toolbar/Button/ButtonCollectionView',
|
||||
'marionette',
|
||||
'Shared/Toolbar/ButtonCollection',
|
||||
'Shared/Toolbar/ButtonModel'
|
||||
],
|
||||
function (App,
|
||||
RadioButtonCollectionView,
|
||||
ButtonCollectionView,
|
||||
ButtonCollection,
|
||||
ButtonModel) {
|
||||
NzbDrone.Shared.Toolbar.ToolbarLayout = Backbone.Marionette.Layout.extend({
|
||||
'Shared/Toolbar/ButtonModel',
|
||||
'Shared/Toolbar/Radio/RadioButtonCollectionView',
|
||||
'Shared/Toolbar/Button/ButtonCollectionView'
|
||||
], function (Marionette, ButtonCollection, ButtonModel, RadioButtonCollectionView, ButtonCollectionView) {
|
||||
return Marionette.Layout.extend({
|
||||
template: 'Shared/Toolbar/ToolbarLayoutTemplate',
|
||||
|
||||
regions: {
|
||||
|
@ -38,6 +33,7 @@ define(
|
|||
|
||||
},
|
||||
|
||||
|
||||
onShow: function () {
|
||||
if (this.left) {
|
||||
_.each(this.left, this._showToolbarLeft, this);
|
||||
|
@ -79,17 +75,17 @@ define(
|
|||
case 'radio':
|
||||
{
|
||||
buttonGroupView = new RadioButtonCollectionView({
|
||||
collection: groupCollection,
|
||||
menu : buttonGroup
|
||||
});
|
||||
collection: groupCollection,
|
||||
menu : buttonGroup
|
||||
});
|
||||
break;
|
||||
}
|
||||
default :
|
||||
{
|
||||
buttonGroupView = new ButtonCollectionView({
|
||||
collection: groupCollection,
|
||||
menu : buttonGroup
|
||||
});
|
||||
collection: groupCollection,
|
||||
menu : buttonGroup
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -97,9 +93,6 @@ define(
|
|||
this[position + '_' + (index + 1).toString()].show(buttonGroupView);
|
||||
}
|
||||
});
|
||||
|
||||
return NzbDrone.Shared.Toolbar.ToolbarLayout;
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue