better behaviour when pressing backspace while autocomplete is set to replace, but not to correct
This commit is contained in:
parent
6e0bafed88
commit
7b15d2bb8f
1 changed files with 3 additions and 16 deletions
|
@ -304,7 +304,6 @@ Ox.Input = function(options, self) {
|
|||
//Ox.print('autocompleteCallback', values[0], self.options.value, self.options.value.length, oldValue, oldCursor)
|
||||
|
||||
var length = self.options.value.length,
|
||||
deleted = length <= oldValue.length - (oldCursor[1] - oldCursor[0]),
|
||||
newValue, newLength,
|
||||
pos = cursor(),
|
||||
selected = -1,
|
||||
|
@ -312,7 +311,7 @@ Ox.Input = function(options, self) {
|
|||
value;
|
||||
|
||||
if (values[0]) {
|
||||
if (self.options.autocompleteReplaceCorrect || !deleted) {
|
||||
if (self.options.autocompleteReplace) {
|
||||
newValue = values[0];
|
||||
} else {
|
||||
newValue = self.options.value;
|
||||
|
@ -326,16 +325,6 @@ Ox.Input = function(options, self) {
|
|||
}
|
||||
newLength = newValue.length;
|
||||
|
||||
/*
|
||||
if (self.options.autocompleteReplaceCorrect) {
|
||||
if (values[0]) {
|
||||
newValue = deleted ? oldValue : values[0];
|
||||
} else {
|
||||
newValue = self.options.value;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
//Ox.print('selectEnd', selectEnd)
|
||||
|
||||
if (self.options.autocompleteReplace) {
|
||||
|
@ -657,7 +646,6 @@ Ox.Input = function(options, self) {
|
|||
newValue = oldValue.substr(0, oldCursor[0] - 1),
|
||||
hasDeletedSelectedEnd = (event.keyCode == 8 || event.keyCode == 46) &&
|
||||
oldCursor[0] < oldCursor[1] && oldCursor[1] == oldValue.length;
|
||||
//Ox.print('keypress', event.keyCode)
|
||||
if (
|
||||
event.keyCode != 9 &&
|
||||
(self.options.type == 'textarea' || event.keyCode != 13) &&
|
||||
|
@ -665,9 +653,8 @@ Ox.Input = function(options, self) {
|
|||
) { // fixme: can't 13 and 27 return false?
|
||||
setTimeout(function() { // wait for val to be set
|
||||
var value = self.$input.val();
|
||||
if (self.options.autocompleteReplaceCorrect && hasDeletedSelectedEnd) {
|
||||
//Ox.print(value, '->', newValue);
|
||||
value = newValue; // value.substr(0, value.length - 1);
|
||||
if (self.options.autocompleteReplace && hasDeletedSelectedEnd) {
|
||||
value = newValue;
|
||||
self.$input.val(value);
|
||||
}
|
||||
if (value != self.options.value) {
|
||||
|
|
Loading…
Reference in a new issue