UI dependency graph cleanup

This commit is contained in:
kayone 2013-10-08 18:43:41 -07:00
parent 86ea33b638
commit 4948d0608b
87 changed files with 1119 additions and 735 deletions

View File

@ -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: { watch: {
options: { options: {
nospawn: false, nospawn: false,
@ -213,6 +232,7 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-notify'); grunt.loadNpmTasks('grunt-notify');
grunt.loadNpmTasks('grunt-curl'); grunt.loadNpmTasks('grunt-curl');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.registerTask('package', ['clean:output', 'copy', 'less', 'handlebars']); grunt.registerTask('package', ['clean:output', 'copy', 'less', 'handlebars']);
grunt.registerTask('default', ['package', 'watch']); grunt.registerTask('default', ['package', 'watch']);

View File

@ -22,6 +22,7 @@
"grunt-contrib-copy": "*", "grunt-contrib-copy": "*",
"grunt-curl": "*", "grunt-curl": "*",
"grunt-notify": "*", "grunt-notify": "*",
"grunt-contrib-clean": "*" "grunt-contrib-clean": "*",
"grunt-contrib-requirejs": "*"
} }
} }

View File

@ -1,7 +1,8 @@
'use strict'; 'use strict';
define( define(
[ [
'app', 'vent',
'AppLayout',
'marionette', 'marionette',
'AddSeries/RootFolders/Layout', 'AddSeries/RootFolders/Layout',
'AddSeries/Existing/AddExistingSeriesCollectionView', 'AddSeries/Existing/AddExistingSeriesCollectionView',
@ -9,7 +10,8 @@ define(
'Quality/QualityProfileCollection', 'Quality/QualityProfileCollection',
'AddSeries/RootFolders/Collection', 'AddSeries/RootFolders/Collection',
'Series/SeriesCollection' 'Series/SeriesCollection'
], function (App, ], function (vent,
AppLayout,
Marionette, Marionette,
RootFolderLayout, RootFolderLayout,
ExistingSeriesCollectionView, ExistingSeriesCollectionView,
@ -43,7 +45,7 @@ define(
}, },
_folderSelected: function (options) { _folderSelected: function (options) {
App.vent.trigger(App.Commands.CloseModalCommand); vent.trigger(vent.Commands.CloseModalCommand);
this.workspace.show(new ExistingSeriesCollectionView({model: options.model})); this.workspace.show(new ExistingSeriesCollectionView({model: options.model}));
}, },
@ -51,7 +53,7 @@ define(
_importSeries: function () { _importSeries: function () {
this.rootFolderLayout = new RootFolderLayout(); this.rootFolderLayout = new RootFolderLayout();
this.rootFolderLayout.on('folderSelected', this._folderSelected, this); this.rootFolderLayout.on('folderSelected', this._folderSelected, this);
App.modalRegion.show(this.rootFolderLayout); AppLayout.modalRegion.show(this.rootFolderLayout);
}, },
_addSeries: function () { _addSeries: function () {

View File

@ -1,14 +1,14 @@
'use strict'; 'use strict';
define( define(
[ [
'app', 'vent',
'marionette', 'marionette',
'AddSeries/AddSeriesCollection', 'AddSeries/AddSeriesCollection',
'AddSeries/SearchResultCollectionView', 'AddSeries/SearchResultCollectionView',
'AddSeries/NotFoundView', 'AddSeries/NotFoundView',
'Shared/LoadingView', 'Shared/LoadingView',
'underscore' 'underscore'
], function (App, Marionette, AddSeriesCollection, SearchResultCollectionView, NotFoundView, LoadingView, _) { ], function (vent, Marionette, AddSeriesCollection, SearchResultCollectionView, NotFoundView, LoadingView, _) {
return Marionette.Layout.extend({ return Marionette.Layout.extend({
template: 'AddSeries/AddSeriesViewTemplate', template: 'AddSeries/AddSeriesViewTemplate',
@ -41,7 +41,7 @@ define(
this.className = 'new-series'; 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.listenTo(this.collection, 'sync', this._showResults);
this.resultCollectionView = new SearchResultCollectionView({ this.resultCollectionView = new SearchResultCollectionView({

View File

@ -20,4 +20,4 @@
<div class="btn btn-block text-center new-series-loadmore x-load-more" style="display: none;"> <div class="btn btn-block text-center new-series-loadmore x-load-more" style="display: none;">
<i class="icon-angle-down"/> <i class="icon-angle-down"/>
more more
</div>{{debug}} </div>

View File

@ -5,4 +5,3 @@
<a href="https://github.com/NzbDrone/NzbDrone/wiki/FAQ#why-cant-i-add-a-new-show-to-nzbdrone-its-on-thetvdb">Why can't I find my show?</a> <a href="https://github.com/NzbDrone/NzbDrone/wiki/FAQ#why-cant-i-add-a-new-show-to-nzbdrone-its-on-thetvdb">Why can't I find my show?</a>
</div> </div>
{{debug}}

View File

@ -1,7 +1,8 @@
'use strict'; 'use strict';
define( define(
[ [
'app', 'vent',
'AppLayout',
'underscore', 'underscore',
'marionette', 'marionette',
'Quality/QualityProfileCollection', 'Quality/QualityProfileCollection',
@ -12,7 +13,7 @@ define(
'Shared/Messenger', 'Shared/Messenger',
'Mixins/AsValidatedView', 'Mixins/AsValidatedView',
'jquery.dotdotdot' '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({ var view = Marionette.ItemView.extend({
@ -41,7 +42,7 @@ define(
this.templateHelpers = {}; this.templateHelpers = {};
this._configureTemplateHelpers(); 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(this.model, 'change', this.render);
this.listenTo(RootFolders, 'all', this.render); this.listenTo(RootFolders, 'all', this.render);
@ -105,7 +106,7 @@ define(
_rootFolderChanged: function () { _rootFolderChanged: function () {
var rootFolderValue = this.ui.rootFolder.val(); var rootFolderValue = this.ui.rootFolder.val();
if (rootFolderValue === 'addNew') { if (rootFolderValue === 'addNew') {
App.modalRegion.show(this.rootFolderLayout); AppLayout.modalRegion.show(this.rootFolderLayout);
} }
else { else {
Config.setValue(Config.Keys.DefaultRootFolderId, rootFolderValue); Config.setValue(Config.Keys.DefaultRootFolderId, rootFolderValue);
@ -113,7 +114,7 @@ define(
}, },
_setRootFolder: function (options) { _setRootFolder: function (options) {
App.vent.trigger(App.Commands.CloseModalCommand); vent.trigger(vent.Commands.CloseModalCommand);
this.ui.rootFolder.val(options.model.id); this.ui.rootFolder.val(options.model.id);
this._rootFolderChanged(); this._rootFolderChanged();
}, },
@ -145,7 +146,7 @@ define(
message: 'Added: ' + self.model.get('title') 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 () { promise.fail(function () {

23
src/UI/AppLayout.js Normal file
View File

@ -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'});
});

View File

@ -2,12 +2,12 @@
define( define(
[ [
'app', 'vent',
'marionette', 'marionette',
'moment', 'moment',
'Calendar/Collection', 'Calendar/Collection',
'fullcalendar' 'fullcalendar'
], function (App, Marionette, Moment, CalendarCollection) { ], function (vent, Marionette, Moment, CalendarCollection) {
var _instance; var _instance;
@ -38,7 +38,7 @@ define(
$(element).children('.fc-event-inner').addClass(event.statusLevel); $(element).children('.fc-event-inner').addClass(event.statusLevel);
}, },
eventClick : function (event) { 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'); var test = currentTime.startOf('day').format('LLLL');
if (end.isBefore(currentTime.startOf('day'))) { if (end.isBefore(currentTime.startOf('day'))) {
statusLevel += ' past' statusLevel += ' past';
} }
return statusLevel; return statusLevel;

View File

@ -2,10 +2,10 @@
define( define(
[ [
'app', 'vent',
'marionette', 'marionette',
'moment' 'moment'
], function (App, Marionette, Moment) { ], function (vent, Marionette, Moment) {
return Marionette.ItemView.extend({ return Marionette.ItemView.extend({
template: 'Calendar/UpcomingItemViewTemplate', template: 'Calendar/UpcomingItemViewTemplate',
tagName : 'div', tagName : 'div',
@ -21,11 +21,11 @@ define(
this.model.set({ this.model.set({
end: end.toISOString() end: end.toISOString()
}) });
}, },
_showEpisodeDetails: function () { _showEpisodeDetails: function () {
App.vent.trigger(App.Commands.ShowEpisodeDetails, {episode: this.model}); vent.trigger(vent.Commands.ShowEpisodeDetails, {episode: this.model});
} }
}); });
}); });

View File

@ -12,8 +12,8 @@ define(
tagName : 'select', tagName : 'select',
events: { events: {
'change': 'save', 'change' : 'save',
'blur': 'close', 'blur' : 'close',
'keydown': 'close' 'keydown': 'close'
}, },
@ -45,12 +45,12 @@ define(
save: function (e) { save: function (e) {
var model = this.model; var model = this.model;
var column = this.column; 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 quality = _.find(this.schema.get('available'), { 'id': selected });
var newQuality = { var newQuality = {
proper: false, proper : false,
quality: quality quality: quality
}; };

View File

@ -2,10 +2,11 @@
define( define(
[ [
'app', 'vent',
'marionette',
'Cells/NzbDroneCell', 'Cells/NzbDroneCell',
'Commands/CommandController' 'Commands/CommandController'
], function (App, NzbDroneCell, CommandController) { ], function (vent, Marionette, NzbDroneCell, CommandController) {
return NzbDroneCell.extend({ return NzbDroneCell.extend({
className: 'episode-actions-cell', className: 'episode-actions-cell',
@ -48,7 +49,7 @@ define(
}, },
_manualSearch: function () { _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' });
} }
}); });
}); });

View File

@ -2,13 +2,13 @@
define( define(
[ [
'app', 'reqres',
'underscore', 'underscore',
'Cells/NzbDroneCell', 'Cells/NzbDroneCell',
'History/Queue/QueueCollection', 'History/Queue/QueueCollection',
'moment', 'moment',
'Shared/FormatHelpers' 'Shared/FormatHelpers'
], function (App, _, NzbDroneCell, QueueCollection, Moment, FormatHelpers) { ], function (Reqres, _, NzbDroneCell, QueueCollection, Moment, FormatHelpers) {
return NzbDroneCell.extend({ return NzbDroneCell.extend({
className: 'episode-status-cell', className: 'episode-status-cell',
@ -33,7 +33,7 @@ define(
var hasFile = this.model.get('hasFile'); var hasFile = this.model.get('hasFile');
if (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); this.listenTo(episodeFile, 'change', this._refresh);

View File

@ -2,9 +2,9 @@
define( define(
[ [
'app', 'vent',
'Cells/NzbDroneCell' 'Cells/NzbDroneCell'
], function (App, NzbDroneCell) { ], function (vent, NzbDroneCell) {
return NzbDroneCell.extend({ return NzbDroneCell.extend({
className: 'episode-title-cell', className: 'episode-title-cell',
@ -27,7 +27,7 @@ define(
_showDetails: function () { _showDetails: function () {
var hideSeriesLink = this.column.get('hideSeriesLink'); 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 });
} }
}); });
}); });

View File

@ -2,9 +2,9 @@
define( define(
[ [
'app', 'vent',
'Cells/NzbDroneCell' 'Cells/NzbDroneCell'
], function (App, NzbDroneCell) { ], function (vent, NzbDroneCell) {
return NzbDroneCell.extend({ return NzbDroneCell.extend({
className: 'series-actions-cell', className: 'series-actions-cell',
@ -27,11 +27,11 @@ define(
}, },
_editSeries: function () { _editSeries: function () {
App.vent.trigger(App.Commands.EditSeriesCommand, {series:this.model}); vent.trigger(vent.Commands.EditSeriesCommand, {series:this.model});
}, },
_removeSeries: function () { _removeSeries: function () {
App.vent.trigger(App.Commands.DeleteSeriesCommand, {series:this.model}); vent.trigger(vent.Commands.DeleteSeriesCommand, {series:this.model});
} }
}); });
}); });

View File

@ -1,12 +1,16 @@
'use strict'; 'use strict';
define( define(
[ [
'app', 'vent',
'Commands/CommandModel', 'Commands/CommandModel',
'Commands/CommandCollection', 'Commands/CommandCollection',
'Commands/CommandMessengerCollectionView',
'underscore', 'underscore',
'jQuery/jquery.spin' 'jQuery/jquery.spin'
], function (App, CommandModel, CommandCollection, _) { ], function (vent, CommandModel, CommandCollection, CommandMessengerCollectionView, _) {
CommandMessengerCollectionView.render();
var singleton = function () { var singleton = function () {
@ -33,11 +37,18 @@ define(
this._bindToCommandModel.call(this, existingCommand, options); this._bindToCommandModel.call(this, existingCommand, options);
} }
CommandCollection.bind('add sync', function (model) { CommandCollection.bind('add', function (model) {
if (model.isSameCommand(options.command)) { if (model.isSameCommand(options.command)) {
self._bindToCommandModel.call(self, model, options); 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) { _bindToCommandModel: function bindToCommand(model, options) {
@ -52,7 +63,7 @@ define(
options.element.stopSpin(); options.element.stopSpin();
if (model.isComplete()) { if (model.isComplete()) {
App.vent.trigger(App.Events.CommandComplete, { command: model, model: options.model }); vent.trigger(vent.Events.CommandComplete, { command: model, model: options.model });
} }
} }
}); });

View File

@ -1,15 +1,14 @@
'use strict'; 'use strict';
define( define(
[ [
'app',
'marionette', 'marionette',
'Commands/CommandCollection', 'Commands/CommandCollection',
'Commands/CommandMessengerItemView' 'Commands/CommandMessengerItemView'
], function (App, Marionette, commandCollection, CommandMessengerItemView) { ], function (Marionette, commandCollection, CommandMessengerItemView) {
var CollectionView = Marionette.CollectionView.extend({ var CollectionView = Marionette.CollectionView.extend({
itemView : CommandMessengerItemView itemView: CommandMessengerItemView
}); });
new CollectionView({collection: commandCollection}); return new CollectionView({collection: commandCollection});
}); });

View File

@ -1,10 +1,9 @@
'use strict'; 'use strict';
define( define(
[ [
'app',
'marionette', 'marionette',
'Shared/Messenger' 'Shared/Messenger'
], function (App, Marionette, Messenger) { ], function ( Marionette, Messenger) {
return Marionette.ItemView.extend({ return Marionette.ItemView.extend({

View File

@ -1,8 +1,8 @@
'use strict'; 'use strict';
define( define(
[ [
'app' 'vent'
], function (App) { ], function (vent) {
return { return {
Events: { Events: {
ConfigUpdatedEvent: 'ConfigUpdatedEvent' ConfigUpdatedEvent: 'ConfigUpdatedEvent'
@ -36,7 +36,7 @@ define(
} }
localStorage.setItem(key, value); localStorage.setItem(key, value);
App.vent.trigger(this.Events.ConfigUpdatedEvent, {key: key, value: value}); vent.trigger(this.Events.ConfigUpdatedEvent, {key: key, value: value});
} }
}; };

View File

@ -1,118 +1,77 @@
'use strict'; 'use strict';
define( define(
[ [
'app', 'Shared/NzbDroneController',
'AppLayout',
'marionette', 'marionette',
'History/HistoryLayout', 'History/HistoryLayout',
'Settings/SettingsLayout', 'Settings/SettingsLayout',
'AddSeries/AddSeriesLayout', 'AddSeries/AddSeriesLayout',
'Series/Index/SeriesIndexLayout',
'Series/Details/SeriesDetailsLayout',
'Series/SeriesCollection',
'Missing/MissingLayout', 'Missing/MissingLayout',
'Calendar/CalendarLayout', 'Calendar/CalendarLayout',
'Release/Layout', 'Release/Layout',
'System/SystemLayout', 'System/SystemLayout',
'SeasonPass/SeasonPassLayout', 'SeasonPass/SeasonPassLayout',
'System/Update/UpdateLayout', 'System/Update/UpdateLayout'
'Shared/NotFoundView', ], function (NzbDroneController,
'Shared/Modal/Region' AppLayout,
], function (App,
Marionette, Marionette,
HistoryLayout, HistoryLayout,
SettingsLayout, SettingsLayout,
AddSeriesLayout, AddSeriesLayout,
SeriesIndexLayout,
SeriesDetailsLayout,
SeriesCollection,
MissingLayout, MissingLayout,
CalendarLayout, CalendarLayout,
ReleaseLayout, ReleaseLayout,
SystemLayout, SystemLayout,
SeasonPassLayout, SeasonPassLayout,
UpdateLayout, UpdateLayout) {
NotFoundView) { return NzbDroneController.extend({
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();
}
},
addSeries: function (action) { addSeries: function (action) {
this._setTitle('Add Series'); this.setTitle('Add Series');
App.mainRegion.show(new AddSeriesLayout({action: action})); AppLayout.mainRegion.show(new AddSeriesLayout({action: action}));
}, },
calendar: function () { calendar: function () {
this._setTitle('Calendar'); this.setTitle('Calendar');
App.mainRegion.show(new CalendarLayout()); AppLayout.mainRegion.show(new CalendarLayout());
}, },
settings: function (action) { settings: function (action) {
this._setTitle('Settings'); this.setTitle('Settings');
App.mainRegion.show(new SettingsLayout({ action: action })); AppLayout.mainRegion.show(new SettingsLayout({ action: action }));
}, },
missing: function () { missing: function () {
this._setTitle('Missing'); this.setTitle('Missing');
App.mainRegion.show(new MissingLayout()); AppLayout.mainRegion.show(new MissingLayout());
}, },
history: function (action) { 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 () { rss: function () {
this._setTitle('RSS'); this.setTitle('RSS');
App.mainRegion.show(new ReleaseLayout()); AppLayout.mainRegion.show(new ReleaseLayout());
}, },
system: function (action) { system: function (action) {
this._setTitle('System'); this.setTitle('System');
App.mainRegion.show(new SystemLayout({ action: action })); AppLayout.mainRegion.show(new SystemLayout({ action: action }));
}, },
seasonPass: function () { seasonPass: function () {
this._setTitle('Season Pass'); this.setTitle('Season Pass');
App.mainRegion.show(new SeasonPassLayout()); AppLayout.mainRegion.show(new SeasonPassLayout());
}, },
update: function () { update: function () {
this._setTitle('Updates'); this.setTitle('Updates');
App.mainRegion.show(new UpdateLayout()); AppLayout.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';
}
} }
}); });
}); });

View File

@ -1,7 +1,6 @@
'use strict'; 'use strict';
define( define(
[ [
'app',
'marionette', 'marionette',
'backgrid', 'backgrid',
'History/HistoryCollection', 'History/HistoryCollection',
@ -10,7 +9,7 @@ define(
'Cells/RelativeDateCell', 'Cells/RelativeDateCell',
'Episode/Activity/NoActivityView', 'Episode/Activity/NoActivityView',
'Shared/LoadingView' '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({ return Marionette.Layout.extend({
template: 'Episode/Activity/EpisodeActivityLayoutTemplate', template: 'Episode/Activity/EpisodeActivityLayoutTemplate',

View File

@ -1,9 +1,8 @@
'use strict'; 'use strict';
define( define(
[ [
'app',
'marionette' 'marionette'
], function (App, Marionette) { ], function (Marionette) {
return Marionette.ItemView.extend({ return Marionette.ItemView.extend({
template: 'Episode/Search/ButtonsViewTemplate' template: 'Episode/Search/ButtonsViewTemplate'

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
define( define(
[ [
'app', 'vent',
'marionette', 'marionette',
'Episode/Search/ButtonsView', 'Episode/Search/ButtonsView',
'Episode/Search/ManualLayout', 'Episode/Search/ManualLayout',
@ -9,7 +9,7 @@ define(
'Series/SeriesCollection', 'Series/SeriesCollection',
'Commands/CommandController', 'Commands/CommandController',
'Shared/LoadingView' 'Shared/LoadingView'
], function (App, Marionette, ButtonsView, ManualSearchLayout, ReleaseCollection, SeriesCollection,CommandController, LoadingView) { ], function (vent, Marionette, ButtonsView, ManualSearchLayout, ReleaseCollection, SeriesCollection,CommandController, LoadingView) {
return Marionette.Layout.extend({ return Marionette.Layout.extend({
template: 'Episode/Search/EpisodeSearchLayoutTemplate', template: 'Episode/Search/EpisodeSearchLayoutTemplate',
@ -50,7 +50,7 @@ define(
episodeIds: [ this.model.get('id') ] episodeIds: [ this.model.get('id') ]
}); });
App.vent.trigger(App.Commands.CloseModalCommand); vent.trigger(vent.Commands.CloseModalCommand);
}, },
_searchManual: function (e) { _searchManual: function (e) {

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
define( define(
[ [
'app', 'reqres',
'marionette', 'marionette',
'backgrid', 'backgrid',
'Series/EpisodeFileModel', 'Series/EpisodeFileModel',
@ -10,7 +10,7 @@ define(
'Cells/QualityCell', 'Cells/QualityCell',
'Episode/Summary/NoFileView', 'Episode/Summary/NoFileView',
'Shared/LoadingView' '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({ return Marionette.Layout.extend({
template: 'Episode/Summary/EpisodeSummaryLayoutTemplate', template: 'Episode/Summary/EpisodeSummaryLayoutTemplate',
@ -55,8 +55,8 @@ define(
if (this.model.get('hasFile')) { if (this.model.get('hasFile')) {
var episodeFileId = this.model.get('episodeFileId'); var episodeFileId = this.model.get('episodeFileId');
if (App.reqres.hasHandler(App.Reqres.GetEpisodeFileById)) { if (reqres.hasHandler(reqres.Requests.GetEpisodeFileById)) {
var episodeFile = App.request(App.Reqres.GetEpisodeFileById, episodeFileId); var episodeFile = reqres.request(reqres.Requests.GetEpisodeFileById, episodeFileId);
var episodeFileCollection = new EpisodeFileCollection(episodeFile, { seriesId: this.model.get('seriesId') }); var episodeFileCollection = new EpisodeFileCollection(episodeFile, { seriesId: this.model.get('seriesId') });
this._showTable(episodeFileCollection); this._showTable(episodeFileCollection);
} }

View File

@ -1,22 +1,18 @@
'use strict'; 'use strict';
define( define(
[ [
'app',
'marionette', 'marionette',
'backbone',
'backgrid', 'backgrid',
'History/Table/HistoryTableLayout', 'History/Table/HistoryTableLayout',
'History/Queue/QueueLayout' 'History/Queue/QueueLayout'
], function (App, ], function (Marionette, Backbone, Backgrid, HistoryTableLayout, QueueLayout) {
Marionette,
Backgrid,
HistoryTableLayout,
QueueLayout) {
return Marionette.Layout.extend({ return Marionette.Layout.extend({
template: 'History/HistoryLayoutTemplate', template: 'History/HistoryLayoutTemplate',
regions: { regions: {
history: '#history', history : '#history',
queueRegion : '#queue' queueRegion: '#queue'
}, },
ui: { ui: {
@ -25,8 +21,8 @@ define(
}, },
events: { events: {
'click .x-history-tab' : '_showHistory', 'click .x-history-tab': '_showHistory',
'click .x-queue-tab' : '_showQueue' 'click .x-queue-tab' : '_showQueue'
}, },
initialize: function (options) { initialize: function (options) {
@ -45,10 +41,8 @@ define(
} }
}, },
_navigate:function(route){ _navigate: function (route) {
require(['Router'], function(){ Backbone.history.navigate(route);
App.Router.navigate(route);
});
}, },
_showHistory: function (e) { _showHistory: function (e) {

View File

@ -2,9 +2,9 @@
define( define(
[ [
'app', 'vent',
'Cells/NzbDroneCell' 'Cells/NzbDroneCell'
], function (App, NzbDroneCell) { ], function (vent, NzbDroneCell) {
return NzbDroneCell.extend({ return NzbDroneCell.extend({
className: 'history-details-cell', className: 'history-details-cell',
@ -21,7 +21,7 @@ define(
}, },
_showDetails: function () { _showDetails: function () {
App.vent.trigger(App.Commands.ShowHistoryDetails, { history: this.model }); vent.trigger(vent.Commands.ShowHistoryDetails, { history: this.model });
} }
}); });
}); });

View File

@ -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('<', '&lt;')
.replace('>', '&gt;')
.replace('&', '&amp;')
.replace('"', '&quot;');
}
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: '<!DOCTYPE html>\n<html>\n<head>\n<title>Module Dependencies</title>\n<style>\nbody {\n font-family: \"Inconsolata\",Andale Mono,Monaco,Monospace;\n color: green;\n}\n\na {\n color: #2E87DD;\n text-decoration: none;\n}\n\na:hover {\n text-decoration: underline;\n}\n\n.mod {\n background-color: #FAFAFA;\n border: 1px solid #E6E6E6;\n border-radius: 5px 5px 5px 5px;\n box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);\n font-size: 13px;\n line-height: 18px;\n margin: 7px 0 21px;\n overflow: auto;\n padding: 5px 10px;\n}\n\n.url {\n font-size: smaller;\n color: grey;\n}\n\nli.standard {\n color: grey;\n}\n\n</style>\n</head>\n<body>\n{content}\n</body>\n</html>\n',
treeDepItemHtml: '<li><a href=\"#mod-{htmlId}\">{id}</a></li>',
treeDepItemNoLinkHtml: '<li class=\"standard\">{id}</li>',
treeItemHtml: '<div class=\"mod\" id=\"mod-{htmlId}\">\n <span class=\"id\">{id}</span>\n <span class=\"url\">{url}</span>\n <ul class=\"deps\">\n {depItems}\n </ul>\n</div>\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: '<!DOCTYPE html>\n<html>\n<head>\n<title>Module Cycles</title>\n<style>\nbody {\n font-family: \"Inconsolata\",Andale Mono,Monaco,Monospace;\n color: green;\n}\n\na {\n color: #2E87DD;\n text-decoration: none;\n}\n\na:hover {\n text-decoration: underline;\n}\n\n.mod {\n background-color: #FAFAFA;\n border: 1px solid #E6E6E6;\n border-radius: 5px 5px 5px 5px;\n box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);\n font-size: 13px;\n line-height: 18px;\n margin: 7px 0 21px;\n overflow: auto;\n padding: 5px 10px;\n}\n\n</style>\n</head>\n<body>\n{content}\n</body>\n</html>\n',
cycleEntryHtml: '<div class=\"mod\">\n <span class=\"id\">{id}</span>\n <ul class=\"chain\">\n {chain}\n </ul>\n</div>\n',
cycleChainEntryHtml: '<li>{id}</li>',
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);
}
};
}());

View File

@ -1,4 +1,4 @@
'use strict'; 'use strict';
define(function () { define(function () {

View File

@ -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);
});*//*
};
}());
*/

View File

@ -1,10 +1,11 @@
'use strict'; 'use strict';
define( define(
[ [
'vent',
'underscore', 'underscore',
'backbone', 'backbone',
'signalR' 'signalR'
], function (_, Backbone) { ], function (vent, _, Backbone) {
_.extend(Backbone.Collection.prototype, { _.extend(Backbone.Collection.prototype, {
bindSignalR: function () { bindSignalR: function () {
@ -25,12 +26,7 @@ define(
console.log(options.action + ': {0}}'.format(options.resource)); console.log(options.action + ': {0}}'.format(options.resource));
}; };
require( collection.listenTo(vent, 'server:' + collection.url.replace('/api/', ''), processMessage);
[
'app'
], function (app) {
collection.listenTo(app.vent, 'server:' + collection.url.replace('/api/', ''), processMessage);
});
return this; return this;
}, },

View File

@ -1,9 +1,9 @@
'use strict'; 'use strict';
define( define(
[ [
'app', 'backbone',
'Series/SeriesCollection' 'Series/SeriesCollection'
], function (App, SeriesCollection) { ], function (Backbone, SeriesCollection) {
$(document).on('keydown', function (e){ $(document).on('keydown', function (e){
if ($(e.target).is('input')) { if ($(e.target).is('input')) {
return; return;
@ -29,7 +29,7 @@ define(
var series = SeriesCollection.findWhere({ title: item }); var series = SeriesCollection.findWhere({ title: item });
this.$element.blur(); 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 });
} }
}); });
}; };

View File

@ -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;
});

View File

@ -2,9 +2,8 @@
define( define(
[ [
'app',
'Settings/SettingsModelBase' 'Settings/SettingsModelBase'
], function (App, ModelBase) { ], function (ModelBase) {
return ModelBase.extend({ return ModelBase.extend({
baseInitialize: ModelBase.prototype.initialize, baseInitialize: ModelBase.prototype.initialize,

View File

@ -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});
});
}
};
});

View File

@ -1,38 +1,16 @@
'use strict'; 'use strict';
require( define(
[ [
'app',
'backbone',
'marionette', 'marionette',
'Controller', 'Controller'
'Series/SeriesCollection', ], function (Marionette, Controller) {
'ProgressMessaging/ProgressMessageCollection',
'Commands/CommandMessengerCollectionView',
'History/Queue/QueueCollection',
'Navbar/NavbarView',
'jQuery/RouteBinder',
'jquery'
], function (App,
Backbone,
Marionette,
Controller,
SeriesCollection,
ProgressMessageCollection,
CommandMessengerCollectionView,
QueueCollection,
NavbarView,
RouterBinder,
$) {
var Router = Marionette.AppRouter.extend({ return Marionette.AppRouter.extend({
controller: new Controller(), controller: new Controller(),
appRoutes : { appRoutes : {
'' : 'series',
'series' : 'series',
'addseries' : 'addSeries', 'addseries' : 'addSeries',
'addseries/:action(/:query)': 'addSeries', 'addseries/:action(/:query)': 'addSeries',
'series/:query' : 'seriesDetails',
'calendar' : 'calendar', 'calendar' : 'calendar',
'settings' : 'settings', 'settings' : 'settings',
'settings/:action(/:query)' : 'settings', 'settings/:action(/:query)' : 'settings',
@ -43,23 +21,8 @@ require(
'system' : 'system', 'system' : 'system',
'system/:action' : 'system', 'system/:action' : 'system',
'seasonpass' : 'seasonPass', '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;
}); });

View File

@ -45,7 +45,7 @@ define(
}, },
_seasonSelected: function () { _seasonSelected: function () {
var seasonNumber = parseInt(this.ui.seasonSelect.val()); var seasonNumber = parseInt(this.ui.seasonSelect.val(), 10);
if (seasonNumber === -1 || isNaN(seasonNumber)) { if (seasonNumber === -1 || isNaN(seasonNumber)) {
return; return;
@ -112,19 +112,18 @@ define(
var element; var element;
if (e.target.localName === 'i') { 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); element = $(e.target);
} }
else { else {
seasonNumber = parseInt($(e.target).attr('data-season-number')); seasonNumber = parseInt($(e.target).attr('data-season-number'), 10);
element = $(e.target).children('i'); element = $(e.target).children('i');
} }
this.model.setSeasonMonitored(seasonNumber); this.model.setSeasonMonitored(seasonNumber);
var savePromise =this.model.save() var savePromise = this.model.save().always(this.render.bind(this));
.always(this.render.bind(this));
element.spinForPromise(savePromise); element.spinForPromise(savePromise);
}, },

View File

@ -1,9 +1,9 @@
'use strict'; 'use strict';
define( define(
[ [
'app', 'vent',
'marionette' 'marionette'
], function (App, Marionette) { ], function (vent, Marionette) {
return Marionette.ItemView.extend({ return Marionette.ItemView.extend({
template: 'Series/Delete/DeleteSeriesTemplate', template: 'Series/Delete/DeleteSeriesTemplate',
@ -24,8 +24,8 @@ define(
data: { 'deleteFiles': deleteFiles }, data: { 'deleteFiles': deleteFiles },
wait: true wait: true
}).done(function () { }).done(function () {
App.vent.trigger(App.Events.SeriesDeleted, { series: self.model }); vent.trigger(vent.Events.SeriesDeleted, { series: self.model });
App.vent.trigger(App.Commands.CloseModalCommand); vent.trigger(vent.Commands.CloseModalCommand);
}); });
} }
}); });

View File

@ -2,8 +2,9 @@
define( define(
[ [
'marionette', 'marionette',
'Series/Details/SeasonLayout' 'Series/Details/SeasonLayout',
], function (Marionette, SeasonLayout) { 'underscore'
], function (Marionette, SeasonLayout, _) {
return Marionette.CollectionView.extend({ return Marionette.CollectionView.extend({
itemView: SeasonLayout, itemView: SeasonLayout,
@ -26,16 +27,15 @@ define(
}, },
onEpisodeGrabbed: function (message) { onEpisodeGrabbed: function (message) {
if (message.episode.series.id != this.episodeCollection.seriesId) { if (message.episode.series.id !== this.episodeCollection.seriesId) {
return; return;
} }
var self = this; var self = this;
_.each(message.episode.episodes, function (episode){ _.each(message.episode.episodes, function (episode) {
var ep = self.episodeCollection.get(episode.id); var ep = self.episodeCollection.get(episode.id);
ep.set('downloading', true); ep.set('downloading', true);
console.debug(episode.title);
}); });
this.render(); this.render();

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
define( define(
[ [
'app', 'vent',
'marionette', 'marionette',
'backgrid', 'backgrid',
'Cells/ToggleCell', 'Cells/ToggleCell',
@ -10,8 +10,9 @@ define(
'Cells/EpisodeStatusCell', 'Cells/EpisodeStatusCell',
'Cells/EpisodeActionsCell', 'Cells/EpisodeActionsCell',
'Commands/CommandController', 'Commands/CommandController',
'moment' 'moment',
], function (App, Marionette, Backgrid, ToggleCell, EpisodeTitleCell, RelativeDateCell, EpisodeStatusCell, EpisodeActionsCell, CommandController, Moment) { 'underscore'
], function (vent, Marionette, Backgrid, ToggleCell, EpisodeTitleCell, RelativeDateCell, EpisodeStatusCell, EpisodeActionsCell, CommandController, Moment,_) {
return Marionette.Layout.extend({ return Marionette.Layout.extend({
template: 'Series/Details/SeasonLayoutTemplate', template: 'Series/Details/SeasonLayoutTemplate',
@ -173,7 +174,7 @@ define(
_afterRename: function () { _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 () { _showEpisodes: function () {

View File

@ -1,8 +1,10 @@
'use strict'; 'use strict';
define( define(
[ [
'app', 'vent',
'reqres',
'marionette', 'marionette',
'backbone',
'Series/EpisodeCollection', 'Series/EpisodeCollection',
'Series/EpisodeFileCollection', 'Series/EpisodeFileCollection',
'Series/SeasonCollection', 'Series/SeasonCollection',
@ -10,9 +12,10 @@ define(
'Series/Details/InfoView', 'Series/Details/InfoView',
'Commands/CommandController', 'Commands/CommandController',
'Shared/LoadingView', 'Shared/LoadingView',
'underscore',
'backstrech', 'backstrech',
'Mixins/backbone.signalr.mixin' '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({ return Marionette.Layout.extend({
itemViewContainer: '.x-series-seasons', itemViewContainer: '.x-series-seasons',
@ -42,10 +45,10 @@ define(
initialize: function () { initialize: function () {
this.listenTo(this.model, 'change:monitored', this._setMonitoredState); this.listenTo(this.model, 'change:monitored', this._setMonitoredState);
this.listenTo(App.vent, App.Events.SeriesDeleted, this._onSeriesDeleted); this.listenTo(vent, vent.Events.SeriesDeleted, this._onSeriesDeleted);
this.listenTo(App.vent, App.Events.SeasonRenamed, this._onSeasonRenamed); 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 () { onShow: function () {
@ -105,7 +108,7 @@ define(
} }
$('body').removeClass('backdrop'); $('body').removeClass('backdrop');
App.reqres.removeHandler(App.Reqres.GetEpisodeFileById); reqres.removeHandler(reqres.Requests.GetEpisodeFileById);
}, },
_toggleMonitored: function () { _toggleMonitored: function () {
@ -132,7 +135,7 @@ define(
}, },
_editSeries: function () { _editSeries: function () {
App.vent.trigger(App.Commands.EditSeriesCommand, {series: this.model}); vent.trigger(vent.Commands.EditSeriesCommand, {series: this.model});
}, },
_refreshSeries: function () { _refreshSeries: function () {
@ -145,7 +148,7 @@ define(
_onSeriesDeleted: function (event) { _onSeriesDeleted: function (event) {
if (this.model.get('id') === event.series.get('id')) { 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 series : self.model
}); });
App.reqres.setHandler(App.Reqres.GetEpisodeFileById, function (episodeFileId) { reqres.setHandler(reqres.Requests.GetEpisodeFileById, function (episodeFileId) {
return self.episodeFileCollection.get(episodeFileId); return self.episodeFileCollection.get(episodeFileId);
}); });

View File

@ -1,13 +1,13 @@
'use strict'; 'use strict';
define( define(
[ [
'app', 'vent',
'marionette', 'marionette',
'Quality/QualityProfileCollection', 'Quality/QualityProfileCollection',
'Mixins/AsModelBoundView', 'Mixins/AsModelBoundView',
'Mixins/AsValidatedView', 'Mixins/AsValidatedView',
'Mixins/AutoComplete' 'Mixins/AutoComplete'
], function (App, Marionette, QualityProfiles, AsModelBoundView, AsValidatedView) { ], function (vent, Marionette, QualityProfiles, AsModelBoundView, AsValidatedView) {
var view = Marionette.ItemView.extend({ var view = Marionette.ItemView.extend({
template: 'Series/Edit/EditSeriesViewTemplate', template: 'Series/Edit/EditSeriesViewTemplate',
@ -36,7 +36,7 @@ define(
this.model.save().done(function () { this.model.save().done(function () {
self.trigger('saved'); self.trigger('saved');
App.vent.trigger(App.Commands.CloseModalCommand); vent.trigger(vent.Commands.CloseModalCommand);
}); });
}, },
@ -45,7 +45,7 @@ define(
}, },
_removeSeries: function () { _removeSeries: function () {
App.vent.trigger(App.Commands.DeleteSeriesCommand, {series:this.model}); vent.trigger(vent.Commands.DeleteSeriesCommand, {series:this.model});
} }
}); });

View File

@ -1,9 +0,0 @@
'use strict';
define(
[
'marionette'
], function (Marionette) {
return Marionette.CompositeView.extend({
template: 'Series/Index/EmptySeriesIndexTemplate'
});
});

View File

@ -2,9 +2,9 @@
define( define(
[ [
'app', 'vent',
'marionette', 'marionette'
], function (App, Marionette) { ], function (vent, Marionette) {
return Marionette.ItemView.extend({ return Marionette.ItemView.extend({
template: 'Series/Index/List/ItemTemplate', template: 'Series/Index/List/ItemTemplate',
@ -18,11 +18,11 @@ define(
}, },
editSeries: function () { editSeries: function () {
App.vent.trigger(App.Commands.EditSeriesCommand, {series: this.model}); vent.trigger(vent.Commands.EditSeriesCommand, {series: this.model});
}, },
removeSeries: function () { removeSeries: function () {
App.vent.trigger(App.Commands.DeleteSeriesCommand, {series: this.model}); vent.trigger(vent.Commands.DeleteSeriesCommand, {series: this.model});
} }
}); });
}); });

View File

@ -2,9 +2,9 @@
define( define(
[ [
'app', 'vent',
'marionette' 'marionette'
], function (App, Marionette) { ], function (vent, Marionette) {
return Marionette.ItemView.extend({ return Marionette.ItemView.extend({
tagName : 'li', tagName : 'li',
@ -25,11 +25,11 @@ define(
editSeries: function () { editSeries: function () {
App.vent.trigger(App.Commands.EditSeriesCommand, {series:this.model}); vent.trigger(vent.Commands.EditSeriesCommand, {series:this.model});
}, },
removeSeries: function () { removeSeries: function () {
App.vent.trigger(App.Commands.DeleteSeriesCommand, {series:this.model}); vent.trigger(vent.Commands.DeleteSeriesCommand, {series:this.model});
}, },
posterHoverAction: function () { posterHoverAction: function () {

View File

@ -2,8 +2,9 @@
define( define(
[ [
'backbone', 'backbone',
'Series/SeriesModel' 'Series/SeriesModel',
], function (Backbone, SeriesModel) { 'api!series'
], function (Backbone, SeriesModel, SeriesData) {
var Collection = Backbone.Collection.extend({ var Collection = Backbone.Collection.extend({
url : window.NzbDrone.ApiRoot + '/series', url : window.NzbDrone.ApiRoot + '/series',
model: SeriesModel, model: SeriesModel,
@ -18,6 +19,6 @@ define(
} }
}); });
var collection = new Collection(); var collection = new Collection(SeriesData);
return collection; return collection;
}); });

View File

@ -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();
}
}
});
});

View File

@ -2,7 +2,6 @@
define( define(
[ [
'backbone', 'backbone',
'underscore' 'underscore'
], function (Backbone, _) { ], function (Backbone, _) {
return Backbone.Model.extend({ return Backbone.Model.extend({

View File

@ -1,10 +1,13 @@
'use strict'; 'use strict';
define(['app', define(
'marionette', [
'Settings/Indexers/ItemView', 'AppLayout',
'Settings/Indexers/EditView', 'marionette',
'Settings/Indexers/Collection'], 'Settings/Indexers/ItemView',
function (App, Marionette, IndexerItemView, IndexerEditView, IndexerCollection) { 'Settings/Indexers/EditView',
'Settings/Indexers/Collection',
'underscore'
], function (AppLayout, Marionette, IndexerItemView, IndexerEditView, IndexerCollection, _) {
return Marionette.CompositeView.extend({ return Marionette.CompositeView.extend({
itemView : IndexerItemView, itemView : IndexerItemView,
itemViewContainer: '#x-indexers', itemViewContainer: '#x-indexers',
@ -18,7 +21,7 @@ define(['app',
'click .x-add-card': '_openSchemaModal' 'click .x-add-card': '_openSchemaModal'
}, },
appendHtml: function(collectionView, itemView, index){ appendHtml: function (collectionView, itemView, index) {
collectionView.ui.addCard.parent('li').before(itemView.el); collectionView.ui.addCard.parent('li').before(itemView.el);
}, },
@ -33,13 +36,13 @@ define(['app',
var model = _.first(collection.models); var model = _.first(collection.models);
model.set({ model.set({
id: undefined, id : undefined,
name: '', name : '',
enable: true enable: true
}); });
var view = new IndexerEditView({ model: model, indexerCollection: self.collection}); var view = new IndexerEditView({ model: model, indexerCollection: self.collection});
App.modalRegion.show(view); AppLayout.modalRegion.show(view);
} }
}); });
} }

View File

@ -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);
}
});
}
});
});

View File

@ -2,16 +2,17 @@
define( define(
[ [
'app', 'vent',
'marionette', 'marionette',
'Mixins/AsModelBoundView', 'Mixins/AsModelBoundView',
'Mixins/AsValidatedView' 'Mixins/AsValidatedView',
], function (App, Marionette, AsModelBoundView, AsValidatedView) { 'underscore'
], function (vent, Marionette, AsModelBoundView, AsValidatedView, _) {
var view = Marionette.ItemView.extend({ var view = Marionette.ItemView.extend({
template: 'Settings/Indexers/EditTemplate', template: 'Settings/Indexers/EditTemplate',
ui : { ui: {
activity: '.x-activity' activity: '.x-activity'
}, },
@ -33,7 +34,7 @@ define(
if (promise) { if (promise) {
promise.done(function () { promise.done(function () {
self.indexerCollection.add(self.model, { merge: true }); self.indexerCollection.add(self.model, { merge: true });
App.vent.trigger(App.Commands.CloseModalCommand); vent.trigger(vent.Commands.CloseModalCommand);
}); });
promise.fail(function () { promise.fail(function () {

View File

@ -2,12 +2,12 @@
define( define(
[ [
'app', 'AppLayout',
'marionette', 'marionette',
'Settings/Notifications/DeleteView', 'Settings/Notifications/DeleteView',
'Mixins/AsModelBoundView', 'Mixins/AsModelBoundView',
'Mixins/AsValidatedView' 'Mixins/AsValidatedView'
], function (App, Marionette, DeleteView, AsModelBoundView, AsValidatedView) { ], function (AppLayout, Marionette, DeleteView, AsModelBoundView, AsValidatedView) {
var view = Marionette.ItemView.extend({ var view = Marionette.ItemView.extend({
template: 'Settings/Indexers/ItemTemplate', template: 'Settings/Indexers/ItemTemplate',
@ -19,7 +19,7 @@ define(
_deleteIndexer: function () { _deleteIndexer: function () {
var view = new DeleteView({ model: this.model}); var view = new DeleteView({ model: this.model});
App.modalRegion.show(view); AppLayout.modalRegion.show(view);
} }
}); });

View File

@ -1,4 +1,4 @@
'use strict'; 'use strict';
define( define(
[ [
'marionette', 'marionette',

View File

@ -1,10 +1,10 @@
'use strict'; 'use strict';
define([ define([
'app', 'AppLayout',
'marionette', 'marionette',
'Settings/Notifications/EditView' 'Settings/Notifications/EditView'
], function (App, Marionette, EditView) { ], function (AppLayout, Marionette, EditView) {
return Marionette.ItemView.extend({ return Marionette.ItemView.extend({
template: 'Settings/Notifications/AddItemTemplate', template: 'Settings/Notifications/AddItemTemplate',
@ -31,7 +31,7 @@ define([
}); });
var editView = new EditView({ model: this.model, notificationCollection: this.notificationCollection }); var editView = new EditView({ model: this.model, notificationCollection: this.notificationCollection });
App.modalRegion.show(editView); AppLayout.modalRegion.show(editView);
} }
}); });
}); });

View File

@ -1,10 +1,9 @@
'use strict'; 'use strict';
define([ define([
'app',
'marionette', 'marionette',
'Settings/Notifications/ItemView', 'Settings/Notifications/ItemView',
'Settings/Notifications/SchemaModal' 'Settings/Notifications/SchemaModal'
], function (App, Marionette, NotificationItemView, SchemaModal) { ], function (Marionette, NotificationItemView, SchemaModal) {
return Marionette.CompositeView.extend({ return Marionette.CompositeView.extend({
itemView : NotificationItemView, itemView : NotificationItemView,
itemViewContainer: '.notifications', itemViewContainer: '.notifications',

View File

@ -1,19 +1,23 @@
'use strict'; 'use strict';
define(['app', 'marionette'], function (App, Marionette) { define(
return Marionette.ItemView.extend({ [
template: 'Settings/Notifications/DeleteTemplate', 'vent',
'marionette'
], function (vent, Marionette) {
return Marionette.ItemView.extend({
template: 'Settings/Notifications/DeleteTemplate',
events: { events: {
'click .x-confirm-delete': '_removeNotification' 'click .x-confirm-delete': '_removeNotification'
}, },
_removeNotification: function () { _removeNotification: function () {
this.model.destroy({ this.model.destroy({
wait : true, wait : true,
success: function () { success: function () {
App.vent.trigger(App.Commands.CloseModalCommand); vent.trigger(vent.Commands.CloseModalCommand);
} }
}); });
} }
});
}); });
});

View File

@ -1,92 +1,93 @@
'use strict'; 'use strict';
define([ define(
'app', [
'marionette', 'vent',
'Settings/Notifications/Model', 'AppLayout',
'Settings/Notifications/DeleteView', 'marionette',
'Shared/Messenger', 'Settings/Notifications/DeleteView',
'Commands/CommandController', 'Commands/CommandController',
'Mixins/AsModelBoundView', 'Mixins/AsModelBoundView',
'Form/FormBuilder' 'Form/FormBuilder',
'underscore'
], function (App, Marionette, NotificationModel, DeleteView, Messenger, CommandController, AsModelBoundView) { ], function (vent, AppLayout, Marionette, DeleteView, CommandController, AsModelBoundView, _) {
var model = Marionette.ItemView.extend({ var model = Marionette.ItemView.extend({
template: 'Settings/Notifications/EditTemplate', template: 'Settings/Notifications/EditTemplate',
events: { events: {
'click .x-save' : '_saveNotification', 'click .x-save' : '_saveNotification',
'click .x-save-and-add' : '_saveAndAddNotification', 'click .x-save-and-add': '_saveAndAddNotification',
'click .x-delete' : '_deleteNotification', 'click .x-delete' : '_deleteNotification',
'click .x-back' : '_back', 'click .x-back' : '_back',
'click .x-test' : '_test' 'click .x-test' : '_test'
}, },
ui: { ui: {
testButton: '.x-test', testButton: '.x-test',
testIcon : '.x-test-icon' testIcon : '.x-test-icon'
}, },
initialize: function (options) { initialize: function (options) {
this.notificationCollection = options.notificationCollection; this.notificationCollection = options.notificationCollection;
}, },
_saveNotification: function () { _saveNotification: function () {
var self = this; var self = this;
var promise = this.model.saveSettings(); var promise = this.model.saveSettings();
if (promise) { if (promise) {
promise.done(function () { promise.done(function () {
self.notificationCollection.add(self.model, { merge: true }); self.notificationCollection.add(self.model, { merge: true });
App.vent.trigger(App.Commands.CloseModalCommand); 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 () { return AsModelBoundView.call(model);
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);
});

View File

@ -1,12 +1,12 @@
'use strict'; 'use strict';
define([ define([
'app', 'AppLayout',
'marionette', 'marionette',
'Settings/Notifications/EditView', 'Settings/Notifications/EditView',
'Settings/Notifications/DeleteView' 'Settings/Notifications/DeleteView'
], function (App, Marionette, EditView, DeleteView) { ], function (AppLayout, Marionette, EditView, DeleteView) {
return Marionette.ItemView.extend({ return Marionette.ItemView.extend({
template: 'Settings/Notifications/ItemTemplate', template: 'Settings/Notifications/ItemTemplate',
@ -23,12 +23,12 @@ define([
_editNotification: function () { _editNotification: function () {
var view = new EditView({ model: this.model, notificationCollection: this.model.collection}); var view = new EditView({ model: this.model, notificationCollection: this.model.collection});
App.modalRegion.show(view); AppLayout.modalRegion.show(view);
}, },
_deleteNotification: function () { _deleteNotification: function () {
var view = new DeleteView({ model: this.model}); var view = new DeleteView({ model: this.model});
App.modalRegion.show(view); AppLayout.modalRegion.show(view);
} }
}); });
}); });

View File

@ -1,9 +1,9 @@
'use strict'; 'use strict';
define([ define([
'app', 'AppLayout',
'Settings/Notifications/Collection', 'Settings/Notifications/Collection',
'Settings/Notifications/AddView' 'Settings/Notifications/AddView'
], function (App, NotificationCollection, AddSelectionNotificationView) { ], function (AppLayout, NotificationCollection, AddSelectionNotificationView) {
return ({ return ({
open: function (collection) { open: function (collection) {
@ -13,7 +13,7 @@ define([
schemaCollection.url = '/api/notification'; schemaCollection.url = '/api/notification';
var view = new AddSelectionNotificationView({ collection: schemaCollection, notificationCollection: collection}); var view = new AddSelectionNotificationView({ collection: schemaCollection, notificationCollection: collection});
App.modalRegion.show(view); AppLayout.modalRegion.show(view);
} }
}); });
}); });

View File

@ -1,18 +1,22 @@
'use strict'; 'use strict';
define(['app', 'handlebars'], function (App,Handlebars) { define(
Handlebars.registerHelper('allowedLabeler', function () { [
var ret = ''; 'handlebars',
var cutoff = this.cutoff; 'underscore'
_.each(this.allowed, function (allowed) { ], function (Handlebars, _) {
if (allowed.id === cutoff.id) { Handlebars.registerHelper('allowedLabeler', function () {
ret += '<span class="label label-info" title="Cutoff">' + allowed.name + '</span> '; var ret = '';
} var cutoff = this.cutoff;
_.each(this.allowed, function (allowed) {
if (allowed.id === cutoff.id) {
ret += '<span class="label label-info" title="Cutoff">' + allowed.name + '</span> ';
}
else { else {
ret += '<span class="label">' + allowed.name + '</span> '; ret += '<span class="label">' + allowed.name + '</span> ';
} }
});
return new Handlebars.SafeString(ret);
}); });
return new Handlebars.SafeString(ret);
}); });
});

View File

@ -1,9 +1,9 @@
'use strict'; 'use strict';
define( define(
[ [
'app', 'vent',
'marionette' 'marionette'
], function (App, Marionette) { ], function (vent, Marionette) {
return Marionette.ItemView.extend({ return Marionette.ItemView.extend({
template: 'Settings/Quality/Profile/DeleteTemplate', template: 'Settings/Quality/Profile/DeleteTemplate',
@ -17,7 +17,7 @@ define(
this.model.destroy({ this.model.destroy({
wait: true wait: true
}).done(function () { }).done(function () {
App.vent.trigger(App.Commands.CloseModalCommand); vent.trigger(vent.Commands.CloseModalCommand);
}); });
} }
}); });

View File

@ -1,11 +1,13 @@
'use strict'; 'use strict';
define( define(
[ [
'app', 'vent',
'marionette', 'marionette',
'backbone',
'Mixins/AsModelBoundView', 'Mixins/AsModelBoundView',
'Mixins/AsValidatedView' 'Mixins/AsValidatedView',
], function (App, Marionette, AsModelBoundView, AsValidatedView) { 'underscore'
], function (vent, Marionette, Backbone, AsModelBoundView, AsValidatedView, _) {
var view = Marionette.ItemView.extend({ var view = Marionette.ItemView.extend({
template: 'Settings/Quality/Profile/EditQualityProfileTemplate', template: 'Settings/Quality/Profile/EditQualityProfileTemplate',
@ -61,7 +63,7 @@ define(
_saveQualityProfile: function () { _saveQualityProfile: function () {
var self = this; 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); this.model.set('cutoff', cutoff);
var promise = this.model.save(); var promise = this.model.save();
@ -69,7 +71,7 @@ define(
if (promise) { if (promise) {
promise.done(function () { promise.done(function () {
self.profileCollection.add(self.model, { merge: true }); self.profileCollection.add(self.model, { merge: true });
App.vent.trigger(App.Commands.CloseModalCommand); vent.trigger(vent.Commands.CloseModalCommand);
}); });
} }
} }

View File

@ -1,11 +1,12 @@
'use strict'; 'use strict';
define(['app', define(['AppLayout',
'marionette', 'marionette',
'Settings/Quality/Profile/QualityProfileView', 'Settings/Quality/Profile/QualityProfileView',
'Settings/Quality/Profile/EditQualityProfileView', 'Settings/Quality/Profile/EditQualityProfileView',
'Settings/Quality/Profile/QualityProfileSchemaCollection' 'Settings/Quality/Profile/QualityProfileSchemaCollection',
], function (App, Marionette, QualityProfileView, EditProfileView, ProfileCollection) { 'underscore'
], function (AppLayout, Marionette, QualityProfileView, EditProfileView, ProfileCollection, _) {
return Marionette.CompositeView.extend({ return Marionette.CompositeView.extend({
itemView : QualityProfileView, itemView : QualityProfileView,
@ -35,7 +36,7 @@ define(['app',
model.collection = self.collection; model.collection = self.collection;
var view = new EditProfileView({ model: model, profileCollection: self.collection}); var view = new EditProfileView({ model: model, profileCollection: self.collection});
App.modalRegion.show(view); AppLayout.modalRegion.show(view);
} }
}); });
} }

View File

@ -2,16 +2,15 @@
define( define(
[ [
'app', 'AppLayout',
'marionette', 'marionette',
'Settings/Quality/Profile/EditQualityProfileView', 'Settings/Quality/Profile/EditQualityProfileView',
'Settings/Quality/Profile/DeleteView', 'Settings/Quality/Profile/DeleteView',
'Series/SeriesCollection', 'Series/SeriesCollection',
'Mixins/AsModelBoundView', 'Mixins/AsModelBoundView',
'Settings/Quality/Profile/AllowedLabeler', 'Settings/Quality/Profile/AllowedLabeler',
'bootstrap', 'bootstrap'
], function (AppLayout, Marionette, EditProfileView, DeleteProfileView, SeriesCollection, AsModelBoundView) {
], function (App, Marionette, EditProfileView, DeleteProfileView, SeriesCollection, AsModelBoundView) {
var view = Marionette.ItemView.extend({ var view = Marionette.ItemView.extend({
template: 'Settings/Quality/Profile/QualityProfileTemplate', template: 'Settings/Quality/Profile/QualityProfileTemplate',
@ -29,12 +28,12 @@ define(
initialize: function () { initialize: function () {
this.listenTo(this.model, 'sync', this.render); this.listenTo(this.model, 'sync', this.render);
this.listenTo(SeriesCollection, 'all', this._updateDisableStatus) this.listenTo(SeriesCollection, 'all', this._updateDisableStatus);
}, },
_editProfile: function () { _editProfile: function () {
var view = new EditProfileView({ model: this.model, profileCollection: this.model.collection }); var view = new EditProfileView({ model: this.model, profileCollection: this.model.collection });
App.modalRegion.show(view); AppLayout.modalRegion.show(view);
}, },
_deleteProfile: function () { _deleteProfile: function () {
@ -43,7 +42,7 @@ define(
} }
var view = new DeleteProfileView({ model: this.model }); var view = new DeleteProfileView({ model: this.model });
App.modalRegion.show(view); AppLayout.modalRegion.show(view);
}, },
onRender: function () { onRender: function () {

View File

@ -1,55 +1,61 @@
'use strict'; 'use strict';
define(['marionette', 'Mixins/AsModelBoundView', 'filesize', 'jquery.knob' ], function (Marionette, AsModelBoundView, Filesize) { define(
[
'marionette',
'Mixins/AsModelBoundView',
'filesize',
'jquery.knob'
], function (Marionette, AsModelBoundView, Filesize) {
var view = Marionette.ItemView.extend({ var view = Marionette.ItemView.extend({
template : 'Settings/Quality/Size/QualitySizeTemplate', template: 'Settings/Quality/Size/QualitySizeTemplate',
tagName : 'li', tagName : 'li',
ui: { ui: {
knob : '.x-knob', knob : '.x-knob',
thirtyMinuteSize: '.x-size-thirty', thirtyMinuteSize: '.x-size-thirty',
sixtyMinuteSize : '.x-size-sixty' sixtyMinuteSize : '.x-size-sixty'
}, },
events: { events: {
'change .x-knob': '_changeMaxSize' 'change .x-knob': '_changeMaxSize'
}, },
initialize: function (options) { initialize: function (options) {
this.qualityProfileCollection = options.qualityProfiles; this.qualityProfileCollection = options.qualityProfiles;
this.filesize = Filesize; this.filesize = Filesize;
}, },
onRender: function () { onRender: function () {
this.ui.knob.knob({ this.ui.knob.knob({
min : 0, min : 0,
max : 200, max : 200,
step : 1, step : 1,
cursor : 25, cursor : 25,
width : 150, width : 150,
stopper : true, stopper : true,
displayInput : false displayInput: false
}); });
this._changeMaxSize(); this._changeMaxSize();
}, },
_changeMaxSize: function () { _changeMaxSize: function () {
var maxSize = this.model.get('maxSize'); var maxSize = this.model.get('maxSize');
var bytes = maxSize * 1024 * 1024; var bytes = maxSize * 1024 * 1024;
var thirty = Filesize(bytes * 30, 1, false); var thirty = Filesize(bytes * 30, 1, false);
var sixty = Filesize(bytes * 60, 1, false); var sixty = Filesize(bytes * 60, 1, false);
if (parseInt(maxSize) === 0) { if (parseInt(maxSize, 10) === 0) {
thirty = 'No Limit'; thirty = 'No Limit';
sixty = 'No Limit'; sixty = 'No Limit';
}
this.ui.thirtyMinuteSize.html(thirty);
this.ui.sixtyMinuteSize.html(sixty);
} }
});
this.ui.thirtyMinuteSize.html(thirty); return AsModelBoundView.call(view);
this.ui.sixtyMinuteSize.html(sixty);
}
}); });
return AsModelBoundView.call(view);
});

View File

@ -1,8 +1,9 @@
'use strict'; 'use strict';
define( define(
[ [
'app', 'vent',
'marionette', 'marionette',
'backbone',
'Settings/SettingsModel', 'Settings/SettingsModel',
'Settings/General/GeneralSettingsModel', 'Settings/General/GeneralSettingsModel',
'Settings/MediaManagement/Naming/Model', 'Settings/MediaManagement/Naming/Model',
@ -16,8 +17,9 @@ define(
'Settings/General/GeneralView', 'Settings/General/GeneralView',
'Shared/LoadingView', 'Shared/LoadingView',
'Config' 'Config'
], function (App, ], function (vent,
Marionette, Marionette,
Backbone,
SettingsModel, SettingsModel,
GeneralSettingsModel, GeneralSettingsModel,
NamingModel, NamingModel,
@ -87,6 +89,8 @@ define(
this.indexerSettings.fetch(), this.indexerSettings.fetch(),
this.notificationSettings.fetch() this.notificationSettings.fetch()
).done(function () { ).done(function () {
if(!self.isClosed)
{
self.loading.$el.hide(); self.loading.$el.hide();
self.mediaManagement.show(new MediaManagementLayout({ settings: self.settings, namingSettings: self.namingSettings })); self.mediaManagement.show(new MediaManagementLayout({ settings: self.settings, namingSettings: self.namingSettings }));
self.quality.show(new QualityLayout({ settings: self.settings })); self.quality.show(new QualityLayout({ settings: self.settings }));
@ -94,6 +98,7 @@ define(
self.downloadClient.show(new DownloadClientLayout({ model: self.settings })); self.downloadClient.show(new DownloadClientLayout({ model: self.settings }));
self.notifications.show(new NotificationCollectionView({ collection: self.notificationSettings })); self.notifications.show(new NotificationCollectionView({ collection: self.notificationSettings }));
self.general.show(new GeneralView({ model: self.generalSettings })); self.general.show(new GeneralView({ model: self.generalSettings }));
}
}); });
this._setAdvancedSettingsState(); this._setAdvancedSettingsState();
@ -179,13 +184,11 @@ define(
}, },
_navigate:function(route){ _navigate:function(route){
require(['Router'], function(){ Backbone.history.navigate(route, {trigger:true});
App.Router.navigate(route);
});
}, },
_save: function () { _save: function () {
App.vent.trigger(App.Commands.SaveSettings); vent.trigger(vent.Commands.SaveSettings);
}, },
_setAdvancedSettingsState: function () { _setAdvancedSettingsState: function () {

View File

@ -1,9 +1,11 @@
'use strict'; 'use strict';
define(['app', define(
'Settings/SettingsModelBase'], function (App, SettingsModelBase) { [
return SettingsModelBase.extend({ 'Settings/SettingsModelBase'
url : window.NzbDrone.ApiRoot + '/settings', ], function (SettingsModelBase) {
successMessage: 'Settings saved', return SettingsModelBase.extend({
errorMessage : 'Failed to save settings' url : window.NzbDrone.ApiRoot + '/settings',
successMessage: 'Settings saved',
errorMessage : 'Failed to save settings'
});
}); });
});

View File

@ -1,34 +1,36 @@
'use strict'; 'use strict';
define(['app', define(
'backbone.deepmodel', [
'Mixins/AsChangeTrackingModel', 'vent',
'Shared/Messenger'], function (App, DeepModel, AsChangeTrackingModel, Messenger) { 'backbone.deepmodel',
var model = DeepModel.DeepModel.extend({ 'Mixins/AsChangeTrackingModel',
'Shared/Messenger'
], function (vent, DeepModel, AsChangeTrackingModel, Messenger) {
var model = DeepModel.DeepModel.extend({
initialize: function () { initialize: function () {
this.listenTo(App.vent, App.Commands.SaveSettings, this.saveSettings); 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( Messenger.monitor({
{ promise : savePromise,
promise : savePromise, successMessage: this.successMessage,
successMessage: this.successMessage, errorMessage : this.errorMessage
errorMessage : this.errorMessage });
});
return savePromise; return savePromise;
}
return undefined;
} }
return undefined; });
}
return AsChangeTrackingModel.call(model);
}); });
return AsChangeTrackingModel.call(model);
});

View File

@ -1,2 +0,0 @@
&copy; Copyright 2013 NzbDrone
<p>v{{version}} ({{ShortDate buildTime}})</p>

View File

@ -1,12 +0,0 @@
'use strict';
define(
[
'marionette',
'System/StatusModel'
], function (Marionette, StatusModel) {
return Marionette.ItemView.extend({
template: 'Shared/Footer/Template',
model : StatusModel
});
});

View File

@ -1,48 +1,47 @@
'use strict'; 'use strict';
define( define(
[ [
'app', 'vent',
'AppLayout',
'marionette', 'marionette',
'Series/Edit/EditSeriesView', 'Series/Edit/EditSeriesView',
'Series/Delete/DeleteSeriesView', 'Series/Delete/DeleteSeriesView',
'Episode/EpisodeDetailsLayout', 'Episode/EpisodeDetailsLayout',
'History/Details/HistoryDetailsView' '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 () { initialize: function () {
App.vent.on(App.Commands.CloseModalCommand, this._closeModal, this); vent.on(vent.Commands.CloseModalCommand, this._closeModal, this);
App.vent.on(App.Commands.EditSeriesCommand, this._editSeries, this); vent.on(vent.Commands.EditSeriesCommand, this._editSeries, this);
App.vent.on(App.Commands.DeleteSeriesCommand, this._deleteSeries, this); vent.on(vent.Commands.DeleteSeriesCommand, this._deleteSeries, this);
App.vent.on(App.Commands.ShowEpisodeDetails, this._showEpisode, this); vent.on(vent.Commands.ShowEpisodeDetails, this._showEpisode, this);
App.vent.on(App.Commands.ShowHistoryDetails, this._showHistory, this); vent.on(vent.Commands.ShowHistoryDetails, this._showHistory, this);
}, },
_closeModal: function () { _closeModal: function () {
App.modalRegion.closeModal(); AppLayout.modalRegion.closeModal();
}, },
_editSeries: function (options) { _editSeries: function (options) {
var view = new EditSeriesView({ model: options.series }); var view = new EditSeriesView({ model: options.series });
App.modalRegion.show(view); AppLayout.modalRegion.show(view);
}, },
_deleteSeries: function (options) { _deleteSeries: function (options) {
var view = new DeleteSeriesView({ model: options.series }); var view = new DeleteSeriesView({ model: options.series });
App.modalRegion.show(view); AppLayout.modalRegion.show(view);
}, },
_showEpisode: function (options) { _showEpisode: function (options) {
var view = new EpisodeDetailsLayout({ model: options.episode, hideSeriesLink: options.hideSeriesLink, openingTab: options.openingTab }); var view = new EpisodeDetailsLayout({ model: options.episode, hideSeriesLink: options.hideSeriesLink, openingTab: options.openingTab });
App.modalRegion.show(view); AppLayout.modalRegion.show(view);
}, },
_showHistory: function (options) { _showHistory: function (options) {
var view = new HistoryDetailsView({ model: options.history }); var view = new HistoryDetailsView({ model: options.history });
App.modalRegion.show(view); AppLayout.modalRegion.show(view);
} }
}); });
return new router();
}); });

View File

@ -1,11 +1,11 @@
'use strict'; 'use strict';
define( define(
[ [
'app', 'jquery',
'$', 'backbone',
'marionette', 'marionette',
'bootstrap' 'bootstrap'
], function (app, $, Marionette) { ], function ($,Backbone, Marionette) {
var region = Marionette.Region.extend({ var region = Marionette.Region.extend({
el: '#modal-region', el: '#modal-region',
@ -39,17 +39,5 @@ define(
}); });
require(
[
'Shared/Modal/Controller'
], function () {
app.addInitializer(function () {
app.addRegions({
modalRegion: region
});
});
});
return region; return region;
}); });

View File

@ -1,3 +1,3 @@
<div> <div>
<img src="/content/images/404.png" style="height:400px; margin-top: 50px"/> <img src="/Content/Images/404.png" style="height:400px; margin-top: 50px"/>
</div> </div>

View File

@ -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';
}
}
});
});

View File

@ -1,9 +1,9 @@
'use strict'; 'use strict';
define( define(
[ [
'app', 'vent',
'signalR' 'signalR'
], function () { ], function (vent) {
return { return {
appInitializer: function () { appInitializer: function () {
@ -31,12 +31,7 @@ define(
}); });
this.signalRconnection.received(function (message) { this.signalRconnection.received(function (message) {
require( vent.trigger('server:' + message.name, message.body);
[
'app'
], function (app) {
app.vent.trigger('server:' + message.name, message.body);
});
}); });
this.signalRconnection.start({ transport: this.signalRconnection.start({ transport:

View File

@ -1,11 +1,11 @@
'use strict'; 'use strict';
define( define(
[ [
'app', 'backbone',
'marionette', 'marionette',
'underscore', 'underscore',
'Commands/CommandController' 'Commands/CommandController'
], function (App, Marionette, _, CommandController) { ], function (Backbone, Marionette, _, CommandController) {
return Marionette.ItemView.extend({ return Marionette.ItemView.extend({
template : 'Shared/Toolbar/ButtonTemplate', template : 'Shared/Toolbar/ButtonTemplate',
@ -61,13 +61,7 @@ define(
invokeRoute: function () { invokeRoute: function () {
var route = this.model.get('route'); var route = this.model.get('route');
if (route) { if (route) {
Backbone.history.navigate(route, {trigger: true});
require(
[
'Router'
], function () {
App.Router.navigate(route, {trigger: true});
});
} }
}, },

View File

@ -2,9 +2,8 @@
define( define(
[ [
'app',
'marionette' 'marionette'
], function (App, Marionette) { ], function (Marionette) {
return Marionette.ItemView.extend({ return Marionette.ItemView.extend({
template: 'System/Logs/Files/ContentsViewTemplate' template: 'System/Logs/Files/ContentsViewTemplate'
}); });

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
define( define(
[ [
'app', 'vent',
'marionette', 'marionette',
'backgrid', 'backgrid',
'System/Logs/Files/FilenameCell', 'System/Logs/Files/FilenameCell',
@ -13,7 +13,7 @@ define(
'System/Logs/Files/ContentsModel', 'System/Logs/Files/ContentsModel',
'Shared/Toolbar/ToolbarLayout', 'Shared/Toolbar/ToolbarLayout',
'Shared/LoadingView' 'Shared/LoadingView'
], function (App, ], function (vent,
Marionette, Marionette,
Backgrid, Backgrid,
FilenameCell, FilenameCell,
@ -57,11 +57,12 @@ define(
initialize: function () { initialize: function () {
this.collection = new LogFileCollection(); this.collection = new LogFileCollection();
App.vent.on(App.Commands.ShowLogFile, this._fetchLogFileContents, this); vent.on(vent.Commands.ShowLogFile, this._fetchLogFileContents, this);
App.vent.on(App.Events.CommandComplete, this._commandComplete, this); vent.on(vent.Events.CommandComplete, this._commandComplete, this);
this.listenTo(this.collection, 'sync', this._collectionSynced); this.listenTo(this.collection, 'sync', this._collectionSynced);
this.collection.fetch(); this.collection.fetch();
}, },
onShow: function () { onShow: function () {

View File

@ -1,9 +1,9 @@
'use strict'; 'use strict';
define( define(
[ [
'app', 'vent',
'backgrid' 'backgrid'
], function (App, Backgrid) { ], function (vent, Backgrid) {
return Backgrid.Row.extend({ return Backgrid.Row.extend({
className: 'log-file-row', className: 'log-file-row',
@ -13,7 +13,7 @@ define(
}, },
_showContents: function () { _showContents: function () {
App.vent.trigger(App.Commands.ShowLogFile, { model: this.model }); vent.trigger(vent.Commands.ShowLogFile, { model: this.model });
} }
}); });
}); });

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
define( define(
[ [
'app', 'vent',
'marionette', 'marionette',
'backgrid', 'backgrid',
'System/Logs/Table/LogTimeCell', 'System/Logs/Table/LogTimeCell',
@ -10,7 +10,7 @@ define(
'System/Logs/LogsCollection', 'System/Logs/LogsCollection',
'Shared/Toolbar/ToolbarLayout', 'Shared/Toolbar/ToolbarLayout',
'Shared/LoadingView' '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({ return Marionette.Layout.extend({
template: 'System/Logs/Table/LogsTableLayoutTemplate', template: 'System/Logs/Table/LogsTableLayoutTemplate',
@ -59,7 +59,7 @@ define(
this.collection = new LogCollection(); this.collection = new LogCollection();
this.collectionPromise = this.collection.fetch(); this.collectionPromise = this.collection.fetch();
App.vent.on(App.Events.CommandComplete, this._commandComplete, this); vent.on(vent.Events.CommandComplete, this._commandComplete, this);
}, },
onRender: function () { onRender: function () {

View File

@ -1,12 +1,12 @@
'use strict'; 'use strict';
define( define(
[ [
'app', 'backbone',
'marionette', 'marionette',
'System/About/AboutView', 'System/About/AboutView',
'System/Logs/LogsLayout', 'System/Logs/LogsLayout',
'System/Update/UpdateLayout' 'System/Update/UpdateLayout'
], function (App, ], function (Backbone,
Marionette, Marionette,
AboutView, AboutView,
LogsLayout, LogsLayout,
@ -52,9 +52,7 @@ define(
}, },
_navigate:function(route){ _navigate:function(route){
require(['Router'], function(){ Backbone.history.navigate(route);
App.Router.navigate(route);
});
}, },
_showAbout: function (e) { _showAbout: function (e) {

View File

@ -2,9 +2,8 @@
define( define(
[ [
'app',
'marionette' 'marionette'
], function (App, Marionette) { ], function (Marionette) {
return Marionette.ItemView.extend({ return Marionette.ItemView.extend({
template: 'System/Update/UpdateItemViewTemplate', template: 'System/Update/UpdateItemViewTemplate',

View File

@ -1,8 +1,5 @@
'use strict'; 'use strict';
require.config({ require.config({
urlArgs: 'v=' + window.NzbDrone.ServerStatus.version,
paths: { paths: {
'backbone' : 'JsLibraries/backbone', 'backbone' : 'JsLibraries/backbone',
'moment' : 'JsLibraries/moment', 'moment' : 'JsLibraries/moment',
@ -16,23 +13,24 @@ require.config({
'backbone.modelbinder': 'JsLibraries/backbone.modelbinder', 'backbone.modelbinder': 'JsLibraries/backbone.modelbinder',
'backgrid' : 'JsLibraries/backbone.backgrid', 'backgrid' : 'JsLibraries/backbone.backgrid',
'backgrid.paginator' : 'JsLibraries/backbone.backgrid.paginator', 'backgrid.paginator' : 'JsLibraries/backbone.backgrid.paginator',
'backgrid.selectall' : 'JsLibraries/backbone.backgrid.selectall', 'backgrid.selectall' : 'JsLibraries/backbone.backgrid.selectall',
'fullcalendar' : 'JsLibraries/fullcalendar', 'fullcalendar' : 'JsLibraries/fullcalendar',
'backstrech' : 'JsLibraries/jquery.backstretch', 'backstrech' : 'JsLibraries/jquery.backstretch',
'$' : 'JsLibraries/jquery',
'underscore' : 'JsLibraries/lodash.underscore', 'underscore' : 'JsLibraries/lodash.underscore',
'marionette' : 'JsLibraries/backbone.marionette', 'marionette' : 'JsLibraries/backbone.marionette',
'signalR' : 'JsLibraries/jquery.signalR', 'signalR' : 'JsLibraries/jquery.signalR',
'jquery.knob' : 'JsLibraries/jquery.knob', 'jquery.knob' : 'JsLibraries/jquery.knob',
'jquery.dotdotdot' : 'JsLibraries/jquery.dotdotdot', 'jquery.dotdotdot' : 'JsLibraries/jquery.dotdotdot',
'libs' : 'JsLibraries/' 'jquery' : 'JsLibraries/jquery',
'libs' : 'JsLibraries/',
'api': 'Require/require.api'
}, },
shim: { shim: {
$: { jquery: {
exports: '$', exports: 'jQuery',
deps : deps :
[ [
'Mixins/jquery.ajax' 'Mixins/jquery.ajax'
@ -53,28 +51,33 @@ require.config({
signalR: { signalR: {
deps: deps:
[ [
'$' 'jquery'
] ]
}, },
bootstrap: { bootstrap: {
deps: deps:
[ [
'$' 'jquery'
] ],
init: function ($) {
$('body').tooltip({
selector: '[title]'
});
}
}, },
backstrech: { backstrech: {
deps: deps:
[ [
'$' 'jquery'
] ]
}, },
underscore: { underscore: {
deps : deps :
[ [
'$' 'jquery'
], ],
exports: '_' exports: '_'
}, },
@ -83,7 +86,7 @@ require.config({
deps : deps :
[ [
'underscore', 'underscore',
'$' 'jquery'
], ],
exports: 'Backbone' exports: 'Backbone'
}, },
@ -123,14 +126,14 @@ require.config({
'jquery.knob': { 'jquery.knob': {
deps: deps:
[ [
'$' 'jquery'
] ]
}, },
'jquery.dotdotdot': { 'jquery.dotdotdot': {
deps: deps:
[ [
'$' 'jquery'
] ]
}, },
@ -190,55 +193,44 @@ require.config({
} }
}); });
require.config({
urlArgs: 'v=' + window.NzbDrone.ServerStatus.version
});
define( define(
[ [
'backbone',
'marionette', 'marionette',
'jQuery/RouteBinder',
'Shared/SignalRBroadcaster', 'Shared/SignalRBroadcaster',
'Navbar/NavbarView',
'AppLayout',
'Series/SeriesController',
'Router',
'Shared/Modal/Controller',
'Instrumentation/StringFormat' 'Instrumentation/StringFormat'
], function (Marionette, SignalRBroadcaster) { ], function (Backbone, Marionette, RouteBinder, SignalRBroadcaster, NavbarView, AppLayout, SeriesController, Router, ModalController) {
new SeriesController();
new ModalController();
new Router();
var app = new Marionette.Application(); var app = new Marionette.Application();
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'
};
app.addInitializer(function () { app.addInitializer(function () {
console.log('starting application'); console.log('starting application');
}); });
app.addInitializer(SignalRBroadcaster.appInitializer, { app: app }); app.addInitializer(SignalRBroadcaster.appInitializer, {
app: app
});
app.addRegions({ app.addInitializer(function () {
navbarRegion: '#nav-region', Backbone.history.start({ pushState: true });
mainRegion : '#main-region', RouteBinder.bind();
footerRegion: '#footer-region' AppLayout.navbarRegion.show(new NavbarView());
$('body').addClass('started');
}); });
app.start(); app.start();
window.require(
[
'Router',
'jQuery/TooltipBinder'
]);
return app;
}); });

View File

@ -74,4 +74,5 @@
<script src="/ServerStatus.js"></script> <script src="/ServerStatus.js"></script>
<script data-main="/app" src="/JsLibraries/require.js"></script> <script data-main="/app" src="/JsLibraries/require.js"></script>
<script src="/JsLibraries/xrayquire.js"></script>
</html> </html>

View File

@ -1,18 +1,18 @@
'use strict'; 'use strict';
define(function () { define(['backbone'],function (Backbone) {
//This module will automatically route all relative links through backbone router rather than //This module will automatically route all relative links through backbone router rather than
//causing links to reload pages. //causing links to reload pages.
var routeBinder = { var routeBinder = {
bind: function (router) { bind: function () {
var self = this; var self = this;
$(document).on('click', 'a[href]', function (event) { $(document).on('click', 'a[href]', function (event) {
self._handleClick(event, router); self._handleClick(event);
}); });
}, },
_handleClick: function (event, router) { _handleClick: function (event) {
var $target = $(event.target); var $target = $(event.target);
//check if tab nav //check if tab nav
@ -41,7 +41,7 @@ define(function () {
if (!href.startsWith('http')) { if (!href.startsWith('http')) {
router.navigate(href, { trigger: true }); Backbone.history.navigate(href, { trigger: true });
} }
else { else {

View File

@ -1,10 +0,0 @@
'use strict';
define(
[
'bootstrap'
], function () {
$('body').tooltip({
selector: '[title]'
});
});

14
src/UI/reqres.js Normal file
View File

@ -0,0 +1,14 @@
define(
[
'marionette',
'backbone'
], function (Marionette, Backbone) {
'use strict';
var reqres = new Backbone.Wreqr.RequestResponse();
reqres.Requests = {
GetEpisodeFileById: 'GetEpisodeFileById'
};
return reqres;
});

28
src/UI/vent.js Normal file
View File

@ -0,0 +1,28 @@
define(
[
'marionette',
'backbone'
], function (Marionette, Backbone) {
'use strict';
var vent = new Backbone.Wreqr.EventAggregator();
vent.Events = {
SeriesAdded : 'series:added',
SeriesDeleted : 'series:deleted',
SeasonRenamed : 'season:renamed',
CommandComplete: 'command:complete'
};
vent.Commands = {
EditSeriesCommand : 'EditSeriesCommand',
DeleteSeriesCommand: 'DeleteSeriesCommand',
CloseModalCommand : 'CloseModalCommand',
ShowEpisodeDetails : 'ShowEpisodeDetails',
ShowHistoryDetails : 'ShowHistoryDetails',
SaveSettings : 'saveSettings',
ShowLogFile : 'showLogFile'
};
return vent;
});