2013-06-22 09:24:24 +03:00
|
|
|
'use strict';
|
2013-06-25 02:41:59 +03:00
|
|
|
define(
|
|
|
|
[
|
|
|
|
'marionette',
|
|
|
|
'Series/Index/Posters/CollectionView',
|
|
|
|
'Series/Index/List/CollectionView',
|
|
|
|
'Series/Index/EmptyView',
|
|
|
|
'Series/SeriesCollection',
|
|
|
|
'Cells/AirDateCell',
|
|
|
|
'Cells/SeriesTitleCell',
|
|
|
|
'Cells/TemplatedCell',
|
|
|
|
'Series/Index/Table/SeriesStatusCell',
|
|
|
|
'Series/Index/Table/Row',
|
|
|
|
'Shared/Toolbar/ToolbarLayout',
|
|
|
|
'Shared/LoadingView'
|
|
|
|
], function (Marionette, PosterCollectionView, ListCollectionView, EmptyView, SeriesCollection, AirDateCell, SeriesTitleCell, TemplatedCell, SeriesStatusCell, SeriesIndexRow,
|
2013-06-29 02:06:16 +03:00
|
|
|
ToolbarLayout, LoadingView) {
|
2013-06-25 02:41:59 +03:00
|
|
|
return Marionette.Layout.extend({
|
2013-04-23 03:35:04 +03:00
|
|
|
template: 'Series/Index/SeriesIndexLayoutTemplate',
|
|
|
|
|
|
|
|
regions: {
|
2013-06-29 02:06:16 +03:00
|
|
|
seriesRegion: '#x-series',
|
|
|
|
toolbar : '#x-toolbar'
|
2013-04-23 03:35:04 +03:00
|
|
|
},
|
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
columns:
|
|
|
|
[
|
|
|
|
{
|
|
|
|
name : 'status',
|
|
|
|
label: '',
|
|
|
|
cell : SeriesStatusCell
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name : 'this',
|
|
|
|
label: 'Title',
|
|
|
|
cell : SeriesTitleCell
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name : 'seasonCount',
|
|
|
|
label: 'Seasons',
|
|
|
|
cell : 'integer'
|
|
|
|
},
|
2013-06-08 10:57:43 +03:00
|
|
|
{
|
2013-06-25 02:41:59 +03:00
|
|
|
name : 'quality',
|
|
|
|
label: 'Quality',
|
|
|
|
cell : 'integer'
|
2013-06-08 10:57:43 +03:00
|
|
|
},
|
|
|
|
{
|
2013-06-25 02:41:59 +03:00
|
|
|
name : 'network',
|
|
|
|
label: 'Network',
|
|
|
|
cell : 'string'
|
2013-06-08 10:57:43 +03:00
|
|
|
},
|
|
|
|
{
|
2013-06-25 02:41:59 +03:00
|
|
|
name : 'nextAiring',
|
|
|
|
label: 'Next Airing',
|
|
|
|
cell : AirDateCell
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name : 'this',
|
|
|
|
label : 'Episodes',
|
|
|
|
sortable: false,
|
|
|
|
template: 'Series/EpisodeProgressTemplate',
|
|
|
|
cell : TemplatedCell
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name : 'this',
|
|
|
|
label : '',
|
|
|
|
sortable: false,
|
|
|
|
template: 'Series/Index/Table/ControlsColumnTemplate',
|
|
|
|
cell : TemplatedCell
|
2013-06-08 10:57:43 +03:00
|
|
|
}
|
2013-06-25 02:41:59 +03:00
|
|
|
],
|
|
|
|
|
|
|
|
leftSideButtons: {
|
|
|
|
type : 'default',
|
|
|
|
storeState: false,
|
|
|
|
items :
|
|
|
|
[
|
|
|
|
{
|
|
|
|
title: 'Add Series',
|
|
|
|
icon : 'icon-plus',
|
2013-06-26 04:00:56 +03:00
|
|
|
route: 'addseries'
|
2013-06-25 02:41:59 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title : 'RSS Sync',
|
|
|
|
icon : 'icon-rss',
|
|
|
|
command : 'rsssync',
|
|
|
|
successMessage: 'RSS Sync Completed',
|
|
|
|
errorMessage : 'RSS Sync Failed!'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title : 'Update Library',
|
|
|
|
icon : 'icon-refresh',
|
|
|
|
command : 'refreshseries',
|
|
|
|
successMessage: 'Library was updated!',
|
|
|
|
errorMessage : 'Library update failed!'
|
|
|
|
}
|
|
|
|
]
|
2013-06-08 10:57:43 +03:00
|
|
|
},
|
|
|
|
|
2013-06-08 11:59:02 +03:00
|
|
|
_showTable: function () {
|
2013-06-29 02:06:16 +03:00
|
|
|
this.currentView = new Backgrid.Grid({
|
2013-06-25 02:41:59 +03:00
|
|
|
row : SeriesIndexRow,
|
2013-06-29 02:06:16 +03:00
|
|
|
collection: SeriesCollection,
|
2013-06-25 02:41:59 +03:00
|
|
|
columns : this.columns,
|
|
|
|
className : 'table table-hover'
|
|
|
|
});
|
2013-04-23 03:35:04 +03:00
|
|
|
|
2013-06-29 02:06:16 +03:00
|
|
|
this._renderView();
|
|
|
|
this._fetchCollection();
|
2013-04-23 03:35:04 +03:00
|
|
|
},
|
|
|
|
|
2013-06-08 11:59:02 +03:00
|
|
|
_showList: function () {
|
2013-06-29 02:06:16 +03:00
|
|
|
this.currentView = new ListCollectionView();
|
|
|
|
this._fetchCollection();
|
2013-04-23 03:35:04 +03:00
|
|
|
},
|
|
|
|
|
2013-06-08 11:59:02 +03:00
|
|
|
_showPosters: function () {
|
2013-06-29 02:06:16 +03:00
|
|
|
this.currentView = new PosterCollectionView();
|
|
|
|
this._fetchCollection();
|
2013-04-24 06:11:45 +03:00
|
|
|
},
|
|
|
|
|
2013-06-29 02:06:16 +03:00
|
|
|
|
|
|
|
initialize: function () {
|
|
|
|
this.seriesCollection = SeriesCollection;
|
|
|
|
|
|
|
|
this.listenTo(SeriesCollection, 'sync', this._renderView);
|
|
|
|
this.listenTo(SeriesCollection, 'remove', this._renderView);
|
2013-04-24 03:30:25 +03:00
|
|
|
},
|
|
|
|
|
2013-06-08 11:59:02 +03:00
|
|
|
|
2013-06-29 02:06:16 +03:00
|
|
|
_renderView: function () {
|
2013-06-08 11:59:02 +03:00
|
|
|
|
2013-06-29 02:06:16 +03:00
|
|
|
if (SeriesCollection.length === 0) {
|
|
|
|
this.seriesRegion.show(new EmptyView());
|
|
|
|
this.toolbar.close();
|
2013-06-08 11:59:02 +03:00
|
|
|
}
|
2013-06-29 02:36:25 +03:00
|
|
|
else {
|
2013-06-29 02:06:16 +03:00
|
|
|
this.currentView.collection = SeriesCollection;
|
|
|
|
this.seriesRegion.show(this.currentView);
|
2013-06-08 11:59:02 +03:00
|
|
|
|
2013-06-29 02:06:16 +03:00
|
|
|
this._showToolbar();
|
2013-06-08 11:59:02 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-04-23 03:35:04 +03:00
|
|
|
|
|
|
|
onShow: function () {
|
2013-06-29 02:36:25 +03:00
|
|
|
this._showToolbar();
|
2013-06-29 02:25:00 +03:00
|
|
|
this._renderView();
|
2013-06-29 02:06:16 +03:00
|
|
|
this._fetchCollection();
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
_fetchCollection: function () {
|
|
|
|
if (SeriesCollection.length === 0) {
|
|
|
|
this.seriesRegion.show(new LoadingView());
|
|
|
|
}
|
|
|
|
|
|
|
|
SeriesCollection.fetch();
|
|
|
|
},
|
|
|
|
|
|
|
|
_showToolbar: function () {
|
|
|
|
|
|
|
|
if (this.toolbar.currentView) {
|
|
|
|
return;
|
|
|
|
}
|
2013-04-24 04:55:29 +03:00
|
|
|
|
2013-04-26 07:45:45 +03:00
|
|
|
var viewButtons = {
|
|
|
|
type : 'radio',
|
2013-06-09 23:51:32 +03:00
|
|
|
storeState : true,
|
|
|
|
menuKey : 'seriesViewMode',
|
|
|
|
defaultAction: 'listView',
|
2013-06-25 02:41:59 +03:00
|
|
|
items :
|
|
|
|
[
|
|
|
|
{
|
2013-07-04 03:57:23 +03:00
|
|
|
key : 'posterView',
|
2013-06-25 02:41:59 +03:00
|
|
|
title : '',
|
2013-07-04 03:57:23 +03:00
|
|
|
icon : 'icon-th-large',
|
|
|
|
callback: this._showPosters
|
2013-06-25 02:41:59 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
key : 'listView',
|
|
|
|
title : '',
|
2013-07-04 03:57:23 +03:00
|
|
|
icon : 'icon-th-list',
|
2013-06-25 02:41:59 +03:00
|
|
|
callback: this._showList
|
|
|
|
},
|
|
|
|
{
|
2013-07-04 03:57:23 +03:00
|
|
|
key : 'tableView',
|
2013-06-25 02:41:59 +03:00
|
|
|
title : '',
|
2013-07-04 03:57:23 +03:00
|
|
|
icon : 'icon-table',
|
|
|
|
callback: this._showTable
|
|
|
|
},
|
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
]
|
2013-04-26 07:45:45 +03:00
|
|
|
};
|
|
|
|
|
2013-06-19 04:02:23 +03:00
|
|
|
this.toolbar.show(new ToolbarLayout({
|
2013-06-25 02:41:59 +03:00
|
|
|
right :
|
|
|
|
[
|
|
|
|
viewButtons
|
|
|
|
],
|
|
|
|
left :
|
|
|
|
[
|
|
|
|
this.leftSideButtons
|
|
|
|
],
|
2013-05-11 23:51:32 +03:00
|
|
|
context: this
|
|
|
|
}));
|
2013-04-23 03:35:04 +03:00
|
|
|
}
|
2013-06-08 10:57:43 +03:00
|
|
|
});
|
|
|
|
});
|