2014-10-31 04:59:21 +00:00
|
|
|
/* jslint node: true */
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var View = require('./view.js').View;
|
|
|
|
var ansi = require('./ansi_term.js');
|
2014-10-31 22:25:11 +00:00
|
|
|
var miscUtil = require('./misc_util.js');
|
2014-10-31 04:59:21 +00:00
|
|
|
var util = require('util');
|
|
|
|
var assert = require('assert');
|
|
|
|
|
|
|
|
exports.MenuView = MenuView;
|
|
|
|
|
|
|
|
function MenuView(client, options) {
|
2014-10-31 22:25:11 +00:00
|
|
|
options.acceptsFocus = miscUtil.valueWithDefault(options.acceptsFocus, true);
|
2014-11-01 15:50:11 +00:00
|
|
|
options.acceptsInput = miscUtil.valueWithDefault(options.acceptsInput, true);
|
2014-10-31 22:25:11 +00:00
|
|
|
|
2014-10-31 04:59:21 +00:00
|
|
|
View.call(this, client, options);
|
|
|
|
|
2014-11-01 15:50:11 +00:00
|
|
|
var self = this;
|
2014-10-31 22:25:11 +00:00
|
|
|
|
|
|
|
//// --- TESTING
|
|
|
|
options.items = [ 'Login', 'Apply', 'Logout' ];
|
|
|
|
//options.itemSpacing = 2;
|
|
|
|
//// --- TESTING
|
|
|
|
|
2014-10-31 04:59:21 +00:00
|
|
|
this.items = [];
|
|
|
|
if(this.options.items) {
|
|
|
|
this.options.items.forEach(function onItem(itemText) {
|
2014-10-31 22:25:11 +00:00
|
|
|
self.items.push({
|
2014-10-31 04:59:21 +00:00
|
|
|
text : itemText,
|
|
|
|
selected : false,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-11-01 15:50:11 +00:00
|
|
|
this.focusedItemIndex = this.options.focusedItemIndex || 0;
|
|
|
|
this.focusedItemIndex = this.items.length >= this.focusedItemIndex ? this.focusedItemIndex : 0;
|
|
|
|
|
2014-10-31 04:59:21 +00:00
|
|
|
this.itemSpacing = this.options.itemSpacing || 1;
|
2014-10-31 22:25:11 +00:00
|
|
|
this.itemSpacing = parseInt(this.itemSpacing, 10);
|
|
|
|
|
2014-10-31 04:59:21 +00:00
|
|
|
this.focusPrefix = this.options.focusPrefix || '';
|
|
|
|
this.focusSuffix = this.options.focusSuffix || '';
|
|
|
|
}
|
|
|
|
|
|
|
|
util.inherits(MenuView, View);
|
|
|
|
|