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

75 lines
1.1 KiB
JavaScript
Raw Normal View History

2016-09-26 09:28:47 +00:00
2022-05-30 01:30:33 +00:00
module.exports = new Class({
Extends: Htk.Field
,Tag: 'htk-entry'
2022-05-30 01:30:33 +00:00
,Properties: {
2022-05-21 21:31:56 +00:00
/**
* Displayed text when there is no content.
*/
placeholder:
{
type: String
2022-11-16 01:46:44 +00:00
,set(x) {
2022-05-21 21:31:56 +00:00
this.node.placeholder = x;
}
2022-11-16 01:46:44 +00:00
,get() {
2022-05-21 21:31:56 +00:00
return this.node.placeholder;
}
},
/**
* Whether is disabled.
*/
disabled:
{
type: Boolean
2022-11-16 01:46:44 +00:00
,set(x) {
2022-05-21 21:31:56 +00:00
this.node.disabled = x;
}
2022-11-16 01:46:44 +00:00
,get() {
2022-05-21 21:31:56 +00:00
return this.node.disabled;
}
},
/**
* Whether is readonly data.
*/
readonly:
{
type: Boolean
2022-11-16 01:46:44 +00:00
,set(x) {
2022-05-21 21:31:56 +00:00
this.node.readonly = x;
}
2022-11-16 01:46:44 +00:00
,get() {
2022-05-21 21:31:56 +00:00
return this.node.readonly;
}
}
}
2022-11-16 01:46:44 +00:00
,render() {
2022-05-21 21:31:56 +00:00
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-11-16 01:46:44 +00:00
,_onChange() {
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-11-16 01:46:44 +00:00
,putValue(value) {
if (!value)
this.node.value = '';
else
this.node.value = value;
}
2022-11-16 01:46:44 +00:00
,setEditable(editable) {
this.node.readOnly = !editable;
}
});