allow limit for autocomplete menu length
This commit is contained in:
parent
28138cc446
commit
3087690d89
2 changed files with 26 additions and 18 deletions
|
@ -69,6 +69,7 @@ Ox.Input = function(options, self) {
|
|||
autocompleteReplaceCorrect: false,
|
||||
autocompleteSelect: false,
|
||||
autocompleteSelectHighlight: false,
|
||||
autocompleteSelectMax: 0,
|
||||
autocompleteSelectSubmit: false,
|
||||
autovalidate: null,
|
||||
changeOnKeypress: false,
|
||||
|
@ -276,12 +277,13 @@ Ox.Input = function(options, self) {
|
|||
if (self.options.value || self.options.autocompleteReplaceCorrect) {
|
||||
if (Ox.isFunction(self.options.autocomplete)) {
|
||||
if (self.options.key) {
|
||||
self.options.autocomplete(self.options.key,
|
||||
self.options.value,
|
||||
autocompleteCallback)
|
||||
self.options.autocomplete(
|
||||
self.options.key, self.options.value, autocompleteCallback
|
||||
);
|
||||
} else {
|
||||
self.options.autocomplete(self.options.value,
|
||||
autocompleteCallback)
|
||||
self.options.autocomplete(
|
||||
self.options.value, autocompleteCallback
|
||||
);
|
||||
}
|
||||
} else {
|
||||
autocompleteCallback(autocompleteFunction(self.options.value));
|
||||
|
@ -334,17 +336,22 @@ Ox.Input = function(options, self) {
|
|||
self.oldCursor = cursor();
|
||||
self.oldValue = self.options.value;
|
||||
self.$autocompleteMenu.options({
|
||||
items: $.map(values, function(v, i) {
|
||||
items: Ox.map(values, function(v, i) {
|
||||
var ret = null;
|
||||
if (
|
||||
!self.options.autocompleteSelectMax ||
|
||||
i < self.options.autocompleteSelectMax
|
||||
) {
|
||||
if (value == v.toLowerCase()) {
|
||||
selected = i;
|
||||
}
|
||||
return {
|
||||
ret = {
|
||||
id: v.toLowerCase().replace(/ /g, '_'), // fixme: need function to do lowercase, underscores etc?
|
||||
title: self.options.autocompleteSelectHighlight ? v.replace(
|
||||
new RegExp('(' + value + ')', 'ig'),
|
||||
'<span class="OxHighlight">$1</span>'
|
||||
) : v
|
||||
title: self.options.autocompleteSelectHighlight ?
|
||||
Ox.highlight(v, value, 'OxHighlight') : v
|
||||
};
|
||||
}
|
||||
return ret;
|
||||
}),
|
||||
selected: selected
|
||||
}).showMenu();
|
||||
|
|
|
@ -462,6 +462,7 @@ Ox.VideoEditor = function(options, self) {
|
|||
autocomplete: self.words,
|
||||
autocompleteSelect: true,
|
||||
autocompleteSelectHighlight: true,
|
||||
autocompleteSelectMax: 10,
|
||||
autocompleteSelectSubmit: true,
|
||||
changeOnKeypress: true,
|
||||
placeholder: 'Find...',
|
||||
|
|
Loading…
Reference in a new issue