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

Fix type and applysuggestions to home.js

This commit is contained in:
Cameron 2020-07-31 17:06:04 +01:00
parent 39627f364a
commit 38d25172d5
5 changed files with 52 additions and 54 deletions

View file

@ -4,67 +4,65 @@ import 'emby-tabs';
import 'emby-button';
import 'emby-scroller';
function getTabs() {
return [{
name: globalize.translate('Home')
}, {
name: globalize.translate('Favorites')
}];
}
function getDefaultTabIndex() {
return 0;
}
function getTabController(index) {
if (null == index) {
throw new Error('index cannot be null');
}
let depends = '';
switch (index) {
case 0:
depends = 'controllers/hometab';
break;
case 1:
depends = 'controllers/favorites';
}
const instance = this;
return import(depends).then(({ default: controllerFactory }) => {
let controller = instance.tabControllers[index];
if (!controller) {
controller = new controllerFactory(instance.view.querySelector(".tabContent[data-index='" + index + "']"), instance.params);
instance.tabControllers[index] = controller;
}
return controller;
});
}
class HomeView {
class HomeView extends TabbedView {
constructor(view, params) {
TabbedView.call(this, view, params);
super(view, params);
}
setTitle() {
Emby.Page.setTitle(null);
}
onPause() {
TabbedView.prototype.onPause.call(this);
super.onPause(this);
document.querySelector('.skinHeader').classList.remove('noHomeButtonHeader');
}
onResume(options) {
TabbedView.prototype.onResume.call(this, options);
super.onResume(this, options);
document.querySelector('.skinHeader').classList.add('noHomeButtonHeader');
}
getDefaultTabIndex() {
return 0;
}
getTabs() {
return [{
name: globalize.translate('Home')
}, {
name: globalize.translate('Favorites')
}];
}
getTabController(index) {
if (null == index) {
throw new Error('index cannot be null');
}
let depends = '';
switch (index) {
case 0:
depends = 'controllers/hometab';
break;
case 1:
depends = 'controllers/favorites';
}
const instance = this;
return import(depends).then(({ default: controllerFactory }) => {
let controller = instance.tabControllers[index];
if (!controller) {
controller = new controllerFactory(instance.view.querySelector(".tabContent[data-index='" + index + "']"), instance.params);
instance.tabControllers[index] = controller;
}
return controller;
});
}
}
Object.assign(HomeView.prototype, TabbedView.prototype);
HomeView.prototype.getTabs = getTabs;
HomeView.prototype.getDefaultTabIndex = getDefaultTabIndex;
HomeView.prototype.getTabController = getTabController;
export default HomeView;