hedera-web/js/htk/entry/index.js

75 lines
1.2 KiB
JavaScript

module.exports = new Class({
Extends: Htk.Field
,Tag: 'htk-entry'
,Properties: {
/**
* Displayed text when there is no content.
*/
placeholder:
{
type: String
,set: function(x) {
this.node.placeholder = x;
}
,get: function() {
return this.node.placeholder;
}
},
/**
* Whether is disabled.
*/
disabled:
{
type: Boolean
,set: function(x) {
this.node.disabled = x;
}
,get: function() {
return this.node.disabled;
}
},
/**
* Whether is readonly data.
*/
readonly:
{
type: Boolean
,set: function(x) {
this.node.readonly = x;
}
,get: function() {
return this.node.readonly;
}
}
}
,render: function() {
var node = this.createRoot('input');
node.type = 'text';
node.addEventListener('change', this._onChange.bind(this));
}
,_onChange: function() {
var newValue;
if (this.node.value == '')
newValue = null;
else
newValue = this.node.value;
this.valueChanged(newValue);
}
,putValue: function(value) {
if (!value)
this.node.value = '';
else
this.node.value = value;
}
,setEditable: function(editable) {
this.node.readOnly = !editable;
}
});