|
|
|
@ -133,14 +133,7 @@ SimpleAutocomplete.prototype.init = function() |
|
|
|
|
|
|
|
|
|
// Set event listeners
|
|
|
|
|
var self = this; |
|
|
|
|
var ie_opera = navigator.userAgent.match('MSIE') || navigator.userAgent.match('Opera'); |
|
|
|
|
if (ie_opera) |
|
|
|
|
this.addRmListener('keydown', function(ev) { return self.onKeyPress(ev); }); |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
this.addRmListener('keydown', function(ev) { return self.onKeyDown(ev); }); |
|
|
|
|
this.addRmListener('keypress', function(ev) { return self.onKeyPress(ev); }); |
|
|
|
|
} |
|
|
|
|
this.addRmListener('keydown', function(ev) { return self.onKeyDown(ev); }); |
|
|
|
|
this.addRmListener('keyup', function(ev) { return self.onKeyUp(ev); }); |
|
|
|
|
this.addRmListener('change', function() { return self.onChange(); }); |
|
|
|
|
this.addRmListener('focus', function() { return self.onInputFocus(); }); |
|
|
|
@ -155,7 +148,7 @@ SimpleAutocomplete.prototype.replaceItems = function(items, append) |
|
|
|
|
if (!append) |
|
|
|
|
{ |
|
|
|
|
this.hintLayer.scrollTop = 0; |
|
|
|
|
this.selectedIndex = -1; |
|
|
|
|
this.selectedIndex = 0; |
|
|
|
|
this.items = []; |
|
|
|
|
if (!items || items.length == 0) |
|
|
|
|
{ |
|
|
|
@ -463,22 +456,8 @@ SimpleAutocomplete.prototype.onKeyUp = function(ev) |
|
|
|
|
return true; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// Cancel handling of Enter key
|
|
|
|
|
SimpleAutocomplete.prototype.onKeyDown = function(ev) |
|
|
|
|
{ |
|
|
|
|
ev = ev||window.event; |
|
|
|
|
if (ev.keyCode == 10 || ev.keyCode == 13) |
|
|
|
|
{ |
|
|
|
|
if (this.hintLayer.style.display == '') |
|
|
|
|
return stopEvent(ev, true, true); |
|
|
|
|
else |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// Handle arrow keys and Enter
|
|
|
|
|
SimpleAutocomplete.prototype.onKeyPress = function(ev) |
|
|
|
|
SimpleAutocomplete.prototype.onKeyDown = function(ev) |
|
|
|
|
{ |
|
|
|
|
if (this.hintLayer.style.display == 'none') |
|
|
|
|
return true; |
|
|
|
|