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

71 lines
1.8 KiB
JavaScript
Raw Normal View History

import TabbedView from 'tabbedView';
import globalize from 'globalize';
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');
2018-10-23 01:05:09 +03:00
}
let depends = '';
2018-10-23 01:05:09 +03:00
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;
2018-10-23 01:05:09 +03:00
}
return controller;
});
}
2018-10-23 01:05:09 +03:00
class HomeView {
constructor(view, params) {
TabbedView.call(this, view, params);
2018-10-23 01:05:09 +03:00
}
setTitle() {
Emby.Page.setTitle(null);
}
onPause() {
TabbedView.prototype.onPause.call(this);
2020-05-04 12:44:12 +02:00
document.querySelector('.skinHeader').classList.remove('noHomeButtonHeader');
}
onResume(options) {
TabbedView.prototype.onResume.call(this, options);
2020-05-04 12:44:12 +02:00
document.querySelector('.skinHeader').classList.add('noHomeButtonHeader');
}
}
Object.assign(HomeView.prototype, TabbedView.prototype);
HomeView.prototype.getTabs = getTabs;
HomeView.prototype.getDefaultTabIndex = getDefaultTabIndex;
HomeView.prototype.getTabController = getTabController;
export default HomeView;