mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
start to rework music tabs
This commit is contained in:
parent
d09b8462c4
commit
387550a5cf
12 changed files with 566 additions and 1555 deletions
|
@ -186,25 +186,129 @@
|
|||
});
|
||||
}
|
||||
|
||||
$(document).on('pagebeforeshow', "#musicRecommendedPage", function () {
|
||||
function loadSuggestionsTab(page, tabContent) {
|
||||
|
||||
var parentId = LibraryMenu.getTopParentId();
|
||||
|
||||
var page = this;
|
||||
|
||||
var containers = page.querySelectorAll('.itemsContainer');
|
||||
var containers = tabContent.querySelectorAll('.itemsContainer');
|
||||
if (enableScrollX()) {
|
||||
$(containers).addClass('hiddenScrollX');
|
||||
} else {
|
||||
$(containers).removeClass('hiddenScrollX');
|
||||
}
|
||||
|
||||
if (LibraryBrowser.needsRefresh(page)) {
|
||||
loadLatest(page, parentId);
|
||||
loadPlaylists(page, parentId);
|
||||
loadRecentlyPlayed(page, parentId);
|
||||
loadFrequentlyPlayed(page, parentId);
|
||||
if (LibraryBrowser.needsRefresh(tabContent)) {
|
||||
console.log('loadSuggestionsTab');
|
||||
loadLatest(tabContent, parentId);
|
||||
loadPlaylists(tabContent, parentId);
|
||||
loadRecentlyPlayed(tabContent, parentId);
|
||||
loadFrequentlyPlayed(tabContent, parentId);
|
||||
}
|
||||
}
|
||||
|
||||
function loadTab(page, index) {
|
||||
|
||||
var tabContent = page.querySelector('.pageTabContent[data-index=\'' + index + '\']');
|
||||
var depends = [];
|
||||
var scope = 'MusicPage';
|
||||
var renderMethod = '';
|
||||
var initMethod = '';
|
||||
|
||||
switch (index) {
|
||||
|
||||
case 0:
|
||||
renderMethod = 'renderSuggestedTab';
|
||||
break;
|
||||
case 1:
|
||||
depends.push('scripts/movies');
|
||||
depends.push('scripts/queryfilters');
|
||||
renderMethod = 'renderMoviesTab';
|
||||
initMethod = 'initMoviesTab';
|
||||
break;
|
||||
case 2:
|
||||
depends.push('scripts/movietrailers');
|
||||
renderMethod = 'renderTrailerTab';
|
||||
initMethod = 'initTrailerTab';
|
||||
break;
|
||||
case 3:
|
||||
depends.push('scripts/moviecollections');
|
||||
renderMethod = 'renderCollectionsTab';
|
||||
initMethod = 'initCollectionsTab';
|
||||
break;
|
||||
case 4:
|
||||
depends.push('scripts/songs');
|
||||
renderMethod = 'renderSongsTab';
|
||||
initMethod = 'initSongsTab';
|
||||
depends.push('scripts/queryfilters');
|
||||
break;
|
||||
case 5:
|
||||
depends.push('scripts/musicgenres');
|
||||
renderMethod = 'renderGenresTab';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
require(depends, function () {
|
||||
|
||||
if (initMethod && !tabContent.initComplete) {
|
||||
|
||||
window[scope][initMethod](page, tabContent);
|
||||
tabContent.initComplete = true;
|
||||
}
|
||||
|
||||
window[scope][renderMethod](page, tabContent);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
window.MusicPage = window.MusicPage || {};
|
||||
window.MusicPage.renderSuggestedTab = loadSuggestionsTab;
|
||||
|
||||
$(document).on('pageinit', "#musicRecommendedPage", function () {
|
||||
|
||||
var page = this;
|
||||
|
||||
$('.recommendations', page).createCardMenus();
|
||||
|
||||
var tabs = page.querySelector('paper-tabs');
|
||||
var pages = page.querySelector('neon-animated-pages');
|
||||
|
||||
var baseUrl = 'musicrecommended.html';
|
||||
var topParentId = LibraryMenu.getTopParentId();
|
||||
if (topParentId) {
|
||||
baseUrl += '?topParentId=' + topParentId;
|
||||
}
|
||||
|
||||
LibraryBrowser.configurePaperLibraryTabs(page, tabs, pages, baseUrl);
|
||||
|
||||
$(pages).on('tabchange', function () {
|
||||
loadTab(page, parseInt(this.selected));
|
||||
});
|
||||
|
||||
}).on('pageshowready', "#musicRecommendedPage", function () {
|
||||
|
||||
var page = this;
|
||||
|
||||
if (!page.getAttribute('data-title')) {
|
||||
|
||||
var parentId = LibraryMenu.getTopParentId();
|
||||
|
||||
if (parentId) {
|
||||
|
||||
ApiClient.getItem(Dashboard.getCurrentUserId(), parentId).done(function (item) {
|
||||
|
||||
page.setAttribute('data-title', item.Name);
|
||||
LibraryMenu.setTitle(item.Name);
|
||||
});
|
||||
|
||||
|
||||
} else {
|
||||
page.setAttribute('data-title', Globalize.translate('TabMusic'));
|
||||
LibraryMenu.setTitle(Globalize.translate('TabMusic'));
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue