From 7b15d2bb8fed7843d8b98a6e21cb07f704185939 Mon Sep 17 00:00:00 2001 From: rolux Date: Fri, 20 May 2011 09:42:17 +0200 Subject: [PATCH] better behaviour when pressing backspace while autocomplete is set to replace, but not to correct --- source/Ox.UI/js/Form/Ox.Input.js | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/source/Ox.UI/js/Form/Ox.Input.js b/source/Ox.UI/js/Form/Ox.Input.js index db66e4bd..1edaafe9 100644 --- a/source/Ox.UI/js/Form/Ox.Input.js +++ b/source/Ox.UI/js/Form/Ox.Input.js @@ -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) {