From 56cf3555a6888268c2d1581d578bb4393347fe17 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 23 Jun 2013 21:28:18 -0700 Subject: [PATCH] Required toolbar --- .../Toolbar/Button/ButtonCollectionView.js | 6 +++--- UI/Shared/Toolbar/Button/ButtonView.js | 17 +++++++++-------- UI/Shared/Toolbar/ButtonCollection.js | 2 +- UI/Shared/Toolbar/ButtonModel.js | 2 +- .../Radio/RadioButtonCollectionView.js | 2 +- UI/Shared/Toolbar/ToolbarLayout.js | 19 ++++++++++++------- 6 files changed, 27 insertions(+), 21 deletions(-) diff --git a/UI/Shared/Toolbar/Button/ButtonCollectionView.js b/UI/Shared/Toolbar/Button/ButtonCollectionView.js index d0d731a06..14acd1629 100644 --- a/UI/Shared/Toolbar/Button/ButtonCollectionView.js +++ b/UI/Shared/Toolbar/Button/ButtonCollectionView.js @@ -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 }); }); diff --git a/UI/Shared/Toolbar/Button/ButtonView.js b/UI/Shared/Toolbar/Button/ButtonView.js index a934d37f3..373822b15 100644 --- a/UI/Shared/Toolbar/Button/ButtonView.js +++ b/UI/Shared/Toolbar/Button/ButtonView.js @@ -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); } } - }); }); diff --git a/UI/Shared/Toolbar/ButtonCollection.js b/UI/Shared/Toolbar/ButtonCollection.js index 1d8b9358f..8a9c4c86c 100644 --- a/UI/Shared/Toolbar/ButtonCollection.js +++ b/UI/Shared/Toolbar/ButtonCollection.js @@ -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 }); }); diff --git a/UI/Shared/Toolbar/ButtonModel.js b/UI/Shared/Toolbar/ButtonModel.js index 075718f05..2995dabeb 100644 --- a/UI/Shared/Toolbar/ButtonModel.js +++ b/UI/Shared/Toolbar/ButtonModel.js @@ -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' : '', diff --git a/UI/Shared/Toolbar/Radio/RadioButtonCollectionView.js b/UI/Shared/Toolbar/Radio/RadioButtonCollectionView.js index 51a8609e2..f7a64a1fc 100644 --- a/UI/Shared/Toolbar/Radio/RadioButtonCollectionView.js +++ b/UI/Shared/Toolbar/Radio/RadioButtonCollectionView.js @@ -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, diff --git a/UI/Shared/Toolbar/ToolbarLayout.js b/UI/Shared/Toolbar/ToolbarLayout.js index 005c11384..1c558dccf 100644 --- a/UI/Shared/Toolbar/ToolbarLayout.js +++ b/UI/Shared/Toolbar/ToolbarLayout.js @@ -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 });