2013-02-23 18:42:15 +01:00
|
|
|
|
define(['app', 'Shared/ModalRegion', 'AddSeries/AddSeriesLayout', 'Series/SeriesCollectionView',
|
|
|
|
|
'Upcoming/UpcomingCollectionView', 'Calendar/CalendarCollectionView', 'Shared/NotificationView',
|
2013-02-27 04:31:35 +01:00
|
|
|
|
'Shared/NotFoundView', 'MainMenuView'], function (app, modalRegion) {
|
2013-02-16 00:38:53 +01:00
|
|
|
|
|
2013-02-18 04:37:13 +01:00
|
|
|
|
var controller = Backbone.Marionette.Controller.extend({
|
2013-02-16 00:38:53 +01:00
|
|
|
|
|
|
|
|
|
addSeries: function (action, query) {
|
|
|
|
|
this.setTitle('Add Series');
|
2013-02-18 04:37:13 +01:00
|
|
|
|
NzbDrone.mainRegion.show(new NzbDrone.AddSeries.AddSeriesLayout(this, action, query));
|
2013-02-16 00:38:53 +01:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
series: function (action, query) {
|
|
|
|
|
this.setTitle('NzbDrone');
|
2013-02-28 05:48:31 +01:00
|
|
|
|
NzbDrone.mainRegion.show(new NzbDrone.Series.SeriesCollectionView());
|
2013-02-16 00:38:53 +01:00
|
|
|
|
},
|
|
|
|
|
|
2013-02-20 08:45:52 +01:00
|
|
|
|
upcoming: function (action, query) {
|
|
|
|
|
this.setTitle('Upcoming');
|
|
|
|
|
NzbDrone.mainRegion.show(new NzbDrone.Upcoming.UpcomingCollectionView(this, action, query));
|
|
|
|
|
},
|
2013-02-23 18:42:15 +01:00
|
|
|
|
|
|
|
|
|
calendar: function (action, query) {
|
|
|
|
|
this.setTitle('Calendar');
|
2013-02-25 01:00:17 +01:00
|
|
|
|
var calendarCollection = new NzbDrone.Calendar.CalendarCollection();
|
|
|
|
|
calendarCollection.fetch();
|
2013-02-28 05:48:31 +01:00
|
|
|
|
NzbDrone.mainRegion.show(new NzbDrone.Calendar.CalendarCollectionView(this, action, query, calendarCollection));
|
2013-02-23 18:42:15 +01:00
|
|
|
|
},
|
2013-02-20 08:45:52 +01:00
|
|
|
|
|
2013-02-16 00:38:53 +01:00
|
|
|
|
notFound: function () {
|
|
|
|
|
this.setTitle('Not Found');
|
2013-02-18 04:37:13 +01:00
|
|
|
|
NzbDrone.mainRegion.show(new NzbDrone.Shared.NotFoundView(this));
|
2013-02-16 00:38:53 +01:00
|
|
|
|
},
|
|
|
|
|
|
2013-02-18 04:37:13 +01:00
|
|
|
|
setTitle: function (title) {
|
2013-02-16 00:38:53 +01:00
|
|
|
|
$('#title-region').html(title);
|
|
|
|
|
|
2013-02-18 04:37:13 +01:00
|
|
|
|
if (title.toLocaleLowerCase() === 'nzbdrone') {
|
2013-02-16 00:38:53 +01:00
|
|
|
|
window.document.title = 'NzbDrone';
|
|
|
|
|
}
|
2013-02-18 04:37:13 +01:00
|
|
|
|
else {
|
2013-02-16 00:38:53 +01:00
|
|
|
|
window.document.title = title + ' - NzbDrone';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2013-02-27 04:31:35 +01:00
|
|
|
|
//Modal dialog initializer
|
2013-02-16 01:49:25 +01:00
|
|
|
|
NzbDrone.addInitializer(function () {
|
|
|
|
|
|
2013-02-18 04:37:13 +01:00
|
|
|
|
NzbDrone.addRegions({ modalRegion: modalRegion });
|
2013-02-16 01:49:25 +01:00
|
|
|
|
|
|
|
|
|
NzbDrone.vent.on(NzbDrone.Events.OpenModalDialog, function (options) {
|
2013-02-18 04:37:13 +01:00
|
|
|
|
console.log('opening modal dialog ' + options.view.template);
|
2013-02-16 01:49:25 +01:00
|
|
|
|
NzbDrone.modalRegion.show(options.view);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
NzbDrone.vent.on(NzbDrone.Events.CloseModalDialog, function () {
|
|
|
|
|
console.log('closing modal dialog');
|
|
|
|
|
NzbDrone.modalRegion.close();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
2013-02-27 04:31:35 +01:00
|
|
|
|
|
2013-02-16 00:38:53 +01:00
|
|
|
|
return new controller();
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|