2
0
mirror of https://github.com/devbridge/jQuery-Autocomplete.git synced 2024-12-23 03:18:55 +00:00

fix(jquery): support for latest 3.3 release

This commit is contained in:
Daniele Scasciafratte 2023-05-17 13:19:47 +02:00
parent 8138252b4c
commit b16a107f46

View File

@ -131,7 +131,7 @@
}; };
function _transformResult(response) { function _transformResult(response) {
return typeof response === 'string' ? $.parseJSON(response) : response; return typeof response === 'string' ? JSON.parse(response) : response;
}; };
function _formatResult(suggestion, currentValue) { function _formatResult(suggestion, currentValue) {
@ -514,7 +514,7 @@
return value; return value;
} }
parts = value.split(delimiter); parts = value.split(delimiter);
return $.trim(parts[parts.length - 1]); return String.prototype.trim(parts[parts.length - 1]);
}, },
getSuggestionsLocal: function (query) { getSuggestionsLocal: function (query) {
@ -555,7 +555,7 @@
params = options.ignoreParams ? null : options.params; params = options.ignoreParams ? null : options.params;
if ($.isFunction(options.lookup)){ if (typeof options.lookup === "function"){
options.lookup(q, function (data) { options.lookup(q, function (data) {
that.suggestions = data.suggestions; that.suggestions = data.suggestions;
that.suggest(); that.suggest();
@ -567,7 +567,7 @@
if (that.isLocal) { if (that.isLocal) {
response = that.getSuggestionsLocal(q); response = that.getSuggestionsLocal(q);
} else { } else {
if ($.isFunction(serviceUrl)) { if (typeof serviceUrl === "function") {
serviceUrl = serviceUrl.call(that.element, q); serviceUrl = serviceUrl.call(that.element, q);
} }
cacheKey = serviceUrl + '?' + $.param(params || {}); cacheKey = serviceUrl + '?' + $.param(params || {});
@ -625,7 +625,7 @@
var that = this, var that = this,
container = $(that.suggestionsContainer); container = $(that.suggestionsContainer);
if ($.isFunction(that.options.onHide) && that.visible) { if (typeof that.options.onHide === "function" && that.visible) {
that.options.onHide.call(that.element, container); that.options.onHide.call(that.element, container);
} }
@ -689,7 +689,7 @@
noSuggestionsContainer.detach(); noSuggestionsContainer.detach();
container.html(html); container.html(html);
if ($.isFunction(beforeRender)) { if (typeof beforeRender === "function") {
beforeRender.call(that.element, container, that.suggestions); beforeRender.call(that.element, container, that.suggestions);
} }
@ -723,7 +723,7 @@
container.empty(); container.empty();
container.append(noSuggestionsContainer); container.append(noSuggestionsContainer);
if ($.isFunction(beforeRender)) { if (typeof beforeRender === "function") {
beforeRender.call(that.element, container, that.suggestions); beforeRender.call(that.element, container, that.suggestions);
} }
@ -783,7 +783,7 @@
if (that.hintValue !== hintValue) { if (that.hintValue !== hintValue) {
that.hintValue = hintValue; that.hintValue = hintValue;
that.hint = suggestion; that.hint = suggestion;
if ($.isFunction(onHintCallback)) { if (typeof onHintCallback === "function") {
onHintCallback.call(that.element, hintValue); onHintCallback.call(that.element, hintValue);
} }
} }
@ -801,7 +801,7 @@
}, },
validateOrientation: function(orientation, fallback) { validateOrientation: function(orientation, fallback) {
orientation = $.trim(orientation || '').toLowerCase(); orientation = String.prototype.trim(orientation || '').toLowerCase();
if($.inArray(orientation, ['auto', 'bottom', 'top']) === -1){ if($.inArray(orientation, ['auto', 'bottom', 'top']) === -1){
orientation = fallback; orientation = fallback;
@ -945,7 +945,7 @@
that.suggestions = []; that.suggestions = [];
that.selection = suggestion; that.selection = suggestion;
if ($.isFunction(onSelectCallback)) { if (typeof onSelectCallback === "function") {
onSelectCallback.call(that.element, suggestion); onSelectCallback.call(that.element, suggestion);
} }
}, },