typeahead: Move highlight_with_escaping into render_person.

This commit is contained in:
Akhil
2017-06-08 04:30:21 +00:00
committed by Tim Abbott
parent 202f01b06c
commit cc0dbef5a4
3 changed files with 9 additions and 8 deletions

View File

@@ -342,8 +342,7 @@ exports.content_highlighter = function (item) {
if (this.completing === 'emoji') {
return "<img class='emoji' src='" + item.emoji_url + "' /> " + item.emoji_name;
} else if (this.completing === 'mention') {
var item_formatted = typeahead_helper.render_person(item);
return typeahead_helper.highlight_with_escaping(this.token, item_formatted);
return typeahead_helper.render_person(this.token, item);
} else if (this.completing === 'stream') {
return typeahead_helper.render_stream(this.token, item);
} else if (this.completing === 'syntax') {
@@ -502,8 +501,7 @@ exports.initialize = function () {
fixed: true,
highlighter: function (item) {
var query = get_last_recipient_in_pm(this.query);
var item_formatted = typeahead_helper.render_person(item);
return typeahead_helper.highlight_with_escaping(query, item_formatted);
return typeahead_helper.render_person(query, item);
},
matcher: function (item) {
var current_recipient = get_last_recipient_in_pm(this.query);

View File

@@ -183,8 +183,7 @@ function show_subscription_settings(sub_row) {
source: people.get_realm_persons, // This is a function.
items: 5,
highlighter: function (item) {
var item_formatted = typeahead_helper.render_person(item);
return typeahead_helper.highlight_with_escaping(this.query, item_formatted);
return typeahead_helper.render_person(this.query, item);
},
matcher: function (item) {
var query = $.trim(this.query.toLowerCase());

View File

@@ -69,11 +69,15 @@ exports.highlight_query_in_phrase = function (query, phrase) {
return result;
};
exports.render_person = function (person) {
exports.render_person = function (token, person) {
if (person.special_item_text) {
return person.special_item_text;
}
return person.full_name + " <" + person.email + ">";
var full_name = exports.highlight_with_escaping(token, person.full_name);
var email = exports.highlight_with_escaping(token, person.email);
return full_name + " <" + email + ">";
};
exports.render_stream = function (token, stream) {