added music folders view

This commit is contained in:
Luke Pulverenti 2015-11-15 21:33:32 -05:00
parent 6afa97f6b8
commit 8d07bdcc53
6 changed files with 143 additions and 4 deletions

View File

@ -662,6 +662,12 @@
self.endSession = function () {
var session = currentWebAppSession;
if (session) {
session.close();
}
if (currentDevice) {
currentDevice.disconnect();
}

View File

@ -67,6 +67,13 @@
function validateProduct(product, callback) {
var productId = product.id;
// We should never get in here with the unlock, but in case we do
if ((productId || '').toLowerCase().indexOf('appunlock') != -1) {
callback(true, product);
return;
}
var cacheKey = productId + (product.transaction.id || '');
var cachedResult = validationCache[cacheKey];

View File

@ -13,6 +13,7 @@
<paper-tab>${TabArtists}</paper-tab>
<paper-tab>${TabSongs}</paper-tab>
<paper-tab>${TabGenres}</paper-tab>
<paper-tab>${TabFolders}</paper-tab>
</paper-tabs>
<div class="legacyTabs scopedLibraryViewNav">
<a href="music.html">${TabSuggestions}</a>
@ -21,6 +22,7 @@
<a href="music.html?tab=3">${TabArtists}</a>
<a href="music.html?tab=4">${TabSongs}</a>
<a href="music.html?tab=5">${TabGenres}</a>
<a href="music.html?tab=6">${TabFolders}</a>
</div>
</div>
@ -111,6 +113,15 @@
<div id="items" class="itemsContainer paddedItemsContainer"></div>
</div>
</neon-animatable>
<neon-animatable>
<div class="pageTabContent" data-index="6">
<div class="viewSettings">
<div class="listTopPaging">
</div>
</div>
<div id="items" class="itemsContainer paddedItemsContainer"></div>
</div>
</neon-animatable>
</neon-animated-pages>
</div>

View File

@ -108,7 +108,7 @@
} else if ($.browser.ipad || $.browser.iphone || $.browser.android) {
cacheDuration = 10000;
} else {
cacheDuration = 60000;
cacheDuration = 30000;
}
if ((now - last) < cacheDuration) {
@ -221,7 +221,7 @@
return !LibraryBrowser.enableFullPaperTabs();
},
configurePaperLibraryTabs: function (ownerpage, tabs, pages, baseUrl) {
configurePaperLibraryTabs: function (ownerpage, tabs, pages) {
// Causing iron-select to not fire in IE and safari
if ($.browser.chrome) {

View File

@ -0,0 +1,110 @@
(function ($, document) {
var data = {};
function getPageData() {
var key = getSavedQueryKey();
var pageData = data[key];
if (!pageData) {
pageData = data[key] = {
query: {
SortBy: "SortName",
SortOrder: "Ascending",
Fields: "PrimaryImageAspectRatio,SortName,SyncInfo",
StartIndex: 0,
ImageTypeLimit: 1,
EnableImageTypes: "Primary,Backdrop,Banner,Thumb",
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;
}
function getSavedQueryKey() {
return LibraryBrowser.getSavedQueryKey('folders');
}
function reloadItems(page, viewPanel) {
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 view = getPageData().view;
var pagingHtml = LibraryBrowser.getQueryPagingHtml({
startIndex: query.StartIndex,
limit: query.Limit,
totalRecordCount: result.TotalRecordCount,
viewButton: false,
showLimit: false,
sortButton: false,
addLayoutButton: false,
currentLayout: view,
updatePageSizeSetting: false,
viewIcon: 'filter-list',
layouts: 'List,Poster,PosterCard,Timeline'
});
page.querySelector('.listTopPaging').innerHTML = pagingHtml;
if (view == "Poster") {
html = LibraryBrowser.getPosterViewHtml({
items: result.Items,
shape: "square",
context: 'music',
showTitle: true,
showParentTitle: true,
lazy: true,
centerText: true,
overlayPlayButton: true
});
}
var elem = page.querySelector('#items');
elem.innerHTML = html + pagingHtml;
ImageLoader.lazyChildren(elem);
$('.btnNextPage', page).on('click', function () {
query.StartIndex += query.Limit;
reloadItems(page, viewPanel);
});
$('.btnPreviousPage', page).on('click', function () {
query.StartIndex -= query.Limit;
reloadItems(page, viewPanel);
});
LibraryBrowser.saveQueryValues(getSavedQueryKey(), query);
LibraryBrowser.setLastRefreshed(page);
Dashboard.hideLoadingMsg();
});
}
window.MusicPage.initFoldersTab = function (page, tabContent) {
};
window.MusicPage.renderFoldersTab = function (page, tabContent) {
if (LibraryBrowser.needsRefresh(tabContent)) {
reloadItems(tabContent);
}
};
})(jQuery, document);

View File

@ -209,7 +209,7 @@
loadRecentlyPlayed(tabContent, parentId);
loadFrequentlyPlayed(tabContent, parentId);
require(['scripts/favorites'], function() {
require(['scripts/favorites'], function () {
FavoriteItems.render(tabContent, Dashboard.getCurrentUserId(), parentId, ['favoriteArtists', 'favoriteAlbums', 'favoriteSongs']);
@ -259,6 +259,11 @@
depends.push('scripts/musicgenres');
renderMethod = 'renderGenresTab';
break;
case 6:
depends.push('scripts/musicfolders');
renderMethod = 'renderFoldersTab';
initMethod = 'initFoldersTab';
break;
default:
break;
}