Required toolbar

pull/6/head
Mark McDowall 12 years ago
parent e856a31a4d
commit 56cf3555a6

@ -1,8 +1,8 @@
'use strict';
define(['app', 'Shared/Toolbar/Button/ButtonView', 'Config'], function () {
NzbDrone.Shared.Toolbar.ButtonCollectionView = Backbone.Marionette.CollectionView.extend({
define(['app', 'Shared/Toolbar/Button/ButtonView', 'Config'], function (App, ButtonView, Config) {
return Backbone.Marionette.CollectionView.extend({
className: 'btn-group',
itemView : NzbDrone.Shared.Toolbar.ButtonView
itemView : ButtonView
});
});

@ -1,7 +1,11 @@
'use strict';
define(['app', 'Config', 'Commands/CommandController', 'Shared/Messenger'], function () {
define(['app', 'Config', 'Commands/CommandController', 'Shared/Messenger'],
function (App,
Config,
CommandController,
Messenger) {
NzbDrone.Shared.Toolbar.ButtonView = Backbone.Marionette.ItemView.extend({
return Backbone.Marionette.ItemView.extend({
template : 'Shared/Toolbar/ButtonTemplate',
className: 'btn',
@ -13,7 +17,6 @@ define(['app', 'Config', 'Commands/CommandController', 'Shared/Messenger'], func
icon: '.x-icon'
},
initialize: function () {
this.storageKey = this.model.get('menuKey') + ':' + this.model.get('key');
this.idle = true;
@ -34,7 +37,6 @@ define(['app', 'Config', 'Commands/CommandController', 'Shared/Messenger'], func
}
},
invokeCommand: function () {
var command = this.model.get('command');
if (command) {
@ -43,10 +45,10 @@ define(['app', 'Config', 'Commands/CommandController', 'Shared/Messenger'], func
this.ui.icon.addClass('icon-spinner icon-spin');
var self = this;
var commandPromise = NzbDrone.Commands.Execute(command);
var commandPromise = CommandController.Execute(command);
commandPromise.done(function () {
if (self.model.get('successMessage')) {
NzbDrone.Shared.Messenger.show({
Messenger.show({
message: self.model.get('successMessage')
});
}
@ -57,7 +59,7 @@ define(['app', 'Config', 'Commands/CommandController', 'Shared/Messenger'], func
return;
}
if (self.model.get('errorMessage')) {
NzbDrone.Shared.Messenger.show({
Messenger.show({
message: self.model.get('errorMessage'),
type : 'error'
});
@ -93,7 +95,6 @@ define(['app', 'Config', 'Commands/CommandController', 'Shared/Messenger'], func
callback.call(this.model.ownerContext);
}
}
});
});

@ -1,6 +1,6 @@
'use strict';
define(['app', 'Shared/Toolbar/ButtonModel'], function () {
NzbDrone.Shared.Toolbar.ButtonCollection = Backbone.Collection.extend({
return Backbone.Collection.extend({
model: NzbDrone.Shared.Toolbar.ButtonModel
});
});

@ -7,7 +7,7 @@ define(['app'], function () {
CallBack : 'CallBack'
};
NzbDrone.Shared.Toolbar.ButtonModel = Backbone.Model.extend({
return Backbone.Model.extend({
defaults: {
'target' : '/nzbdrone/route',
'title' : '',

@ -5,7 +5,7 @@ define(
'Shared/Toolbar/Radio/RadioButtonView',
'Config'
], function (App, RadioButtonView, Config) {
NzbDrone.Shared.Toolbar.RadioButtonCollectionView = Backbone.Marionette.CollectionView.extend({
return Backbone.Marionette.CollectionView.extend({
className: 'btn-group',
itemView : NzbDrone.Shared.Toolbar.RadioButtonView,

@ -4,8 +4,14 @@ define(
'app',
'Shared/Toolbar/Radio/RadioButtonCollectionView',
'Shared/Toolbar/Button/ButtonCollectionView',
'Shared/Toolbar/ButtonCollection'
], function () {
'Shared/Toolbar/ButtonCollection',
'Shared/Toolbar/ButtonModel'
],
function (App,
RadioButtonCollectionView,
ButtonCollectionView,
ButtonCollection,
ButtonModel) {
NzbDrone.Shared.Toolbar.ToolbarLayout = Backbone.Marionette.Layout.extend({
template: 'Shared/Toolbar/ToolbarLayoutTemplate',
@ -32,7 +38,6 @@ define(
},
onShow: function () {
if (this.left) {
_.each(this.left, this._showToolbarLeft, this);
@ -53,7 +58,7 @@ define(
_showToolbar: function (buttonGroup, index, position) {
var groupCollection = new NzbDrone.Shared.Toolbar.ButtonCollection();
var groupCollection = new ButtonCollection();
_.each(buttonGroup.items, function (button) {
@ -61,7 +66,7 @@ define(
throw 'must provide key for all buttons when storSstate is enabled';
}
var model = new NzbDrone.Shared.Toolbar.ButtonModel(button);
var model = new ButtonModel(button);
model.set('menuKey', buttonGroup.menuKey);
model.ownerContext = this.toolbarContext;
groupCollection.add(model);
@ -73,7 +78,7 @@ define(
switch (buttonGroup.type) {
case 'radio':
{
buttonGroupView = new NzbDrone.Shared.Toolbar.RadioButtonCollectionView({
buttonGroupView = new RadioButtonCollectionView({
collection: groupCollection,
menu : buttonGroup
});
@ -81,7 +86,7 @@ define(
}
default :
{
buttonGroupView = new NzbDrone.Shared.Toolbar.ButtonCollectionView({
buttonGroupView = new ButtonCollectionView({
collection: groupCollection,
menu : buttonGroup
});

Loading…
Cancel
Save