Autocomplete on each recipient when composing a huddle.

(imported from commit 0a95f431d960f8a39544d4598fd859a8090fbfa3)
This commit is contained in:
Jessica McKellar 2012-10-05 17:39:13 -04:00
parent 9ecb978388
commit 321c2df67e
1 changed files with 18 additions and 1 deletions

View File

@ -91,7 +91,24 @@ function update_autocomplete() {
});
$( "#recipient" ).typeahead({
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;