define('application/widgets/guide/directdial', [
'rofl/widgets/container',
'rofl/widgets/label'
], function (
Container,
Label
) {
'use strict';
return Container.extend({
/**
* Initialises the widget.
*/
init: function init () {
init.base.call(this);
this._keys = '';
this.addClass('directdial');
this._build();
},
/**
* Builds the widget.
*
* @private
*/
_build: function () {
var label = this._label = new Label({ text: '' });
this.appendChildWidget(label);
},
/**
* Sets the key input.
*
* @param {string} input - The input value.
*/
setKeyInput: function (input) {
var keys = this._keys;
if (keys.length === 3) {
keys = '';
}
keys += input;
this._label.setText(keys);
this._keys = keys;
},
/**
* Returns the current input.
*
* @returns {string} - The current input.
*/
getCurrentInput: function () {
return this._keys;
},
/**
* Resets the direct dial.
*/
reset: function () {
this._keys = '';
this._label.setText('');
}
});
});