From d71867a09026032a1e0e88aeaec0ca66fab473f2 Mon Sep 17 00:00:00 2001 From: Tomas Kirda Date: Sun, 21 Sep 2014 22:18:09 -0500 Subject: [PATCH] Rev for 1.2.14 release --- bower.json | 2 +- devbridge-autocomplete.jquery.json | 2 +- dist/jquery.autocomplete.js | 19 ++++++++++++++++++- package.json | 2 +- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/bower.json b/bower.json index 5d28288..45d74a0 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "devbridge-autocomplete", - "version": "1.2.13", + "version": "1.2.14", "homepage": "https://github.com/devbridge/jQuery-Autocomplete", "authors": [ "Tomas Kirda" diff --git a/devbridge-autocomplete.jquery.json b/devbridge-autocomplete.jquery.json index 040267a..ade1d79 100644 --- a/devbridge-autocomplete.jquery.json +++ b/devbridge-autocomplete.jquery.json @@ -6,7 +6,7 @@ "ajax", "autocomplete" ], - "version": "1.2.13", + "version": "1.2.14", "author": { "name": "Tomas Kirda", "url": "https://github.com/tkirda" diff --git a/dist/jquery.autocomplete.js b/dist/jquery.autocomplete.js index 82ae5af..2004a9d 100644 --- a/dist/jquery.autocomplete.js +++ b/dist/jquery.autocomplete.js @@ -1,5 +1,5 @@ /** -* Ajax Autocomplete for jQuery, version 1.2.13 +* Ajax Autocomplete for jQuery, version 1.2.14 * (c) 2014 Tomas Kirda * * Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license. @@ -613,6 +613,7 @@ var that = this, options = that.options, + groupBy = options.groupBy, formatResult = options.formatResult, value = that.getQuery(that.currentValue), className = that.classes.suggestion, @@ -621,6 +622,18 @@ noSuggestionsContainer = $(that.noSuggestionsContainer), beforeRender = options.beforeRender, html = '', + category, + formatGroup = function (suggestion, index) { + var currentCategory = suggestion.data[groupBy]; + + if (category === currentCategory){ + return ''; + } + + category = currentCategory; + + return '
' + category + '
'; + }, index; if (options.triggerSelectOnValidInput) { @@ -633,6 +646,10 @@ // Build suggestions inner HTML: $.each(that.suggestions, function (i, suggestion) { + if (groupBy){ + html += formatGroup(suggestion, value, i); + } + html += '
' + formatResult(suggestion, value) + '
'; }); diff --git a/package.json b/package.json index 43860c8..9b302cc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "devbridge-autocomplete", - "version": "1.2.13", + "version": "1.2.14", "description": "Autocomplete provides suggestions while you type into the text field.", "homepage": "https://github.com/devbridge/jQuery-Autocomplete", "author": "Tomas Kirda (https://twitter.com/tkirda)",