(function() { 'use strict'; $(document).on( 'focus', '[data-atwho-users-edit]', function() { if (_.isUndefined($(this).data('atwho'))) { $(this) .atwho({ at: '@', callbacks: { remoteFilter: function(query, callback) { $.getJSON( '/organizations/1/atwho_users.json', {query: query}, function(data) { callback(data.users); } ); }, tplEval: function(_tpl, map) { var res; try { res = ''; res += '
  • '; res += ''; res += ' '; res += ''; res += map.full_name; res += ''; res += ' '; res += ''; res += ' '; res += ''; res += map.email; res += ''; res += '
  • '; } catch (_error) { res = ''; } return res; }, highlighter: function(li, query) { var li2 = $(li); li2.addClass('highlighted'); var prevVal = li2 .find('[data-full-name]') .html(); var newVal = prevVal .replace(query, '' + query + ''); li2.find('[data-full-name]').html(newVal); prevVal = li2 .find('[data-email]') .html(); newVal = prevVal .replace(query, '' + query + ''); li2.find('[data-email]').html(newVal); return li2.html(); } }, insertTpl: '[${atwho-at}${full_name}~${id}]', limit: 5, startWithSpace: true }); } }); })();