You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Readarr/UI/Series/Index/SeriesIndexLayout.js

188 lines
6.9 KiB

12 years ago
"use strict";
define([
'app',
'Series/Index/List/CollectionView',
'Series/Index/Posters/CollectionView',
12 years ago
'Series/Index/EmptyView',
'Series/Index/Table/AirDateCell',
12 years ago
'Series/Index/Table/SeriesStatusCell',
'Shared/Toolbar/ToolbarView',
'Shared/Toolbar/ToolbarLayout',
'Config'
12 years ago
],
function () {
12 years ago
NzbDrone.Series.Index.SeriesIndexLayout = Backbone.Marionette.Layout.extend({
template: 'Series/Index/SeriesIndexLayoutTemplate',
regions: {
series : '#x-series',
toolbar: '#x-toolbar'
12 years ago
},
ui: {
},
events: {
'click .x-series-change-view': 'changeView'
},
showTable: function () {
12 years ago
var columns = [
12 years ago
{
12 years ago
name : 'status',
label : '',
editable : false,
cell : 'seriesStatus',
headerCell: 'nzbDrone'
12 years ago
},
{
12 years ago
name : 'title',
label : 'Title',
editable : false,
cell : Backgrid.TemplateBackedCell.extend({ template: 'Series/Index/Table/SeriesTitleTemplate' }),
headerCell: 'nzbDrone'
12 years ago
},
{
12 years ago
name : 'seasonCount',
label : 'Seasons',
editable : false,
cell : 'integer',
headerCell: 'nzbDrone'
12 years ago
},
{
12 years ago
name : 'quality',
label : 'Quality',
editable : false,
cell : 'integer',
headerCell: 'nzbDrone'
12 years ago
},
{
12 years ago
name : 'network',
label : 'Network',
editable : false,
cell : 'string',
headerCell: 'nzbDrone'
12 years ago
},
{
12 years ago
name : 'nextAiring',
label : 'Next Airing',
editable : false,
cell : 'airDate',
headerCell: 'nzbDrone'
12 years ago
},
{
12 years ago
name : 'episodes',
label : 'Episodes',
editable : false,
sortable : false,
cell : Backgrid.TemplateBackedCell.extend({ template: 'Series/EpisodeProgressTemplate' }),
headerCell: 'nzbDrone'
12 years ago
},
{
12 years ago
name : 'edit',
label : '',
editable : false,
sortable : false,
cell : Backgrid.TemplateBackedCell.extend({ template: 'Series/Index/Table/ControlsColumnTemplate' }),
headerCell: 'nzbDrone'
12 years ago
}
];
12 years ago
12 years ago
this.series.show(new Backgrid.Grid(
{
12 years ago
row : Backgrid.SeriesIndexTableRow,
columns : columns,
collection: this.seriesCollection,
className : 'table table-hover'
12 years ago
}));
},
showList: function () {
this.series.show(new NzbDrone.Series.Index.List.CollectionView({ collection: this.seriesCollection }));
},
showPosters: function () {
this.series.show(new NzbDrone.Series.Index.Posters.CollectionView({ collection: this.seriesCollection }));
},
12 years ago
showEmpty: function () {
this.series.show(new NzbDrone.Series.Index.EmptyView());
},
12 years ago
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 () {
var menuLeft = new NzbDrone.Shared.Toolbar.CommandCollection();
menuLeft.add(new NzbDrone.Shared.Toolbar.CommandModel({title: "Add Series", icon: "icon-plus"}));
menuLeft.add(new NzbDrone.Shared.Toolbar.CommandModel({title: "RSS Sync", icon: "icon-rss"}));
menuLeft.add(new NzbDrone.Shared.Toolbar.CommandModel({title: "Sync Database", icon: "icon-refresh"}));
var menuRight = new NzbDrone.Shared.Toolbar.CommandCollection();
menuRight.add(new NzbDrone.Shared.Toolbar.CommandModel({title: "Add Series", icon: "icon-plus"}));
menuRight.add(new NzbDrone.Shared.Toolbar.CommandModel({title: "RSS Sync", icon: "icon-rss"}));
menuRight.add(new NzbDrone.Shared.Toolbar.CommandModel({title: "Sync Database", icon: "icon-refresh"}));
12 years ago
this.toolbar.show(new NzbDrone.Shared.Toolbar.ToolbarLayout({left: [ menuLeft, menuLeft], right: [menuRight]}));
12 years ago
switch (this.viewStyle) {
case 1:
this.showList();
break;
case 2:
this.showPosters();
break;
12 years ago
default:
this.showTable();
}
},
changeView: function (e) {
e.preventDefault();
var view = parseInt($(e.target).data('target'));
var target = $(e.target);
12 years ago
if (isNaN(view)) {
view = parseInt($(e.target).parent('a').data('target'));
target = $(e.target).parent('a');
12 years ago
}
if (view === 1) {
NzbDrone.Config.SeriesViewStyle(1);
this.showList();
}
else if (view === 2) {
NzbDrone.Config.SeriesViewStyle(2);
this.showPosters();
}
12 years ago
else {
NzbDrone.Config.SeriesViewStyle(0);
this.showTable();
}
this.setActive(target);
12 years ago
},
setActive: function (element) {
this.$('a').removeClass('active');
$(element).addClass('active');
}
});
});