From 096df2d3da802e47cb92851e0da23cef0dfafd77 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Thu, 28 Feb 2013 16:20:49 -0500 Subject: [PATCH] typeahead_helper: Rename render_pm_object and cleanup usage. (imported from commit 28bca00802e189daed22dcabba1241ef2625536e) --- zephyr/static/js/search.js | 24 ++++++++++++------------ zephyr/static/js/typeahead_helper.js | 6 +++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/zephyr/static/js/search.js b/zephyr/static/js/search.js index c0b51ce28a..26c841ddf0 100644 --- a/zephyr/static/js/search.js +++ b/zephyr/static/js/search.js @@ -13,23 +13,31 @@ var search_active = false; var labels = []; var mapped = {}; +function get_query(obj) { + return obj.query; +} + +function get_person(obj) { + return typeahead_helper.render_person(obj.query); +} + function render_object_in_parts(obj) { // N.B. action is *not* escaped by the caller switch (obj.action) { case 'search': - return {prefix: 'Find', query: obj.query, suffix: 'in page'}; + return {prefix: 'Find', query: get_query(obj), suffix: 'in page'}; case 'stream': - return {prefix: 'Narrow to stream', query: obj.query, suffix: ''}; + return {prefix: 'Narrow to stream', query: get_query(obj), suffix: ''}; case 'private_message': return {prefix: 'Narrow to private messages with', - query: typeahead_helper.render_pm_object(obj.query), + query: get_person(obj), suffix: ''}; case 'sender': return {prefix: 'Narrow to messages sent by', - query: typeahead_helper.render_pm_object(obj.query), + query: get_person(obj), suffix: ''}; case 'operators': @@ -114,14 +122,6 @@ function narrow_or_search_for_term(item) { return item; } -function get_query(obj) { - return obj.query; -} - -function get_person(obj) { - return typeahead_helper.render_pm_object(obj.query); -} - function searchbox_sorter(items) { var objects_by_action = {}; var result = []; diff --git a/zephyr/static/js/typeahead_helper.js b/zephyr/static/js/typeahead_helper.js index e62077b08f..819dbddc11 100644 --- a/zephyr/static/js/typeahead_helper.js +++ b/zephyr/static/js/typeahead_helper.js @@ -46,12 +46,12 @@ exports.highlight_with_escaping = function (query, item) { exports.private_message_typeahead_list = []; exports.private_message_mapped = {}; -exports.render_pm_object = function (person) { +exports.render_person = function (person) { return person.full_name + " <" + person.email + ">"; }; function add_to_known_recipients(recipient_data, count_towards_autocomplete_preference) { - var name_string = exports.render_pm_object(recipient_data); + var name_string = exports.render_person(recipient_data); if (exports.private_message_mapped[name_string] === undefined) { exports.private_message_mapped[name_string] = recipient_data; exports.private_message_mapped[name_string].count = 0; @@ -63,7 +63,7 @@ function add_to_known_recipients(recipient_data, count_towards_autocomplete_pref } exports.known_to_typeahead = function (recipient_data) { - return exports.private_message_mapped[exports.render_pm_object(recipient_data)] !== undefined; + return exports.private_message_mapped[exports.render_person(recipient_data)] !== undefined; }; exports.update_all_recipients = function (recipients) {