0
1
Fork 0
hedera-web-mindshore/js/htk/field/entry.js

77 lines
1.2 KiB
JavaScript
Raw Normal View History

2016-09-26 09:28:47 +00:00
module.exports = new Class
({
Extends: Htk.Field
,Tag: 'htk-entry'
2022-05-21 21:31:56 +00:00
,Properties:
{
2022-05-21 21:31:56 +00:00
/**
* 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');
2016-10-16 14:16:08 +00:00
node.type = 'text';
2022-05-21 21:31:56 +00:00
node.addEventListener('change', this._onChange.bind(this));
}
2022-05-21 21:31:56 +00:00
,_onChange: function(event) {
var newValue;
if (this.node.value == '')
newValue = null;
else
newValue = this.node.value;
2022-05-21 21:31:56 +00:00
this.valueChanged(newValue);
}
2022-05-21 21:31:56 +00:00
,putValue: function(value) {
if (!value)
this.node.value = '';
else
this.node.value = value;
}
2022-05-21 21:31:56 +00:00
,setEditable: function(editable) {
this.node.readOnly = !editable;
}
});