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,
|
autocompleteReplaceCorrect: false,
|
||||||
autocompleteSelect: false,
|
autocompleteSelect: false,
|
||||||
autocompleteSelectHighlight: false,
|
autocompleteSelectHighlight: false,
|
||||||
|
autocompleteSelectMax: 0,
|
||||||
autocompleteSelectSubmit: false,
|
autocompleteSelectSubmit: false,
|
||||||
autovalidate: null,
|
autovalidate: null,
|
||||||
changeOnKeypress: false,
|
changeOnKeypress: false,
|
||||||
|
@ -274,14 +275,15 @@ Ox.Input = function(options, self) {
|
||||||
Ox.print('autocomplete', oldValue, oldCursor)
|
Ox.print('autocomplete', oldValue, oldCursor)
|
||||||
|
|
||||||
if (self.options.value || self.options.autocompleteReplaceCorrect) {
|
if (self.options.value || self.options.autocompleteReplaceCorrect) {
|
||||||
if(Ox.isFunction(self.options.autocomplete)) {
|
if (Ox.isFunction(self.options.autocomplete)) {
|
||||||
if(self.options.key) {
|
if (self.options.key) {
|
||||||
self.options.autocomplete(self.options.key,
|
self.options.autocomplete(
|
||||||
self.options.value,
|
self.options.key, self.options.value, autocompleteCallback
|
||||||
autocompleteCallback)
|
);
|
||||||
} else {
|
} else {
|
||||||
self.options.autocomplete(self.options.value,
|
self.options.autocomplete(
|
||||||
autocompleteCallback)
|
self.options.value, autocompleteCallback
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
autocompleteCallback(autocompleteFunction(self.options.value));
|
autocompleteCallback(autocompleteFunction(self.options.value));
|
||||||
|
@ -334,17 +336,22 @@ Ox.Input = function(options, self) {
|
||||||
self.oldCursor = cursor();
|
self.oldCursor = cursor();
|
||||||
self.oldValue = self.options.value;
|
self.oldValue = self.options.value;
|
||||||
self.$autocompleteMenu.options({
|
self.$autocompleteMenu.options({
|
||||||
items: $.map(values, function(v, i) {
|
items: Ox.map(values, function(v, i) {
|
||||||
if (value == v.toLowerCase()) {
|
var ret = null;
|
||||||
selected = i;
|
if (
|
||||||
|
!self.options.autocompleteSelectMax ||
|
||||||
|
i < self.options.autocompleteSelectMax
|
||||||
|
) {
|
||||||
|
if (value == v.toLowerCase()) {
|
||||||
|
selected = i;
|
||||||
|
}
|
||||||
|
ret = {
|
||||||
|
id: v.toLowerCase().replace(/ /g, '_'), // fixme: need function to do lowercase, underscores etc?
|
||||||
|
title: self.options.autocompleteSelectHighlight ?
|
||||||
|
Ox.highlight(v, value, 'OxHighlight') : v
|
||||||
|
};
|
||||||
}
|
}
|
||||||
return {
|
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
|
|
||||||
};
|
|
||||||
}),
|
}),
|
||||||
selected: selected
|
selected: selected
|
||||||
}).showMenu();
|
}).showMenu();
|
||||||
|
@ -404,7 +411,7 @@ Ox.Input = function(options, self) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if (Ox.isRegExp(self.options.autovalidate)) {
|
} else if (Ox.isRegExp(self.options.autovalidate)) {
|
||||||
autovalidateCallback(autovalidateFunction(self.options.value));
|
autovalidateCallback(autovalidateFunction(self.options.value));
|
||||||
} else {
|
} else {
|
||||||
autovalidateTypeFunction(self.options.type, self.options.value);
|
autovalidateTypeFunction(self.options.type, self.options.value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -462,6 +462,7 @@ Ox.VideoEditor = function(options, self) {
|
||||||
autocomplete: self.words,
|
autocomplete: self.words,
|
||||||
autocompleteSelect: true,
|
autocompleteSelect: true,
|
||||||
autocompleteSelectHighlight: true,
|
autocompleteSelectHighlight: true,
|
||||||
|
autocompleteSelectMax: 10,
|
||||||
autocompleteSelectSubmit: true,
|
autocompleteSelectSubmit: true,
|
||||||
changeOnKeypress: true,
|
changeOnKeypress: true,
|
||||||
placeholder: 'Find...',
|
placeholder: 'Find...',
|
||||||
|
|
Loading…
Reference in a new issue