2
0
mirror of https://github.com/devbridge/jQuery-Autocomplete.git synced 2024-11-09 23:01:00 +00:00

Rev for 1.2.14 release

This commit is contained in:
Tomas Kirda 2014-09-21 22:18:09 -05:00
parent fb920860c5
commit d71867a090
4 changed files with 21 additions and 4 deletions

View File

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

View File

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

View File

@ -1,5 +1,5 @@
/** /**
* Ajax Autocomplete for jQuery, version 1.2.13 * Ajax Autocomplete for jQuery, version 1.2.14
* (c) 2014 Tomas Kirda * (c) 2014 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.
@ -613,6 +613,7 @@
var that = this, var that = this,
options = that.options, options = that.options,
groupBy = options.groupBy,
formatResult = options.formatResult, formatResult = options.formatResult,
value = that.getQuery(that.currentValue), value = that.getQuery(that.currentValue),
className = that.classes.suggestion, className = that.classes.suggestion,
@ -621,6 +622,18 @@
noSuggestionsContainer = $(that.noSuggestionsContainer), noSuggestionsContainer = $(that.noSuggestionsContainer),
beforeRender = options.beforeRender, beforeRender = options.beforeRender,
html = '', html = '',
category,
formatGroup = function (suggestion, index) {
var currentCategory = suggestion.data[groupBy];
if (category === currentCategory){
return '';
}
category = currentCategory;
return '<div class="autocomplete-group"><strong>' + category + '</strong></div>';
},
index; index;
if (options.triggerSelectOnValidInput) { if (options.triggerSelectOnValidInput) {
@ -633,6 +646,10 @@
// Build suggestions inner HTML: // Build suggestions inner HTML:
$.each(that.suggestions, function (i, suggestion) { $.each(that.suggestions, function (i, suggestion) {
if (groupBy){
html += formatGroup(suggestion, value, i);
}
html += '<div class="' + className + '" data-index="' + i + '">' + formatResult(suggestion, value) + '</div>'; html += '<div class="' + className + '" data-index="' + i + '">' + formatResult(suggestion, value) + '</div>';
}); });

View File

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