1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

split up home page scripts

This commit is contained in:
Luke Pulverenti 2015-08-18 11:35:51 -04:00
parent 42ff117d72
commit ceeb569571
5 changed files with 50 additions and 54 deletions

View file

@ -141,20 +141,10 @@
});
}
$(document).on('pageinitdepends', "#indexPage", function () {
var page = this;
var tabContent = page.querySelector('.homeFavoritesTabContent');
$(page.querySelector('neon-animated-pages')).on('tabchange', function () {
if (parseInt(this.selected) == 2) {
if (LibraryBrowser.needsRefresh(tabContent)) {
loadSections(tabContent, Dashboard.getCurrentUserId());
}
}
});
});
window.HomePage.renderFavorites = function (page, tabContent) {
if (LibraryBrowser.needsRefresh(tabContent)) {
loadSections(tabContent, Dashboard.getCurrentUserId());
}
};
})(jQuery, document);

View file

@ -78,20 +78,10 @@
});
}
$(document).on('pageinitdepends', "#indexPage", function () {
var page = this;
var tabContent = page.querySelector('.homeNextUpTabContent');
$(page.querySelector('neon-animated-pages')).on('tabchange', function () {
if (parseInt(this.selected) == 1) {
if (LibraryBrowser.needsRefresh(tabContent)) {
reload(tabContent);
}
}
});
});
window.HomePage.renderNextUp = function (page, tabContent) {
if (LibraryBrowser.needsRefresh(tabContent)) {
reload(tabContent);
}
};
})(jQuery, document);

View file

@ -120,20 +120,10 @@
ImageLoader.lazyChildren(elem);
}
$(document).on('pageinitdepends', "#indexPage", function () {
var page = this;
$(page.querySelector('neon-animated-pages')).on('tabchange', function () {
if (parseInt(this.selected) == 3) {
var tabContent = page.querySelector('.homeUpcomingTabContent');
if (LibraryBrowser.needsRefresh(tabContent)) {
loadUpcoming(tabContent);
}
}
});
});
window.HomePage.renderUpcoming = function (page, tabContent) {
if (LibraryBrowser.needsRefresh(tabContent)) {
loadUpcoming(tabContent);
}
};
})(jQuery, document);

View file

@ -164,9 +164,7 @@
});
}
function loadHomeTab(page) {
var tabContent = page.querySelector('.homeTabContent');
function loadHomeTab(page, tabContent) {
if (LibraryBrowser.needsRefresh(tabContent)) {
if (window.ApiClient) {
@ -196,14 +194,38 @@
function loadTab(page, index) {
var tabContent = page.querySelector('.pageTabContent[data-index=\'' + index + '\']');
var depends = [];
var scope = 'HomePage';
var method = '';
switch (index) {
case 0:
loadHomeTab(page);
depends.push('scripts/sections');
method = 'renderHomeTab';
break;
case 1:
depends.push('scripts/homenextup');
method = 'renderNextUp';
break;
case 2:
depends.push('scripts/favorites');
method = 'renderFavorites';
break;
case 3:
depends.push('scripts/homeupcoming');
method = 'renderUpcoming';
break;
default:
break;
}
require(depends, function () {
window[scope][method](page, tabContent);
});
}
$(document).on('pageinitdepends', "#indexPage", function () {
@ -248,4 +270,8 @@
});
}
window.HomePage = {
renderHomeTab: loadHomeTab
};
})(jQuery, document);