Skip to content

Commit 8d18bda

Browse files
author
Tomas Kirda
committed
Rev for 1.2.26 release
1 parent 25de88e commit 8d18bda

File tree

5 files changed

+21
-16
lines changed

5 files changed

+21
-16
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.25",
3+
"version": "1.2.26",
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.25",
9+
"version": "1.2.26",
1010
"author": {
1111
"name": "Tomas Kirda",
1212
"url": "https://github.com/tkirda"

dist/jquery.autocomplete.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
/**
2-
* Ajax Autocomplete for jQuery, version 1.2.25
2+
* Ajax Autocomplete for jQuery, version 1.2.26
33
* (c) 2015 Tomas Kirda
44
*
55
* Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.
66
* For details, see the web site: https://github.com/devbridge/jQuery-Autocomplete
77
*/
88

9-
/*jslint browser: true, white: true, plusplus: true, vars: true */
9+
/*jslint browser: true, white: true, single: true, this: true, multivar: true */
1010
/*global define, window, document, jQuery, exports, require */
1111

1212
// Expose plugin as an AMD module if AMD loader is present:
1313
(function (factory) {
14-
'use strict';
14+
"use strict";
1515
if (typeof define === 'function' && define.amd) {
1616
// AMD. Register as an anonymous module.
1717
define(['jquery'], factory);
@@ -29,7 +29,7 @@
2929
utils = (function () {
3030
return {
3131
escapeRegExChars: function (value) {
32-
return value.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
32+
return value.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&");
3333
},
3434
createNode: function (containerClass) {
3535
var div = document.createElement('div');
@@ -52,7 +52,7 @@
5252
};
5353

5454
function Autocomplete(el, options) {
55-
var noop = function () { },
55+
var noop = $.noop,
5656
that = this,
5757
defaults = {
5858
ajaxSettings: {},
@@ -158,7 +158,7 @@
158158
that.element.setAttribute('autocomplete', 'off');
159159

160160
that.killerFn = function (e) {
161-
if ($(e.target).closest('.' + that.options.containerClass).length === 0) {
161+
if (!$(e.target).closest('.' + that.options.containerClass).length) {
162162
that.killSuggestions();
163163
that.disableKillerFn();
164164
}
@@ -354,7 +354,13 @@
354354
that.stopKillSuggestions();
355355
that.intervalId = window.setInterval(function () {
356356
if (that.visible) {
357-
that.el.val(that.currentValue);
357+
// No need to restore value when
358+
// preserveInput === true,
359+
// because we did not change it
360+
if (!that.options.preserveInput) {
361+
that.el.val(that.currentValue);
362+
}
363+
358364
that.hide();
359365
}
360366

@@ -635,7 +641,7 @@
635641
},
636642

637643
suggest: function () {
638-
if (this.suggestions.length === 0) {
644+
if (!this.suggestions.length) {
639645
if (this.options.showNoSuggestionNotice) {
640646
this.noSuggestions();
641647
} else {
@@ -733,7 +739,6 @@
733739
// If width is auto, adjust width before displaying suggestions,
734740
// because if instance was created before input had width, it will be zero.
735741
// Also it adjusts if input width has changed.
736-
// -2px to account for suggestions border.
737742
if (options.width === 'auto') {
738743
width = that.el.outerWidth();
739744
container.css('width', width > 0 ? width : 300);
@@ -803,7 +808,7 @@
803808
// Cache results if cache is not disabled:
804809
if (!options.noCache) {
805810
that.cachedResponse[cacheKey] = result;
806-
if (options.preventBadQueries && result.suggestions.length === 0) {
811+
if (options.preventBadQueries && !result.suggestions.length) {
807812
that.badQueries.push(originalQuery);
808813
}
809814
}
@@ -961,7 +966,7 @@
961966
var dataKey = 'autocomplete';
962967
// If function invoked without argument return
963968
// instance of the first matched element:
964-
if (arguments.length === 0) {
969+
if (!arguments.length) {
965970
return this.first().data(dataKey);
966971
}
967972

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