2013-04-23 00:35:04 +00:00
|
|
|
"use strict";
|
|
|
|
define([
|
|
|
|
'app',
|
|
|
|
'Series/Index/List/CollectionView',
|
2013-04-24 03:11:45 +00:00
|
|
|
'Series/Index/Posters/CollectionView',
|
2013-04-24 00:30:25 +00:00
|
|
|
'Series/Index/EmptyView',
|
|
|
|
'Config',
|
|
|
|
'Series/Index/Table/AirDateCell',
|
|
|
|
'Series/Index/Table/SeriesStatusCell'
|
2013-04-23 00:35:04 +00:00
|
|
|
],
|
2013-04-23 02:07:21 +00:00
|
|
|
function () {
|
2013-04-23 00:35:04 +00:00
|
|
|
NzbDrone.Series.Index.SeriesIndexLayout = Backbone.Marionette.Layout.extend({
|
|
|
|
template: 'Series/Index/SeriesIndexLayoutTemplate',
|
|
|
|
|
|
|
|
regions: {
|
|
|
|
series: '#x-series'
|
|
|
|
},
|
|
|
|
|
|
|
|
ui: {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
events: {
|
|
|
|
'click .x-series-change-view': 'changeView'
|
|
|
|
},
|
|
|
|
|
|
|
|
showTable: function () {
|
|
|
|
|
|
|
|
var columns =
|
2013-04-23 02:07:21 +00:00
|
|
|
[
|
|
|
|
{
|
|
|
|
name : 'status',
|
|
|
|
label : '',
|
|
|
|
editable: false,
|
|
|
|
cell : 'seriesStatus'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name : 'title',
|
|
|
|
label : 'Title',
|
|
|
|
editable: false,
|
|
|
|
cell : 'string'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name : 'seasonCount',
|
|
|
|
label : 'Seasons',
|
|
|
|
editable: false,
|
|
|
|
cell : 'integer'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name : 'quality',
|
|
|
|
label : 'Quality',
|
|
|
|
editable: false,
|
|
|
|
cell : 'integer'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name : 'network',
|
|
|
|
label : 'Network',
|
|
|
|
editable: false,
|
|
|
|
cell : 'string'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name : 'nextAiring',
|
|
|
|
label : 'Next Airing',
|
|
|
|
editable : false,
|
|
|
|
cell : 'datetime',
|
|
|
|
formatter: new Backgrid.AirDateFormatter()
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name : 'episodes',
|
|
|
|
label : 'Episodes',
|
|
|
|
editable: false,
|
|
|
|
sortable: false,
|
|
|
|
cell : 'string'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name : 'edit',
|
|
|
|
label : '',
|
|
|
|
editable: false,
|
|
|
|
sortable: false,
|
|
|
|
cell : 'string'
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
var grid = new Backgrid.Grid(
|
2013-04-23 00:35:04 +00:00
|
|
|
{
|
|
|
|
name: 'status',
|
|
|
|
label: '',
|
|
|
|
editable: false,
|
2013-04-23 07:11:52 +00:00
|
|
|
cell: 'seriesStatus',
|
|
|
|
headerCell: 'nzbDrone'
|
2013-04-23 00:35:04 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'title',
|
|
|
|
label: 'Title',
|
|
|
|
editable: false,
|
2013-04-23 15:29:05 +00:00
|
|
|
cell: Backgrid.TemplateBackedCell.extend({ template: 'Series/Index/Table/SeriesTitleTemplate' }),
|
2013-04-23 07:11:52 +00:00
|
|
|
headerCell: 'nzbDrone'
|
2013-04-23 00:35:04 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'seasonCount',
|
|
|
|
label: 'Seasons',
|
|
|
|
editable: false,
|
2013-04-23 07:11:52 +00:00
|
|
|
cell: 'integer',
|
|
|
|
headerCell: 'nzbDrone'
|
2013-04-23 00:35:04 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'quality',
|
|
|
|
label: 'Quality',
|
|
|
|
editable: false,
|
2013-04-23 07:11:52 +00:00
|
|
|
cell: 'integer',
|
|
|
|
headerCell: 'nzbDrone'
|
2013-04-23 00:35:04 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'network',
|
|
|
|
label: 'Network',
|
|
|
|
editable: false,
|
2013-04-23 07:11:52 +00:00
|
|
|
cell: 'string',
|
|
|
|
headerCell: 'nzbDrone'
|
2013-04-23 00:35:04 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'nextAiring',
|
|
|
|
label: 'Next Airing',
|
|
|
|
editable: false,
|
2013-04-23 07:11:52 +00:00
|
|
|
cell: 'airDate',
|
|
|
|
headerCell: 'nzbDrone'
|
2013-04-23 00:35:04 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'episodes',
|
|
|
|
label: 'Episodes',
|
|
|
|
editable: false,
|
|
|
|
sortable: false,
|
2013-04-23 15:29:05 +00:00
|
|
|
cell: Backgrid.TemplateBackedCell.extend({ template: 'Series/EpisodeProgressTemplate' }),
|
2013-04-23 07:11:52 +00:00
|
|
|
headerCell: 'nzbDrone'
|
2013-04-23 00:35:04 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'edit',
|
|
|
|
label: '',
|
|
|
|
editable: false,
|
|
|
|
sortable: false,
|
2013-04-23 15:29:05 +00:00
|
|
|
cell: Backgrid.TemplateBackedCell.extend({ template: 'Series/Index/Table/ControlsColumnTemplate' }),
|
2013-04-23 07:11:52 +00:00
|
|
|
headerCell: 'nzbDrone'
|
2013-04-23 00:35:04 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
this.series.show(new Backgrid.Grid(
|
|
|
|
{
|
2013-04-23 06:06:55 +00:00
|
|
|
row: Backgrid.SeriesIndexTableRow,
|
2013-04-23 00:35:04 +00:00
|
|
|
columns : columns,
|
|
|
|
collection : this.seriesCollection,
|
|
|
|
className: 'table table-hover'
|
|
|
|
}));
|
|
|
|
},
|
|
|
|
|
|
|
|
showList: function () {
|
|
|
|
this.series.show(new NzbDrone.Series.Index.List.CollectionView({ collection: this.seriesCollection }));
|
|
|
|
},
|
|
|
|
|
2013-04-24 03:11:45 +00:00
|
|
|
showPosters: function () {
|
|
|
|
this.series.show(new NzbDrone.Series.Index.Posters.CollectionView({ collection: this.seriesCollection }));
|
|
|
|
},
|
|
|
|
|
2013-04-24 00:30:25 +00:00
|
|
|
showEmpty: function () {
|
|
|
|
this.series.show(new NzbDrone.Series.Index.EmptyView());
|
|
|
|
},
|
|
|
|
|
2013-04-23 00:35:04 +00:00
|
|
|
initialize: function () {
|
|
|
|
this.viewStyle = NzbDrone.Config.SeriesViewStyle();
|
|
|
|
this.seriesCollection = new NzbDrone.Series.SeriesCollection();
|
|
|
|
this.seriesCollection.fetch();
|
|
|
|
},
|
|
|
|
|
|
|
|
onRender: function () {
|
|
|
|
var element = this.$('a[data-target="' + this.viewStyle + '"]').removeClass('active');
|
|
|
|
this.setActive(element);
|
|
|
|
},
|
|
|
|
|
|
|
|
onShow: function () {
|
|
|
|
switch (this.viewStyle) {
|
|
|
|
case 1:
|
|
|
|
this.showList();
|
|
|
|
break;
|
2013-04-24 03:11:45 +00:00
|
|
|
case 2:
|
|
|
|
this.showPosters();
|
|
|
|
break;
|
2013-04-23 00:35:04 +00:00
|
|
|
default:
|
|
|
|
this.showTable();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
changeView: function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
var view = parseInt($(e.target).data('target'));
|
2013-04-24 03:34:27 +00:00
|
|
|
var target = $(e.target);
|
2013-04-23 00:35:04 +00:00
|
|
|
|
|
|
|
if (isNaN(view)) {
|
|
|
|
view = parseInt($(e.target).parent('a').data('target'));
|
2013-04-24 03:34:27 +00:00
|
|
|
target = $(e.target).parent('a');
|
2013-04-23 00:35:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (view === 1) {
|
|
|
|
NzbDrone.Config.SeriesViewStyle(1);
|
|
|
|
this.showList();
|
|
|
|
}
|
|
|
|
|
2013-04-24 03:11:45 +00:00
|
|
|
else if (view === 2) {
|
|
|
|
NzbDrone.Config.SeriesViewStyle(2);
|
|
|
|
this.showPosters();
|
|
|
|
}
|
|
|
|
|
2013-04-23 00:35:04 +00:00
|
|
|
else {
|
|
|
|
NzbDrone.Config.SeriesViewStyle(0);
|
|
|
|
this.showTable();
|
|
|
|
}
|
2013-04-24 03:34:27 +00:00
|
|
|
|
|
|
|
this.setActive(target);
|
2013-04-23 00:35:04 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
setActive: function (element) {
|
|
|
|
this.$('a').removeClass('active');
|
|
|
|
$(element).addClass('active');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|