mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-04 05:52:44 +08:00
56 lines
913 B
JavaScript
56 lines
913 B
JavaScript
export class AbstractScreen {
|
|
oCross = null;
|
|
sScreenName;
|
|
aViewModels;
|
|
|
|
constructor(screenName, viewModels = []) {
|
|
this.sScreenName = screenName;
|
|
this.aViewModels = Array.isArray(viewModels) ? viewModels : [];
|
|
}
|
|
|
|
/**
|
|
* @returns {Array}
|
|
*/
|
|
get viewModels() {
|
|
return this.aViewModels;
|
|
}
|
|
|
|
/**
|
|
* @returns {string}
|
|
*/
|
|
screenName() {
|
|
return this.sScreenName;
|
|
}
|
|
|
|
/**
|
|
* @returns {?Array)}
|
|
*/
|
|
routes() {
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* @returns {?Object}
|
|
*/
|
|
get __cross() {
|
|
return this.oCross;
|
|
}
|
|
|
|
/**
|
|
* @returns {void}
|
|
*/
|
|
onStart() {
|
|
if (!this.__started) {
|
|
this.__started = true;
|
|
const routes = this.routes();
|
|
if (Array.isNotEmpty(routes)) {
|
|
let route = new Crossroads(),
|
|
fMatcher = (this.onRoute || (()=>{})).bind(this);
|
|
|
|
routes.forEach(item => item && route && (route.addRoute(item[0], fMatcher).rules = item[1]));
|
|
|
|
this.oCross = route;
|
|
}
|
|
}
|
|
}
|
|
}
|