2015-07-08 22:52:25 -07:00
|
|
|
|
(function ($, document) {
|
|
|
|
|
|
|
|
|
|
var view = LibraryBrowser.getDefaultItemsView('Poster', 'Poster');
|
|
|
|
|
|
|
|
|
|
var data = {};
|
|
|
|
|
|
|
|
|
|
function getQuery() {
|
|
|
|
|
|
|
|
|
|
var key = getSavedQueryKey();
|
|
|
|
|
var pageData = data[key];
|
|
|
|
|
|
|
|
|
|
if (!pageData) {
|
|
|
|
|
pageData = data[key] = {
|
|
|
|
|
query: {
|
|
|
|
|
SortBy: "SortName",
|
|
|
|
|
SortOrder: "Ascending",
|
|
|
|
|
Recursive: true,
|
|
|
|
|
Fields: "PrimaryImageAspectRatio,SortName,SyncInfo",
|
|
|
|
|
ImageTypeLimit: 1,
|
|
|
|
|
EnableImageTypes: "Primary,Backdrop,Banner,Thumb",
|
|
|
|
|
StartIndex: 0,
|
|
|
|
|
Limit: LibraryBrowser.getDefaultPageSize()
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var type = getParameterByName('type');
|
|
|
|
|
if (type) {
|
|
|
|
|
pageData.query.IncludeItemTypes = type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var filters = getParameterByName('filters');
|
|
|
|
|
if (type) {
|
|
|
|
|
pageData.query.Filters = filters;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-12 12:33:00 -07:00
|
|
|
|
pageData.query.ParentId = getParameterByName('parentid') || LibraryMenu.getTopParentId();
|
2015-07-08 22:52:25 -07:00
|
|
|
|
LibraryBrowser.loadSavedQueryValues(key, pageData.query);
|
|
|
|
|
}
|
|
|
|
|
return pageData.query;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getSavedQueryKey() {
|
|
|
|
|
|
|
|
|
|
return getWindowUrl();
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-12 12:33:00 -07:00
|
|
|
|
function onListItemClick(e) {
|
|
|
|
|
|
|
|
|
|
var page = $(this).parents('.page')[0];
|
|
|
|
|
var info = LibraryBrowser.getListItemInfo(this);
|
|
|
|
|
|
|
|
|
|
if (info.mediaType == 'Photo') {
|
|
|
|
|
var query = getQuery();
|
|
|
|
|
|
|
|
|
|
require(['scripts/photos'], function () {
|
|
|
|
|
Photos.startSlideshow(page, query, info.id);
|
|
|
|
|
});
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-08 22:52:25 -07:00
|
|
|
|
function reloadItems(page) {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
var query = getQuery();
|
|
|
|
|
|
|
|
|
|
ApiClient.getItems(Dashboard.getCurrentUserId(), query).done(function (result) {
|
|
|
|
|
|
|
|
|
|
// Scroll back up so they can see the results from the beginning
|
|
|
|
|
window.scrollTo(0, 0);
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
var pagingHtml = LibraryBrowser.getQueryPagingHtml({
|
|
|
|
|
startIndex: query.StartIndex,
|
|
|
|
|
limit: query.Limit,
|
|
|
|
|
totalRecordCount: result.TotalRecordCount,
|
|
|
|
|
showLimit: false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
page.querySelector('.listTopPaging').innerHTML = pagingHtml;
|
|
|
|
|
|
2015-07-12 12:33:00 -07:00
|
|
|
|
var posterOptions = {
|
|
|
|
|
items: result.Items,
|
|
|
|
|
shape: "auto",
|
|
|
|
|
centerText: true,
|
|
|
|
|
lazy: true,
|
|
|
|
|
overlayText: true
|
|
|
|
|
};
|
2015-07-08 22:52:25 -07:00
|
|
|
|
|
2015-07-12 12:33:00 -07:00
|
|
|
|
if (query.IncludeItemTypes == "MusicAlbum") {
|
|
|
|
|
posterOptions.overlayText = false;
|
|
|
|
|
posterOptions.showParentTitle = true;
|
|
|
|
|
posterOptions.overlayPlayButton = true;
|
2015-07-08 22:52:25 -07:00
|
|
|
|
}
|
2015-07-12 12:33:00 -07:00
|
|
|
|
else if (query.IncludeItemTypes == "MusicArtist") {
|
|
|
|
|
posterOptions.overlayText = false;
|
|
|
|
|
posterOptions.overlayPlayButton = true;
|
2015-07-08 22:52:25 -07:00
|
|
|
|
}
|
2015-07-12 12:33:00 -07:00
|
|
|
|
else if (query.IncludeItemTypes == "Episode") {
|
|
|
|
|
posterOptions.overlayText = false;
|
|
|
|
|
posterOptions.showParentTitle = true;
|
|
|
|
|
posterOptions.overlayPlayButton = true;
|
|
|
|
|
posterOptions.centerText = false;
|
2015-07-08 22:52:25 -07:00
|
|
|
|
}
|
2015-07-09 20:00:03 -07:00
|
|
|
|
|
2015-07-12 12:33:00 -07:00
|
|
|
|
// Poster
|
|
|
|
|
html = LibraryBrowser.getPosterViewHtml(posterOptions);
|
2015-07-08 22:52:25 -07:00
|
|
|
|
|
|
|
|
|
var elem = page.querySelector('#items');
|
|
|
|
|
elem.innerHTML = html + pagingHtml;
|
|
|
|
|
ImageLoader.lazyChildren(elem);
|
|
|
|
|
|
|
|
|
|
$('.btnNextPage', page).on('click', function () {
|
|
|
|
|
query.StartIndex += query.Limit;
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.btnPreviousPage', page).on('click', function () {
|
|
|
|
|
query.StartIndex -= query.Limit;
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
LibraryBrowser.setLastRefreshed(page);
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-12 12:33:00 -07:00
|
|
|
|
$(document).on('pageinitdepends', "#secondaryItemsPage", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
$(page).on('click', '.mediaItem', onListItemClick);
|
|
|
|
|
|
|
|
|
|
}).on('pagebeforeshowready', "#secondaryItemsPage", function () {
|
2015-07-08 22:52:25 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
2015-07-12 12:33:00 -07:00
|
|
|
|
if (getParameterByName('parentid')) {
|
|
|
|
|
ApiClient.getItem(Dashboard.getCurrentUserId(), getParameterByName('parentid')).done(function (parent) {
|
|
|
|
|
LibraryMenu.setTitle(parent.Name);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-08 22:52:25 -07:00
|
|
|
|
if (LibraryBrowser.needsRefresh(page)) {
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})(jQuery, document);
|