Changeset - c47ab93fdc72
[Not reviewed]
default
0 1 0
Mads Kiilerich - 8 years ago 2017-09-15 03:06:30
mads@kiilerich.com
autocomplete: highlight the matched search string - use select2-match class as select2 itself does
1 file changed with 2 insertions and 2 deletions:
0 comments (0 inline, 0 general)
kallithea/public/js/base.js
Show inline comments
 
@@ -1061,27 +1061,27 @@ var autocompleteMatchGroups = function (
 
        }
 
    }
 
    return matches;
 
};
 

	
 
// Highlight the snippet if it is found in the full text.
 
// Snippet must be lowercased already.
 
var autocompleteHighlightMatch = function (full, snippet) {
 
    var matchindex = full.toLowerCase().indexOf(snippet);
 
    if (matchindex <0)
 
        return full;
 
    return full.substring(0, matchindex)
 
        + "<span class='match'>"
 
        + '<span class="select2-match">'
 
        + full.substr(matchindex, snippet.length)
 
        + "</span>" + full.substring(matchindex + snippet.length);
 
        + '</span>' + full.substring(matchindex + snippet.length);
 
};
 

	
 
// Return html snippet for showing the provided gravatar url
 
var gravatar = function(gravatar_lnk, size, cssclass) {
 
    if (!gravatar_lnk) {
 
        return '';
 
    }
 
    if (gravatar_lnk == 'default') {
 
        return '<i class="icon-user {1}" style="font-size: {0}px;"></i>'.format(size, cssclass);
 
    }
 
    return '<img alt="" class="{2}" style="width: {0}px; height: {0}px" src="{1}"/>'.format(size, gravatar_lnk, cssclass);
 
}
0 comments (0 inline, 0 general)