Allow to hightlight matches
This commit is contained in:
parent
f858ee43ea
commit
b5bd497a1f
1 changed files with 11 additions and 0 deletions
|
@ -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'>"
|
||||
|
|
Loading…
Reference in a new issue