Skip to content

Commit

Permalink
Rev for 1.2.5 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomas Kirda committed Mar 27, 2013
1 parent 7af8d62 commit 364fd6a
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 46 deletions.
2 changes: 1 addition & 1 deletion devbridge-autocomplete.jquery.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"ajax",
"autocomplete"
],
"version": "1.2.3",
"version": "1.2.5",
"author": {
"name": "Tomas Kirda",
"url": "https://github.com/tkirda"
Expand Down
35 changes: 18 additions & 17 deletions dist/jquery.autocomplete.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Ajax Autocomplete for jQuery, version 1.2.4
* Ajax Autocomplete for jQuery, version 1.2.5
* (c) 2013 Tomas Kirda
*
* Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.
Expand Down Expand Up @@ -89,13 +89,13 @@
onSearchComplete: noop,
containerClass: 'autocomplete-suggestions',
tabDisabled: false,
dataType : 'text',
dataType: 'text',
lookupFilter: function (suggestion, originalQuery, queryLowerCase) {
return suggestion.value.toLowerCase().indexOf(queryLowerCase) !== -1;
},
paramName: 'query',
transformResult: function (response) {
return response.suggestions;
return typeof response === 'string' ? $.parseJSON(response) : response;
}
};

Expand Down Expand Up @@ -244,7 +244,7 @@
}

offset = that.el.offset();

$(that.suggestionsContainer).css({
top: (offset.top + that.el.outerHeight()) + 'px',
left: offset.left + 'px'
Expand Down Expand Up @@ -401,15 +401,15 @@
that.suggestions = response.suggestions;
that.suggest();
} else if (!that.isBadQuery(q)) {
options.onSearchStart.call(that.element, q);
options.params[options.paramName] = q;
options.onSearchStart.call(that.element, options.params);
$.ajax({
url: options.serviceUrl,
data: options.params,
type: options.type,
dataType: options.dataType
}).done(function (txt) {
that.processResponse(txt);
}).done(function (data) {
that.processResponse(data, q);
options.onSearchComplete.call(that.element, q);
});
}
Expand Down Expand Up @@ -475,23 +475,24 @@
return suggestions;
},

processResponse: function (text) {
processResponse: function (response, originalQuery) {
var that = this,
response = typeof text == 'string' ? $.parseJSON(text) : text;
options = that.options,
result = options.transformResult(response, originalQuery);

response.suggestions = that.verifySuggestionsFormat(that.options.transformResult(response));
result.suggestions = that.verifySuggestionsFormat(result.suggestions);

// Cache results if cache is not disabled:
if (!that.options.noCache) {
that.cachedResponse[response[that.options.paramName]] = response;
if (response.suggestions.length === 0) {
that.badQueries.push(response[that.options.paramName]);
if (!options.noCache) {
that.cachedResponse[result[options.paramName]] = result;
if (result.suggestions.length === 0) {
that.badQueries.push(result[options.paramName]);
}
}

// Display suggestions only if returned query matches current value:
if (response[that.options.paramName] === that.getQuery(that.currentValue)) {
that.suggestions = response.suggestions;
if (originalQuery === that.getQuery(that.currentValue)) {
that.suggestions = result.suggestions;
that.suggest();
}
},
Expand Down Expand Up @@ -631,4 +632,4 @@
}
});
};
}));
}));
31 changes: 15 additions & 16 deletions dist/jquery.autocomplete.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 364fd6a

Please sign in to comment.