mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 20:19:22 +03:00
*.jsx -> *.js
This commit is contained in:
parent
0a2b826f71
commit
e88c193334
98 changed files with 341 additions and 340 deletions
66
dev/Knoin/AbstractScreen.js
Normal file
66
dev/Knoin/AbstractScreen.js
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
|
||||
import _ from '_';
|
||||
import crossroads from 'crossroads';
|
||||
import {isArray, isNonEmptyArray, noop} from 'Common/Utils';
|
||||
|
||||
class AbstractScreen
|
||||
{
|
||||
constructor(screenName, viewModels = [])
|
||||
{
|
||||
this.oCross = null;
|
||||
this.sScreenName = screenName;
|
||||
this.aViewModels = 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 = _.bind(this.onRoute || noop, this);
|
||||
route = crossroads.create();
|
||||
|
||||
_.each(routes, (aItem) => {
|
||||
route.addRoute(aItem[0], fMatcher).rules = aItem[1];
|
||||
});
|
||||
|
||||
this.oCross = route;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export {AbstractScreen, AbstractScreen as default};
|
||||
Loading…
Add table
Add a link
Reference in a new issue