From 571e3a3512c52b32dbff2bf89c579c39d8e1646f Mon Sep 17 00:00:00 2001 From: rlx <0x0073@0x2620.org> Date: Fri, 11 Nov 2011 11:48:52 +0000 Subject: [PATCH] in input elements, disable showing the autocomplete menu on focus --- source/Ox.UI/js/Form/Ox.Filter.js | 26 +++++++++++---------- source/Ox.UI/js/Form/Ox.FormElementGroup.js | 3 +++ source/Ox.UI/js/Form/Ox.Input.js | 7 ++++-- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/source/Ox.UI/js/Form/Ox.Filter.js b/source/Ox.UI/js/Form/Ox.Filter.js index f56311c6..fa48ff6f 100644 --- a/source/Ox.UI/js/Form/Ox.Filter.js +++ b/source/Ox.UI/js/Form/Ox.Filter.js @@ -75,8 +75,8 @@ Ox.Filter = function(options, self) { {id: '!=,', title: 'is not between'} ], list: [ - {id: '=', title: 'is'}, - {id: '!=', title: 'is not'} + {id: '==', title: 'is'}, + {id: '!==', title: 'is not'} ], number: [ {id: '=', title: 'is'}, @@ -120,7 +120,7 @@ Ox.Filter = function(options, self) { float: 0, hue: 0, integer: 0, - list: 0, + list: '', string: '', text: '', time: '00:00:00', @@ -599,16 +599,17 @@ Ox.Filter = function(options, self) { ] }) ).bindEvent({ - change: function(data) { - Ox.Log('FILTER', 'change event', data) - var $element = data._element.parent(); - changeConditionValue( - $element.data('position'), - $element.data('subposition'), - data.value - ); - } + change: change, + submit: change }); + function change(data) { + var $element = data._element.parent(); + changeConditionValue( + $element.data('position'), + $element.data('subposition'), + data.value + ); + } } function renderConditions() { @@ -705,6 +706,7 @@ Ox.Filter = function(options, self) { $input = Ox.Input({ autocomplete: findKey.values, autocompleteSelect: true, + autocompleteSelectSubmit: true, value: value, width: 288 }); diff --git a/source/Ox.UI/js/Form/Ox.FormElementGroup.js b/source/Ox.UI/js/Form/Ox.FormElementGroup.js index b7df468a..045cee1d 100644 --- a/source/Ox.UI/js/Form/Ox.FormElementGroup.js +++ b/source/Ox.UI/js/Form/Ox.FormElementGroup.js @@ -45,6 +45,9 @@ Ox.FormElementGroup = function(options, self) { change: function(data) { that.triggerEvent({change: {value: that.value()}}); }, + submit: function(data) { + that.triggerEvent({change: {value: that.value()}}); + }, validate: function(data) { that.triggerEvent({validate: data}); } diff --git a/source/Ox.UI/js/Form/Ox.Input.js b/source/Ox.UI/js/Form/Ox.Input.js index bd694399..b46cdca3 100644 --- a/source/Ox.UI/js/Form/Ox.Input.js +++ b/source/Ox.UI/js/Form/Ox.Input.js @@ -300,7 +300,7 @@ Ox.Input = function(options, self) { oldValue = Ox.isUndefined(oldValue) ? self.options.value : oldValue; oldCursor = Ox.isUndefined(oldCursor) ? cursor() : oldCursor; - Ox.Log('Form', 'autocomplete', oldValue, oldCursor) + Ox.Log('AUTO', 'autocomplete', oldValue, oldCursor) if (self.options.value || self.options.autocompleteReplaceCorrect) { if (Ox.isFunction(self.options.autocomplete)) { @@ -404,6 +404,7 @@ Ox.Input = function(options, self) { }); self.selectEventBound = true; } + Ox.Log('AUTO', 'show menu') self.$autocompleteMenu.options({ selected: selected }).showMenu(); @@ -692,7 +693,8 @@ Ox.Input = function(options, self) { // fixme: different in webkit and firefox (?), see keyboard handler, need generic function Ox.UI.$document.keydown(keydown); //Ox.UI.$document.keypress(keypress); - self.options.autocompleteSelect && setTimeout(autocomplete, 0); // fixme: why is the timeout needed? + // temporarily disabled autocomplete on focus + //self.options.autocompleteSelect && setTimeout(autocomplete, 0); // fixme: why is the timeout needed? } that.triggerEvent('focus'); } @@ -725,6 +727,7 @@ Ox.Input = function(options, self) { } if (value != self.options.value) { self.options.value = value; + Ox.Log('AUTO', 'call autocomplete from keydown') self.options.autocomplete && autocomplete(oldValue, oldCursor); self.options.autovalidate && autovalidate(oldValue, oldCursor); self.options.changeOnKeypress && that.triggerEvent({