hedera-web/js/htk/field/search-entry.js

52 lines
888 B
JavaScript
Raw Normal View History

2015-11-19 13:57:23 +00:00
2016-09-26 09:28:47 +00:00
module.exports = new Class
2015-11-19 13:57:23 +00:00
({
Extends: Htk.Field
,Tag: 'htk-search-entry'
2016-10-16 14:16:08 +00:00
,render: function ()
2015-11-19 13:57:23 +00:00
{
2016-10-16 14:16:08 +00:00
var div = this.createRoot ('div');
2015-11-19 13:57:23 +00:00
2016-09-26 09:28:47 +00:00
var icon = new Htk.Icon ({
icon: 'search',
alt: _('Search')
});
div.appendChild (icon.node);
2015-11-19 13:57:23 +00:00
2016-10-16 14:16:08 +00:00
var input = this.createElement ('input');
2015-11-19 13:57:23 +00:00
input.className = 'entry';
input.type = 'text';
input.placeholder = _('Search');
input.addEventListener ('change', this._onChange.bind (this));
div.appendChild (input);
this._input = input;
}
2017-11-22 12:25:19 +00:00
,_onChange: function ()
2015-11-19 13:57:23 +00:00
{
var newValue;
if (this._input.value === '')
newValue = undefined;
else
newValue = this._input.value;
2017-11-20 12:15:01 +00:00
this._notifyFieldChange (newValue);
2015-11-19 13:57:23 +00:00
}
2017-11-20 12:15:01 +00:00
,_putFieldValue: function (value)
2015-11-19 13:57:23 +00:00
{
if (!value)
this._input.value = '';
else
this._input.value = value;
}
,setEditable: function (editable)
{
this.node.readOnly = !editable;
}
});