mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 12:33:40 +00:00
Move get_cleaned_pm_recipients() to helper module.
This break's typeahead_helper's dependency on composebox_typeahead.
This commit is contained in:
@@ -13,16 +13,6 @@ var composebox_typeahead = (function () {
|
||||
|
||||
var exports = {};
|
||||
|
||||
// Returns an array of private message recipients, removing empty elements.
|
||||
// For example, "a,,b, " => ["a", "b"]
|
||||
exports.get_cleaned_pm_recipients = function (query_string) {
|
||||
var recipients = util.extract_pm_recipients(query_string);
|
||||
recipients = _.filter(recipients, function (elem) {
|
||||
return elem.match(/\S/);
|
||||
});
|
||||
return recipients;
|
||||
};
|
||||
|
||||
var seen_topics = new Dict();
|
||||
|
||||
exports.add_topic = function (uc_stream, uc_topic) {
|
||||
@@ -483,7 +473,7 @@ exports.initialize = function () {
|
||||
this.query, matches, current_stream);
|
||||
},
|
||||
updater: function (item, event) {
|
||||
var previous_recipients = exports.get_cleaned_pm_recipients(this.query);
|
||||
var previous_recipients = typeahead_helper.get_cleaned_pm_recipients(this.query);
|
||||
previous_recipients.pop();
|
||||
previous_recipients = previous_recipients.join(", ");
|
||||
if (previous_recipients.length !== 0) {
|
||||
@@ -501,7 +491,7 @@ exports.initialize = function () {
|
||||
|
||||
$( "#private_message_recipient" ).blur(function () {
|
||||
var val = $(this).val();
|
||||
var recipients = exports.get_cleaned_pm_recipients(val);
|
||||
var recipients = typeahead_helper.get_cleaned_pm_recipients(val);
|
||||
$(this).val(recipients.join(", "));
|
||||
});
|
||||
};
|
||||
|
||||
@@ -2,6 +2,17 @@ var typeahead_helper = (function () {
|
||||
|
||||
var exports = {};
|
||||
|
||||
// Returns an array of private message recipients, removing empty elements.
|
||||
// For example, "a,,b, " => ["a", "b"]
|
||||
exports.get_cleaned_pm_recipients = function (query_string) {
|
||||
var recipients = util.extract_pm_recipients(query_string);
|
||||
recipients = _.filter(recipients, function (elem) {
|
||||
return elem.match(/\S/);
|
||||
});
|
||||
return recipients;
|
||||
};
|
||||
|
||||
|
||||
// Loosely based on Bootstrap's default highlighter, but with escaping added.
|
||||
exports.highlight_with_escaping = function (query, item) {
|
||||
// query: The text currently in the searchbox
|
||||
@@ -213,7 +224,7 @@ exports.sort_streams = function (matches, query) {
|
||||
|
||||
exports.sort_recipientbox_typeahead = function (query, matches, current_stream) {
|
||||
// input_text may be one or more pm recipients
|
||||
var cleaned = composebox_typeahead.get_cleaned_pm_recipients(query);
|
||||
var cleaned = exports.get_cleaned_pm_recipients(query);
|
||||
query = cleaned[cleaned.length - 1];
|
||||
return exports.sort_recipients(matches, query, current_stream);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user