changeset 6804:2f93ca3eab8b

autocomplete: make autocompleteFormatter compatible with select2 The parameters are different, but select2 and the old YAHOO AutoComplete library provide/require pretty much the same functionality. This will allow gradual migration to select2.
author Mads Kiilerich <mads@kiilerich.com>
date Sun, 13 Aug 2017 17:19:18 +0200
parents 3fb0ce6de10d
children 4d7d3445e388
files kallithea/public/js/base.js
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/public/js/base.js	Sun Aug 13 01:59:19 2017 +0200
+++ b/kallithea/public/js/base.js	Sun Aug 13 17:19:18 2017 +0200
@@ -1055,7 +1055,11 @@
 
 // Custom formatter to highlight the matching letters
 var autocompleteFormatter = function (oResultData, sQuery, sResultMatch) {
-    var query = sQuery.toLowerCase();
+    var query;
+    if (sQuery && sQuery.toLowerCase) // YAHOO AutoComplete
+        query = sQuery.toLowerCase();
+    else if (sResultMatch && sResultMatch.term) // select2 - parameter names doesn't match
+        query = sResultMatch.term.toLowerCase();
 
     // group
     if (oResultData.grname != undefined) {