1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2024-12-26 17:59:14 +00:00
Radarr/NzbDrone.Backbone/Controller.js

106 lines
3.7 KiB
JavaScript
Raw Normal View History

2013-03-02 19:13:23 +00:00
define(['app', 'Shared/ModalRegion', 'AddSeries/AddSeriesLayout',
2013-03-03 22:42:26 +00:00
'Series/Index/SeriesIndexCollectionView', 'Upcoming/UpcomingCollectionView',
2013-03-02 19:13:23 +00:00
'Calendar/CalendarCollectionView', 'Shared/NotificationView',
'Shared/NotFoundView', 'MainMenuView', 'HeaderView',
2013-03-04 00:29:48 +00:00
'Series/Details/SeriesDetailsView', 'Series/EpisodeCollection',
2013-03-21 03:02:57 +00:00
'Settings/SettingsLayout', 'Missing/MissingCollectionView'],
2013-03-02 19:13:23 +00:00
function (app, modalRegion) {
2013-02-15 23:38:53 +00:00
2013-02-18 03:37:13 +00:00
var controller = Backbone.Marionette.Controller.extend({
2013-02-15 23:38:53 +00:00
addSeries: function (action, query) {
this.setTitle('Add Series');
2013-02-18 03:37:13 +00:00
NzbDrone.mainRegion.show(new NzbDrone.AddSeries.AddSeriesLayout(this, action, query));
2013-02-15 23:38:53 +00:00
},
series: function (action, query) {
this.setTitle('NzbDrone');
2013-03-03 22:42:26 +00:00
NzbDrone.mainRegion.show(new NzbDrone.Series.Index.SeriesIndexCollectionView());
2013-02-15 23:38:53 +00:00
},
2013-02-20 07:45:52 +00:00
upcoming: function (action, query) {
this.setTitle('Upcoming');
NzbDrone.mainRegion.show(new NzbDrone.Upcoming.UpcomingCollectionView(this, action, query));
},
calendar: function (action, query) {
this.setTitle('Calendar');
2013-02-25 00:00:17 +00:00
var calendarCollection = new NzbDrone.Calendar.CalendarCollection();
calendarCollection.fetch();
2013-02-28 04:48:31 +00:00
NzbDrone.mainRegion.show(new NzbDrone.Calendar.CalendarCollectionView(this, action, query, calendarCollection));
},
2013-02-20 07:45:52 +00:00
2013-03-02 19:13:23 +00:00
seriesDetails: function (query) {
var self = this;
this.setTitle('Loading Series');
var series = new NzbDrone.Series.SeriesModel({ id: query });
series.fetch({
success: function (seriesModel) {
self.setTitle(seriesModel.get('title'));
NzbDrone.mainRegion.show(new NzbDrone.Series.Details.SeriesDetailsView({ model: seriesModel }));
2013-03-02 19:13:23 +00:00
}
});
},
2013-03-04 00:09:43 +00:00
settings: function(action, query) {
this.setTitle('Settings');
var settingsModel = new NzbDrone.Settings.SettingsModel();
settingsModel.fetch({
2013-03-21 03:02:57 +00:00
success: function(settings) {
2013-03-04 00:09:43 +00:00
NzbDrone.mainRegion.show(new NzbDrone.Settings.SettingsLayout(this, action, query, settings));
}
});
},
2013-03-21 03:02:57 +00:00
missing: function(action, query) {
this.setTitle('Missing');
var missingCollection = new NzbDrone.Missing.MissingCollection();
missingCollection.fetch({
success: function(missing) {
NzbDrone.mainRegion.show(new NzbDrone.Missing.MissingCollectionView(this, action, query, missing));
}
})
},
2013-02-15 23:38:53 +00:00
notFound: function () {
this.setTitle('Not Found');
2013-02-18 03:37:13 +00:00
NzbDrone.mainRegion.show(new NzbDrone.Shared.NotFoundView(this));
2013-02-15 23:38:53 +00:00
},
2013-02-18 03:37:13 +00:00
setTitle: function (title) {
2013-02-15 23:38:53 +00:00
$('#title-region').html(title);
2013-02-18 03:37:13 +00:00
if (title.toLocaleLowerCase() === 'nzbdrone') {
2013-02-15 23:38:53 +00:00
window.document.title = 'NzbDrone';
}
2013-02-18 03:37:13 +00:00
else {
2013-02-15 23:38:53 +00:00
window.document.title = title + ' - NzbDrone';
}
}
});
//Modal dialog initializer
2013-02-16 00:49:25 +00:00
NzbDrone.addInitializer(function () {
2013-02-18 03:37:13 +00:00
NzbDrone.addRegions({ modalRegion: modalRegion });
2013-02-16 00:49:25 +00:00
NzbDrone.vent.on(NzbDrone.Events.OpenModalDialog, function (options) {
2013-02-18 03:37:13 +00:00
console.log('opening modal dialog ' + options.view.template);
2013-02-16 00:49:25 +00:00
NzbDrone.modalRegion.show(options.view);
});
NzbDrone.vent.on(NzbDrone.Events.CloseModalDialog, function () {
console.log('closing modal dialog');
NzbDrone.modalRegion.close();
});
});
2013-02-15 23:38:53 +00:00
return new controller();
});