mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-12-31 03:52:01 +08:00
39 lines
714 B
JavaScript
39 lines
714 B
JavaScript
import { isArray, arrayLength } from 'Common/Utils';
|
|
|
|
export class AbstractScreen {
|
|
constructor(screenName, viewModels = []) {
|
|
this.__cross = null;
|
|
this.screenName = screenName;
|
|
this.viewModels = isArray(viewModels) ? viewModels : [];
|
|
}
|
|
|
|
/**
|
|
* @returns {?Array)}
|
|
*/
|
|
routes() {
|
|
return null;
|
|
}
|
|
|
|
/*
|
|
onBuild(viewModelDom) {}
|
|
onShow() {}
|
|
onHide() {}
|
|
__started
|
|
__builded
|
|
*/
|
|
|
|
/**
|
|
* @returns {void}
|
|
*/
|
|
onStart() {
|
|
const routes = this.routes();
|
|
if (arrayLength(routes)) {
|
|
let route = new Crossroads(),
|
|
fMatcher = (this.onRoute || (()=>0)).bind(this);
|
|
|
|
routes.forEach(item => item && route && (route.addRoute(item[0], fMatcher).rules = item[1]));
|
|
|
|
this.__cross = route;
|
|
}
|
|
}
|
|
}
|