mirror of https://github.com/zulip/zulip.git
Autocomplete on each recipient when composing a huddle.
(imported from commit 0a95f431d960f8a39544d4598fd859a8090fbfa3)
This commit is contained in:
parent
9ecb978388
commit
321c2df67e
|
@ -91,7 +91,24 @@ function update_autocomplete() {
|
||||||
});
|
});
|
||||||
$( "#recipient" ).typeahead({
|
$( "#recipient" ).typeahead({
|
||||||
source: people_list,
|
source: people_list,
|
||||||
items: 4
|
items: 4,
|
||||||
|
matcher: function (item) {
|
||||||
|
// Assumes we are matching on email addresses, not
|
||||||
|
// e.g. full names which would have spaces.
|
||||||
|
var current_recipient = $(this.query.split(" ")).last()[0];
|
||||||
|
// Case-insensitive (from Bootstrap's default matcher).
|
||||||
|
return (item.toLowerCase().indexOf(current_recipient.toLowerCase()) !== -1);
|
||||||
|
},
|
||||||
|
updater: function (item) {
|
||||||
|
var previous_recipients = this.query.split(" ");
|
||||||
|
previous_recipients.pop();
|
||||||
|
previous_recipients = previous_recipients.join(" ");
|
||||||
|
if (previous_recipients.length !== 0) {
|
||||||
|
previous_recipients += " ";
|
||||||
|
}
|
||||||
|
return previous_recipients + item;
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
autocomplete_needs_update = false;
|
autocomplete_needs_update = false;
|
||||||
|
|
Loading…
Reference in New Issue