Ox.Input: add autocompleteSelectOffset and autocompleteSelectUpdate options

This commit is contained in:
rolux 2014-12-17 14:35:10 +00:00
parent a21327ff7e
commit c36243d31c

View file

@ -12,7 +12,9 @@ Ox.Input <f> Input Element
autocompleteSelect <b> if true, menu is displayed autocompleteSelect <b> if true, menu is displayed
autocompleteSelectHighlight <b> if true, value in menu is highlighted autocompleteSelectHighlight <b> if true, value in menu is highlighted
autocompleteSelectMaxWidth <n|0> Maximum width of autocomplete menu, or 0 autocompleteSelectMaxWidth <n|0> Maximum width of autocomplete menu, or 0
autocompleteSelectOffset <o|{left: 4, top: 0}> Offset of autocomplete menu
autocompleteSelectSubmit <b> if true, submit input on menu selection autocompleteSelectSubmit <b> if true, submit input on menu selection
autocompleteSelectUpdate <b> if true, update menu position on keypress
autocorrect <s|r|f|null> ('email', 'float', 'int', 'phone', 'url'), or autocorrect <s|r|f|null> ('email', 'float', 'int', 'phone', 'url'), or
<r> regexp(value), or <r> regexp(value), or
<f> function(key, value, blur, callback), returns value <f> function(key, value, blur, callback), returns value
@ -84,7 +86,9 @@ Ox.Input = function(options, self) {
autocompleteSelectHighlight: false, autocompleteSelectHighlight: false,
autocompleteSelectMax: 0, autocompleteSelectMax: 0,
autocompleteSelectMaxWidth: 0, autocompleteSelectMaxWidth: 0,
autocompleteSelectOffset: {left: 4, top: 0},
autocompleteSelectSubmit: false, autocompleteSelectSubmit: false,
autocompleteSelectUpdate: false,
autovalidate: null, autovalidate: null,
changeOnKeypress: false, changeOnKeypress: false,
clear: false, clear: false,
@ -480,6 +484,9 @@ Ox.Input = function(options, self) {
}); });
self.selectEventBound = true; self.selectEventBound = true;
} }
if (self.options.autocompleteSelectUpdate) {
self.$autocompleteMenu.updatePosition();
}
self.$autocompleteMenu.options({ self.$autocompleteMenu.options({
selected: selected selected: selected
}).showMenu(); }).showMenu();
@ -725,10 +732,7 @@ Ox.Input = function(options, self) {
element: self.$input, element: self.$input,
id: self.options.id + 'Menu', // fixme: we do this in other places ... are we doing it the same way? var name?, id: self.options.id + 'Menu', // fixme: we do this in other places ... are we doing it the same way? var name?,
maxWidth: self.options.autocompleteSelectMaxWidth, maxWidth: self.options.autocompleteSelectMaxWidth,
offset: { offset: self.options.autocompleteSelectOffset
left: 4,
top: 0
}
}) })
.addClass('OxAutocompleteMenu OxKeyboardFocus') .addClass('OxAutocompleteMenu OxKeyboardFocus')
.bindEvent({ .bindEvent({