From 7bbc79dd46f8b23961d6abc9567dc66365d03398 Mon Sep 17 00:00:00 2001 From: Pedro Vereza Date: Fri, 24 Oct 2014 09:57:15 -0200 Subject: Issue #78 - Tokenize emails on blur --- .../app/js/mail_view/ui/recipients/recipients_input.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'web-ui/app') diff --git a/web-ui/app/js/mail_view/ui/recipients/recipients_input.js b/web-ui/app/js/mail_view/ui/recipients/recipients_input.js index e39ebf6a..a74e871e 100644 --- a/web-ui/app/js/mail_view/ui/recipients/recipients_input.js +++ b/web-ui/app/js/mail_view/ui/recipients/recipients_input.js @@ -102,10 +102,8 @@ define([ } if (isEnterAddressKey(keyPressed)) { - if (!_.isEmpty(this.$node.val())) { - this.recipientSelected(null, { value: this.$node.val() }); - event.preventDefault(); - } + this.tokenizeRecipient(event); + if((keyPressed !== 9 /* tab */)) { event.preventDefault(); } @@ -113,6 +111,15 @@ define([ }; + this.tokenizeRecipient = function (event) { + if (_.isEmpty(this.$node.val())) { + return; + } + + this.recipientSelected(null, {value: this.$node.val() }); + event.preventDefault(); + } + this.recipientSelected = function (event, data) { var value = (data && data.value) || this.$node.val(); @@ -141,11 +148,11 @@ define([ this.trigger(document, toTrigger, { name: this.attr.name }); }; - this.after('initialize', function () { self = this; this.init(); this.on('typeahead:selected typeahead:autocompleted', this.recipientSelected); + this.on(this.$node, 'blur', this.tokenizeRecipient); this.on(this.$node, 'keydown', this.processSpecialKey); this.on(this.$node, 'keyup', this.warnSendButtonOfInputState); -- cgit v1.2.3