2020-07-28 22:04:01 +01:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2020-07-31 15:54:47 +01:00
|
|
|
let depends = '';
|
2018-10-23 01:05:09 +03:00
|
|
|
|
2020-07-28 22:04:01 +01:00
|
|
|
switch (index) {
|
|
|
|
case 0:
|
2020-07-31 15:54:47 +01:00
|
|
|
depends = 'controllers/hometab';
|
2020-07-28 22:04:01 +01:00
|
|
|
break;
|
2019-11-06 13:43:39 +03:00
|
|
|
|
2020-07-28 22:04:01 +01:00
|
|
|
case 1:
|
2020-07-31 15:54:47 +01:00
|
|
|
depends = 'controllers/favorites';
|
2020-07-28 22:04:01 +01:00
|
|
|
}
|
2019-11-06 13:43:39 +03:00
|
|
|
|
2020-07-28 22:04:01 +01:00
|
|
|
const instance = this;
|
2020-07-31 15:54:47 +01:00
|
|
|
return import(depends).then(({ default: controllerFactory }) => {
|
2020-07-28 22:04:01 +01:00
|
|
|
let controller = instance.tabControllers[index];
|
2019-11-06 13:43:39 +03:00
|
|
|
|
2020-07-28 22:04:01 +01:00
|
|
|
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
|
|
|
}
|
2019-11-06 13:43:39 +03:00
|
|
|
|
2020-07-28 22:04:01 +01:00
|
|
|
return controller;
|
|
|
|
});
|
|
|
|
}
|
2018-10-23 01:05:09 +03:00
|
|
|
|
2020-07-28 22:04:01 +01:00
|
|
|
class HomeView {
|
|
|
|
constructor(view, params) {
|
2019-11-06 13:43:39 +03:00
|
|
|
TabbedView.call(this, view, params);
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2020-07-28 22:04:01 +01:00
|
|
|
setTitle() {
|
2019-11-06 13:43:39 +03:00
|
|
|
Emby.Page.setTitle(null);
|
2020-07-28 22:04:01 +01:00
|
|
|
}
|
|
|
|
onPause() {
|
2019-11-06 13:43:39 +03:00
|
|
|
TabbedView.prototype.onPause.call(this);
|
2020-05-04 12:44:12 +02:00
|
|
|
document.querySelector('.skinHeader').classList.remove('noHomeButtonHeader');
|
2020-07-28 22:04:01 +01:00
|
|
|
}
|
|
|
|
onResume(options) {
|
2019-11-06 13:43:39 +03:00
|
|
|
TabbedView.prototype.onResume.call(this, options);
|
2020-05-04 12:44:12 +02:00
|
|
|
document.querySelector('.skinHeader').classList.add('noHomeButtonHeader');
|
2020-07-28 22:04:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Object.assign(HomeView.prototype, TabbedView.prototype);
|
|
|
|
HomeView.prototype.getTabs = getTabs;
|
|
|
|
HomeView.prototype.getDefaultTabIndex = getDefaultTabIndex;
|
|
|
|
HomeView.prototype.getTabController = getTabController;
|
2019-11-06 13:43:39 +03:00
|
|
|
|
2020-07-28 22:04:01 +01:00
|
|
|
export default HomeView;
|