mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-08-02 07:51:52 +02:00
* Rewrite of Views functional. WIP more to come
This commit is contained in:
parent
51d15659d5
commit
381ded17a6
6 changed files with 328 additions and 12 deletions
44
core/mci_view_factory.js
Normal file
44
core/mci_view_factory.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
/* jslint node: true */
|
||||
'use strict';
|
||||
|
||||
var TextView = require('./text_view.js').TextView;
|
||||
var EditTextView = require('./edit_text_view.js').EditTextView;
|
||||
var assert = require('assert');
|
||||
|
||||
exports.MCIViewFactory = MCIViewFactory;
|
||||
|
||||
function MCIViewFactory(client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
MCIViewFactory.prototype.createFromMCI = function(mci) {
|
||||
assert(mci.code);
|
||||
assert(mci.id > 0);
|
||||
assert(mci.position);
|
||||
|
||||
var view;
|
||||
var options = {
|
||||
id : mci.id,
|
||||
color : mci.color,
|
||||
focusColor : mci.focusColor,
|
||||
position : { x : mci.position[0], y : mci.position[1] },
|
||||
};
|
||||
|
||||
switch(mci.code) {
|
||||
case 'EV' :
|
||||
if(mci.args.length > 0) {
|
||||
options.maxLength = mci.args[0];
|
||||
options.dimens = { width : options.maxLength };
|
||||
}
|
||||
|
||||
if(mci.args.length > 1) {
|
||||
options.textStyle = mci.args[1];
|
||||
}
|
||||
|
||||
view = new EditTextView(this.client, options);
|
||||
break;
|
||||
}
|
||||
|
||||
return view;
|
||||
};
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue