2020-05-04 12:44:12 +02:00
|
|
|
define(['tabbedView', 'globalize', 'require', 'emby-tabs', 'emby-button', 'emby-scroller'], function (TabbedView, globalize, require) {
|
|
|
|
'use strict';
|
2018-10-23 01:05:09 +03:00
|
|
|
|
|
|
|
function getTabs() {
|
|
|
|
return [{
|
2020-05-04 12:44:12 +02:00
|
|
|
name: globalize.translate('Home')
|
2018-10-23 01:05:09 +03:00
|
|
|
}, {
|
2020-05-04 12:44:12 +02:00
|
|
|
name: globalize.translate('Favorites')
|
2019-11-06 13:43:39 +03:00
|
|
|
}];
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getDefaultTabIndex() {
|
2019-11-06 13:43:39 +03:00
|
|
|
return 0;
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getRequirePromise(deps) {
|
2019-11-06 13:43:39 +03:00
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
|
require(deps, resolve);
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getTabController(index) {
|
2019-11-06 13:43:39 +03:00
|
|
|
if (null == index) {
|
2020-05-04 12:44:12 +02:00
|
|
|
throw new Error('index cannot be null');
|
2019-11-06 13:43:39 +03:00
|
|
|
}
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var depends = [];
|
2019-11-06 13:43:39 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
switch (index) {
|
|
|
|
case 0:
|
2020-05-04 12:44:12 +02:00
|
|
|
depends.push('controllers/hometab');
|
2018-10-23 01:05:09 +03:00
|
|
|
break;
|
2019-11-06 13:43:39 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
case 1:
|
2020-05-04 12:44:12 +02:00
|
|
|
depends.push('controllers/favorites');
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-11-06 13:43:39 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var instance = this;
|
2019-11-06 13:43:39 +03:00
|
|
|
return getRequirePromise(depends).then(function (controllerFactory) {
|
2018-10-23 01:05:09 +03:00
|
|
|
var controller = instance.tabControllers[index];
|
2019-11-06 13:43:39 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
if (!controller) {
|
2019-11-06 13:43:39 +03:00
|
|
|
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
|
|
|
|
|
|
|
return controller;
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function HomeView(view, params) {
|
2019-11-06 13:43:39 +03:00
|
|
|
TabbedView.call(this, view, params);
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-11-06 13:43:39 +03:00
|
|
|
|
|
|
|
Object.assign(HomeView.prototype, TabbedView.prototype);
|
|
|
|
HomeView.prototype.getTabs = getTabs;
|
|
|
|
HomeView.prototype.getDefaultTabIndex = getDefaultTabIndex;
|
|
|
|
HomeView.prototype.getTabController = getTabController;
|
|
|
|
|
|
|
|
HomeView.prototype.setTitle = function () {
|
|
|
|
Emby.Page.setTitle(null);
|
|
|
|
};
|
|
|
|
|
|
|
|
HomeView.prototype.onPause = function () {
|
|
|
|
TabbedView.prototype.onPause.call(this);
|
2020-05-04 12:44:12 +02:00
|
|
|
document.querySelector('.skinHeader').classList.remove('noHomeButtonHeader');
|
2019-11-06 13:43:39 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
HomeView.prototype.onResume = function (options) {
|
|
|
|
TabbedView.prototype.onResume.call(this, options);
|
2020-05-04 12:44:12 +02:00
|
|
|
document.querySelector('.skinHeader').classList.add('noHomeButtonHeader');
|
2019-11-06 13:43:39 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
return HomeView;
|
|
|
|
});
|