Allow to hightlight matches

This commit is contained in:
Alfredo Sumaran 2016-03-11 20:38:19 -05:00 committed by Jacob Schatz
parent f858ee43ea
commit b5bd497a1f

View file

@ -252,6 +252,8 @@ class GitLabDropdown
if selected
cssClass = "is-active"
text = @highlightTextMatches(text, @filterInput.val())
html = "<li>"
html += "<a href='#{url}' class='#{cssClass}'>"
html += text
@ -260,6 +262,15 @@ class GitLabDropdown
return html
highlightTextMatches: (text, term) ->
occurrences = fuzzaldrinPlus.match(text, term)
textArr = text.split('')
textArr.forEach (character, i, textArr) ->
if i in occurrences
textArr[i] = "<b>#{character}</b>"
textArr.join ''
noResults: ->
html = "<li>"
html += "<a href='#' class='is-focused'>"