Skip to content

Commit 95a329d

Browse files
author
Tomas Kirda
committed
Rev for 1.2.25 release
1 parent 3f53453 commit 95a329d

File tree

5 files changed

+18
-10
lines changed

5 files changed

+18
-10
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.24",
3+
"version": "1.2.25",
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.24",
9+
"version": "1.2.25",
1010
"author": {
1111
"name": "Tomas Kirda",
1212
"url": "https://github.com/tkirda"

dist/jquery.autocomplete.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Ajax Autocomplete for jQuery, version 1.2.24
2+
* Ajax Autocomplete for jQuery, version 1.2.25
33
* (c) 2015 Tomas Kirda
44
*
55
* Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.
@@ -127,8 +127,13 @@
127127
$.Autocomplete = Autocomplete;
128128

129129
Autocomplete.formatResult = function (suggestion, currentValue) {
130-
var pattern = '(' + utils.escapeRegExChars(currentValue) + ')';
130+
// Do not replace anything if there current value is empty
131+
if (!currentValue) {
132+
return suggestion.value;
133+
}
131134

135+
var pattern = '(' + utils.escapeRegExChars(currentValue) + ')';
136+
132137
return suggestion.value
133138
.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>')
134139
.replace(/&/g, '&amp;')
@@ -188,6 +193,7 @@
188193
// Listen for click event on suggestions list:
189194
container.on('click.autocomplete', suggestionSelector, function () {
190195
that.select($(this).data('index'));
196+
return false;
191197
});
192198

193199
that.fixPositionCapture = function () {
@@ -208,8 +214,10 @@
208214

209215
onFocus: function () {
210216
var that = this;
217+
211218
that.fixPosition();
212-
if (that.options.minChars === 0 && that.el.val().length === 0) {
219+
220+
if (that.el.val().length >= that.options.minChars) {
213221
that.onValueChange();
214222
}
215223
},
@@ -672,7 +680,7 @@
672680
html += formatGroup(suggestion, value, i);
673681
}
674682

675-
html += '<div class="' + className + '" data-index="' + i + '">' + formatResult(suggestion, value) + '</div>';
683+
html += '<div class="' + className + '" data-index="' + i + '">' + formatResult(suggestion, value, i) + '</div>';
676684
});
677685

678686
this.adjustContainerWidth();
@@ -681,7 +689,7 @@
681689
container.html(html);
682690

683691
if ($.isFunction(beforeRender)) {
684-
beforeRender.call(that.element, container, that.sugestions);
692+
beforeRender.call(that.element, container, that.suggestions);
685693
}
686694

687695
that.fixPosition();

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.24",
3+
"version": "1.2.25",
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)