forked from verdnatura/hedera-web
53 lines
980 B
JavaScript
53 lines
980 B
JavaScript
|
|
||
|
Htk.SearchEntry = new Class
|
||
|
({
|
||
|
Extends: Htk.Field
|
||
|
,Tag: 'htk-search-entry'
|
||
|
|
||
|
,initialize: function (props)
|
||
|
{
|
||
|
var div = this.createElement ('div');
|
||
|
div.className = 'htk-search-entry';
|
||
|
|
||
|
var img = document.createElement ('img');
|
||
|
img.alt = _('Search');
|
||
|
img.src = 'image/search.svg';
|
||
|
div.appendChild (img);
|
||
|
|
||
|
var input = document.createElement ('input');
|
||
|
input.className = 'entry';
|
||
|
input.type = 'text';
|
||
|
input.placeholder = _('Search');
|
||
|
input.addEventListener ('change', this._onChange.bind (this));
|
||
|
div.appendChild (input);
|
||
|
|
||
|
this._input = input;
|
||
|
this.parent (props);
|
||
|
}
|
||
|
|
||
|
,_onChange: function (event)
|
||
|
{
|
||
|
var newValue;
|
||
|
|
||
|
if (this._input.value === '')
|
||
|
newValue = undefined;
|
||
|
else
|
||
|
newValue = this._input.value;
|
||
|
|
||
|
this.valueChanged (newValue);
|
||
|
}
|
||
|
|
||
|
,putValue: function (value)
|
||
|
{
|
||
|
if (!value)
|
||
|
this._input.value = '';
|
||
|
else
|
||
|
this._input.value = value;
|
||
|
}
|
||
|
|
||
|
,setEditable: function (editable)
|
||
|
{
|
||
|
this.node.readOnly = !editable;
|
||
|
}
|
||
|
});
|