2020-08-14 08:46:34 +02:00
|
|
|
import TabbedView from '../components/tabbedview/tabbedview';
|
|
|
|
import globalize from '../scripts/globalize';
|
|
|
|
import '../elements/emby-tabs/emby-tabs';
|
|
|
|
import '../elements/emby-button/emby-button';
|
|
|
|
import '../elements/emby-scroller/emby-scroller';
|
2020-07-28 22:04:01 +01:00
|
|
|
|
2020-07-31 17:06:04 +01:00
|
|
|
class HomeView extends TabbedView {
|
|
|
|
constructor(view, params) {
|
|
|
|
super(view, params);
|
|
|
|
}
|
2020-07-28 22:04:01 +01:00
|
|
|
|
2020-07-31 17:06:04 +01:00
|
|
|
setTitle() {
|
|
|
|
Emby.Page.setTitle(null);
|
|
|
|
}
|
2020-07-28 22:04:01 +01:00
|
|
|
|
2020-07-31 17:06:04 +01:00
|
|
|
onPause() {
|
|
|
|
super.onPause(this);
|
|
|
|
document.querySelector('.skinHeader').classList.remove('noHomeButtonHeader');
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
2020-07-31 17:06:04 +01:00
|
|
|
onResume(options) {
|
|
|
|
super.onResume(this, options);
|
|
|
|
document.querySelector('.skinHeader').classList.add('noHomeButtonHeader');
|
|
|
|
}
|
2018-10-23 01:05:09 +03:00
|
|
|
|
2020-07-31 17:06:04 +01:00
|
|
|
getDefaultTabIndex() {
|
|
|
|
return 0;
|
|
|
|
}
|
2019-11-06 13:43:39 +03:00
|
|
|
|
2020-07-31 17:06:04 +01:00
|
|
|
getTabs() {
|
|
|
|
return [{
|
|
|
|
name: globalize.translate('Home')
|
|
|
|
}, {
|
|
|
|
name: globalize.translate('Favorites')
|
|
|
|
}];
|
2020-07-28 22:04:01 +01:00
|
|
|
}
|
2019-11-06 13:43:39 +03:00
|
|
|
|
2020-07-31 17:06:04 +01:00
|
|
|
getTabController(index) {
|
2020-07-30 16:07:13 +02:00
|
|
|
if (index == null) {
|
2020-07-31 17:06:04 +01:00
|
|
|
throw new Error('index cannot be null');
|
|
|
|
}
|
|
|
|
|
|
|
|
let depends = '';
|
2019-11-06 13:43:39 +03:00
|
|
|
|
2020-07-31 17:06:04 +01:00
|
|
|
switch (index) {
|
|
|
|
case 0:
|
2020-08-16 20:24:45 +02:00
|
|
|
depends = 'hometab';
|
2020-07-31 17:06:04 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2020-08-16 20:24:45 +02:00
|
|
|
depends = 'favorites';
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-11-06 13:43:39 +03:00
|
|
|
|
2020-07-31 17:06:04 +01:00
|
|
|
const instance = this;
|
2020-08-16 20:24:45 +02:00
|
|
|
return import(/* webpackChunkName: "[request]" */ `../controllers/${depends}`).then(({ default: controllerFactory }) => {
|
2020-07-31 17:06:04 +01:00
|
|
|
let controller = instance.tabControllers[index];
|
2018-10-23 01:05:09 +03:00
|
|
|
|
2020-07-31 17:06:04 +01:00
|
|
|
if (!controller) {
|
2020-08-08 18:41:23 +01:00
|
|
|
controller = new controllerFactory(instance.view.querySelector(".tabContent[data-index='" + index + "']"), instance.params);
|
2020-07-31 17:06:04 +01:00
|
|
|
instance.tabControllers[index] = controller;
|
|
|
|
}
|
|
|
|
|
|
|
|
return controller;
|
|
|
|
});
|
2020-07-28 22:04:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default HomeView;
|