mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-06-30 07:46:27 +00:00
isUnd(*) to native undefined === *
isFunc to native typeof * === 'function'
isObject to native typeof * === 'object'
microtime() to native Date().getTime();
noop to native ()=>{}
noopFalse to native ()=>false
noopTrue to native ()=>true
boolToAjax to native *?'1':'0'
Underscore.js to native
64 lines
994 B
JavaScript
64 lines
994 B
JavaScript
import crossroads from 'crossroads';
|
|
import { isNonEmptyArray } from 'Common/Utils';
|
|
|
|
export class AbstractScreen {
|
|
oCross = null;
|
|
sScreenName;
|
|
aViewModels;
|
|
|
|
constructor(screenName, viewModels = []) {
|
|
this.sScreenName = screenName;
|
|
this.aViewModels = Array.isArray(viewModels) ? viewModels : [];
|
|
}
|
|
|
|
/**
|
|
* @returns {Array}
|
|
*/
|
|
viewModels() {
|
|
return this.aViewModels;
|
|
}
|
|
|
|
/**
|
|
* @returns {string}
|
|
*/
|
|
screenName() {
|
|
return this.sScreenName;
|
|
}
|
|
|
|
/**
|
|
* @returns {?Array)}
|
|
*/
|
|
routes() {
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* @returns {?Object}
|
|
*/
|
|
__cross() {
|
|
return this.oCross;
|
|
}
|
|
|
|
/**
|
|
* @returns {void}
|
|
*/
|
|
__start() {
|
|
let route = null,
|
|
fMatcher = null;
|
|
const routes = this.routes();
|
|
|
|
if (isNonEmptyArray(routes)) {
|
|
fMatcher = (this.onRoute || (()=>{})).bind(this);
|
|
route = crossroads.create();
|
|
|
|
routes.forEach((item) => {
|
|
if (item && route) {
|
|
route.addRoute(item[0], fMatcher).rules = item[1];
|
|
}
|
|
});
|
|
|
|
this.oCross = route;
|
|
}
|
|
}
|
|
}
|