diff --git a/Gruntfile.js b/Gruntfile.js
index bd0bb243e..9780b6e71 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -155,6 +155,25 @@ module.exports = function (grunt) {
}
},
+ requirejs: {
+ compile:{
+ options: {
+ mainConfigFile: "_output/UI/app.js",
+ fileExclusionRegExp: /^.*\.(?!js$)[^.]+$/,
+ preserveLicenseComments: true,
+ dir: "rjs/",
+ optimize: 'none',
+ removeCombined: true,
+ inlineText: false,
+ modules: [{
+ name: 'app',
+ exclude: ['JsLibraries/jquery']
+ }],
+
+ }
+ }
+ },
+
watch: {
options: {
nospawn: false,
@@ -213,6 +232,7 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-notify');
grunt.loadNpmTasks('grunt-curl');
+ grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.registerTask('package', ['clean:output', 'copy', 'less', 'handlebars']);
grunt.registerTask('default', ['package', 'watch']);
diff --git a/package.json b/package.json
index 4ce59dc39..13dce8658 100644
--- a/package.json
+++ b/package.json
@@ -22,6 +22,7 @@
"grunt-contrib-copy": "*",
"grunt-curl": "*",
"grunt-notify": "*",
- "grunt-contrib-clean": "*"
+ "grunt-contrib-clean": "*",
+ "grunt-contrib-requirejs": "*"
}
}
diff --git a/src/UI/AddSeries/AddSeriesLayout.js b/src/UI/AddSeries/AddSeriesLayout.js
index 9d5eaa04c..23c21d2ed 100644
--- a/src/UI/AddSeries/AddSeriesLayout.js
+++ b/src/UI/AddSeries/AddSeriesLayout.js
@@ -1,7 +1,8 @@
'use strict';
define(
[
- 'app',
+ 'vent',
+ 'AppLayout',
'marionette',
'AddSeries/RootFolders/Layout',
'AddSeries/Existing/AddExistingSeriesCollectionView',
@@ -9,7 +10,8 @@ define(
'Quality/QualityProfileCollection',
'AddSeries/RootFolders/Collection',
'Series/SeriesCollection'
- ], function (App,
+ ], function (vent,
+ AppLayout,
Marionette,
RootFolderLayout,
ExistingSeriesCollectionView,
@@ -43,7 +45,7 @@ define(
},
_folderSelected: function (options) {
- App.vent.trigger(App.Commands.CloseModalCommand);
+ vent.trigger(vent.Commands.CloseModalCommand);
this.workspace.show(new ExistingSeriesCollectionView({model: options.model}));
},
@@ -51,7 +53,7 @@ define(
_importSeries: function () {
this.rootFolderLayout = new RootFolderLayout();
this.rootFolderLayout.on('folderSelected', this._folderSelected, this);
- App.modalRegion.show(this.rootFolderLayout);
+ AppLayout.modalRegion.show(this.rootFolderLayout);
},
_addSeries: function () {
diff --git a/src/UI/AddSeries/AddSeriesView.js b/src/UI/AddSeries/AddSeriesView.js
index 2eb2596d6..1f96de134 100644
--- a/src/UI/AddSeries/AddSeriesView.js
+++ b/src/UI/AddSeries/AddSeriesView.js
@@ -1,14 +1,14 @@
'use strict';
define(
[
- 'app',
+ 'vent',
'marionette',
'AddSeries/AddSeriesCollection',
'AddSeries/SearchResultCollectionView',
'AddSeries/NotFoundView',
'Shared/LoadingView',
'underscore'
- ], function (App, Marionette, AddSeriesCollection, SearchResultCollectionView, NotFoundView, LoadingView, _) {
+ ], function (vent, Marionette, AddSeriesCollection, SearchResultCollectionView, NotFoundView, LoadingView, _) {
return Marionette.Layout.extend({
template: 'AddSeries/AddSeriesViewTemplate',
@@ -41,7 +41,7 @@ define(
this.className = 'new-series';
}
- this.listenTo(App.vent, App.Events.SeriesAdded, this._onSeriesAdded);
+ this.listenTo(vent, vent.Events.SeriesAdded, this._onSeriesAdded);
this.listenTo(this.collection, 'sync', this._showResults);
this.resultCollectionView = new SearchResultCollectionView({
diff --git a/src/UI/AddSeries/AddSeriesViewTemplate.html b/src/UI/AddSeries/AddSeriesViewTemplate.html
index 518a5ed15..8c0a87817 100644
--- a/src/UI/AddSeries/AddSeriesViewTemplate.html
+++ b/src/UI/AddSeries/AddSeriesViewTemplate.html
@@ -20,4 +20,4 @@
more
-
{{debug}}
+
diff --git a/src/UI/AddSeries/NotFoundTemplate.html b/src/UI/AddSeries/NotFoundTemplate.html
index fa6c8f5b2..cfe1e34e6 100644
--- a/src/UI/AddSeries/NotFoundTemplate.html
+++ b/src/UI/AddSeries/NotFoundTemplate.html
@@ -5,4 +5,3 @@
Why can't I find my show?
-{{debug}}
diff --git a/src/UI/AddSeries/SearchResultView.js b/src/UI/AddSeries/SearchResultView.js
index a25d36e5c..53bd3246b 100644
--- a/src/UI/AddSeries/SearchResultView.js
+++ b/src/UI/AddSeries/SearchResultView.js
@@ -1,7 +1,8 @@
'use strict';
define(
[
- 'app',
+ 'vent',
+ 'AppLayout',
'underscore',
'marionette',
'Quality/QualityProfileCollection',
@@ -12,7 +13,7 @@ define(
'Shared/Messenger',
'Mixins/AsValidatedView',
'jquery.dotdotdot'
- ], function (App, _, Marionette, QualityProfiles, RootFolders, RootFolderLayout, SeriesCollection, Config, Messenger, AsValidatedView) {
+ ], function (vent, AppLayout, _, Marionette, QualityProfiles, RootFolders, RootFolderLayout, SeriesCollection, Config, Messenger, AsValidatedView) {
var view = Marionette.ItemView.extend({
@@ -41,7 +42,7 @@ define(
this.templateHelpers = {};
this._configureTemplateHelpers();
- this.listenTo(App.vent, Config.Events.ConfigUpdatedEvent, this._onConfigUpdated);
+ this.listenTo(vent, Config.Events.ConfigUpdatedEvent, this._onConfigUpdated);
this.listenTo(this.model, 'change', this.render);
this.listenTo(RootFolders, 'all', this.render);
@@ -105,7 +106,7 @@ define(
_rootFolderChanged: function () {
var rootFolderValue = this.ui.rootFolder.val();
if (rootFolderValue === 'addNew') {
- App.modalRegion.show(this.rootFolderLayout);
+ AppLayout.modalRegion.show(this.rootFolderLayout);
}
else {
Config.setValue(Config.Keys.DefaultRootFolderId, rootFolderValue);
@@ -113,7 +114,7 @@ define(
},
_setRootFolder: function (options) {
- App.vent.trigger(App.Commands.CloseModalCommand);
+ vent.trigger(vent.Commands.CloseModalCommand);
this.ui.rootFolder.val(options.model.id);
this._rootFolderChanged();
},
@@ -145,7 +146,7 @@ define(
message: 'Added: ' + self.model.get('title')
});
- App.vent.trigger(App.Events.SeriesAdded, { series: self.model });
+ vent.trigger(vent.Events.SeriesAdded, { series: self.model });
});
promise.fail(function () {
diff --git a/src/UI/AppLayout.js b/src/UI/AppLayout.js
new file mode 100644
index 000000000..b063516f3
--- /dev/null
+++ b/src/UI/AppLayout.js
@@ -0,0 +1,23 @@
+define(
+ [
+ 'marionette',
+ 'Shared/Modal/ModalRegion'
+ ], function (Marionette, ModalRegion) {
+ 'use strict';
+
+ var Layout = Marionette.Layout.extend({
+
+ regions: {
+ navbarRegion: '#nav-region',
+ mainRegion : '#main-region'
+ },
+
+ initialize: function () {
+ this.addRegions({
+ modalRegion: ModalRegion
+ });
+ }
+ });
+
+ return new Layout({el: 'body'});
+ });
diff --git a/src/UI/Calendar/CalendarView.js b/src/UI/Calendar/CalendarView.js
index ec4012a8e..0d4422845 100644
--- a/src/UI/Calendar/CalendarView.js
+++ b/src/UI/Calendar/CalendarView.js
@@ -2,12 +2,12 @@
define(
[
- 'app',
+ 'vent',
'marionette',
'moment',
'Calendar/Collection',
'fullcalendar'
- ], function (App, Marionette, Moment, CalendarCollection) {
+ ], function (vent, Marionette, Moment, CalendarCollection) {
var _instance;
@@ -38,7 +38,7 @@ define(
$(element).children('.fc-event-inner').addClass(event.statusLevel);
},
eventClick : function (event) {
- App.vent.trigger(App.Commands.ShowEpisodeDetails, {episode: event.model});
+ vent.trigger(vent.Commands.ShowEpisodeDetails, {episode: event.model});
}
});
@@ -108,7 +108,7 @@ define(
var test = currentTime.startOf('day').format('LLLL');
if (end.isBefore(currentTime.startOf('day'))) {
- statusLevel += ' past'
+ statusLevel += ' past';
}
return statusLevel;
diff --git a/src/UI/Calendar/UpcomingItemView.js b/src/UI/Calendar/UpcomingItemView.js
index b2abd380b..3117f207c 100644
--- a/src/UI/Calendar/UpcomingItemView.js
+++ b/src/UI/Calendar/UpcomingItemView.js
@@ -2,10 +2,10 @@
define(
[
- 'app',
+ 'vent',
'marionette',
'moment'
- ], function (App, Marionette, Moment) {
+ ], function (vent, Marionette, Moment) {
return Marionette.ItemView.extend({
template: 'Calendar/UpcomingItemViewTemplate',
tagName : 'div',
@@ -21,11 +21,11 @@ define(
this.model.set({
end: end.toISOString()
- })
+ });
},
_showEpisodeDetails: function () {
- App.vent.trigger(App.Commands.ShowEpisodeDetails, {episode: this.model});
+ vent.trigger(vent.Commands.ShowEpisodeDetails, {episode: this.model});
}
});
});
diff --git a/src/UI/Cells/Edit/QualityCellEditor.js b/src/UI/Cells/Edit/QualityCellEditor.js
index 51ebceb55..dee096929 100644
--- a/src/UI/Cells/Edit/QualityCellEditor.js
+++ b/src/UI/Cells/Edit/QualityCellEditor.js
@@ -12,8 +12,8 @@ define(
tagName : 'select',
events: {
- 'change': 'save',
- 'blur': 'close',
+ 'change' : 'save',
+ 'blur' : 'close',
'keydown': 'close'
},
@@ -45,12 +45,12 @@ define(
save: function (e) {
var model = this.model;
var column = this.column;
- var selected = parseInt(this.$el.val());
+ var selected = parseInt(this.$el.val(), 10);
var quality = _.find(this.schema.get('available'), { 'id': selected });
var newQuality = {
- proper: false,
+ proper : false,
quality: quality
};
diff --git a/src/UI/Cells/EpisodeActionsCell.js b/src/UI/Cells/EpisodeActionsCell.js
index 229c52f06..ad87c1468 100644
--- a/src/UI/Cells/EpisodeActionsCell.js
+++ b/src/UI/Cells/EpisodeActionsCell.js
@@ -2,10 +2,11 @@
define(
[
- 'app',
+ 'vent',
+ 'marionette',
'Cells/NzbDroneCell',
'Commands/CommandController'
- ], function (App, NzbDroneCell, CommandController) {
+ ], function (vent, Marionette, NzbDroneCell, CommandController) {
return NzbDroneCell.extend({
className: 'episode-actions-cell',
@@ -48,7 +49,7 @@ define(
},
_manualSearch: function () {
- App.vent.trigger(App.Commands.ShowEpisodeDetails, { episode: this.cellValue, hideSeriesLink: true, openingTab: 'search' });
+ vent.trigger(vent.Commands.ShowEpisodeDetails, { episode: this.cellValue, hideSeriesLink: true, openingTab: 'search' });
}
});
});
diff --git a/src/UI/Cells/EpisodeStatusCell.js b/src/UI/Cells/EpisodeStatusCell.js
index a8f5c8c00..2e9a69453 100644
--- a/src/UI/Cells/EpisodeStatusCell.js
+++ b/src/UI/Cells/EpisodeStatusCell.js
@@ -2,13 +2,13 @@
define(
[
- 'app',
+ 'reqres',
'underscore',
'Cells/NzbDroneCell',
'History/Queue/QueueCollection',
'moment',
'Shared/FormatHelpers'
- ], function (App, _, NzbDroneCell, QueueCollection, Moment, FormatHelpers) {
+ ], function (Reqres, _, NzbDroneCell, QueueCollection, Moment, FormatHelpers) {
return NzbDroneCell.extend({
className: 'episode-status-cell',
@@ -33,7 +33,7 @@ define(
var hasFile = this.model.get('hasFile');
if (hasFile) {
- var episodeFile = App.request(App.Reqres.GetEpisodeFileById, this.model.get('episodeFileId'));
+ var episodeFile = Reqres.request(reqres.Requests.GetEpisodeFileById, this.model.get('episodeFileId'));
this.listenTo(episodeFile, 'change', this._refresh);
diff --git a/src/UI/Cells/EpisodeTitleCell.js b/src/UI/Cells/EpisodeTitleCell.js
index ae0143c0c..2e6ed9605 100644
--- a/src/UI/Cells/EpisodeTitleCell.js
+++ b/src/UI/Cells/EpisodeTitleCell.js
@@ -2,9 +2,9 @@
define(
[
- 'app',
+ 'vent',
'Cells/NzbDroneCell'
- ], function (App, NzbDroneCell) {
+ ], function (vent, NzbDroneCell) {
return NzbDroneCell.extend({
className: 'episode-title-cell',
@@ -27,7 +27,7 @@ define(
_showDetails: function () {
var hideSeriesLink = this.column.get('hideSeriesLink');
- App.vent.trigger(App.Commands.ShowEpisodeDetails, { episode: this.cellValue, hideSeriesLink: hideSeriesLink });
+ vent.trigger(vent.Commands.ShowEpisodeDetails, { episode: this.cellValue, hideSeriesLink: hideSeriesLink });
}
});
});
diff --git a/src/UI/Cells/SeriesActionsCell.js b/src/UI/Cells/SeriesActionsCell.js
index 84e90c688..83a3ba1d2 100644
--- a/src/UI/Cells/SeriesActionsCell.js
+++ b/src/UI/Cells/SeriesActionsCell.js
@@ -2,9 +2,9 @@
define(
[
- 'app',
+ 'vent',
'Cells/NzbDroneCell'
- ], function (App, NzbDroneCell) {
+ ], function (vent, NzbDroneCell) {
return NzbDroneCell.extend({
className: 'series-actions-cell',
@@ -27,11 +27,11 @@ define(
},
_editSeries: function () {
- App.vent.trigger(App.Commands.EditSeriesCommand, {series:this.model});
+ vent.trigger(vent.Commands.EditSeriesCommand, {series:this.model});
},
_removeSeries: function () {
- App.vent.trigger(App.Commands.DeleteSeriesCommand, {series:this.model});
+ vent.trigger(vent.Commands.DeleteSeriesCommand, {series:this.model});
}
});
});
diff --git a/src/UI/Commands/CommandController.js b/src/UI/Commands/CommandController.js
index 8e14512cf..4bb78f011 100644
--- a/src/UI/Commands/CommandController.js
+++ b/src/UI/Commands/CommandController.js
@@ -1,12 +1,16 @@
'use strict';
define(
[
- 'app',
+ 'vent',
'Commands/CommandModel',
'Commands/CommandCollection',
+ 'Commands/CommandMessengerCollectionView',
'underscore',
'jQuery/jquery.spin'
- ], function (App, CommandModel, CommandCollection, _) {
+ ], function (vent, CommandModel, CommandCollection, CommandMessengerCollectionView, _) {
+
+
+ CommandMessengerCollectionView.render();
var singleton = function () {
@@ -33,11 +37,18 @@ define(
this._bindToCommandModel.call(this, existingCommand, options);
}
- CommandCollection.bind('add sync', function (model) {
+ CommandCollection.bind('add', function (model) {
if (model.isSameCommand(options.command)) {
self._bindToCommandModel.call(self, model, options);
}
});
+
+ CommandCollection.bind('add sync', function () {
+ var command = CommandCollection.findCommand(options.command);
+ if (command) {
+ self._bindToCommandModel.call(self, command, options);
+ }
+ });
},
_bindToCommandModel: function bindToCommand(model, options) {
@@ -52,7 +63,7 @@ define(
options.element.stopSpin();
if (model.isComplete()) {
- App.vent.trigger(App.Events.CommandComplete, { command: model, model: options.model });
+ vent.trigger(vent.Events.CommandComplete, { command: model, model: options.model });
}
}
});
diff --git a/src/UI/Commands/CommandMessengerCollectionView.js b/src/UI/Commands/CommandMessengerCollectionView.js
index 238642ab6..dd8058c7e 100644
--- a/src/UI/Commands/CommandMessengerCollectionView.js
+++ b/src/UI/Commands/CommandMessengerCollectionView.js
@@ -1,15 +1,14 @@
'use strict';
define(
[
- 'app',
'marionette',
'Commands/CommandCollection',
'Commands/CommandMessengerItemView'
- ], function (App, Marionette, commandCollection, CommandMessengerItemView) {
+ ], function (Marionette, commandCollection, CommandMessengerItemView) {
var CollectionView = Marionette.CollectionView.extend({
- itemView : CommandMessengerItemView
+ itemView: CommandMessengerItemView
});
- new CollectionView({collection: commandCollection});
+ return new CollectionView({collection: commandCollection});
});
diff --git a/src/UI/Commands/CommandMessengerItemView.js b/src/UI/Commands/CommandMessengerItemView.js
index 03199462b..d772943be 100644
--- a/src/UI/Commands/CommandMessengerItemView.js
+++ b/src/UI/Commands/CommandMessengerItemView.js
@@ -1,10 +1,9 @@
'use strict';
define(
[
- 'app',
'marionette',
'Shared/Messenger'
- ], function (App, Marionette, Messenger) {
+ ], function ( Marionette, Messenger) {
return Marionette.ItemView.extend({
diff --git a/src/UI/Config.js b/src/UI/Config.js
index e5409f25b..f1bbf757c 100644
--- a/src/UI/Config.js
+++ b/src/UI/Config.js
@@ -1,8 +1,8 @@
'use strict';
define(
[
- 'app'
- ], function (App) {
+ 'vent'
+ ], function (vent) {
return {
Events: {
ConfigUpdatedEvent: 'ConfigUpdatedEvent'
@@ -36,7 +36,7 @@ define(
}
localStorage.setItem(key, value);
- App.vent.trigger(this.Events.ConfigUpdatedEvent, {key: key, value: value});
+ vent.trigger(this.Events.ConfigUpdatedEvent, {key: key, value: value});
}
};
diff --git a/src/UI/Controller.js b/src/UI/Controller.js
index 97efe7b3d..ff9dec7ef 100644
--- a/src/UI/Controller.js
+++ b/src/UI/Controller.js
@@ -1,118 +1,77 @@
'use strict';
define(
[
- 'app',
+ 'Shared/NzbDroneController',
+ 'AppLayout',
'marionette',
'History/HistoryLayout',
'Settings/SettingsLayout',
'AddSeries/AddSeriesLayout',
- 'Series/Index/SeriesIndexLayout',
- 'Series/Details/SeriesDetailsLayout',
- 'Series/SeriesCollection',
'Missing/MissingLayout',
'Calendar/CalendarLayout',
'Release/Layout',
'System/SystemLayout',
'SeasonPass/SeasonPassLayout',
- 'System/Update/UpdateLayout',
- 'Shared/NotFoundView',
- 'Shared/Modal/Region'
- ], function (App,
+ 'System/Update/UpdateLayout'
+ ], function (NzbDroneController,
+ AppLayout,
Marionette,
HistoryLayout,
SettingsLayout,
AddSeriesLayout,
- SeriesIndexLayout,
- SeriesDetailsLayout,
- SeriesCollection,
MissingLayout,
CalendarLayout,
ReleaseLayout,
SystemLayout,
SeasonPassLayout,
- UpdateLayout,
- NotFoundView) {
- return Marionette.Controller.extend({
-
- series: function () {
- this._setTitle('NzbDrone');
- App.mainRegion.show(new SeriesIndexLayout());
- },
-
- seriesDetails: function (query) {
- var series = SeriesCollection.where({titleSlug: query});
-
- if (series.length !== 0) {
- var targetSeries = series[0];
- this._setTitle(targetSeries.get('title'));
- App.mainRegion.show(new SeriesDetailsLayout({ model: targetSeries }));
- }
- else {
- this.notFound();
- }
- },
+ UpdateLayout) {
+ return NzbDroneController.extend({
addSeries: function (action) {
- this._setTitle('Add Series');
- App.mainRegion.show(new AddSeriesLayout({action: action}));
+ this.setTitle('Add Series');
+ AppLayout.mainRegion.show(new AddSeriesLayout({action: action}));
},
calendar: function () {
- this._setTitle('Calendar');
- App.mainRegion.show(new CalendarLayout());
+ this.setTitle('Calendar');
+ AppLayout.mainRegion.show(new CalendarLayout());
},
settings: function (action) {
- this._setTitle('Settings');
- App.mainRegion.show(new SettingsLayout({ action: action }));
+ this.setTitle('Settings');
+ AppLayout.mainRegion.show(new SettingsLayout({ action: action }));
},
missing: function () {
- this._setTitle('Missing');
+ this.setTitle('Missing');
- App.mainRegion.show(new MissingLayout());
+ AppLayout.mainRegion.show(new MissingLayout());
},
history: function (action) {
- this._setTitle('History');
+ this.setTitle('History');
- App.mainRegion.show(new HistoryLayout({ action: action }));
+ AppLayout.mainRegion.show(new HistoryLayout({ action: action }));
},
rss: function () {
- this._setTitle('RSS');
- App.mainRegion.show(new ReleaseLayout());
+ this.setTitle('RSS');
+ AppLayout.mainRegion.show(new ReleaseLayout());
},
system: function (action) {
- this._setTitle('System');
- App.mainRegion.show(new SystemLayout({ action: action }));
+ this.setTitle('System');
+ AppLayout.mainRegion.show(new SystemLayout({ action: action }));
},
seasonPass: function () {
- this._setTitle('Season Pass');
- App.mainRegion.show(new SeasonPassLayout());
+ this.setTitle('Season Pass');
+ AppLayout.mainRegion.show(new SeasonPassLayout());
},
update: function () {
- this._setTitle('Updates');
- App.mainRegion.show(new UpdateLayout());
- },
-
- notFound: function () {
- this._setTitle('Not Found');
- App.mainRegion.show(new NotFoundView(this));
- },
-
- _setTitle: function (title) {
- //$('#title-region').html(title);
-
- if (title.toLocaleLowerCase() === 'nzbdrone') {
- window.document.title = 'NzbDrone';
- }
- else {
- window.document.title = title + ' - NzbDrone';
- }
+ this.setTitle('Updates');
+ AppLayout.mainRegion.show(new UpdateLayout());
}
});
});
diff --git a/src/UI/Episode/Activity/EpisodeActivityLayout.js b/src/UI/Episode/Activity/EpisodeActivityLayout.js
index ccfb3f128..f1ed7cbbb 100644
--- a/src/UI/Episode/Activity/EpisodeActivityLayout.js
+++ b/src/UI/Episode/Activity/EpisodeActivityLayout.js
@@ -1,7 +1,6 @@
'use strict';
define(
[
- 'app',
'marionette',
'backgrid',
'History/HistoryCollection',
@@ -10,7 +9,7 @@ define(
'Cells/RelativeDateCell',
'Episode/Activity/NoActivityView',
'Shared/LoadingView'
- ], function (App, Marionette, Backgrid, HistoryCollection, EventTypeCell, QualityCell, RelativeDateCell, NoActivityView, LoadingView) {
+ ], function (Marionette, Backgrid, HistoryCollection, EventTypeCell, QualityCell, RelativeDateCell, NoActivityView, LoadingView) {
return Marionette.Layout.extend({
template: 'Episode/Activity/EpisodeActivityLayoutTemplate',
diff --git a/src/UI/Episode/Search/ButtonsView.js b/src/UI/Episode/Search/ButtonsView.js
index 6daa5abb4..10832c661 100644
--- a/src/UI/Episode/Search/ButtonsView.js
+++ b/src/UI/Episode/Search/ButtonsView.js
@@ -1,9 +1,8 @@
'use strict';
define(
[
- 'app',
'marionette'
- ], function (App, Marionette) {
+ ], function (Marionette) {
return Marionette.ItemView.extend({
template: 'Episode/Search/ButtonsViewTemplate'
diff --git a/src/UI/Episode/Search/EpisodeSearchLayout.js b/src/UI/Episode/Search/EpisodeSearchLayout.js
index a58c5db41..f527ec038 100644
--- a/src/UI/Episode/Search/EpisodeSearchLayout.js
+++ b/src/UI/Episode/Search/EpisodeSearchLayout.js
@@ -1,7 +1,7 @@
'use strict';
define(
[
- 'app',
+ 'vent',
'marionette',
'Episode/Search/ButtonsView',
'Episode/Search/ManualLayout',
@@ -9,7 +9,7 @@ define(
'Series/SeriesCollection',
'Commands/CommandController',
'Shared/LoadingView'
- ], function (App, Marionette, ButtonsView, ManualSearchLayout, ReleaseCollection, SeriesCollection,CommandController, LoadingView) {
+ ], function (vent, Marionette, ButtonsView, ManualSearchLayout, ReleaseCollection, SeriesCollection,CommandController, LoadingView) {
return Marionette.Layout.extend({
template: 'Episode/Search/EpisodeSearchLayoutTemplate',
@@ -50,7 +50,7 @@ define(
episodeIds: [ this.model.get('id') ]
});
- App.vent.trigger(App.Commands.CloseModalCommand);
+ vent.trigger(vent.Commands.CloseModalCommand);
},
_searchManual: function (e) {
diff --git a/src/UI/Episode/Summary/EpisodeSummaryLayout.js b/src/UI/Episode/Summary/EpisodeSummaryLayout.js
index 3ee5fe57d..32011b169 100644
--- a/src/UI/Episode/Summary/EpisodeSummaryLayout.js
+++ b/src/UI/Episode/Summary/EpisodeSummaryLayout.js
@@ -1,7 +1,7 @@
'use strict';
define(
[
- 'app',
+ 'reqres',
'marionette',
'backgrid',
'Series/EpisodeFileModel',
@@ -10,7 +10,7 @@ define(
'Cells/QualityCell',
'Episode/Summary/NoFileView',
'Shared/LoadingView'
- ], function (App, Marionette, Backgrid, EpisodeFileModel, EpisodeFileCollection, FileSizeCell, QualityCell, NoFileView, LoadingView) {
+ ], function (reqres, Marionette, Backgrid, EpisodeFileModel, EpisodeFileCollection, FileSizeCell, QualityCell, NoFileView, LoadingView) {
return Marionette.Layout.extend({
template: 'Episode/Summary/EpisodeSummaryLayoutTemplate',
@@ -55,8 +55,8 @@ define(
if (this.model.get('hasFile')) {
var episodeFileId = this.model.get('episodeFileId');
- if (App.reqres.hasHandler(App.Reqres.GetEpisodeFileById)) {
- var episodeFile = App.request(App.Reqres.GetEpisodeFileById, episodeFileId);
+ if (reqres.hasHandler(reqres.Requests.GetEpisodeFileById)) {
+ var episodeFile = reqres.request(reqres.Requests.GetEpisodeFileById, episodeFileId);
var episodeFileCollection = new EpisodeFileCollection(episodeFile, { seriesId: this.model.get('seriesId') });
this._showTable(episodeFileCollection);
}
diff --git a/src/UI/History/HistoryLayout.js b/src/UI/History/HistoryLayout.js
index c055984f8..04f5bc12f 100644
--- a/src/UI/History/HistoryLayout.js
+++ b/src/UI/History/HistoryLayout.js
@@ -1,22 +1,18 @@
'use strict';
define(
[
- 'app',
'marionette',
+ 'backbone',
'backgrid',
'History/Table/HistoryTableLayout',
'History/Queue/QueueLayout'
- ], function (App,
- Marionette,
- Backgrid,
- HistoryTableLayout,
- QueueLayout) {
+ ], function (Marionette, Backbone, Backgrid, HistoryTableLayout, QueueLayout) {
return Marionette.Layout.extend({
template: 'History/HistoryLayoutTemplate',
regions: {
- history: '#history',
- queueRegion : '#queue'
+ history : '#history',
+ queueRegion: '#queue'
},
ui: {
@@ -25,8 +21,8 @@ define(
},
events: {
- 'click .x-history-tab' : '_showHistory',
- 'click .x-queue-tab' : '_showQueue'
+ 'click .x-history-tab': '_showHistory',
+ 'click .x-queue-tab' : '_showQueue'
},
initialize: function (options) {
@@ -45,10 +41,8 @@ define(
}
},
- _navigate:function(route){
- require(['Router'], function(){
- App.Router.navigate(route);
- });
+ _navigate: function (route) {
+ Backbone.history.navigate(route);
},
_showHistory: function (e) {
diff --git a/src/UI/History/Table/HistoryDetailsCell.js b/src/UI/History/Table/HistoryDetailsCell.js
index 33ba3d609..5f29097c3 100644
--- a/src/UI/History/Table/HistoryDetailsCell.js
+++ b/src/UI/History/Table/HistoryDetailsCell.js
@@ -2,9 +2,9 @@
define(
[
- 'app',
+ 'vent',
'Cells/NzbDroneCell'
- ], function (App, NzbDroneCell) {
+ ], function (vent, NzbDroneCell) {
return NzbDroneCell.extend({
className: 'history-details-cell',
@@ -21,7 +21,7 @@ define(
},
_showDetails: function () {
- App.vent.trigger(App.Commands.ShowHistoryDetails, { history: this.model });
+ vent.trigger(vent.Commands.ShowHistoryDetails, { history: this.model });
}
});
});
diff --git a/src/UI/JsLibraries/xrayquire.js b/src/UI/JsLibraries/xrayquire.js
new file mode 100644
index 000000000..934f7f613
--- /dev/null
+++ b/src/UI/JsLibraries/xrayquire.js
@@ -0,0 +1,416 @@
+/**
+ * @license xrayquire 0.0.0 Copyright (c) 2012, The Dojo Foundation All Rights Reserved.
+ * Available via the MIT or new BSD license.
+ * see: http://github.com/requirejs/xrayquire for details
+ */
+/*jslint nomen: true */
+/*global requirejs, console, window */
+
+/**
+ * Put a script tag in the HTML that references this script right after the
+ * script tag for require.js.
+ */
+
+var xrayquire;
+(function () {
+ 'use strict';
+
+ var contexts = {},
+ config = typeof xrayquire === 'undefined' ? {} : xrayquire,
+ s = requirejs.s,
+ oldNewContext = s.newContext,
+ tokenRegExp = /\{(\w+)\}/g,
+ standardDeps = {
+ require: true,
+ exports: true,
+ module: true
+ },
+ prop;
+
+ function each(ary, func) {
+ if (ary) {
+ var i;
+ for (i = 0; i < ary.length; i += 1) {
+ if (ary[i] && func(ary[i], i, ary)) {
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * Cycles over properties in an object and calls a function for each
+ * property value. If the function returns a truthy value, then the
+ * iteration is stopped.
+ */
+ function eachProp(obj, func) {
+ var prop;
+ for (prop in obj) {
+ if (obj.hasOwnProperty(prop)) {
+ if (func(obj[prop], prop)) {
+ break;
+ }
+ }
+ }
+ }
+
+ function hasProp(obj, prop) {
+ return obj.hasOwnProperty(prop);
+ }
+
+ /**
+ * Simple function to mix in properties from source into target,
+ * but only if target does not already have a property of the same name.
+ * This is not robust in IE for transferring methods that match
+ * Object.prototype names, but the uses of mixin here seem unlikely to
+ * trigger a problem related to that.
+ */
+ function mixin(target, source, force, deepStringMixin) {
+ if (source) {
+ eachProp(source, function (value, prop) {
+ if (force || !hasProp(target, prop)) {
+ if (deepStringMixin && typeof value !== 'string') {
+ if (!target[prop]) {
+ target[prop] = {};
+ }
+ mixin(target[prop], value, force, deepStringMixin);
+ } else {
+ target[prop] = value;
+ }
+ }
+ });
+ }
+ return target;
+ }
+
+ function isRequire(id) {
+ return id.indexOf('_@r') !== -1;
+ }
+
+ function formatId(id) {
+ //If the ID is for a require call, make it prettier.
+ return isRequire(id) ? 'require()' : id;
+ }
+
+ function formatUrl(url) {
+ return !url || isRequire(url) ? '' : url;
+ }
+
+ function getX(context) {
+ if (!context.xray) {
+ context.xray = {
+ traced: {},
+ traceOrder: [],
+ mixedCases: {}
+ };
+ }
+ return context.xray;
+ }
+
+ function modContext(context) {
+ var oldLoad = context.load,
+ modProto = context.Module.prototype,
+ oldModuleEnable = modProto.enable,
+ xray = getX(context),
+ traced = xray.traced,
+ mixedCases = xray.mixedCases;
+
+ function trackModule(mod) {
+ var id = mod.map.id,
+ traceData;
+
+ //If an intermediate module from a plugin, do not
+ //track it
+ if (mod.map.prefix && id.indexOf('_unnormalized') !== -1) {
+ return;
+ }
+
+ //Cycle through the dependencies now, wire this up here
+ //instead of context.load so that we get a recording of
+ //modules as they are encountered, and not as they
+ //are fetched/loaded, since things could fall over between
+ //now and then.
+ if (!traced[id] || !traced[id].deps || !traced[id].deps.length) {
+ each(mod.depMaps, function (dep) {
+ var depId = dep.id,
+ lowerId = depId.toLowerCase();
+
+ if (mixedCases[lowerId] && depId !== mixedCases[lowerId].id) {
+ console.error('Mixed case modules may conflict: ' +
+ formatId(mixedCases[lowerId].refId) +
+ ' asked for: "' +
+ mixedCases[lowerId].id +
+ '" and ' +
+ formatId(id) +
+ ' asked for: "' +
+ depId +
+ '"');
+ } else {
+ mixedCases[lowerId] = {
+ refId: id,
+ id: depId
+ };
+ }
+ });
+
+ traceData = {
+ map: mod.map,
+ deps: mod.depMaps
+ };
+
+ //Only add this to the order if not previously added.
+ if (!traced[id]) {
+ xray.traceOrder.push(id);
+ }
+
+ //Set the data again in case this enable has the
+ //real dependencies. Some first calls of enable do
+ //not have the dependencies known yet.
+ traced[id] = traceData;
+ }
+ }
+
+ modProto.enable = function () {
+ var result = oldModuleEnable.apply(this, arguments);
+ trackModule(this);
+ return result;
+ };
+
+ //Collect any modules that are already in process
+ eachProp(context.registry, function (mod) {
+ if (mod.enabled) {
+ trackModule(mod);
+ }
+ });
+
+ return context;
+ }
+
+ //Mod any existing contexts.
+ eachProp(requirejs.s.contexts, function (context) {
+ modContext(context);
+ });
+
+ //Apply mods to any new context.
+ s.newContext = function (name) {
+ return modContext(oldNewContext);
+ };
+
+ requirejs.onResourceLoad = function (context, map, deps) {
+ var id = map.id;
+
+ if (typeof context.defined[id] === 'undefined') {
+ //May be a problem with a circular dependency.
+ //console.error(id + ' has undefined module value, may be part ' +
+ // 'of a bad circular reference');
+ }
+ };
+
+
+ function sortTraceOrder(traceOrder) {
+ //Sort the traceOrder, but do it by lowercase comparisons,
+ //to keep 'something' and 'Something' next to each other.
+ traceOrder.sort(function (a, b) {
+ return a.toLowerCase() > b.toLowerCase() ? 1 : -1;
+ });
+ }
+
+ function htmlEscape(id) {
+ return (id || '')
+ .replace('<', '<')
+ .replace('>', '>')
+ .replace('&', '&')
+ .replace('"', '"');
+ }
+
+ function template(contents, data) {
+ return contents.replace(tokenRegExp, function (match, token) {
+ var result = data[token];
+
+ //Just use empty string for null or undefined
+ if (result === null || result === undefined) {
+ result = '';
+ }
+
+ return result;
+ });
+ }
+
+
+ function findCycle(mod, traced, masterVisited, visited) {
+ var id = mod.map.id,
+ depArray = mod.deps,
+ foundModule;
+
+ //Do not bother with require calls or standard deps,
+ //or things that are already listed in a cycle
+ if (isRequire(id) || masterVisited[id] || standardDeps[id]) {
+ return;
+ }
+
+ //Found the cycle.
+ if (visited[id]) {
+ return {
+ mod: mod,
+ visited: visited
+ };
+ }
+
+ visited[id] = true;
+
+ //Trace through the dependencies.
+ each(depArray, function (depMap) {
+ var depId = depMap.id,
+ depMod = traced[depId];
+
+ if (!depMod) {
+ return;
+ }
+
+ //mixin visited to a new object for each dependency, so that
+ //sibling dependencies in this object to not generate a
+ //false positive match on a cycle. Ideally an Object.create
+ //type of prototype delegation would be used here, but
+ //optimizing for file size vs. execution speed since hopefully
+ //the trees are small for circular dependency scans relative
+ //to the full app perf.
+ return (foundModule = findCycle(depMod, traced, masterVisited, mixin({}, visited)));
+ });
+
+ return foundModule;
+ }
+
+ function showHtml(html) {
+ //Convert to URL encoded data
+ html = encodeURIComponent(html);
+
+ //Display the HTML
+ window.open('data:text/html;charset=utf-8,' + html, '_blank');
+ }
+
+ /**
+ * Public API
+ */
+ xrayquire = {
+ treeHtml: '\n\n\nModule Dependencies\n\n\n\n{content}\n\n\n',
+ treeDepItemHtml: '{id}',
+ treeDepItemNoLinkHtml: '{id}',
+ treeItemHtml: '\n',
+
+ makeHtmlId: function (id) {
+ return encodeURIComponent(id);
+ },
+
+ makeTemplateData: function (mod) {
+ return {
+ htmlId: xrayquire.makeHtmlId(mod.id),
+ id: htmlEscape(formatId(mod.id)),
+ url: htmlEscape(formatUrl(mod.url))
+ };
+ },
+
+ showTree: function (contextName) {
+ var context = requirejs.s.contexts[contextName || '_'],
+ xray = getX(context),
+ traced = xray.traced,
+ html = '';
+
+ sortTraceOrder(xray.traceOrder);
+
+ //Generate the HTML
+ each(xray.traceOrder, function (id) {
+ var mod = traced[id],
+ templateData = xrayquire.makeTemplateData(mod.map);
+
+ //Do not bother if this is a require() call with no
+ //dependencies
+ if (isRequire(mod.map.id) && (!mod.deps || !mod.deps.length)) {
+ return;
+ }
+
+ templateData.depItems = '';
+
+ each(mod.deps, function (dep) {
+ var depHtmlTemplate = standardDeps[dep.id] ?
+ xrayquire.treeDepItemNoLinkHtml :
+ xrayquire.treeDepItemHtml;
+
+ templateData.depItems += template(depHtmlTemplate,
+ xrayquire.makeTemplateData(dep));
+ });
+
+ html += template(xrayquire.treeItemHtml, templateData);
+ });
+
+ //Put the HTML in a full HTML document.
+ html = template(xrayquire.treeHtml, {
+ content: html
+ });
+
+ showHtml(html);
+ },
+
+ getCycles: function (contextName) {
+ var context = requirejs.s.contexts[contextName || '_'],
+ cycles = {},
+ xray = getX(context),
+ traced = xray.traced,
+ masterVisited = {},
+ foundCycle = false;
+
+ sortTraceOrder(xray.traceOrder);
+
+ each(xray.traceOrder, function (id) {
+ var mod = traced[id],
+ cycleInfo = findCycle(mod, traced, masterVisited, {});
+
+ if (cycleInfo) {
+ foundCycle = true;
+ mod = cycleInfo.mod;
+ mixin(masterVisited, cycleInfo.visited);
+
+ cycles[mod.map.id] = {
+ visited: cycleInfo.visited
+ };
+ }
+ });
+
+ return foundCycle ? cycles : null;
+ },
+
+ cycleHtml: '\n\n\nModule Cycles\n\n\n\n{content}\n\n\n',
+ cycleEntryHtml: '\n',
+ cycleChainEntryHtml: '{id}',
+
+ showCycles: function (contextName) {
+ var cycles = xrayquire.getCycles(contextName),
+ html = '';
+
+ if (cycles) {
+ eachProp(cycles, function (cycle, id) {
+ var chainHtml = '';
+ eachProp(cycle.visited, function (value, cycleId) {
+ if (cycleId !== id) {
+ chainHtml += template(xrayquire.cycleChainEntryHtml, {
+ id: cycleId
+ });
+ }
+ });
+
+ html += template(xrayquire.cycleEntryHtml, {
+ id: id,
+ chain: chainHtml
+ });
+ });
+ } else {
+ html = 'No cycles found';
+ }
+
+ html = template(xrayquire.cycleHtml, {
+ content: html
+ });
+
+ showHtml(html);
+ }
+ };
+}());
diff --git a/src/UI/Mixins/AutoComplete.js b/src/UI/Mixins/AutoComplete.js
index 0bc512be2..7903cef05 100644
--- a/src/UI/Mixins/AutoComplete.js
+++ b/src/UI/Mixins/AutoComplete.js
@@ -1,4 +1,4 @@
-'use strict';
+'use strict';
define(function () {
diff --git a/src/UI/Mixins/backbone.marionette.region.mixin.js b/src/UI/Mixins/backbone.marionette.region.mixin.js
deleted file mode 100644
index 916d5a14e..000000000
--- a/src/UI/Mixins/backbone.marionette.region.mixin.js
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
-'use strict';
-
-(function () {
-
- var _originalRegionClose = Marionette.Region.prototype.close;
-*/
-/*
- Marionette.Region.prototype.open = function (view) {
- var self = this;
-
- self.$el.html(view.el);
-
- //self.$el.fadeIn(100);
- };*//*
-
-
- Marionette.Region.prototype.close = function () {
-*/
-/* this.$el.fadeOut(200, function () {
- _originalRegionClose.apply(this, arguments);
- });*//*
-
- };
-}());
-*/
diff --git a/src/UI/Mixins/backbone.signalr.mixin.js b/src/UI/Mixins/backbone.signalr.mixin.js
index 759488776..80817cf03 100644
--- a/src/UI/Mixins/backbone.signalr.mixin.js
+++ b/src/UI/Mixins/backbone.signalr.mixin.js
@@ -1,10 +1,11 @@
'use strict';
define(
[
+ 'vent',
'underscore',
'backbone',
'signalR'
- ], function (_, Backbone) {
+ ], function (vent, _, Backbone) {
_.extend(Backbone.Collection.prototype, {
bindSignalR: function () {
@@ -25,12 +26,7 @@ define(
console.log(options.action + ': {0}}'.format(options.resource));
};
- require(
- [
- 'app'
- ], function (app) {
- collection.listenTo(app.vent, 'server:' + collection.url.replace('/api/', ''), processMessage);
- });
+ collection.listenTo(vent, 'server:' + collection.url.replace('/api/', ''), processMessage);
return this;
},
diff --git a/src/UI/Navbar/Search.js b/src/UI/Navbar/Search.js
index 4e0e3b7d5..d880af439 100644
--- a/src/UI/Navbar/Search.js
+++ b/src/UI/Navbar/Search.js
@@ -1,9 +1,9 @@
'use strict';
define(
[
- 'app',
+ 'backbone',
'Series/SeriesCollection'
- ], function (App, SeriesCollection) {
+ ], function (Backbone, SeriesCollection) {
$(document).on('keydown', function (e){
if ($(e.target).is('input')) {
return;
@@ -29,7 +29,7 @@ define(
var series = SeriesCollection.findWhere({ title: item });
this.$element.blur();
- App.Router.navigate('/series/{0}'.format(series.get('titleSlug')), { trigger: true });
+ Backbone.history.navigate('/series/{0}'.format(series.get('titleSlug')), { trigger: true });
}
});
};
diff --git a/src/UI/ProgressMessaging/ProgressMessageCollection.js b/src/UI/ProgressMessaging/ProgressMessageCollection.js
deleted file mode 100644
index ca74fb638..000000000
--- a/src/UI/ProgressMessaging/ProgressMessageCollection.js
+++ /dev/null
@@ -1,47 +0,0 @@
-'use strict';
-define(
- [
- 'app',
- 'backbone',
- 'Shared/Messenger',
- 'Mixins/backbone.signalr.mixin'
- ], function (App, Backbone, Messenger) {
-
- var ProgressMessageCollection = Backbone.Collection.extend({
- url : window.NzbDrone.ApiRoot + '/progressmessage',
- model: Backbone.Model,
-
- initialize: function(){
-
- }
-
- });
-
- var collection = new ProgressMessageCollection();//.bindSignalR();
-
- /* collection.signalRconnection.received(function (message) {
-
- var type = getMessengerType(message.status);
- var hideAfter = type === 'info' ? 60 :5;
-
- Messenger.show({
- id : message.commandId,
- message : message.message,
- type : type,
- hideAfter: hideAfter
- });
- });*/
-
- var getMessengerType = function (status) {
- switch (status) {
- case 'completed':
- return 'success';
- case 'failed':
- return 'error';
- default:
- return 'info';
- }
- };
-
- return collection;
- });
diff --git a/src/UI/Quality/QualitySizeModel.js b/src/UI/Quality/QualitySizeModel.js
index 1b8c6a3cc..4b0872ec2 100644
--- a/src/UI/Quality/QualitySizeModel.js
+++ b/src/UI/Quality/QualitySizeModel.js
@@ -2,9 +2,8 @@
define(
[
- 'app',
'Settings/SettingsModelBase'
- ], function (App, ModelBase) {
+ ], function (ModelBase) {
return ModelBase.extend({
baseInitialize: ModelBase.prototype.initialize,
diff --git a/src/UI/Require/require.api.js b/src/UI/Require/require.api.js
new file mode 100644
index 000000000..e3d855279
--- /dev/null
+++ b/src/UI/Require/require.api.js
@@ -0,0 +1,25 @@
+define(function () {
+ 'use strict';
+ return {
+ load: function (name, parentRequire, onload, config) {
+
+ if(config.isBuild){
+ return onload();
+ }
+
+ var resource = name.split('!')[0];
+ var url = window.NzbDrone.ApiRoot + '/' + resource;
+
+ $.ajax({
+ url: url
+ }).done(function (data) {
+ onload(data);
+ }).error(function (xhr, status, error) {
+ onload.error({
+ xhr : xhr,
+ status: status,
+ error : error});
+ });
+ }
+ };
+ });
diff --git a/src/UI/Router.js b/src/UI/Router.js
index a37039da1..d8532756f 100644
--- a/src/UI/Router.js
+++ b/src/UI/Router.js
@@ -1,38 +1,16 @@
'use strict';
-require(
+define(
[
- 'app',
- 'backbone',
'marionette',
- 'Controller',
- 'Series/SeriesCollection',
- 'ProgressMessaging/ProgressMessageCollection',
- 'Commands/CommandMessengerCollectionView',
- 'History/Queue/QueueCollection',
- 'Navbar/NavbarView',
- 'jQuery/RouteBinder',
- 'jquery'
- ], function (App,
- Backbone,
- Marionette,
- Controller,
- SeriesCollection,
- ProgressMessageCollection,
- CommandMessengerCollectionView,
- QueueCollection,
- NavbarView,
- RouterBinder,
- $) {
+ 'Controller'
+ ], function (Marionette, Controller) {
- var Router = Marionette.AppRouter.extend({
+ return Marionette.AppRouter.extend({
controller: new Controller(),
appRoutes : {
- '' : 'series',
- 'series' : 'series',
'addseries' : 'addSeries',
'addseries/:action(/:query)': 'addSeries',
- 'series/:query' : 'seriesDetails',
'calendar' : 'calendar',
'settings' : 'settings',
'settings/:action(/:query)' : 'settings',
@@ -43,23 +21,8 @@ require(
'system' : 'system',
'system/:action' : 'system',
'seasonpass' : 'seasonPass',
- ':whatever' : 'notFound'
+ ':whatever' : 'showNotFound'
}
});
-
- App.addInitializer(function () {
-
- App.Router = new Router();
-
- SeriesCollection.fetch().done(function () {
- Backbone.history.start({ pushState: true });
- RouterBinder.bind(App.Router);
- App.navbarRegion.show(new NavbarView());
- $('body').addClass('started');
- });
- });
-
- return App.Router;
-
});
diff --git a/src/UI/SeasonPass/SeriesLayout.js b/src/UI/SeasonPass/SeriesLayout.js
index 34b26855a..828f25341 100644
--- a/src/UI/SeasonPass/SeriesLayout.js
+++ b/src/UI/SeasonPass/SeriesLayout.js
@@ -45,7 +45,7 @@ define(
},
_seasonSelected: function () {
- var seasonNumber = parseInt(this.ui.seasonSelect.val());
+ var seasonNumber = parseInt(this.ui.seasonSelect.val(), 10);
if (seasonNumber === -1 || isNaN(seasonNumber)) {
return;
@@ -112,19 +112,18 @@ define(
var element;
if (e.target.localName === 'i') {
- seasonNumber = parseInt($(e.target).parent('td').attr('data-season-number'));
+ seasonNumber = parseInt($(e.target).parent('td').attr('data-season-number'), 10);
element = $(e.target);
}
else {
- seasonNumber = parseInt($(e.target).attr('data-season-number'));
+ seasonNumber = parseInt($(e.target).attr('data-season-number'), 10);
element = $(e.target).children('i');
}
this.model.setSeasonMonitored(seasonNumber);
- var savePromise =this.model.save()
- .always(this.render.bind(this));
+ var savePromise = this.model.save().always(this.render.bind(this));
element.spinForPromise(savePromise);
},
diff --git a/src/UI/Series/Delete/DeleteSeriesView.js b/src/UI/Series/Delete/DeleteSeriesView.js
index 75af268ca..e3808e73b 100644
--- a/src/UI/Series/Delete/DeleteSeriesView.js
+++ b/src/UI/Series/Delete/DeleteSeriesView.js
@@ -1,9 +1,9 @@
'use strict';
define(
[
- 'app',
+ 'vent',
'marionette'
- ], function (App, Marionette) {
+ ], function (vent, Marionette) {
return Marionette.ItemView.extend({
template: 'Series/Delete/DeleteSeriesTemplate',
@@ -24,8 +24,8 @@ define(
data: { 'deleteFiles': deleteFiles },
wait: true
}).done(function () {
- App.vent.trigger(App.Events.SeriesDeleted, { series: self.model });
- App.vent.trigger(App.Commands.CloseModalCommand);
+ vent.trigger(vent.Events.SeriesDeleted, { series: self.model });
+ vent.trigger(vent.Commands.CloseModalCommand);
});
}
});
diff --git a/src/UI/Series/Details/SeasonCollectionView.js b/src/UI/Series/Details/SeasonCollectionView.js
index 52a549df3..d3fde1b24 100644
--- a/src/UI/Series/Details/SeasonCollectionView.js
+++ b/src/UI/Series/Details/SeasonCollectionView.js
@@ -2,8 +2,9 @@
define(
[
'marionette',
- 'Series/Details/SeasonLayout'
- ], function (Marionette, SeasonLayout) {
+ 'Series/Details/SeasonLayout',
+ 'underscore'
+ ], function (Marionette, SeasonLayout, _) {
return Marionette.CollectionView.extend({
itemView: SeasonLayout,
@@ -26,16 +27,15 @@ define(
},
onEpisodeGrabbed: function (message) {
- if (message.episode.series.id != this.episodeCollection.seriesId) {
+ if (message.episode.series.id !== this.episodeCollection.seriesId) {
return;
}
var self = this;
- _.each(message.episode.episodes, function (episode){
+ _.each(message.episode.episodes, function (episode) {
var ep = self.episodeCollection.get(episode.id);
ep.set('downloading', true);
- console.debug(episode.title);
});
this.render();
diff --git a/src/UI/Series/Details/SeasonLayout.js b/src/UI/Series/Details/SeasonLayout.js
index ddc2f74d2..8015ce0e1 100644
--- a/src/UI/Series/Details/SeasonLayout.js
+++ b/src/UI/Series/Details/SeasonLayout.js
@@ -1,7 +1,7 @@
'use strict';
define(
[
- 'app',
+ 'vent',
'marionette',
'backgrid',
'Cells/ToggleCell',
@@ -10,8 +10,9 @@ define(
'Cells/EpisodeStatusCell',
'Cells/EpisodeActionsCell',
'Commands/CommandController',
- 'moment'
- ], function (App, Marionette, Backgrid, ToggleCell, EpisodeTitleCell, RelativeDateCell, EpisodeStatusCell, EpisodeActionsCell, CommandController, Moment) {
+ 'moment',
+ 'underscore'
+ ], function (vent, Marionette, Backgrid, ToggleCell, EpisodeTitleCell, RelativeDateCell, EpisodeStatusCell, EpisodeActionsCell, CommandController, Moment,_) {
return Marionette.Layout.extend({
template: 'Series/Details/SeasonLayoutTemplate',
@@ -173,7 +174,7 @@ define(
_afterRename: function () {
- App.vent.trigger(App.Events.SeasonRenamed, { series: this.series, seasonNumber: this.model.get('seasonNumber') });
+ vent.trigger(vent.Events.SeasonRenamed, { series: this.series, seasonNumber: this.model.get('seasonNumber') });
},
_showEpisodes: function () {
diff --git a/src/UI/Series/Details/SeriesDetailsLayout.js b/src/UI/Series/Details/SeriesDetailsLayout.js
index 5e0066564..e2b4ce627 100644
--- a/src/UI/Series/Details/SeriesDetailsLayout.js
+++ b/src/UI/Series/Details/SeriesDetailsLayout.js
@@ -1,8 +1,10 @@
'use strict';
define(
[
- 'app',
+ 'vent',
+ 'reqres',
'marionette',
+ 'backbone',
'Series/EpisodeCollection',
'Series/EpisodeFileCollection',
'Series/SeasonCollection',
@@ -10,9 +12,10 @@ define(
'Series/Details/InfoView',
'Commands/CommandController',
'Shared/LoadingView',
+ 'underscore',
'backstrech',
'Mixins/backbone.signalr.mixin'
- ], function (App, Marionette, EpisodeCollection, EpisodeFileCollection, SeasonCollection, SeasonCollectionView, InfoView, CommandController, LoadingView) {
+ ], function (vent,reqres, Marionette, Backbone, EpisodeCollection, EpisodeFileCollection, SeasonCollection, SeasonCollectionView, InfoView, CommandController, LoadingView, _) {
return Marionette.Layout.extend({
itemViewContainer: '.x-series-seasons',
@@ -42,10 +45,10 @@ define(
initialize: function () {
this.listenTo(this.model, 'change:monitored', this._setMonitoredState);
- this.listenTo(App.vent, App.Events.SeriesDeleted, this._onSeriesDeleted);
- this.listenTo(App.vent, App.Events.SeasonRenamed, this._onSeasonRenamed);
+ this.listenTo(vent, vent.Events.SeriesDeleted, this._onSeriesDeleted);
+ this.listenTo(vent, vent.Events.SeasonRenamed, this._onSeasonRenamed);
- App.vent.on(App.Events.CommandComplete, this._commandComplete, this);
+ vent.on(vent.Events.CommandComplete, this._commandComplete, this);
},
onShow: function () {
@@ -105,7 +108,7 @@ define(
}
$('body').removeClass('backdrop');
- App.reqres.removeHandler(App.Reqres.GetEpisodeFileById);
+ reqres.removeHandler(reqres.Requests.GetEpisodeFileById);
},
_toggleMonitored: function () {
@@ -132,7 +135,7 @@ define(
},
_editSeries: function () {
- App.vent.trigger(App.Commands.EditSeriesCommand, {series: this.model});
+ vent.trigger(vent.Commands.EditSeriesCommand, {series: this.model});
},
_refreshSeries: function () {
@@ -145,7 +148,7 @@ define(
_onSeriesDeleted: function (event) {
if (this.model.get('id') === event.series.get('id')) {
- App.Router.navigate('/', { trigger: true });
+ Backbone.history.navigate('/', { trigger: true });
}
},
@@ -180,7 +183,7 @@ define(
series : self.model
});
- App.reqres.setHandler(App.Reqres.GetEpisodeFileById, function (episodeFileId) {
+ reqres.setHandler(reqres.Requests.GetEpisodeFileById, function (episodeFileId) {
return self.episodeFileCollection.get(episodeFileId);
});
diff --git a/src/UI/Series/Edit/EditSeriesView.js b/src/UI/Series/Edit/EditSeriesView.js
index b01926c80..29d922fbb 100644
--- a/src/UI/Series/Edit/EditSeriesView.js
+++ b/src/UI/Series/Edit/EditSeriesView.js
@@ -1,13 +1,13 @@
'use strict';
define(
[
- 'app',
+ 'vent',
'marionette',
'Quality/QualityProfileCollection',
'Mixins/AsModelBoundView',
'Mixins/AsValidatedView',
'Mixins/AutoComplete'
- ], function (App, Marionette, QualityProfiles, AsModelBoundView, AsValidatedView) {
+ ], function (vent, Marionette, QualityProfiles, AsModelBoundView, AsValidatedView) {
var view = Marionette.ItemView.extend({
template: 'Series/Edit/EditSeriesViewTemplate',
@@ -36,7 +36,7 @@ define(
this.model.save().done(function () {
self.trigger('saved');
- App.vent.trigger(App.Commands.CloseModalCommand);
+ vent.trigger(vent.Commands.CloseModalCommand);
});
},
@@ -45,7 +45,7 @@ define(
},
_removeSeries: function () {
- App.vent.trigger(App.Commands.DeleteSeriesCommand, {series:this.model});
+ vent.trigger(vent.Commands.DeleteSeriesCommand, {series:this.model});
}
});
diff --git a/src/UI/Series/Index/EmptySeriesIndexView.js b/src/UI/Series/Index/EmptySeriesIndexView.js
deleted file mode 100644
index b222390ab..000000000
--- a/src/UI/Series/Index/EmptySeriesIndexView.js
+++ /dev/null
@@ -1,9 +0,0 @@
-'use strict';
-define(
- [
- 'marionette'
- ], function (Marionette) {
- return Marionette.CompositeView.extend({
- template: 'Series/Index/EmptySeriesIndexTemplate'
- });
- });
diff --git a/src/UI/Series/Index/List/ItemView.js b/src/UI/Series/Index/List/ItemView.js
index 6cb776cab..e6da6377b 100644
--- a/src/UI/Series/Index/List/ItemView.js
+++ b/src/UI/Series/Index/List/ItemView.js
@@ -2,9 +2,9 @@
define(
[
- 'app',
- 'marionette',
- ], function (App, Marionette) {
+ 'vent',
+ 'marionette'
+ ], function (vent, Marionette) {
return Marionette.ItemView.extend({
template: 'Series/Index/List/ItemTemplate',
@@ -18,11 +18,11 @@ define(
},
editSeries: function () {
- App.vent.trigger(App.Commands.EditSeriesCommand, {series: this.model});
+ vent.trigger(vent.Commands.EditSeriesCommand, {series: this.model});
},
removeSeries: function () {
- App.vent.trigger(App.Commands.DeleteSeriesCommand, {series: this.model});
+ vent.trigger(vent.Commands.DeleteSeriesCommand, {series: this.model});
}
});
});
diff --git a/src/UI/Series/Index/Posters/ItemView.js b/src/UI/Series/Index/Posters/ItemView.js
index 1f474c8bc..02d4ba713 100644
--- a/src/UI/Series/Index/Posters/ItemView.js
+++ b/src/UI/Series/Index/Posters/ItemView.js
@@ -2,9 +2,9 @@
define(
[
- 'app',
+ 'vent',
'marionette'
- ], function (App, Marionette) {
+ ], function (vent, Marionette) {
return Marionette.ItemView.extend({
tagName : 'li',
@@ -25,11 +25,11 @@ define(
editSeries: function () {
- App.vent.trigger(App.Commands.EditSeriesCommand, {series:this.model});
+ vent.trigger(vent.Commands.EditSeriesCommand, {series:this.model});
},
removeSeries: function () {
- App.vent.trigger(App.Commands.DeleteSeriesCommand, {series:this.model});
+ vent.trigger(vent.Commands.DeleteSeriesCommand, {series:this.model});
},
posterHoverAction: function () {
diff --git a/src/UI/Series/SeriesCollection.js b/src/UI/Series/SeriesCollection.js
index 188382775..b7458ef52 100644
--- a/src/UI/Series/SeriesCollection.js
+++ b/src/UI/Series/SeriesCollection.js
@@ -2,8 +2,9 @@
define(
[
'backbone',
- 'Series/SeriesModel'
- ], function (Backbone, SeriesModel) {
+ 'Series/SeriesModel',
+ 'api!series'
+ ], function (Backbone, SeriesModel, SeriesData) {
var Collection = Backbone.Collection.extend({
url : window.NzbDrone.ApiRoot + '/series',
model: SeriesModel,
@@ -18,6 +19,6 @@ define(
}
});
- var collection = new Collection();
+ var collection = new Collection(SeriesData);
return collection;
});
diff --git a/src/UI/Series/SeriesController.js b/src/UI/Series/SeriesController.js
new file mode 100644
index 000000000..ccef200ed
--- /dev/null
+++ b/src/UI/Series/SeriesController.js
@@ -0,0 +1,40 @@
+'use strict';
+define(
+ [
+ 'Shared/NzbDroneController',
+ 'AppLayout',
+ 'Series/SeriesCollection',
+ 'Series/Index/SeriesIndexLayout',
+ 'Series/Details/SeriesDetailsLayout'
+ ], function (NzbDroneController, AppLayout, SeriesCollection, SeriesIndexLayout, SeriesDetailsLayout) {
+
+ return NzbDroneController.extend({
+
+
+ initialize: function () {
+ this.route('', this.series);
+ this.route('series', this.series);
+ this.route('series/:query', this.seriesDetails);
+ },
+
+
+ series: function () {
+ this.setTitle('NzbDrone');
+ AppLayout.mainRegion.show(new SeriesIndexLayout());
+ },
+
+ seriesDetails: function (query) {
+ var series = SeriesCollection.where({titleSlug: query});
+
+ if (series.length !== 0) {
+ var targetSeries = series[0];
+ this.setTitle(targetSeries.get('title'));
+ AppLayout.mainRegion.show(new SeriesDetailsLayout({ model: targetSeries }));
+ }
+ else {
+ this.showNotFound();
+ }
+ }
+ });
+ });
+
diff --git a/src/UI/Series/SeriesModel.js b/src/UI/Series/SeriesModel.js
index e73d9cc33..92b3cdd73 100644
--- a/src/UI/Series/SeriesModel.js
+++ b/src/UI/Series/SeriesModel.js
@@ -2,7 +2,6 @@
define(
[
'backbone',
-
'underscore'
], function (Backbone, _) {
return Backbone.Model.extend({
diff --git a/src/UI/Settings/Indexers/CollectionView.js b/src/UI/Settings/Indexers/CollectionView.js
index df09ff132..ea3c5d218 100644
--- a/src/UI/Settings/Indexers/CollectionView.js
+++ b/src/UI/Settings/Indexers/CollectionView.js
@@ -1,10 +1,13 @@
'use strict';
-define(['app',
- 'marionette',
- 'Settings/Indexers/ItemView',
- 'Settings/Indexers/EditView',
- 'Settings/Indexers/Collection'],
- function (App, Marionette, IndexerItemView, IndexerEditView, IndexerCollection) {
+define(
+ [
+ 'AppLayout',
+ 'marionette',
+ 'Settings/Indexers/ItemView',
+ 'Settings/Indexers/EditView',
+ 'Settings/Indexers/Collection',
+ 'underscore'
+ ], function (AppLayout, Marionette, IndexerItemView, IndexerEditView, IndexerCollection, _) {
return Marionette.CompositeView.extend({
itemView : IndexerItemView,
itemViewContainer: '#x-indexers',
@@ -18,7 +21,7 @@ define(['app',
'click .x-add-card': '_openSchemaModal'
},
- appendHtml: function(collectionView, itemView, index){
+ appendHtml: function (collectionView, itemView, index) {
collectionView.ui.addCard.parent('li').before(itemView.el);
},
@@ -33,13 +36,13 @@ define(['app',
var model = _.first(collection.models);
model.set({
- id: undefined,
- name: '',
+ id : undefined,
+ name : '',
enable: true
});
var view = new IndexerEditView({ model: model, indexerCollection: self.collection});
- App.modalRegion.show(view);
+ AppLayout.modalRegion.show(view);
}
});
}
diff --git a/src/UI/Settings/Indexers/DeleteView.js b/src/UI/Settings/Indexers/DeleteView.js
deleted file mode 100644
index b6d27184d..000000000
--- a/src/UI/Settings/Indexers/DeleteView.js
+++ /dev/null
@@ -1,19 +0,0 @@
-'use strict';
-define(['app', 'marionette'], function (App, Marionette) {
- return Marionette.ItemView.extend({
- template: 'Settings/Notifications/DeleteTemplate',
-
- events: {
- 'click .x-confirm-delete': '_removeIndexer'
- },
-
- _removeIndexer: function () {
- this.model.destroy({
- wait : true,
- success: function () {
- App.vent.trigger(App.Commands.CloseModalCommand);
- }
- });
- }
- });
-});
diff --git a/src/UI/Settings/Indexers/EditView.js b/src/UI/Settings/Indexers/EditView.js
index 4d0defee0..05793bf1c 100644
--- a/src/UI/Settings/Indexers/EditView.js
+++ b/src/UI/Settings/Indexers/EditView.js
@@ -2,16 +2,17 @@
define(
[
- 'app',
+ 'vent',
'marionette',
'Mixins/AsModelBoundView',
- 'Mixins/AsValidatedView'
- ], function (App, Marionette, AsModelBoundView, AsValidatedView) {
+ 'Mixins/AsValidatedView',
+ 'underscore'
+ ], function (vent, Marionette, AsModelBoundView, AsValidatedView, _) {
var view = Marionette.ItemView.extend({
template: 'Settings/Indexers/EditTemplate',
- ui : {
+ ui: {
activity: '.x-activity'
},
@@ -33,7 +34,7 @@ define(
if (promise) {
promise.done(function () {
self.indexerCollection.add(self.model, { merge: true });
- App.vent.trigger(App.Commands.CloseModalCommand);
+ vent.trigger(vent.Commands.CloseModalCommand);
});
promise.fail(function () {
diff --git a/src/UI/Settings/Indexers/ItemView.js b/src/UI/Settings/Indexers/ItemView.js
index 2b9d2fed2..4f940cfc3 100644
--- a/src/UI/Settings/Indexers/ItemView.js
+++ b/src/UI/Settings/Indexers/ItemView.js
@@ -2,12 +2,12 @@
define(
[
- 'app',
+ 'AppLayout',
'marionette',
'Settings/Notifications/DeleteView',
'Mixins/AsModelBoundView',
'Mixins/AsValidatedView'
- ], function (App, Marionette, DeleteView, AsModelBoundView, AsValidatedView) {
+ ], function (AppLayout, Marionette, DeleteView, AsModelBoundView, AsValidatedView) {
var view = Marionette.ItemView.extend({
template: 'Settings/Indexers/ItemTemplate',
@@ -19,7 +19,7 @@ define(
_deleteIndexer: function () {
var view = new DeleteView({ model: this.model});
- App.modalRegion.show(view);
+ AppLayout.modalRegion.show(view);
}
});
diff --git a/src/UI/Settings/MediaManagement/FileManagement/FileManagementView.js b/src/UI/Settings/MediaManagement/FileManagement/FileManagementView.js
index af28961b3..ff6a247b9 100644
--- a/src/UI/Settings/MediaManagement/FileManagement/FileManagementView.js
+++ b/src/UI/Settings/MediaManagement/FileManagement/FileManagementView.js
@@ -1,4 +1,4 @@
-'use strict';
+'use strict';
define(
[
'marionette',
diff --git a/src/UI/Settings/Notifications/AddItemView.js b/src/UI/Settings/Notifications/AddItemView.js
index e6b320b7d..0183404dc 100644
--- a/src/UI/Settings/Notifications/AddItemView.js
+++ b/src/UI/Settings/Notifications/AddItemView.js
@@ -1,10 +1,10 @@
'use strict';
define([
- 'app',
+ 'AppLayout',
'marionette',
'Settings/Notifications/EditView'
-], function (App, Marionette, EditView) {
+], function (AppLayout, Marionette, EditView) {
return Marionette.ItemView.extend({
template: 'Settings/Notifications/AddItemTemplate',
@@ -31,7 +31,7 @@ define([
});
var editView = new EditView({ model: this.model, notificationCollection: this.notificationCollection });
- App.modalRegion.show(editView);
+ AppLayout.modalRegion.show(editView);
}
});
});
diff --git a/src/UI/Settings/Notifications/CollectionView.js b/src/UI/Settings/Notifications/CollectionView.js
index f3f5fd3d9..571c26f9d 100644
--- a/src/UI/Settings/Notifications/CollectionView.js
+++ b/src/UI/Settings/Notifications/CollectionView.js
@@ -1,10 +1,9 @@
'use strict';
define([
- 'app',
'marionette',
'Settings/Notifications/ItemView',
'Settings/Notifications/SchemaModal'
-], function (App, Marionette, NotificationItemView, SchemaModal) {
+], function (Marionette, NotificationItemView, SchemaModal) {
return Marionette.CompositeView.extend({
itemView : NotificationItemView,
itemViewContainer: '.notifications',
diff --git a/src/UI/Settings/Notifications/DeleteView.js b/src/UI/Settings/Notifications/DeleteView.js
index 68af79465..24a03f776 100644
--- a/src/UI/Settings/Notifications/DeleteView.js
+++ b/src/UI/Settings/Notifications/DeleteView.js
@@ -1,19 +1,23 @@
'use strict';
-define(['app', 'marionette'], function (App, Marionette) {
- return Marionette.ItemView.extend({
- template: 'Settings/Notifications/DeleteTemplate',
+define(
+ [
+ 'vent',
+ 'marionette'
+ ], function (vent, Marionette) {
+ return Marionette.ItemView.extend({
+ template: 'Settings/Notifications/DeleteTemplate',
- events: {
- 'click .x-confirm-delete': '_removeNotification'
- },
+ events: {
+ 'click .x-confirm-delete': '_removeNotification'
+ },
- _removeNotification: function () {
- this.model.destroy({
- wait : true,
- success: function () {
- App.vent.trigger(App.Commands.CloseModalCommand);
- }
- });
- }
+ _removeNotification: function () {
+ this.model.destroy({
+ wait : true,
+ success: function () {
+ vent.trigger(vent.Commands.CloseModalCommand);
+ }
+ });
+ }
+ });
});
-});
diff --git a/src/UI/Settings/Notifications/EditView.js b/src/UI/Settings/Notifications/EditView.js
index 244ea8e18..a355df7bc 100644
--- a/src/UI/Settings/Notifications/EditView.js
+++ b/src/UI/Settings/Notifications/EditView.js
@@ -1,92 +1,93 @@
'use strict';
-define([
- 'app',
- 'marionette',
- 'Settings/Notifications/Model',
- 'Settings/Notifications/DeleteView',
- 'Shared/Messenger',
- 'Commands/CommandController',
- 'Mixins/AsModelBoundView',
- 'Form/FormBuilder'
-
-], function (App, Marionette, NotificationModel, DeleteView, Messenger, CommandController, AsModelBoundView) {
-
- var model = Marionette.ItemView.extend({
- template: 'Settings/Notifications/EditTemplate',
-
- events: {
- 'click .x-save' : '_saveNotification',
- 'click .x-save-and-add' : '_saveAndAddNotification',
- 'click .x-delete' : '_deleteNotification',
- 'click .x-back' : '_back',
- 'click .x-test' : '_test'
- },
-
- ui: {
- testButton: '.x-test',
- testIcon : '.x-test-icon'
- },
-
- initialize: function (options) {
- this.notificationCollection = options.notificationCollection;
- },
-
- _saveNotification: function () {
- var self = this;
- var promise = this.model.saveSettings();
-
- if (promise) {
- promise.done(function () {
- self.notificationCollection.add(self.model, { merge: true });
- App.vent.trigger(App.Commands.CloseModalCommand);
- });
+define(
+ [
+ 'vent',
+ 'AppLayout',
+ 'marionette',
+ 'Settings/Notifications/DeleteView',
+ 'Commands/CommandController',
+ 'Mixins/AsModelBoundView',
+ 'Form/FormBuilder',
+ 'underscore'
+
+ ], function (vent, AppLayout, Marionette, DeleteView, CommandController, AsModelBoundView, _) {
+
+ var model = Marionette.ItemView.extend({
+ template: 'Settings/Notifications/EditTemplate',
+
+ events: {
+ 'click .x-save' : '_saveNotification',
+ 'click .x-save-and-add': '_saveAndAddNotification',
+ 'click .x-delete' : '_deleteNotification',
+ 'click .x-back' : '_back',
+ 'click .x-test' : '_test'
+ },
+
+ ui: {
+ testButton: '.x-test',
+ testIcon : '.x-test-icon'
+ },
+
+ initialize: function (options) {
+ this.notificationCollection = options.notificationCollection;
+ },
+
+ _saveNotification: function () {
+ var self = this;
+ var promise = this.model.saveSettings();
+
+ if (promise) {
+ promise.done(function () {
+ self.notificationCollection.add(self.model, { merge: true });
+ vent.trigger(vent.Commands.CloseModalCommand);
+ });
+ }
+ },
+
+ _saveAndAddNotification: function () {
+ var self = this;
+ var promise = this.model.saveSettings();
+
+ if (promise) {
+ promise.done(function () {
+ self.notificationCollection.add(self.model, { merge: true });
+
+ require('Settings/Notifications/SchemaModal').open(self.notificationCollection);
+ });
+ }
+ },
+
+ _deleteNotification: function () {
+ var view = new DeleteView({ model: this.model });
+ AppLayout.modalRegion.show(view);
+ },
+
+ _back: function () {
+ require('Settings/Notifications/SchemaModal').open(this.notificationCollection);
+ },
+
+ _test: function () {
+ var testCommand = this.model.get('testCommand');
+ if (testCommand) {
+ this.idle = false;
+ var properties = {};
+
+ _.each(this.model.get('fields'), function (field) {
+ properties[field.name] = field.value;
+ });
+
+
+ CommandController.Execute(testCommand, properties);
+ }
+ },
+
+ _testOnAlways: function () {
+ if (!this.isClosed) {
+ this.idle = true;
+ }
}
- },
+ });
- _saveAndAddNotification: function () {
- var self = this;
- var promise = this.model.saveSettings();
-
- if (promise) {
- promise.done(function () {
- self.notificationCollection.add(self.model, { merge: true });
-
- require('Settings/Notifications/SchemaModal').open(self.notificationCollection);
- });
- }
- },
-
- _deleteNotification: function () {
- var view = new DeleteView({ model: this.model });
- App.modalRegion.show(view);
- },
-
- _back: function () {
- require('Settings/Notifications/SchemaModal').open(this.notificationCollection);
- },
-
- _test: function () {
- var testCommand = this.model.get('testCommand');
- if (testCommand) {
- this.idle = false;
- var properties = {};
-
- _.each(this.model.get('fields'), function (field) {
- properties[field.name] = field.value;
- });
-
-
- CommandController.Execute(testCommand, properties);
- }
- },
-
- _testOnAlways: function () {
- if (!this.isClosed) {
- this.idle = true;
- }
- }
+ return AsModelBoundView.call(model);
});
-
- return AsModelBoundView.call(model);
-});
diff --git a/src/UI/Settings/Notifications/ItemView.js b/src/UI/Settings/Notifications/ItemView.js
index 3bc0ac117..532f294e8 100644
--- a/src/UI/Settings/Notifications/ItemView.js
+++ b/src/UI/Settings/Notifications/ItemView.js
@@ -1,12 +1,12 @@
'use strict';
define([
- 'app',
+ 'AppLayout',
'marionette',
'Settings/Notifications/EditView',
'Settings/Notifications/DeleteView'
-], function (App, Marionette, EditView, DeleteView) {
+], function (AppLayout, Marionette, EditView, DeleteView) {
return Marionette.ItemView.extend({
template: 'Settings/Notifications/ItemTemplate',
@@ -23,12 +23,12 @@ define([
_editNotification: function () {
var view = new EditView({ model: this.model, notificationCollection: this.model.collection});
- App.modalRegion.show(view);
+ AppLayout.modalRegion.show(view);
},
_deleteNotification: function () {
var view = new DeleteView({ model: this.model});
- App.modalRegion.show(view);
+ AppLayout.modalRegion.show(view);
}
});
});
diff --git a/src/UI/Settings/Notifications/SchemaModal.js b/src/UI/Settings/Notifications/SchemaModal.js
index 254fff06f..319509d57 100644
--- a/src/UI/Settings/Notifications/SchemaModal.js
+++ b/src/UI/Settings/Notifications/SchemaModal.js
@@ -1,9 +1,9 @@
'use strict';
define([
- 'app',
+ 'AppLayout',
'Settings/Notifications/Collection',
'Settings/Notifications/AddView'
-], function (App, NotificationCollection, AddSelectionNotificationView) {
+], function (AppLayout, NotificationCollection, AddSelectionNotificationView) {
return ({
open: function (collection) {
@@ -13,7 +13,7 @@ define([
schemaCollection.url = '/api/notification';
var view = new AddSelectionNotificationView({ collection: schemaCollection, notificationCollection: collection});
- App.modalRegion.show(view);
+ AppLayout.modalRegion.show(view);
}
});
});
diff --git a/src/UI/Settings/Quality/Profile/AllowedLabeler.js b/src/UI/Settings/Quality/Profile/AllowedLabeler.js
index 50f93b437..fed162e17 100644
--- a/src/UI/Settings/Quality/Profile/AllowedLabeler.js
+++ b/src/UI/Settings/Quality/Profile/AllowedLabeler.js
@@ -1,18 +1,22 @@
'use strict';
-define(['app', 'handlebars'], function (App,Handlebars) {
- Handlebars.registerHelper('allowedLabeler', function () {
- var ret = '';
- var cutoff = this.cutoff;
- _.each(this.allowed, function (allowed) {
- if (allowed.id === cutoff.id) {
- ret += '' + allowed.name + ' ';
- }
+define(
+ [
+ 'handlebars',
+ 'underscore'
+ ], function (Handlebars, _) {
+ Handlebars.registerHelper('allowedLabeler', function () {
+ var ret = '';
+ var cutoff = this.cutoff;
+ _.each(this.allowed, function (allowed) {
+ if (allowed.id === cutoff.id) {
+ ret += '' + allowed.name + ' ';
+ }
- else {
- ret += '' + allowed.name + ' ';
- }
- });
+ else {
+ ret += '' + allowed.name + ' ';
+ }
+ });
- return new Handlebars.SafeString(ret);
+ return new Handlebars.SafeString(ret);
+ });
});
-});
diff --git a/src/UI/Settings/Quality/Profile/DeleteView.js b/src/UI/Settings/Quality/Profile/DeleteView.js
index 1805e66f9..313ffb4cc 100644
--- a/src/UI/Settings/Quality/Profile/DeleteView.js
+++ b/src/UI/Settings/Quality/Profile/DeleteView.js
@@ -1,9 +1,9 @@
'use strict';
define(
[
- 'app',
+ 'vent',
'marionette'
- ], function (App, Marionette) {
+ ], function (vent, Marionette) {
return Marionette.ItemView.extend({
template: 'Settings/Quality/Profile/DeleteTemplate',
@@ -17,7 +17,7 @@ define(
this.model.destroy({
wait: true
}).done(function () {
- App.vent.trigger(App.Commands.CloseModalCommand);
+ vent.trigger(vent.Commands.CloseModalCommand);
});
}
});
diff --git a/src/UI/Settings/Quality/Profile/EditQualityProfileView.js b/src/UI/Settings/Quality/Profile/EditQualityProfileView.js
index 52c275144..503d820fc 100644
--- a/src/UI/Settings/Quality/Profile/EditQualityProfileView.js
+++ b/src/UI/Settings/Quality/Profile/EditQualityProfileView.js
@@ -1,11 +1,13 @@
'use strict';
define(
[
- 'app',
+ 'vent',
'marionette',
+ 'backbone',
'Mixins/AsModelBoundView',
- 'Mixins/AsValidatedView'
- ], function (App, Marionette, AsModelBoundView, AsValidatedView) {
+ 'Mixins/AsValidatedView',
+ 'underscore'
+ ], function (vent, Marionette, Backbone, AsModelBoundView, AsValidatedView, _) {
var view = Marionette.ItemView.extend({
template: 'Settings/Quality/Profile/EditQualityProfileTemplate',
@@ -61,7 +63,7 @@ define(
_saveQualityProfile: function () {
var self = this;
- var cutoff = _.findWhere(this.model.get('allowed'), { id: parseInt(this.ui.cutoff.val())});
+ var cutoff = _.findWhere(this.model.get('allowed'), { id: parseInt(this.ui.cutoff.val(), 10)});
this.model.set('cutoff', cutoff);
var promise = this.model.save();
@@ -69,7 +71,7 @@ define(
if (promise) {
promise.done(function () {
self.profileCollection.add(self.model, { merge: true });
- App.vent.trigger(App.Commands.CloseModalCommand);
+ vent.trigger(vent.Commands.CloseModalCommand);
});
}
}
diff --git a/src/UI/Settings/Quality/Profile/QualityProfileCollectionView.js b/src/UI/Settings/Quality/Profile/QualityProfileCollectionView.js
index 7ea2e822c..066bf986e 100644
--- a/src/UI/Settings/Quality/Profile/QualityProfileCollectionView.js
+++ b/src/UI/Settings/Quality/Profile/QualityProfileCollectionView.js
@@ -1,11 +1,12 @@
'use strict';
-define(['app',
+define(['AppLayout',
'marionette',
'Settings/Quality/Profile/QualityProfileView',
'Settings/Quality/Profile/EditQualityProfileView',
- 'Settings/Quality/Profile/QualityProfileSchemaCollection'
-], function (App, Marionette, QualityProfileView, EditProfileView, ProfileCollection) {
+ 'Settings/Quality/Profile/QualityProfileSchemaCollection',
+ 'underscore'
+], function (AppLayout, Marionette, QualityProfileView, EditProfileView, ProfileCollection, _) {
return Marionette.CompositeView.extend({
itemView : QualityProfileView,
@@ -35,7 +36,7 @@ define(['app',
model.collection = self.collection;
var view = new EditProfileView({ model: model, profileCollection: self.collection});
- App.modalRegion.show(view);
+ AppLayout.modalRegion.show(view);
}
});
}
diff --git a/src/UI/Settings/Quality/Profile/QualityProfileView.js b/src/UI/Settings/Quality/Profile/QualityProfileView.js
index 854520a24..439ad62f4 100644
--- a/src/UI/Settings/Quality/Profile/QualityProfileView.js
+++ b/src/UI/Settings/Quality/Profile/QualityProfileView.js
@@ -2,16 +2,15 @@
define(
[
- 'app',
+ 'AppLayout',
'marionette',
'Settings/Quality/Profile/EditQualityProfileView',
'Settings/Quality/Profile/DeleteView',
'Series/SeriesCollection',
'Mixins/AsModelBoundView',
'Settings/Quality/Profile/AllowedLabeler',
- 'bootstrap',
-
- ], function (App, Marionette, EditProfileView, DeleteProfileView, SeriesCollection, AsModelBoundView) {
+ 'bootstrap'
+ ], function (AppLayout, Marionette, EditProfileView, DeleteProfileView, SeriesCollection, AsModelBoundView) {
var view = Marionette.ItemView.extend({
template: 'Settings/Quality/Profile/QualityProfileTemplate',
@@ -29,12 +28,12 @@ define(
initialize: function () {
this.listenTo(this.model, 'sync', this.render);
- this.listenTo(SeriesCollection, 'all', this._updateDisableStatus)
+ this.listenTo(SeriesCollection, 'all', this._updateDisableStatus);
},
_editProfile: function () {
var view = new EditProfileView({ model: this.model, profileCollection: this.model.collection });
- App.modalRegion.show(view);
+ AppLayout.modalRegion.show(view);
},
_deleteProfile: function () {
@@ -43,7 +42,7 @@ define(
}
var view = new DeleteProfileView({ model: this.model });
- App.modalRegion.show(view);
+ AppLayout.modalRegion.show(view);
},
onRender: function () {
diff --git a/src/UI/Settings/Quality/Size/QualitySizeView.js b/src/UI/Settings/Quality/Size/QualitySizeView.js
index 7f1339fcb..12c03bcd0 100644
--- a/src/UI/Settings/Quality/Size/QualitySizeView.js
+++ b/src/UI/Settings/Quality/Size/QualitySizeView.js
@@ -1,55 +1,61 @@
'use strict';
-define(['marionette', 'Mixins/AsModelBoundView', 'filesize', 'jquery.knob' ], function (Marionette, AsModelBoundView, Filesize) {
-
- var view = Marionette.ItemView.extend({
- template : 'Settings/Quality/Size/QualitySizeTemplate',
- tagName : 'li',
-
- ui: {
- knob : '.x-knob',
- thirtyMinuteSize: '.x-size-thirty',
- sixtyMinuteSize : '.x-size-sixty'
- },
-
- events: {
- 'change .x-knob': '_changeMaxSize'
- },
-
- initialize: function (options) {
- this.qualityProfileCollection = options.qualityProfiles;
- this.filesize = Filesize;
- },
-
- onRender: function () {
- this.ui.knob.knob({
- min : 0,
- max : 200,
- step : 1,
- cursor : 25,
- width : 150,
- stopper : true,
- displayInput : false
- });
-
- this._changeMaxSize();
- },
-
- _changeMaxSize: function () {
- var maxSize = this.model.get('maxSize');
- var bytes = maxSize * 1024 * 1024;
- var thirty = Filesize(bytes * 30, 1, false);
- var sixty = Filesize(bytes * 60, 1, false);
-
- if (parseInt(maxSize) === 0) {
- thirty = 'No Limit';
- sixty = 'No Limit';
+define(
+ [
+ 'marionette',
+ 'Mixins/AsModelBoundView',
+ 'filesize',
+ 'jquery.knob'
+ ], function (Marionette, AsModelBoundView, Filesize) {
+
+ var view = Marionette.ItemView.extend({
+ template: 'Settings/Quality/Size/QualitySizeTemplate',
+ tagName : 'li',
+
+ ui: {
+ knob : '.x-knob',
+ thirtyMinuteSize: '.x-size-thirty',
+ sixtyMinuteSize : '.x-size-sixty'
+ },
+
+ events: {
+ 'change .x-knob': '_changeMaxSize'
+ },
+
+ initialize: function (options) {
+ this.qualityProfileCollection = options.qualityProfiles;
+ this.filesize = Filesize;
+ },
+
+ onRender: function () {
+ this.ui.knob.knob({
+ min : 0,
+ max : 200,
+ step : 1,
+ cursor : 25,
+ width : 150,
+ stopper : true,
+ displayInput: false
+ });
+
+ this._changeMaxSize();
+ },
+
+ _changeMaxSize: function () {
+ var maxSize = this.model.get('maxSize');
+ var bytes = maxSize * 1024 * 1024;
+ var thirty = Filesize(bytes * 30, 1, false);
+ var sixty = Filesize(bytes * 60, 1, false);
+
+ if (parseInt(maxSize, 10) === 0) {
+ thirty = 'No Limit';
+ sixty = 'No Limit';
+ }
+
+ this.ui.thirtyMinuteSize.html(thirty);
+ this.ui.sixtyMinuteSize.html(sixty);
}
+ });
- this.ui.thirtyMinuteSize.html(thirty);
- this.ui.sixtyMinuteSize.html(sixty);
- }
+ return AsModelBoundView.call(view);
});
-
- return AsModelBoundView.call(view);
-});
diff --git a/src/UI/Settings/SettingsLayout.js b/src/UI/Settings/SettingsLayout.js
index cad4cfaa9..f03ac5416 100644
--- a/src/UI/Settings/SettingsLayout.js
+++ b/src/UI/Settings/SettingsLayout.js
@@ -1,8 +1,9 @@
-'use strict';
+'use strict';
define(
[
- 'app',
+ 'vent',
'marionette',
+ 'backbone',
'Settings/SettingsModel',
'Settings/General/GeneralSettingsModel',
'Settings/MediaManagement/Naming/Model',
@@ -16,8 +17,9 @@ define(
'Settings/General/GeneralView',
'Shared/LoadingView',
'Config'
- ], function (App,
+ ], function (vent,
Marionette,
+ Backbone,
SettingsModel,
GeneralSettingsModel,
NamingModel,
@@ -87,6 +89,8 @@ define(
this.indexerSettings.fetch(),
this.notificationSettings.fetch()
).done(function () {
+ if(!self.isClosed)
+ {
self.loading.$el.hide();
self.mediaManagement.show(new MediaManagementLayout({ settings: self.settings, namingSettings: self.namingSettings }));
self.quality.show(new QualityLayout({ settings: self.settings }));
@@ -94,6 +98,7 @@ define(
self.downloadClient.show(new DownloadClientLayout({ model: self.settings }));
self.notifications.show(new NotificationCollectionView({ collection: self.notificationSettings }));
self.general.show(new GeneralView({ model: self.generalSettings }));
+ }
});
this._setAdvancedSettingsState();
@@ -179,13 +184,11 @@ define(
},
_navigate:function(route){
- require(['Router'], function(){
- App.Router.navigate(route);
- });
+ Backbone.history.navigate(route, {trigger:true});
},
_save: function () {
- App.vent.trigger(App.Commands.SaveSettings);
+ vent.trigger(vent.Commands.SaveSettings);
},
_setAdvancedSettingsState: function () {
diff --git a/src/UI/Settings/SettingsModel.js b/src/UI/Settings/SettingsModel.js
index 1fbccdb74..0b5da8dd2 100644
--- a/src/UI/Settings/SettingsModel.js
+++ b/src/UI/Settings/SettingsModel.js
@@ -1,9 +1,11 @@
-'use strict';
-define(['app',
- 'Settings/SettingsModelBase'], function (App, SettingsModelBase) {
- return SettingsModelBase.extend({
- url : window.NzbDrone.ApiRoot + '/settings',
- successMessage: 'Settings saved',
- errorMessage : 'Failed to save settings'
+'use strict';
+define(
+ [
+ 'Settings/SettingsModelBase'
+ ], function (SettingsModelBase) {
+ return SettingsModelBase.extend({
+ url : window.NzbDrone.ApiRoot + '/settings',
+ successMessage: 'Settings saved',
+ errorMessage : 'Failed to save settings'
+ });
});
-});
diff --git a/src/UI/Settings/SettingsModelBase.js b/src/UI/Settings/SettingsModelBase.js
index 8ea3d5e19..5b2b5bec3 100644
--- a/src/UI/Settings/SettingsModelBase.js
+++ b/src/UI/Settings/SettingsModelBase.js
@@ -1,34 +1,36 @@
'use strict';
-define(['app',
- 'backbone.deepmodel',
- 'Mixins/AsChangeTrackingModel',
- 'Shared/Messenger'], function (App, DeepModel, AsChangeTrackingModel, Messenger) {
- var model = DeepModel.DeepModel.extend({
+define(
+ [
+ 'vent',
+ 'backbone.deepmodel',
+ 'Mixins/AsChangeTrackingModel',
+ 'Shared/Messenger'
+ ], function (vent, DeepModel, AsChangeTrackingModel, Messenger) {
+ var model = DeepModel.DeepModel.extend({
- initialize: function () {
- this.listenTo(App.vent, App.Commands.SaveSettings, this.saveSettings);
- },
+ initialize: function () {
+ this.listenTo(vent, vent.Commands.SaveSettings, this.saveSettings);
+ },
- saveSettings: function () {
+ saveSettings: function () {
- if (!this.isSaved) {
+ if (!this.isSaved) {
- var savePromise = this.save();
+ var savePromise = this.save();
- Messenger.monitor(
- {
- promise : savePromise,
- successMessage: this.successMessage,
- errorMessage : this.errorMessage
- });
+ Messenger.monitor({
+ promise : savePromise,
+ successMessage: this.successMessage,
+ errorMessage : this.errorMessage
+ });
- return savePromise;
+ return savePromise;
+ }
+
+ return undefined;
}
- return undefined;
- }
+ });
+ return AsChangeTrackingModel.call(model);
});
-
- return AsChangeTrackingModel.call(model);
-});
diff --git a/src/UI/Shared/Footer/Template.html b/src/UI/Shared/Footer/Template.html
deleted file mode 100644
index 36085cf7c..000000000
--- a/src/UI/Shared/Footer/Template.html
+++ /dev/null
@@ -1,2 +0,0 @@
-© Copyright 2013 NzbDrone
-v{{version}} ({{ShortDate buildTime}})
diff --git a/src/UI/Shared/Footer/View.js b/src/UI/Shared/Footer/View.js
deleted file mode 100644
index 846ff843d..000000000
--- a/src/UI/Shared/Footer/View.js
+++ /dev/null
@@ -1,12 +0,0 @@
-'use strict';
-define(
- [
- 'marionette',
- 'System/StatusModel'
- ], function (Marionette, StatusModel) {
- return Marionette.ItemView.extend({
-
- template: 'Shared/Footer/Template',
- model : StatusModel
- });
- });
diff --git a/src/UI/Shared/Modal/Controller.js b/src/UI/Shared/Modal/Controller.js
index cbb97ebf5..465119a0f 100644
--- a/src/UI/Shared/Modal/Controller.js
+++ b/src/UI/Shared/Modal/Controller.js
@@ -1,48 +1,47 @@
'use strict';
define(
[
- 'app',
+ 'vent',
+ 'AppLayout',
'marionette',
'Series/Edit/EditSeriesView',
'Series/Delete/DeleteSeriesView',
'Episode/EpisodeDetailsLayout',
'History/Details/HistoryDetailsView'
- ], function (App, Marionette, EditSeriesView, DeleteSeriesView, EpisodeDetailsLayout, HistoryDetailsView) {
+ ], function (vent, AppLayout, Marionette, EditSeriesView, DeleteSeriesView, EpisodeDetailsLayout, HistoryDetailsView) {
- var router = Marionette.AppRouter.extend({
+ return Marionette.AppRouter.extend({
initialize: function () {
- App.vent.on(App.Commands.CloseModalCommand, this._closeModal, this);
- App.vent.on(App.Commands.EditSeriesCommand, this._editSeries, this);
- App.vent.on(App.Commands.DeleteSeriesCommand, this._deleteSeries, this);
- App.vent.on(App.Commands.ShowEpisodeDetails, this._showEpisode, this);
- App.vent.on(App.Commands.ShowHistoryDetails, this._showHistory, this);
+ vent.on(vent.Commands.CloseModalCommand, this._closeModal, this);
+ vent.on(vent.Commands.EditSeriesCommand, this._editSeries, this);
+ vent.on(vent.Commands.DeleteSeriesCommand, this._deleteSeries, this);
+ vent.on(vent.Commands.ShowEpisodeDetails, this._showEpisode, this);
+ vent.on(vent.Commands.ShowHistoryDetails, this._showHistory, this);
},
_closeModal: function () {
- App.modalRegion.closeModal();
+ AppLayout.modalRegion.closeModal();
},
_editSeries: function (options) {
var view = new EditSeriesView({ model: options.series });
- App.modalRegion.show(view);
+ AppLayout.modalRegion.show(view);
},
_deleteSeries: function (options) {
var view = new DeleteSeriesView({ model: options.series });
- App.modalRegion.show(view);
+ AppLayout.modalRegion.show(view);
},
_showEpisode: function (options) {
var view = new EpisodeDetailsLayout({ model: options.episode, hideSeriesLink: options.hideSeriesLink, openingTab: options.openingTab });
- App.modalRegion.show(view);
+ AppLayout.modalRegion.show(view);
},
_showHistory: function (options) {
var view = new HistoryDetailsView({ model: options.history });
- App.modalRegion.show(view);
+ AppLayout.modalRegion.show(view);
}
});
-
- return new router();
});
diff --git a/src/UI/Shared/Modal/Region.js b/src/UI/Shared/Modal/ModalRegion.js
similarity index 75%
rename from src/UI/Shared/Modal/Region.js
rename to src/UI/Shared/Modal/ModalRegion.js
index a0cab051c..f2a776050 100644
--- a/src/UI/Shared/Modal/Region.js
+++ b/src/UI/Shared/Modal/ModalRegion.js
@@ -1,11 +1,11 @@
'use strict';
define(
[
- 'app',
- '$',
+ 'jquery',
+ 'backbone',
'marionette',
'bootstrap'
- ], function (app, $, Marionette) {
+ ], function ($,Backbone, Marionette) {
var region = Marionette.Region.extend({
el: '#modal-region',
@@ -39,17 +39,5 @@ define(
});
- require(
- [
- 'Shared/Modal/Controller'
- ], function () {
-
- app.addInitializer(function () {
- app.addRegions({
- modalRegion: region
- });
- });
- });
-
return region;
});
diff --git a/src/UI/Shared/NotFoundTemplate.html b/src/UI/Shared/NotFoundTemplate.html
index 3b4272fca..9a0173122 100644
--- a/src/UI/Shared/NotFoundTemplate.html
+++ b/src/UI/Shared/NotFoundTemplate.html
@@ -1,3 +1,3 @@
-
+
diff --git a/src/UI/Shared/NzbDroneController.js b/src/UI/Shared/NzbDroneController.js
new file mode 100644
index 000000000..2ff57cfd4
--- /dev/null
+++ b/src/UI/Shared/NzbDroneController.js
@@ -0,0 +1,25 @@
+'use strict';
+define(
+ [
+ 'AppLayout',
+ 'marionette',
+ 'Shared/NotFoundView'
+ ], function (AppLayout, Marionette, NotFoundView) {
+ return Marionette.AppRouter.extend({
+
+ showNotFound: function () {
+ this.setTitle('Not Found');
+ AppLayout.mainRegion.show(new NotFoundView(this));
+ },
+
+ setTitle: function (title) {
+ if (title.toLocaleLowerCase() === 'nzbdrone') {
+ window.document.title = 'NzbDrone';
+ }
+ else {
+ window.document.title = title + ' - NzbDrone';
+ }
+ }
+ });
+ });
+
diff --git a/src/UI/Shared/SignalRBroadcaster.js b/src/UI/Shared/SignalRBroadcaster.js
index 14f322fd1..453b08843 100644
--- a/src/UI/Shared/SignalRBroadcaster.js
+++ b/src/UI/Shared/SignalRBroadcaster.js
@@ -1,9 +1,9 @@
'use strict';
define(
[
- 'app',
+ 'vent',
'signalR'
- ], function () {
+ ], function (vent) {
return {
appInitializer: function () {
@@ -31,12 +31,7 @@ define(
});
this.signalRconnection.received(function (message) {
- require(
- [
- 'app'
- ], function (app) {
- app.vent.trigger('server:' + message.name, message.body);
- });
+ vent.trigger('server:' + message.name, message.body);
});
this.signalRconnection.start({ transport:
diff --git a/src/UI/Shared/Toolbar/Button/ButtonView.js b/src/UI/Shared/Toolbar/Button/ButtonView.js
index 5a16c7d3c..a35d1a048 100644
--- a/src/UI/Shared/Toolbar/Button/ButtonView.js
+++ b/src/UI/Shared/Toolbar/Button/ButtonView.js
@@ -1,11 +1,11 @@
'use strict';
define(
[
- 'app',
+ 'backbone',
'marionette',
'underscore',
'Commands/CommandController'
- ], function (App, Marionette, _, CommandController) {
+ ], function (Backbone, Marionette, _, CommandController) {
return Marionette.ItemView.extend({
template : 'Shared/Toolbar/ButtonTemplate',
@@ -61,13 +61,7 @@ define(
invokeRoute: function () {
var route = this.model.get('route');
if (route) {
-
- require(
- [
- 'Router'
- ], function () {
- App.Router.navigate(route, {trigger: true});
- });
+ Backbone.history.navigate(route, {trigger: true});
}
},
diff --git a/src/UI/System/Logs/Files/ContentsView.js b/src/UI/System/Logs/Files/ContentsView.js
index 2fd2cd1a1..8efd98a37 100644
--- a/src/UI/System/Logs/Files/ContentsView.js
+++ b/src/UI/System/Logs/Files/ContentsView.js
@@ -2,9 +2,8 @@
define(
[
- 'app',
'marionette'
- ], function (App, Marionette) {
+ ], function (Marionette) {
return Marionette.ItemView.extend({
template: 'System/Logs/Files/ContentsViewTemplate'
});
diff --git a/src/UI/System/Logs/Files/LogFileLayout.js b/src/UI/System/Logs/Files/LogFileLayout.js
index 8af432ce3..e1ab9d69b 100644
--- a/src/UI/System/Logs/Files/LogFileLayout.js
+++ b/src/UI/System/Logs/Files/LogFileLayout.js
@@ -1,7 +1,7 @@
'use strict';
define(
[
- 'app',
+ 'vent',
'marionette',
'backgrid',
'System/Logs/Files/FilenameCell',
@@ -13,7 +13,7 @@ define(
'System/Logs/Files/ContentsModel',
'Shared/Toolbar/ToolbarLayout',
'Shared/LoadingView'
- ], function (App,
+ ], function (vent,
Marionette,
Backgrid,
FilenameCell,
@@ -57,11 +57,12 @@ define(
initialize: function () {
this.collection = new LogFileCollection();
- App.vent.on(App.Commands.ShowLogFile, this._fetchLogFileContents, this);
- App.vent.on(App.Events.CommandComplete, this._commandComplete, this);
+ vent.on(vent.Commands.ShowLogFile, this._fetchLogFileContents, this);
+ vent.on(vent.Events.CommandComplete, this._commandComplete, this);
this.listenTo(this.collection, 'sync', this._collectionSynced);
this.collection.fetch();
+
},
onShow: function () {
diff --git a/src/UI/System/Logs/Files/Row.js b/src/UI/System/Logs/Files/Row.js
index 67f207667..543893b00 100644
--- a/src/UI/System/Logs/Files/Row.js
+++ b/src/UI/System/Logs/Files/Row.js
@@ -1,9 +1,9 @@
'use strict';
define(
[
- 'app',
+ 'vent',
'backgrid'
- ], function (App, Backgrid) {
+ ], function (vent, Backgrid) {
return Backgrid.Row.extend({
className: 'log-file-row',
@@ -13,7 +13,7 @@ define(
},
_showContents: function () {
- App.vent.trigger(App.Commands.ShowLogFile, { model: this.model });
+ vent.trigger(vent.Commands.ShowLogFile, { model: this.model });
}
});
});
diff --git a/src/UI/System/Logs/Table/LogsTableLayout.js b/src/UI/System/Logs/Table/LogsTableLayout.js
index 9512e4105..9288474c3 100644
--- a/src/UI/System/Logs/Table/LogsTableLayout.js
+++ b/src/UI/System/Logs/Table/LogsTableLayout.js
@@ -1,7 +1,7 @@
'use strict';
define(
[
- 'app',
+ 'vent',
'marionette',
'backgrid',
'System/Logs/Table/LogTimeCell',
@@ -10,7 +10,7 @@ define(
'System/Logs/LogsCollection',
'Shared/Toolbar/ToolbarLayout',
'Shared/LoadingView'
- ], function (App, Marionette, Backgrid, LogTimeCell, LogLevelCell, GridPager, LogCollection, ToolbarLayout, LoadingView) {
+ ], function (vent, Marionette, Backgrid, LogTimeCell, LogLevelCell, GridPager, LogCollection, ToolbarLayout, LoadingView) {
return Marionette.Layout.extend({
template: 'System/Logs/Table/LogsTableLayoutTemplate',
@@ -59,7 +59,7 @@ define(
this.collection = new LogCollection();
this.collectionPromise = this.collection.fetch();
- App.vent.on(App.Events.CommandComplete, this._commandComplete, this);
+ vent.on(vent.Events.CommandComplete, this._commandComplete, this);
},
onRender: function () {
diff --git a/src/UI/System/SystemLayout.js b/src/UI/System/SystemLayout.js
index ed41fd345..7aca9042f 100644
--- a/src/UI/System/SystemLayout.js
+++ b/src/UI/System/SystemLayout.js
@@ -1,12 +1,12 @@
'use strict';
define(
[
- 'app',
+ 'backbone',
'marionette',
'System/About/AboutView',
'System/Logs/LogsLayout',
'System/Update/UpdateLayout'
- ], function (App,
+ ], function (Backbone,
Marionette,
AboutView,
LogsLayout,
@@ -52,9 +52,7 @@ define(
},
_navigate:function(route){
- require(['Router'], function(){
- App.Router.navigate(route);
- });
+ Backbone.history.navigate(route);
},
_showAbout: function (e) {
diff --git a/src/UI/System/Update/UpdateItemView.js b/src/UI/System/Update/UpdateItemView.js
index 682b5d77f..79186cd65 100644
--- a/src/UI/System/Update/UpdateItemView.js
+++ b/src/UI/System/Update/UpdateItemView.js
@@ -2,9 +2,8 @@
define(
[
- 'app',
'marionette'
- ], function (App, Marionette) {
+ ], function (Marionette) {
return Marionette.ItemView.extend({
template: 'System/Update/UpdateItemViewTemplate',
diff --git a/src/UI/app.js b/src/UI/app.js
index 0d1df7b88..2404374fd 100644
--- a/src/UI/app.js
+++ b/src/UI/app.js
@@ -1,8 +1,5 @@
'use strict';
require.config({
-
- urlArgs: 'v=' + window.NzbDrone.ServerStatus.version,
-
paths: {
'backbone' : 'JsLibraries/backbone',
'moment' : 'JsLibraries/moment',
@@ -16,23 +13,24 @@ require.config({
'backbone.modelbinder': 'JsLibraries/backbone.modelbinder',
'backgrid' : 'JsLibraries/backbone.backgrid',
'backgrid.paginator' : 'JsLibraries/backbone.backgrid.paginator',
- 'backgrid.selectall' : 'JsLibraries/backbone.backgrid.selectall',
+ 'backgrid.selectall' : 'JsLibraries/backbone.backgrid.selectall',
'fullcalendar' : 'JsLibraries/fullcalendar',
'backstrech' : 'JsLibraries/jquery.backstretch',
- '$' : 'JsLibraries/jquery',
'underscore' : 'JsLibraries/lodash.underscore',
'marionette' : 'JsLibraries/backbone.marionette',
'signalR' : 'JsLibraries/jquery.signalR',
'jquery.knob' : 'JsLibraries/jquery.knob',
'jquery.dotdotdot' : 'JsLibraries/jquery.dotdotdot',
- 'libs' : 'JsLibraries/'
+ 'jquery' : 'JsLibraries/jquery',
+ 'libs' : 'JsLibraries/',
+
+ 'api': 'Require/require.api'
},
shim: {
- $: {
- exports: '$',
-
+ jquery: {
+ exports: 'jQuery',
deps :
[
'Mixins/jquery.ajax'
@@ -53,28 +51,33 @@ require.config({
signalR: {
deps:
[
- '$'
+ 'jquery'
]
},
bootstrap: {
deps:
[
- '$'
- ]
+ 'jquery'
+ ],
+ init: function ($) {
+ $('body').tooltip({
+ selector: '[title]'
+ });
+ }
},
backstrech: {
deps:
[
- '$'
+ 'jquery'
]
},
underscore: {
deps :
[
- '$'
+ 'jquery'
],
exports: '_'
},
@@ -83,7 +86,7 @@ require.config({
deps :
[
'underscore',
- '$'
+ 'jquery'
],
exports: 'Backbone'
},
@@ -123,14 +126,14 @@ require.config({
'jquery.knob': {
deps:
[
- '$'
+ 'jquery'
]
},
'jquery.dotdotdot': {
deps:
[
- '$'
+ 'jquery'
]
},
@@ -190,55 +193,44 @@ require.config({
}
});
+require.config({
+ urlArgs: 'v=' + window.NzbDrone.ServerStatus.version
+});
+
define(
[
+ 'backbone',
'marionette',
+ 'jQuery/RouteBinder',
'Shared/SignalRBroadcaster',
+ 'Navbar/NavbarView',
+ 'AppLayout',
+ 'Series/SeriesController',
+ 'Router',
+ 'Shared/Modal/Controller',
'Instrumentation/StringFormat'
- ], function (Marionette, SignalRBroadcaster) {
+ ], function (Backbone, Marionette, RouteBinder, SignalRBroadcaster, NavbarView, AppLayout, SeriesController, Router, ModalController) {
- var app = new Marionette.Application();
+ new SeriesController();
+ new ModalController();
+ new Router();
- app.Events = {
- SeriesAdded : 'series:added',
- SeriesDeleted : 'series:deleted',
- SeasonRenamed : 'season:renamed',
- CommandComplete: 'command:complete'
- };
-
- app.Commands = {
- EditSeriesCommand : 'EditSeriesCommand',
- DeleteSeriesCommand : 'DeleteSeriesCommand',
- CloseModalCommand : 'CloseModalCommand',
- ShowEpisodeDetails : 'ShowEpisodeDetails',
- ShowHistoryDetails : 'ShowHistoryDetails',
- SaveSettings : 'saveSettings',
- ShowLogFile : 'showLogFile'
- };
-
- app.Reqres = {
- GetEpisodeFileById: 'GetEpisodeFileById'
- };
+ var app = new Marionette.Application();
app.addInitializer(function () {
console.log('starting application');
});
- app.addInitializer(SignalRBroadcaster.appInitializer, { app: app });
+ app.addInitializer(SignalRBroadcaster.appInitializer, {
+ app: app
+ });
- app.addRegions({
- navbarRegion: '#nav-region',
- mainRegion : '#main-region',
- footerRegion: '#footer-region'
+ app.addInitializer(function () {
+ Backbone.history.start({ pushState: true });
+ RouteBinder.bind();
+ AppLayout.navbarRegion.show(new NavbarView());
+ $('body').addClass('started');
});
app.start();
-
- window.require(
- [
- 'Router',
- 'jQuery/TooltipBinder'
- ]);
-
- return app;
});
diff --git a/src/UI/index.html b/src/UI/index.html
index 3e57b6590..5af3cf1a8 100644
--- a/src/UI/index.html
+++ b/src/UI/index.html
@@ -74,4 +74,5 @@
+