2
0
mirror of https://github.com/devbridge/jQuery-Autocomplete.git synced 2024-11-25 06:07:45 +00:00

Rev for 1.2.26 release

This commit is contained in:
Tomas Kirda 2016-07-28 15:52:45 -05:00
parent 25de88ee6b
commit 8d18bdadba
5 changed files with 21 additions and 16 deletions

View File

@ -1,6 +1,6 @@
{
"name": "devbridge-autocomplete",
"version": "1.2.25",
"version": "1.2.26",
"homepage": "https://github.com/devbridge/jQuery-Autocomplete",
"authors": [
"Tomas Kirda"

View File

@ -6,7 +6,7 @@
"ajax",
"autocomplete"
],
"version": "1.2.25",
"version": "1.2.26",
"author": {
"name": "Tomas Kirda",
"url": "https://github.com/tkirda"

View File

@ -1,17 +1,17 @@
/**
* Ajax Autocomplete for jQuery, version 1.2.25
* Ajax Autocomplete for jQuery, version 1.2.26
* (c) 2015 Tomas Kirda
*
* Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.
* For details, see the web site: https://github.com/devbridge/jQuery-Autocomplete
*/
/*jslint browser: true, white: true, plusplus: true, vars: true */
/*jslint browser: true, white: true, single: true, this: true, multivar: true */
/*global define, window, document, jQuery, exports, require */
// Expose plugin as an AMD module if AMD loader is present:
(function (factory) {
'use strict';
"use strict";
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
@ -29,7 +29,7 @@
utils = (function () {
return {
escapeRegExChars: function (value) {
return value.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
return value.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&");
},
createNode: function (containerClass) {
var div = document.createElement('div');
@ -52,7 +52,7 @@
};
function Autocomplete(el, options) {
var noop = function () { },
var noop = $.noop,
that = this,
defaults = {
ajaxSettings: {},
@ -158,7 +158,7 @@
that.element.setAttribute('autocomplete', 'off');
that.killerFn = function (e) {
if ($(e.target).closest('.' + that.options.containerClass).length === 0) {
if (!$(e.target).closest('.' + that.options.containerClass).length) {
that.killSuggestions();
that.disableKillerFn();
}
@ -354,7 +354,13 @@
that.stopKillSuggestions();
that.intervalId = window.setInterval(function () {
if (that.visible) {
that.el.val(that.currentValue);
// No need to restore value when
// preserveInput === true,
// because we did not change it
if (!that.options.preserveInput) {
that.el.val(that.currentValue);
}
that.hide();
}
@ -635,7 +641,7 @@
},
suggest: function () {
if (this.suggestions.length === 0) {
if (!this.suggestions.length) {
if (this.options.showNoSuggestionNotice) {
this.noSuggestions();
} else {
@ -733,7 +739,6 @@
// If width is auto, adjust width before displaying suggestions,
// because if instance was created before input had width, it will be zero.
// Also it adjusts if input width has changed.
// -2px to account for suggestions border.
if (options.width === 'auto') {
width = that.el.outerWidth();
container.css('width', width > 0 ? width : 300);
@ -803,7 +808,7 @@
// Cache results if cache is not disabled:
if (!options.noCache) {
that.cachedResponse[cacheKey] = result;
if (options.preventBadQueries && result.suggestions.length === 0) {
if (options.preventBadQueries && !result.suggestions.length) {
that.badQueries.push(originalQuery);
}
}
@ -961,7 +966,7 @@
var dataKey = 'autocomplete';
// If function invoked without argument return
// instance of the first matched element:
if (arguments.length === 0) {
if (!arguments.length) {
return this.first().data(dataKey);
}

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"name": "devbridge-autocomplete",
"version": "1.2.25",
"version": "1.2.26",
"description": "Autocomplete provides suggestions while you type into the text field.",
"homepage": "https://github.com/devbridge/jQuery-Autocomplete",
"author": "Tomas Kirda (https://twitter.com/tkirda)",