mirror of
https://github.com/devbridge/jQuery-Autocomplete.git
synced 2024-11-29 08:14:06 +00:00
Revert "Revert Vytautas commit to restore original spacing"
This reverts commit 57f88e5a64
.
This commit is contained in:
parent
bd7581610d
commit
3d27c27846
@ -1,11 +1,11 @@
|
|||||||
/**
|
/**
|
||||||
* Ajax Autocomplete for jQuery, version 1.1.5
|
* Ajax Autocomplete for jQuery, version 1.1.3
|
||||||
* (c) 2010 Tomas Kirda, Vytautas Pranskunas
|
* (c) 2010 Tomas Kirda
|
||||||
*
|
*
|
||||||
* 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/
|
||||||
*
|
*
|
||||||
* Last Review: 07/24/2012
|
* Last Review: 04/19/2010
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*jslint onevar: true, evil: true, nomen: true, eqeqeq: true, bitwise: true, regexp: true, newcap: true, immed: true */
|
/*jslint onevar: true, evil: true, nomen: true, eqeqeq: true, bitwise: true, regexp: true, newcap: true, immed: true */
|
||||||
@ -31,7 +31,6 @@
|
|||||||
this.intervalId = 0;
|
this.intervalId = 0;
|
||||||
this.cachedResponse = [];
|
this.cachedResponse = [];
|
||||||
this.onChangeInterval = null;
|
this.onChangeInterval = null;
|
||||||
this.onChange = null;
|
|
||||||
this.ignoreValueChange = false;
|
this.ignoreValueChange = false;
|
||||||
this.serviceUrl = options.serviceUrl;
|
this.serviceUrl = options.serviceUrl;
|
||||||
this.isLocal = false;
|
this.isLocal = false;
|
||||||
@ -49,22 +48,10 @@
|
|||||||
};
|
};
|
||||||
this.initialize();
|
this.initialize();
|
||||||
this.setOptions(options);
|
this.setOptions(options);
|
||||||
this.el.data('autocomplete', this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$.fn.autocomplete = function (options, optionName) {
|
$.fn.autocomplete = function(options) {
|
||||||
|
return new Autocomplete(this.get(0)||$('<input />'), options);
|
||||||
var autocompleteControl;
|
|
||||||
|
|
||||||
if (typeof options == 'string') {
|
|
||||||
autocompleteControl = this.data('autocomplete');
|
|
||||||
if (typeof autocompleteControl[options] == 'function') {
|
|
||||||
autocompleteControl[options](optionName);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
autocompleteControl = new Autocomplete(this.get(0) || $('<input />'), options);
|
|
||||||
}
|
|
||||||
return autocompleteControl;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -101,17 +88,12 @@
|
|||||||
this.el.keyup(function(e) { me.onKeyUp(e); });
|
this.el.keyup(function(e) { me.onKeyUp(e); });
|
||||||
this.el.blur(function() { me.enableKillerFn(); });
|
this.el.blur(function() { me.enableKillerFn(); });
|
||||||
this.el.focus(function() { me.fixPosition(); });
|
this.el.focus(function() { me.fixPosition(); });
|
||||||
this.el.change(function () { me.onValueChanged(); });
|
|
||||||
},
|
|
||||||
|
|
||||||
extendOptions: function (options) {
|
|
||||||
$.extend(this.options, options);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
setOptions: function(options){
|
setOptions: function(options){
|
||||||
var o = this.options;
|
var o = this.options;
|
||||||
this.extendOptions(options);
|
$.extend(o, options);
|
||||||
if (o.lookup || o.isLocal) {
|
if(o.lookup){
|
||||||
this.isLocal = true;
|
this.isLocal = true;
|
||||||
if($.isArray(o.lookup)){ o.lookup = { suggestions:o.lookup, data:[] }; }
|
if($.isArray(o.lookup)){ o.lookup = { suggestions:o.lookup, data:[] }; }
|
||||||
}
|
}
|
||||||
@ -157,10 +139,6 @@
|
|||||||
window.clearInterval(this.intervalId);
|
window.clearInterval(this.intervalId);
|
||||||
},
|
},
|
||||||
|
|
||||||
onValueChanged: function () {
|
|
||||||
this.change(this.selectedIndex);
|
|
||||||
},
|
|
||||||
|
|
||||||
onKeyPress: function(e) {
|
onKeyPress: function(e) {
|
||||||
if (this.disabled || !this.enabled) { return; }
|
if (this.disabled || !this.enabled) { return; }
|
||||||
// return will exit the function
|
// return will exit the function
|
||||||
@ -252,9 +230,8 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
getSuggestions: function(q) {
|
getSuggestions: function(q) {
|
||||||
|
|
||||||
var cr, me;
|
var cr, me;
|
||||||
cr = this.isLocal ? this.getSuggestionsLocal(q) : this.cachedResponse[q]; //dadeta this.options.isLocal ||
|
cr = this.isLocal ? this.getSuggestionsLocal(q) : this.cachedResponse[q];
|
||||||
if (cr && $.isArray(cr.suggestions)) {
|
if (cr && $.isArray(cr.suggestions)) {
|
||||||
this.suggestions = cr.suggestions;
|
this.suggestions = cr.suggestions;
|
||||||
this.data = cr.data;
|
this.data = cr.data;
|
||||||
@ -281,7 +258,6 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
suggest: function() {
|
suggest: function() {
|
||||||
|
|
||||||
if (this.suggestions.length === 0) {
|
if (this.suggestions.length === 0) {
|
||||||
this.hide();
|
this.hide();
|
||||||
return;
|
return;
|
||||||
@ -358,25 +334,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
change: function (i) {
|
|
||||||
var selectedValue, fn, me;
|
|
||||||
me = this;
|
|
||||||
selectedValue = this.suggestions[i];
|
|
||||||
if (selectedValue) {
|
|
||||||
var s, d;
|
|
||||||
s = me.suggestions[i];
|
|
||||||
d = me.data[i];
|
|
||||||
me.el.val(me.getValue(s));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
s = '';
|
|
||||||
d = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn = me.options.onChange;
|
|
||||||
if ($.isFunction(fn)) { fn(s, d, me.el); }
|
|
||||||
},
|
|
||||||
|
|
||||||
moveUp: function() {
|
moveUp: function() {
|
||||||
if (this.selectedIndex === -1) { return; }
|
if (this.selectedIndex === -1) { return; }
|
||||||
if (this.selectedIndex === 0) {
|
if (this.selectedIndex === 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user