2016-07-29 23:23:56 -07:00
|
|
|
|
define(['jQuery', 'cardBuilder', 'emby-itemscontainer'], function ($, cardBuilder) {
|
2015-04-19 08:54:20 -07:00
|
|
|
|
|
2016-01-24 12:39:03 -07:00
|
|
|
|
var view = 'Poster';
|
2015-04-19 08:54:20 -07:00
|
|
|
|
|
2015-07-12 12:33:00 -07:00
|
|
|
|
var data = {};
|
2016-04-27 10:52:27 -07:00
|
|
|
|
function getQuery() {
|
2015-07-12 12:33:00 -07:00
|
|
|
|
|
2016-04-27 10:52:27 -07:00
|
|
|
|
var key = getSavedQueryKey();
|
2015-07-12 12:33:00 -07:00
|
|
|
|
var pageData = data[key];
|
|
|
|
|
|
|
|
|
|
if (!pageData) {
|
|
|
|
|
pageData = data[key] = {
|
|
|
|
|
query: {
|
2016-04-27 10:52:27 -07:00
|
|
|
|
SortBy: "IsFolder,SortName",
|
2015-07-12 12:33:00 -07:00
|
|
|
|
SortOrder: "Ascending",
|
2016-08-01 22:55:52 -07:00
|
|
|
|
Fields: "PrimaryImageAspectRatio,SortName",
|
2015-07-12 12:33:00 -07:00
|
|
|
|
ImageTypeLimit: 1,
|
|
|
|
|
EnableImageTypes: "Primary",
|
|
|
|
|
StartIndex: 0,
|
|
|
|
|
Limit: LibraryBrowser.getDefaultPageSize()
|
|
|
|
|
}
|
|
|
|
|
};
|
2016-04-27 10:52:27 -07:00
|
|
|
|
|
|
|
|
|
pageData.query.Recursive = false;
|
|
|
|
|
pageData.query.MediaTypes = null;
|
|
|
|
|
pageData.query.ParentId = getParameterByName('parentId') || LibraryMenu.getTopParentId();
|
|
|
|
|
|
2015-07-12 12:33:00 -07:00
|
|
|
|
LibraryBrowser.loadSavedQueryValues(key, pageData.query);
|
|
|
|
|
}
|
|
|
|
|
return pageData.query;
|
|
|
|
|
}
|
2015-04-19 08:54:20 -07:00
|
|
|
|
|
2016-04-27 10:52:27 -07:00
|
|
|
|
function getSavedQueryKey() {
|
2015-04-19 08:54:20 -07:00
|
|
|
|
|
2016-04-27 10:52:27 -07:00
|
|
|
|
return LibraryBrowser.getSavedQueryKey('v1');
|
2015-04-19 08:54:20 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-27 10:52:27 -07:00
|
|
|
|
function reloadItems(page) {
|
2015-04-19 08:54:20 -07:00
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
2016-04-27 10:52:27 -07:00
|
|
|
|
var query = getQuery();
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.getItems(Dashboard.getCurrentUserId(), query).then(function (result) {
|
2015-04-19 08:54:20 -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);
|
2015-04-19 08:54:20 -07:00
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
var pagingHtml = LibraryBrowser.getQueryPagingHtml({
|
|
|
|
|
startIndex: query.StartIndex,
|
|
|
|
|
limit: query.Limit,
|
|
|
|
|
totalRecordCount: result.TotalRecordCount,
|
|
|
|
|
viewButton: false,
|
|
|
|
|
showLimit: false
|
|
|
|
|
});
|
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
page.querySelector('.listTopPaging').innerHTML = pagingHtml;
|
2015-04-19 08:54:20 -07:00
|
|
|
|
|
2015-05-12 21:55:19 -07:00
|
|
|
|
if (view == "Poster") {
|
|
|
|
|
// Poster
|
2016-07-29 23:23:56 -07:00
|
|
|
|
html = cardBuilder.getCardsHtml({
|
2015-05-12 21:55:19 -07:00
|
|
|
|
items: result.Items,
|
2015-07-12 12:33:00 -07:00
|
|
|
|
shape: "square",
|
2015-05-12 21:55:19 -07:00
|
|
|
|
context: getParameterByName('context') || 'photos',
|
2015-10-25 22:29:32 -07:00
|
|
|
|
overlayText: true,
|
2015-05-12 21:55:19 -07:00
|
|
|
|
lazy: true,
|
2015-07-12 12:33:00 -07:00
|
|
|
|
coverImage: true,
|
2016-04-27 10:52:27 -07:00
|
|
|
|
showTitle: false,
|
2015-08-16 08:53:30 -07:00
|
|
|
|
centerText: true
|
2015-05-12 21:55:19 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
2015-04-19 08:54:20 -07:00
|
|
|
|
|
2015-07-12 12:33:00 -07:00
|
|
|
|
var elem = page.querySelector('.itemsContainer');
|
2015-06-28 07:45:21 -07:00
|
|
|
|
elem.innerHTML = html + pagingHtml;
|
|
|
|
|
ImageLoader.lazyChildren(elem);
|
2015-04-19 08:54:20 -07:00
|
|
|
|
|
|
|
|
|
$('.btnNextPage', page).on('click', function () {
|
|
|
|
|
query.StartIndex += query.Limit;
|
2016-04-27 10:52:27 -07:00
|
|
|
|
reloadItems(page);
|
2015-04-19 08:54:20 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.btnPreviousPage', page).on('click', function () {
|
|
|
|
|
query.StartIndex -= query.Limit;
|
2016-04-27 10:52:27 -07:00
|
|
|
|
reloadItems(page);
|
2015-04-19 08:54:20 -07:00
|
|
|
|
});
|
|
|
|
|
|
2016-04-27 10:52:27 -07:00
|
|
|
|
LibraryBrowser.saveQueryValues(getSavedQueryKey(), query);
|
2015-04-19 08:54:20 -07:00
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-09 21:29:04 -07:00
|
|
|
|
function startSlideshow(page, itemQuery, startItemId) {
|
2015-04-22 06:28:45 -07:00
|
|
|
|
|
|
|
|
|
var userId = Dashboard.getCurrentUserId();
|
|
|
|
|
|
2015-05-09 21:29:04 -07:00
|
|
|
|
var localQuery = $.extend({}, itemQuery);
|
2015-04-22 06:28:45 -07:00
|
|
|
|
localQuery.StartIndex = 0;
|
|
|
|
|
localQuery.Limit = null;
|
|
|
|
|
localQuery.MediaTypes = "Photo";
|
|
|
|
|
localQuery.Recursive = true;
|
|
|
|
|
localQuery.Filters = "IsNotFolder";
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.getItems(userId, localQuery).then(function (result) {
|
2015-04-22 06:28:45 -07:00
|
|
|
|
|
2015-05-09 21:29:04 -07:00
|
|
|
|
showSlideshow(page, result.Items, startItemId);
|
2015-04-22 06:28:45 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-09 21:29:04 -07:00
|
|
|
|
function showSlideshow(page, items, startItemId) {
|
2015-04-22 06:28:45 -07:00
|
|
|
|
|
2015-05-09 21:29:04 -07:00
|
|
|
|
var index = items.map(function (i) {
|
|
|
|
|
return i.Id;
|
|
|
|
|
|
|
|
|
|
}).indexOf(startItemId);
|
|
|
|
|
|
|
|
|
|
if (index == -1) {
|
|
|
|
|
index = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-30 23:03:40 -07:00
|
|
|
|
require(['slideshow'], function (slideshow) {
|
2015-04-22 06:28:45 -07:00
|
|
|
|
|
2016-01-30 23:03:40 -07:00
|
|
|
|
var newSlideShow = new slideshow({
|
|
|
|
|
showTitle: false,
|
|
|
|
|
cover: false,
|
|
|
|
|
items: items,
|
|
|
|
|
startIndex: index,
|
|
|
|
|
interval: 7000,
|
|
|
|
|
interactive: true
|
2015-05-08 20:48:43 -07:00
|
|
|
|
});
|
2016-01-30 23:03:40 -07:00
|
|
|
|
|
|
|
|
|
newSlideShow.show();
|
2015-04-22 06:28:45 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-09 21:29:04 -07:00
|
|
|
|
function onListItemClick(e) {
|
|
|
|
|
|
2015-07-12 12:33:00 -07:00
|
|
|
|
var page = $(this).parents('.page')[0];
|
2015-05-09 21:29:04 -07:00
|
|
|
|
var info = LibraryBrowser.getListItemInfo(this);
|
|
|
|
|
|
|
|
|
|
if (info.mediaType == 'Photo') {
|
2016-04-27 10:52:27 -07:00
|
|
|
|
var query = getQuery();
|
2015-07-12 12:33:00 -07:00
|
|
|
|
|
2015-05-09 21:29:04 -07:00
|
|
|
|
Photos.startSlideshow(page, query, info.id);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
pageIdOn('pageinit', "photosPage", function () {
|
2015-04-19 08:54:20 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
2016-04-27 10:52:27 -07:00
|
|
|
|
reloadItems(page, 0);
|
2015-04-19 08:54:20 -07:00
|
|
|
|
|
2015-07-12 12:33:00 -07:00
|
|
|
|
$(page).on('click', '.mediaItem', onListItemClick);
|
2015-04-19 08:54:20 -07:00
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2015-05-09 21:29:04 -07:00
|
|
|
|
window.Photos = {
|
|
|
|
|
startSlideshow: startSlideshow
|
|
|
|
|
};
|
|
|
|
|
|
2016-03-18 21:26:17 -07:00
|
|
|
|
});
|