Hide on pressing ESC key until next input change

master
Vitaliy Filippov 2012-10-13 22:27:40 +00:00
parent 5104cfaf82
commit 50ccb83a58
1 changed files with 8 additions and 1 deletions

View File

@ -378,7 +378,7 @@ SimpleAutocomplete.prototype.onChange = function()
SimpleAutocomplete.prototype.onKeyUp = function(ev) SimpleAutocomplete.prototype.onKeyUp = function(ev)
{ {
ev = ev||window.event; ev = ev||window.event;
if (ev.keyCode != 10 && ev.keyCode != 13) if (ev.keyCode == 38 || ev.keyCode == 40)
this.show(); this.show();
if (ev.keyCode == 38 || ev.keyCode == 40 || ev.keyCode == 10 || ev.keyCode == 13) if (ev.keyCode == 38 || ev.keyCode == 40 || ev.keyCode == 10 || ev.keyCode == 13)
{ {
@ -421,6 +421,11 @@ SimpleAutocomplete.prototype.onKeyPress = function(ev)
this.selectItem(this.selectedIndex); this.selectItem(this.selectedIndex);
return stopEvent(ev, true, true); return stopEvent(ev, true, true);
} }
else if (ev.keyCode == 27) // escape
{
this.hide();
return stopEvent(ev, true, true);
}
else else
return true; return true;
// scrolling // scrolling
@ -441,6 +446,8 @@ SimpleAutocomplete.prototype.onKeyPress = function(ev)
// Called when input receives focus // Called when input receives focus
SimpleAutocomplete.prototype.onInputFocus = function() SimpleAutocomplete.prototype.onInputFocus = function()
{ {
if (this.disabledUntil)
this.enable();
this.show(); this.show();
this.input.autocomplete = 'off'; this.input.autocomplete = 'off';
this.hasFocus = true; this.hasFocus = true;