2
0
mirror of https://github.com/devbridge/jQuery-Autocomplete.git synced 2024-11-29 08:14:06 +00:00

Fix spacing and jslint code

This commit is contained in:
Tomas Kirda 2012-11-08 15:17:10 -06:00
parent b31504a027
commit b4de69f24f

View File

@ -1,6 +1,6 @@
/** /**
* Ajax Autocomplete for jQuery, version 1.1.5 * Ajax Autocomplete for jQuery, version 1.1.5
* (c) 2010 Tomas Kirda, Vytautas Pranskunas * (c) 2012 Tomas Kirda, Vytautas Pranskunas
* *
* Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license. * Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.
* For details, see the web site: http://www.devbridge.com/projects/autocomplete/jquery/ * For details, see the web site: http://www.devbridge.com/projects/autocomplete/jquery/
@ -8,10 +8,11 @@
* Last Review: 07/24/2012 * Last Review: 07/24/2012
*/ */
/*jslint onevar: true, evil: true, nomen: true, eqeqeq: true, bitwise: true, regexp: true, newcap: true, immed: true */ /*jslint browser: true, white: true, plusplus: true */
/*global window: true, document: true, clearInterval: true, setInterval: true, jQuery: true */ /*global window: true, document: true, clearInterval: true, setInterval: true, jQuery: true */
(function ($) { (function ($) {
'use strict';
var reEscape = new RegExp('(\\' + ['/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\'].join('|\\') + ')', 'g'); var reEscape = new RegExp('(\\' + ['/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\'].join('|\\') + ')', 'g');
@ -56,9 +57,9 @@
var autocompleteControl; var autocompleteControl;
if (typeof options == 'string') { if (typeof options === 'string') {
autocompleteControl = this.data('autocomplete'); autocompleteControl = this.data('autocomplete');
if (typeof autocompleteControl[options] == 'function') { if (typeof autocompleteControl[options] === 'function') {
autocompleteControl[options](optionName); autocompleteControl[options](optionName);
} }
} else { } else {
@ -307,6 +308,7 @@
}, },
processResponse: function (text) { processResponse: function (text) {
/*jslint evil: true */
var response; var response;
try { try {
response = eval('(' + text + ')'); response = eval('(' + text + ')');
@ -330,12 +332,16 @@
if (this.selectedIndex !== -1 && divs.length > this.selectedIndex) { if (this.selectedIndex !== -1 && divs.length > this.selectedIndex) {
$(divs.get(this.selectedIndex)).removeClass(); $(divs.get(this.selectedIndex)).removeClass();
} }
this.selectedIndex = index; this.selectedIndex = index;
if (this.selectedIndex !== -1 && divs.length > this.selectedIndex) { if (this.selectedIndex !== -1 && divs.length > this.selectedIndex) {
activeItem = divs.get(this.selectedIndex); activeItem = divs.get(this.selectedIndex);
$(activeItem).addClass('selected'); $(activeItem).addClass('selected');
}
return activeItem; return activeItem;
}
return null;
}, },
deactivate: function (div, index) { deactivate: function (div, index) {
@ -359,11 +365,10 @@
}, },
change: function (i) { change: function (i) {
var selectedValue, fn, me; var selectedValue, fn, me, s, d;
me = this; me = this;
selectedValue = this.suggestions[i]; selectedValue = this.suggestions[i];
if (selectedValue) { if (selectedValue) {
var s, d;
s = me.suggestions[i]; s = me.suggestions[i];
d = me.data[i]; d = me.data[i];
me.el.val(me.getValue(s)); me.el.val(me.getValue(s));
@ -427,7 +432,6 @@
if (arr.length === 1) { return value; } if (arr.length === 1) { return value; }
return currVal.substr(0, currVal.length - arr[arr.length - 1].length) + value; return currVal.substr(0, currVal.length - arr[arr.length - 1].length) + value;
} }
}; };
}(jQuery)); }(jQuery));