Skip to content

Commit 7f81f72

Browse files
author
Tomas Kirda
committed
Rev for 1.2.20 release
1 parent ab1c27b commit 7f81f72

File tree

5 files changed

+17
-34
lines changed

5 files changed

+17
-34
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "devbridge-autocomplete",
3-
"version": "1.2.19",
3+
"version": "1.2.20",
44
"homepage": "https://github.com/devbridge/jQuery-Autocomplete",
55
"authors": [
66
"Tomas Kirda"

devbridge-autocomplete.jquery.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"ajax",
77
"autocomplete"
88
],
9-
"version": "1.2.19",
9+
"version": "1.2.20",
1010
"author": {
1111
"name": "Tomas Kirda",
1212
"url": "https://github.com/tkirda"

dist/jquery.autocomplete.js

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Ajax Autocomplete for jQuery, version 1.2.19
2+
* Ajax Autocomplete for jQuery, version 1.2.20
33
* (c) 2015 Tomas Kirda
44
*
55
* Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.
@@ -464,8 +464,7 @@
464464
var that = this,
465465
options = that.options,
466466
value = that.el.val(),
467-
query = that.getQuery(value),
468-
index;
467+
query = that.getQuery(value);
469468

470469
if (that.selection && that.currentValue !== query) {
471470
that.selection = null;
@@ -477,12 +476,9 @@
477476
that.selectedIndex = -1;
478477

479478
// Check existing suggestion for the match before proceeding:
480-
if (options.triggerSelectOnValidInput) {
481-
index = that.findSuggestionIndex(query);
482-
if (index !== -1) {
483-
that.select(index);
484-
return;
485-
}
479+
if (options.triggerSelectOnValidInput && that.isExactMatch(query)) {
480+
that.select(0);
481+
return;
486482
}
487483

488484
if (query.length < options.minChars) {
@@ -492,19 +488,10 @@
492488
}
493489
},
494490

495-
findSuggestionIndex: function (query) {
496-
var that = this,
497-
index = -1,
498-
queryLowerCase = query.toLowerCase();
491+
isExactMatch: function (query) {
492+
var suggestions = this.suggestions;
499493

500-
$.each(that.suggestions, function (i, suggestion) {
501-
if (suggestion.value.toLowerCase() === queryLowerCase) {
502-
index = i;
503-
return false;
504-
}
505-
});
506-
507-
return index;
494+
return (suggestions.length === 1 && suggestions[0].value.toLowerCase() === query.toLowerCase());
508495
},
509496

510497
getQuery: function (value) {
@@ -668,15 +655,11 @@
668655
category = currentCategory;
669656

670657
return '<div class="autocomplete-group"><strong>' + category + '</strong></div>';
671-
},
672-
index;
658+
};
673659

674-
if (options.triggerSelectOnValidInput) {
675-
index = that.findSuggestionIndex(value);
676-
if (index !== -1) {
677-
that.select(index);
678-
return;
679-
}
660+
if (options.triggerSelectOnValidInput && that.isExactMatch(value)) {
661+
that.select(0);
662+
return;
680663
}
681664

682665
// Build suggestions inner HTML:

dist/jquery.autocomplete.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "devbridge-autocomplete",
3-
"version": "1.2.19",
3+
"version": "1.2.20",
44
"description": "Autocomplete provides suggestions while you type into the text field.",
55
"homepage": "https://github.com/devbridge/jQuery-Autocomplete",
66
"author": "Tomas Kirda (https://twitter.com/tkirda)",

0 commit comments

Comments
 (0)