2013-04-19 16:57:23 -07:00
|
|
|
|
(function ($, document) {
|
|
|
|
|
|
2015-09-03 09:39:24 -07:00
|
|
|
|
var data = {};
|
|
|
|
|
function getPageData() {
|
|
|
|
|
var key = getSavedQueryKey();
|
|
|
|
|
var pageData = data[key];
|
|
|
|
|
|
|
|
|
|
if (!pageData) {
|
|
|
|
|
pageData = data[key] = {
|
|
|
|
|
query: {
|
|
|
|
|
SortBy: "SortName",
|
|
|
|
|
SortOrder: "Ascending",
|
|
|
|
|
IncludeItemTypes: "Audio,MusicVideo",
|
|
|
|
|
Recursive: true,
|
|
|
|
|
Fields: "DateCreated,SyncInfo,ItemCounts",
|
|
|
|
|
StartIndex: 0,
|
|
|
|
|
Limit: LibraryBrowser.getDefaultPageSize()
|
|
|
|
|
},
|
|
|
|
|
view: LibraryBrowser.getSavedView(key) || LibraryBrowser.getDefaultItemsView('Thumb', 'Thumb')
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
pageData.query.ParentId = LibraryMenu.getTopParentId();
|
|
|
|
|
LibraryBrowser.loadSavedQueryValues(key, pageData.query);
|
|
|
|
|
}
|
|
|
|
|
return pageData;
|
|
|
|
|
}
|
2015-05-17 12:50:37 -07:00
|
|
|
|
|
2015-09-03 09:39:24 -07:00
|
|
|
|
function getQuery() {
|
2013-04-19 16:57:23 -07:00
|
|
|
|
|
2015-09-03 09:39:24 -07:00
|
|
|
|
return getPageData().query;
|
|
|
|
|
}
|
2013-04-19 16:57:23 -07:00
|
|
|
|
|
2014-05-01 19:54:33 -07:00
|
|
|
|
function getSavedQueryKey() {
|
|
|
|
|
|
2015-10-14 21:32:10 -07:00
|
|
|
|
return LibraryBrowser.getSavedQueryKey('genres');
|
2014-05-01 19:54:33 -07:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-19 16:57:23 -07:00
|
|
|
|
function reloadItems(page) {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
2015-09-03 09:39:24 -07:00
|
|
|
|
var query = getQuery();
|
|
|
|
|
|
2015-11-28 01:07:44 -07:00
|
|
|
|
ApiClient.getMusicGenres(Dashboard.getCurrentUserId(), query).then(function (result) {
|
2013-04-19 16:57:23 -07:00
|
|
|
|
|
2013-05-18 10:07: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);
|
2013-05-18 10:07:20 -07:00
|
|
|
|
|
2013-04-19 16:57:23 -07:00
|
|
|
|
var html = '';
|
|
|
|
|
|
2015-09-03 09:39:24 -07:00
|
|
|
|
var view = getPageData().view;
|
|
|
|
|
|
2015-01-22 23:15:15 -07:00
|
|
|
|
$('.listTopPaging', page).html(LibraryBrowser.getQueryPagingHtml({
|
2014-07-19 21:46:29 -07:00
|
|
|
|
startIndex: query.StartIndex,
|
|
|
|
|
limit: query.Limit,
|
|
|
|
|
totalRecordCount: result.TotalRecordCount,
|
2014-08-02 19:16:37 -07:00
|
|
|
|
showLimit: false,
|
2015-09-03 09:39:24 -07:00
|
|
|
|
updatePageSizeSetting: false,
|
|
|
|
|
addLayoutButton: true,
|
|
|
|
|
currentLayout: view
|
|
|
|
|
|
2015-09-05 21:53:37 -07:00
|
|
|
|
}));
|
2013-04-19 16:57:23 -07:00
|
|
|
|
|
2015-05-12 21:55:19 -07:00
|
|
|
|
if (view == "Thumb") {
|
|
|
|
|
html = LibraryBrowser.getPosterViewHtml({
|
|
|
|
|
items: result.Items,
|
|
|
|
|
shape: "backdrop",
|
|
|
|
|
preferThumb: true,
|
|
|
|
|
showItemCounts: true,
|
2015-07-06 09:40:55 -07:00
|
|
|
|
lazy: true,
|
2015-05-12 21:55:19 -07:00
|
|
|
|
centerText: true,
|
2015-07-06 09:40:55 -07:00
|
|
|
|
overlayPlayButton: true
|
2015-05-12 21:55:19 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else if (view == "ThumbCard") {
|
|
|
|
|
|
|
|
|
|
html = LibraryBrowser.getPosterViewHtml({
|
|
|
|
|
items: result.Items,
|
|
|
|
|
shape: "backdrop",
|
|
|
|
|
preferThumb: true,
|
|
|
|
|
showItemCounts: true,
|
|
|
|
|
cardLayout: true,
|
|
|
|
|
lazy: true,
|
|
|
|
|
showTitle: true
|
|
|
|
|
});
|
|
|
|
|
}
|
2015-12-16 14:27:19 -07:00
|
|
|
|
else if (view == "Poster") {
|
|
|
|
|
html = LibraryBrowser.getPosterViewHtml({
|
|
|
|
|
items: result.Items,
|
|
|
|
|
shape: "portrait",
|
|
|
|
|
centerText: true,
|
|
|
|
|
showItemCounts: true,
|
|
|
|
|
lazy: true
|
|
|
|
|
});
|
|
|
|
|
}
|
2013-04-19 16:57:23 -07:00
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
var elem = page.querySelector('#items');
|
|
|
|
|
elem.innerHTML = html;
|
|
|
|
|
ImageLoader.lazyChildren(elem);
|
2013-04-19 16:57:23 -07:00
|
|
|
|
|
|
|
|
|
$('.btnNextPage', page).on('click', function () {
|
|
|
|
|
query.StartIndex += query.Limit;
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.btnPreviousPage', page).on('click', function () {
|
|
|
|
|
query.StartIndex -= query.Limit;
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
2015-09-03 09:39:24 -07:00
|
|
|
|
$('.btnChangeLayout', page).on('layoutchange', function (e, layout) {
|
|
|
|
|
getPageData().view = layout;
|
|
|
|
|
LibraryBrowser.saveViewSetting(getSavedQueryKey(), layout);
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
2014-05-01 19:54:33 -07:00
|
|
|
|
LibraryBrowser.saveQueryValues(getSavedQueryKey(), query);
|
2015-09-03 09:39:24 -07:00
|
|
|
|
|
2013-04-19 16:57:23 -07:00
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-03 09:39:24 -07:00
|
|
|
|
window.MusicPage.renderGenresTab = function (page, tabContent) {
|
2013-04-19 16:57:23 -07:00
|
|
|
|
|
2015-09-03 09:39:24 -07:00
|
|
|
|
if (LibraryBrowser.needsRefresh(tabContent)) {
|
|
|
|
|
reloadItems(tabContent);
|
2013-05-15 12:40:47 -07:00
|
|
|
|
}
|
2015-09-03 09:39:24 -07:00
|
|
|
|
};
|
2013-04-19 16:57:23 -07:00
|
|
|
|
|
|
|
|
|
})(jQuery, document);
|