diff --git a/dashboard-ui/scripts/favorites.js b/dashboard-ui/scripts/favorites.js
index 0b37dc05d..3f63f7566 100644
--- a/dashboard-ui/scripts/favorites.js
+++ b/dashboard-ui/scripts/favorites.js
@@ -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);
\ No newline at end of file
diff --git a/dashboard-ui/scripts/homenextup.js b/dashboard-ui/scripts/homenextup.js
index 7fa7b2da5..1d3115e2a 100644
--- a/dashboard-ui/scripts/homenextup.js
+++ b/dashboard-ui/scripts/homenextup.js
@@ -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);
\ No newline at end of file
diff --git a/dashboard-ui/scripts/homeupcoming.js b/dashboard-ui/scripts/homeupcoming.js
index d62425e49..d0114b28b 100644
--- a/dashboard-ui/scripts/homeupcoming.js
+++ b/dashboard-ui/scripts/homeupcoming.js
@@ -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);
\ No newline at end of file
diff --git a/dashboard-ui/scripts/indexpage.js b/dashboard-ui/scripts/indexpage.js
index a3baa9a75..1cdb2a90e 100644
--- a/dashboard-ui/scripts/indexpage.js
+++ b/dashboard-ui/scripts/indexpage.js
@@ -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);