diff --git a/NzbDrone.Common/Composition/Container.cs b/NzbDrone.Common/Composition/Container.cs index 9de414480..2033d3405 100644 --- a/NzbDrone.Common/Composition/Container.cs +++ b/NzbDrone.Common/Composition/Container.cs @@ -11,13 +11,7 @@ public class Container : IContainer public Container(TinyIoCContainer container) { _container = container; - //_container.Options.AllowOverridingRegistrations = true; - - - //_container.RegisterSingle(LogManager.GetCurrentClassLogger()); - _container.Register(this); - //container.RegisterWithContext(dependencyContext => LogManager.GetLogger(dependencyContext.ImplementationType.Name)); } public void Register() diff --git a/UI/Series/Index/SeriesIndexLayout.js b/UI/Series/Index/SeriesIndexLayout.js index 820211631..4519e93e1 100644 --- a/UI/Series/Index/SeriesIndexLayout.js +++ b/UI/Series/Index/SeriesIndexLayout.js @@ -111,7 +111,7 @@ define([ var viewButtons = { type : 'radio', - storeState : 'true', + storeState : true, menuKey : 'seriesViewMode', defaultAction: 'listView', items : [ @@ -136,7 +136,34 @@ define([ ] }; - this.toolbar.show(new NzbDrone.Shared.Toolbar.ToolbarLayout({right: [ viewButtons], context: this})); + + var leftSideButtons = { + type : 'default', + storeState: false, + items : [ + { + title: 'Add Series', + icon : 'icon-plus', + route: 'series/add' + }, + { + title : 'RSS Sync', + icon : 'icon-rss', + command: 'rsssync' + }, + { + title : 'Update Library', + icon : 'icon-refresh', + command: 'updatelibrary' + } + ] + }; + + this.toolbar.show(new NzbDrone.Shared.Toolbar.ToolbarLayout({ + right : [ viewButtons], + left : [ leftSideButtons], + context: this + })); } }) diff --git a/UI/Shared/Toolbar/Button/ButtonCollectionView.js b/UI/Shared/Toolbar/Button/ButtonCollectionView.js new file mode 100644 index 000000000..07c75bb97 --- /dev/null +++ b/UI/Shared/Toolbar/Button/ButtonCollectionView.js @@ -0,0 +1,9 @@ +"use strict"; +define(['app', 'Shared/Toolbar/Button/ButtonView', 'Config'], function () { + NzbDrone.Shared.Toolbar.ButtonCollectionView = Backbone.Marionette.CollectionView.extend({ + className: 'btn-group', + itemView : NzbDrone.Shared.Toolbar.ButtonView + }); +}); + + diff --git a/UI/Shared/Toolbar/Button/ButtonView.js b/UI/Shared/Toolbar/Button/ButtonView.js new file mode 100644 index 000000000..0683d4709 --- /dev/null +++ b/UI/Shared/Toolbar/Button/ButtonView.js @@ -0,0 +1,63 @@ +"use strict"; +define(['app', 'Config'], function () { + + NzbDrone.Shared.Toolbar.ButtonView = Backbone.Marionette.ItemView.extend({ + template : 'Shared/Toolbar/ButtonTemplate', + className: 'btn', + + events: { + 'click': 'onClick' + }, + + + initialize: function () { + this.storageKey = this.model.get('menuKey') + ':' + this.model.get('key'); + }, + + onRender: function () { + if (this.model.get('active')) { + this.$el.addClass('active'); + this.invokeCallback(); + } + }, + + onClick: function () { + this.invokeRoute(); + this.invokeCallback(); + this.invokeCommand(); + }, + + + invokeCommand: function () { + var command = this.model.get('command'); + if (command) { + window.alert(command); + } + }, + + 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); + } + } + + }); +}); + + + + diff --git a/UI/Shared/Toolbar/ToolbarLayout.js b/UI/Shared/Toolbar/ToolbarLayout.js index 05c64e0e5..6850be9ee 100644 --- a/UI/Shared/Toolbar/ToolbarLayout.js +++ b/UI/Shared/Toolbar/ToolbarLayout.js @@ -1,5 +1,5 @@ "use strict"; -define(['app', 'Shared/Toolbar/Radio/RadioButtonCollectionView', 'Shared/Toolbar/ButtonCollection'], function () { +define(['app', 'Shared/Toolbar/Radio/RadioButtonCollectionView','Shared/Toolbar/Button/ButtonCollectionView', 'Shared/Toolbar/ButtonCollection'], function () { NzbDrone.Shared.Toolbar.ToolbarLayout = Backbone.Marionette.Layout.extend({ template: 'Shared/Toolbar/ToolbarLayoutTemplate', @@ -64,12 +64,25 @@ define(['app', 'Shared/Toolbar/Radio/RadioButtonCollectionView', 'Shared/Toolbar var buttonGroupView; - if (buttonGroup.type === 'radio') { - buttonGroupView = new NzbDrone.Shared.Toolbar.RadioButtonCollectionView( - { - collection: groupCollection, - menu : buttonGroup - }); + switch (buttonGroup.type) { + case 'radio': + { + buttonGroupView = new NzbDrone.Shared.Toolbar.RadioButtonCollectionView( + { + collection: groupCollection, + menu : buttonGroup + }); + break; + } + default : + { + buttonGroupView = new NzbDrone.Shared.Toolbar.ButtonCollectionView( + { + collection: groupCollection, + menu : buttonGroup + }); + break; + } } this[position + '_' + (index + 1).toString()].show(buttonGroupView);