2013-09-13 13:45:27 -07:00
|
|
|
|
(function ($, document) {
|
|
|
|
|
|
2015-09-21 10:46:02 -07:00
|
|
|
|
var data = {};
|
|
|
|
|
|
|
|
|
|
function getPageData() {
|
|
|
|
|
var key = getSavedQueryKey();
|
|
|
|
|
var pageData = data[key];
|
|
|
|
|
|
|
|
|
|
if (!pageData) {
|
|
|
|
|
pageData = data[key] = {
|
|
|
|
|
query: {
|
|
|
|
|
SortBy: "SeriesSortName,SortName",
|
|
|
|
|
SortOrder: "Ascending",
|
|
|
|
|
IncludeItemTypes: "Episode",
|
|
|
|
|
Recursive: true,
|
|
|
|
|
Fields: "PrimaryImageAspectRatio,MediaSourceCount,UserData,SyncInfo",
|
|
|
|
|
IsMissing: false,
|
|
|
|
|
IsVirtualUnaired: false,
|
|
|
|
|
ImageTypeLimit: 1,
|
|
|
|
|
EnableImageTypes: "Primary,Backdrop,Banner,Thumb",
|
|
|
|
|
StartIndex: 0,
|
|
|
|
|
Limit: LibraryBrowser.getDefaultPageSize()
|
|
|
|
|
},
|
|
|
|
|
view: LibraryBrowser.getSavedView(key) || LibraryBrowser.getDefaultItemsView('Poster', 'Poster')
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
pageData.query.ParentId = LibraryMenu.getTopParentId();
|
|
|
|
|
LibraryBrowser.loadSavedQueryValues(key, pageData.query);
|
|
|
|
|
}
|
|
|
|
|
return pageData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getQuery() {
|
|
|
|
|
|
|
|
|
|
return getPageData().query;
|
|
|
|
|
}
|
2013-10-16 16:35:11 -07:00
|
|
|
|
|
2014-05-01 19:54:33 -07:00
|
|
|
|
function getSavedQueryKey() {
|
|
|
|
|
|
2015-10-14 21:32:10 -07:00
|
|
|
|
return LibraryBrowser.getSavedQueryKey('episodes');
|
2014-05-01 19:54:33 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-15 09:42:57 -07:00
|
|
|
|
function reloadItems(page) {
|
2013-09-13 13:45:27 -07:00
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
2015-09-21 10:46:02 -07:00
|
|
|
|
var query = getQuery();
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.getItems(Dashboard.getCurrentUserId(), query).then(function (result) {
|
2013-09-13 13:45:27 -07:00
|
|
|
|
|
|
|
|
|
// Scroll back up so they can see the results from the beginning
|
2015-06-28 07:45:21 -07:00
|
|
|
|
window.scrollTo(0, 0);
|
2013-09-13 13:45:27 -07:00
|
|
|
|
|
2015-09-21 10:46:02 -07:00
|
|
|
|
var view = getPageData().view;
|
|
|
|
|
|
2013-09-13 13:45:27 -07:00
|
|
|
|
var html = '';
|
2015-01-28 12:30:45 -07:00
|
|
|
|
var pagingHtml = LibraryBrowser.getQueryPagingHtml({
|
2014-07-19 21:46:29 -07:00
|
|
|
|
startIndex: query.StartIndex,
|
|
|
|
|
limit: query.Limit,
|
|
|
|
|
totalRecordCount: result.TotalRecordCount,
|
|
|
|
|
showLimit: false,
|
2015-09-21 10:46:02 -07:00
|
|
|
|
updatePageSizeSetting: false,
|
|
|
|
|
addLayoutButton: true,
|
|
|
|
|
sortButton: true,
|
|
|
|
|
currentLayout: view,
|
2016-02-15 09:42:57 -07:00
|
|
|
|
layouts: 'Poster,PosterCard',
|
|
|
|
|
filterButton: true
|
2015-01-28 12:30:45 -07:00
|
|
|
|
});
|
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
page.querySelector('.listTopPaging').innerHTML = pagingHtml;
|
2013-09-13 13:45:27 -07:00
|
|
|
|
|
2016-02-15 09:42:57 -07:00
|
|
|
|
updateFilterControls(page);
|
2013-10-18 09:09:47 -07:00
|
|
|
|
|
2014-07-05 12:57:18 -07:00
|
|
|
|
if (view == "List") {
|
|
|
|
|
|
|
|
|
|
html = LibraryBrowser.getListViewHtml({
|
|
|
|
|
items: result.Items,
|
|
|
|
|
sortBy: query.SortBy
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else if (view == "Poster") {
|
|
|
|
|
html += LibraryBrowser.getPosterViewHtml({
|
|
|
|
|
items: result.Items,
|
|
|
|
|
shape: "backdrop",
|
|
|
|
|
showTitle: true,
|
|
|
|
|
showParentTitle: true,
|
2014-08-01 19:34:45 -07:00
|
|
|
|
overlayText: true,
|
2014-07-10 21:27:46 -07:00
|
|
|
|
lazy: true,
|
2016-02-12 13:26:03 -07:00
|
|
|
|
showDetailsMenu: true,
|
|
|
|
|
overlayPlayButton: true
|
2014-07-05 12:57:18 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
2014-11-10 20:41:19 -07:00
|
|
|
|
else if (view == "PosterCard") {
|
|
|
|
|
html += LibraryBrowser.getPosterViewHtml({
|
|
|
|
|
items: result.Items,
|
|
|
|
|
shape: "backdrop",
|
|
|
|
|
showTitle: true,
|
|
|
|
|
showParentTitle: true,
|
|
|
|
|
lazy: true,
|
2015-05-14 19:16:57 -07:00
|
|
|
|
cardLayout: true,
|
|
|
|
|
showDetailsMenu: true
|
2014-11-10 20:41:19 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
2013-12-21 11:37:34 -07:00
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
var elem = page.querySelector('.itemsContainer');
|
|
|
|
|
elem.innerHTML = html + pagingHtml;
|
|
|
|
|
ImageLoader.lazyChildren(elem);
|
2013-09-13 13:45:27 -07:00
|
|
|
|
|
|
|
|
|
$('.btnNextPage', page).on('click', function () {
|
|
|
|
|
query.StartIndex += query.Limit;
|
2016-02-15 09:42:57 -07:00
|
|
|
|
reloadItems(page);
|
2013-09-13 13:45:27 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.btnPreviousPage', page).on('click', function () {
|
|
|
|
|
query.StartIndex -= query.Limit;
|
2016-02-15 09:42:57 -07:00
|
|
|
|
reloadItems(page);
|
2015-09-21 10:46:02 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.btnChangeLayout', page).on('layoutchange', function (e, layout) {
|
|
|
|
|
getPageData().view = layout;
|
|
|
|
|
LibraryBrowser.saveViewSetting(getSavedQueryKey(), layout);
|
2016-02-15 09:42:57 -07:00
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.btnFilter', page).on('click', function () {
|
|
|
|
|
showFilterMenu(page);
|
2015-09-21 10:46:02 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// On callback make sure to set StartIndex = 0
|
|
|
|
|
$('.btnSort', page).on('click', function () {
|
|
|
|
|
LibraryBrowser.showSortMenu({
|
|
|
|
|
items: [{
|
|
|
|
|
name: Globalize.translate('OptionNameSort'),
|
|
|
|
|
id: 'SeriesSortName,SortName'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: Globalize.translate('OptionTvdbRating'),
|
|
|
|
|
id: 'CommunityRating,SeriesSortName,SortName'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: Globalize.translate('OptionDateAdded'),
|
|
|
|
|
id: 'DateCreated,SeriesSortName,SortName'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: Globalize.translate('OptionPremiereDate'),
|
|
|
|
|
id: 'PremiereDate,SeriesSortName,SortName'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: Globalize.translate('OptionDatePlayed'),
|
|
|
|
|
id: 'DatePlayed,SeriesSortName,SortName'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: Globalize.translate('OptionParentalRating'),
|
|
|
|
|
id: 'OfficialRating,SeriesSortName,SortName'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: Globalize.translate('OptionPlayCount'),
|
|
|
|
|
id: 'PlayCount,SeriesSortName,SortName'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: Globalize.translate('OptionRuntime'),
|
|
|
|
|
id: 'Runtime,SeriesSortName,SortName'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: Globalize.translate('OptionVideoBitrate'),
|
|
|
|
|
id: 'VideoBitRate,SeriesSortName,SortName'
|
|
|
|
|
}],
|
|
|
|
|
callback: function () {
|
2016-02-15 09:42:57 -07:00
|
|
|
|
reloadItems(page);
|
2015-09-21 10:46:02 -07:00
|
|
|
|
},
|
|
|
|
|
query: query
|
|
|
|
|
});
|
2013-09-13 13:45:27 -07:00
|
|
|
|
});
|
|
|
|
|
|
2014-05-01 19:54:33 -07:00
|
|
|
|
LibraryBrowser.saveQueryValues(getSavedQueryKey(), query);
|
2013-09-13 13:45:27 -07:00
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-15 09:42:57 -07:00
|
|
|
|
function showFilterMenu(page) {
|
2013-10-18 09:09:47 -07:00
|
|
|
|
|
2016-02-15 09:42:57 -07:00
|
|
|
|
require(['components/filterdialog/filterdialog'], function (filterDialogFactory) {
|
2013-10-18 09:09:47 -07:00
|
|
|
|
|
2016-02-15 09:42:57 -07:00
|
|
|
|
var filterDialog = new filterDialogFactory({
|
|
|
|
|
query: getQuery(),
|
|
|
|
|
mode: 'episodes'
|
|
|
|
|
});
|
2013-10-18 09:09:47 -07:00
|
|
|
|
|
2016-02-15 09:42:57 -07:00
|
|
|
|
Events.on(filterDialog, 'filterchange', function () {
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
2013-10-18 09:09:47 -07:00
|
|
|
|
|
2016-02-15 09:42:57 -07:00
|
|
|
|
filterDialog.show();
|
2015-09-11 09:26:06 -07:00
|
|
|
|
});
|
2016-02-15 09:42:57 -07:00
|
|
|
|
}
|
2013-10-18 09:09:47 -07:00
|
|
|
|
|
2016-02-15 09:42:57 -07:00
|
|
|
|
function updateFilterControls(tabContent) {
|
2013-10-18 09:09:47 -07:00
|
|
|
|
|
2016-02-15 09:42:57 -07:00
|
|
|
|
var query = getQuery();
|
2013-10-18 09:09:47 -07:00
|
|
|
|
|
2015-09-21 10:46:02 -07:00
|
|
|
|
$('.alphabetPicker', tabContent).alphaValue(query.NameStartsWithOrGreater);
|
2013-10-18 09:09:47 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-15 09:42:57 -07:00
|
|
|
|
function initPage(tabContent) {
|
2013-10-16 16:35:11 -07:00
|
|
|
|
|
2015-09-21 10:46:02 -07:00
|
|
|
|
$('.alphabetPicker', tabContent).on('alphaselect', function (e, character) {
|
2013-09-13 13:45:27 -07:00
|
|
|
|
|
2015-09-21 10:46:02 -07:00
|
|
|
|
var query = getQuery();
|
2013-09-13 13:45:27 -07:00
|
|
|
|
query.NameStartsWithOrGreater = character;
|
|
|
|
|
query.StartIndex = 0;
|
|
|
|
|
|
2016-02-15 09:42:57 -07:00
|
|
|
|
reloadItems(tabContent);
|
2013-09-13 13:45:27 -07:00
|
|
|
|
|
|
|
|
|
}).on('alphaclear', function (e) {
|
|
|
|
|
|
2015-09-21 10:46:02 -07:00
|
|
|
|
var query = getQuery();
|
2013-09-13 13:45:27 -07:00
|
|
|
|
query.NameStartsWithOrGreater = '';
|
|
|
|
|
|
2016-02-15 09:42:57 -07:00
|
|
|
|
reloadItems(tabContent);
|
2013-09-13 13:45:27 -07:00
|
|
|
|
});
|
|
|
|
|
|
2015-09-21 10:46:02 -07:00
|
|
|
|
$('.itemsContainer', tabContent).on('needsrefresh', function () {
|
2014-03-19 10:44:55 -07:00
|
|
|
|
|
2016-02-15 09:42:57 -07:00
|
|
|
|
reloadItems(tabContent);
|
2014-03-19 10:44:55 -07:00
|
|
|
|
});
|
2015-09-21 10:46:02 -07:00
|
|
|
|
}
|
2014-03-19 10:44:55 -07:00
|
|
|
|
|
2015-09-21 10:46:02 -07:00
|
|
|
|
window.TvPage.initEpisodesTab = function (page, tabContent) {
|
2013-10-17 11:24:27 -07:00
|
|
|
|
|
2016-02-15 09:42:57 -07:00
|
|
|
|
initPage(tabContent);
|
2015-09-21 10:46:02 -07:00
|
|
|
|
};
|
2013-10-17 11:24:27 -07:00
|
|
|
|
|
2015-09-21 10:46:02 -07:00
|
|
|
|
window.TvPage.renderEpisodesTab = function (page, tabContent) {
|
2013-10-17 11:24:27 -07:00
|
|
|
|
|
2015-09-21 10:46:02 -07:00
|
|
|
|
if (LibraryBrowser.needsRefresh(tabContent)) {
|
2016-02-15 09:42:57 -07:00
|
|
|
|
reloadItems(tabContent);
|
|
|
|
|
updateFilterControls(tabContent);
|
2013-10-17 11:24:27 -07:00
|
|
|
|
}
|
2015-09-21 10:46:02 -07:00
|
|
|
|
};
|
2013-09-13 13:45:27 -07:00
|
|
|
|
|
|
|
|
|
})(jQuery, document);
|