snappymail/dev/Knoin/AbstractScreen.js
RainLoop Team 06274c6a7c Code refactoring
Fixed owncloud password encoder/decoder (#291)
Fixed ckeditor in ownCloud iframe (Closes #302)
Release commit
2014-09-06 01:44:29 +04:00

91 lines
1.4 KiB
JavaScript

(function () {
'use strict';
var
_ = require('_'),
crossroads = require('crossroads'),
Utils = require('Common/Utils')
;
/**
* @param {string} sScreenName
* @param {?=} aViewModels = []
* @constructor
*/
function AbstractScreen(sScreenName, aViewModels)
{
this.sScreenName = sScreenName;
this.aViewModels = Utils.isArray(aViewModels) ? aViewModels : [];
}
/**
* @type {Array}
*/
AbstractScreen.prototype.oCross = null;
/**
* @type {string}
*/
AbstractScreen.prototype.sScreenName = '';
/**
* @type {Array}
*/
AbstractScreen.prototype.aViewModels = [];
/**
* @return {Array}
*/
AbstractScreen.prototype.viewModels = function ()
{
return this.aViewModels;
};
/**
* @return {string}
*/
AbstractScreen.prototype.screenName = function ()
{
return this.sScreenName;
};
AbstractScreen.prototype.routes = function ()
{
return null;
};
/**
* @return {?Object}
*/
AbstractScreen.prototype.__cross = function ()
{
return this.oCross;
};
AbstractScreen.prototype.__start = function ()
{
var
aRoutes = this.routes(),
oRoute = null,
fMatcher = null
;
if (Utils.isNonEmptyArray(aRoutes))
{
fMatcher = _.bind(this.onRoute || Utils.emptyFunction, this);
oRoute = crossroads.create();
_.each(aRoutes, function (aItem) {
oRoute.addRoute(aItem[0], fMatcher).rules = aItem[1];
});
this.oCross = oRoute;
}
};
module.exports = AbstractScreen;
}());