diff --git a/app/assets/javascripts/sitewide/atwho_res.js.erb b/app/assets/javascripts/sitewide/atwho_res.js.erb index b6a5f447d..82c571af9 100644 --- a/app/assets/javascripts/sitewide/atwho_res.js.erb +++ b/app/assets/javascripts/sitewide/atwho_res.js.erb @@ -49,63 +49,26 @@ var SmartAnnotation = (function() { DEFAULT_SEARCH_FILTER = FilterTypeEnum.REPOSITORY, atWhoUpdating = false; - var defaultRepId; + function _matchHighlighter(html, query, filterType) { + var $html = $(html); + var $li_text = $html.find('.item-text'); - // helper methods for AtWho callback - function _templateEval(_tpl, map) { - var res; - try { - res = generateTemplate(map); - } catch (_error) { - res = ''; - } - return res; - } + if ($li_text.length === 0 || !query) return html; - function _matchHighlighter(li, query, filterType) { - var $li, re; + $.each($li_text, function(i, item) { + $(item).html($(item).text().replace(new RegExp(query, 'gi'), '$&')); + }) - function highlight(el, sel, re) { - var prevVal, newVal; - prevVal = el.find(sel).html(); - newVal = prevVal.replace(re, '$&'); - el.find(sel).html(newVal); - } - - if (!query || $(li).data('no-results')) { - return li; - } - - $li = $(li); - re = new RegExp(query, 'gi'); - // search_filter is not passed for the user - if(filterType) { - highlight($li, '[data-val=name]', re); - } else { - highlight($li, '[data-val=full-name]', re); - highlight($li, '[data-val=email]', re); - } - - return $li[0].outerHTML + return $html; } function _generateInputTag(value, li) { return `[#${li.attr('data-name')}~${li.attr('data-type')}~${li.attr('data-id')}]`; } - // initialise dropdown dismiss button - function initDismissButton($currentAtWho) { - $currentAtWho.find('.dismiss').off('click') - .on('click', function() { - $(field).atwho('destroy'); - init(); - }); - } - // Generates suggestion dropdown filter function generateFilterMenu(active, res_data) { var menu = ''; - var rep_buttons = ''; $.ajax({ async: false, dataType: 'json', @@ -117,17 +80,6 @@ var SmartAnnotation = (function() { return menu; } - function noResultsTemplate() { - return `