summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTulio Casagrande <tcasagra@thoughtworks.com>2016-06-13 17:46:33 -0300
committerTulio Casagrande <tcasagra@thoughtworks.com>2016-06-13 17:46:33 -0300
commitcd354c295e088d24a521b6df93b73133602513af (patch)
treef8b0be9a149cc3344e899abc4b5c4055db5549cb
parentc384e5ff9b3bf1527732cf765b50dc436b36c8e1 (diff)
Change blur to focusout on recipients_input
Fix: #631
-rw-r--r--web-ui/app/js/mail_view/ui/recipients/recipients_input.js2
-rw-r--r--web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js48
2 files changed, 25 insertions, 25 deletions
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 62bc9c4a..8a9c4eaf 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
@@ -166,7 +166,7 @@ define([
self = this;
this.init();
this.on('typeahead:selected typeahead:autocompleted', this.recipientSelected);
- this.on(this.$node, 'blur', this.tokenizeRecipient);
+ this.on(this.$node, 'focusout', this.tokenizeRecipient);
this.on(this.$node, 'keydown', this.processSpecialKey);
this.on(this.$node, 'keyup', this.warnSendButtonOfInputState);
diff --git a/web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js b/web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js
index 829bf890..07a20204 100644
--- a/web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js
+++ b/web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js
@@ -109,20 +109,20 @@ describeComponent('mail_view/ui/recipients/recipients_input',function () {
});
});
- describe('on blur', function() {
- var addressEnteredEvent, blurEvent;
+ describe('on focusout', function() {
+ var addressEnteredEvent, focusoutEvent;
beforeEach(function() {
addressEnteredEvent = spyOnEvent(this.$node, Pixelated.events.ui.recipients.entered);
- blurEvent = $.Event('blur');
- spyOn(blurEvent, 'preventDefault');
+ focusoutEvent = $.Event('focusout');
+ spyOn(focusoutEvent, 'preventDefault');
});
it('tokenizes and sanitize recipient email if there is an input val', function() {
this.$node.val('a@b.c, Friend <friend@domain.com>; d@e.f , , , , , , , ,');
- this.$node.trigger(blurEvent);
+ this.$node.trigger(focusoutEvent);
- expect(blurEvent.preventDefault).toHaveBeenCalled();
+ expect(focusoutEvent.preventDefault).toHaveBeenCalled();
expect(addressEnteredEvent.callCount).toEqual(3);
expect(addressEnteredEvent.calls[0].data).toEqual({name: 'to', address: 'a@b.c'});
@@ -132,9 +132,9 @@ describeComponent('mail_view/ui/recipients/recipients_input',function () {
it('tokenizes and sanitize adresses separated by space, comma and semicolon', function() {
this.$node.val('a@b.c Friend <friend@domain.com>, d@e.f; g@h.i');
- this.$node.trigger(blurEvent);
+ this.$node.trigger(focusoutEvent);
- expect(blurEvent.preventDefault).toHaveBeenCalled();
+ expect(focusoutEvent.preventDefault).toHaveBeenCalled();
expect(addressEnteredEvent.callCount).toEqual(4);
expect(addressEnteredEvent.calls[0].data).toEqual({name: 'to', address: 'a@b.c'});
@@ -145,61 +145,61 @@ describeComponent('mail_view/ui/recipients/recipients_input',function () {
});
describe('validate email format', function() {
- var invalidAddressEnteredEvent, addressEnteredEvent, blurEvent;
+ var invalidAddressEnteredEvent, addressEnteredEvent, focusoutEvent;
beforeEach(function () {
invalidAddressEnteredEvent = spyOnEvent(this.$node, Pixelated.events.ui.recipients.enteredInvalid);
addressEnteredEvent = spyOnEvent(this.$node, Pixelated.events.ui.recipients.entered);
- blurEvent = $.Event('blur');
- spyOn(blurEvent, 'preventDefault');
+ focusoutEvent = $.Event('focusout');
+ spyOn(focusoutEvent, 'preventDefault');
});
it('displays it as an invalid address token', function() {
this.$node.val('invalid');
- this.$node.trigger(blurEvent);
+ this.$node.trigger(focusoutEvent);
- expect(blurEvent.preventDefault).toHaveBeenCalled();
+ expect(focusoutEvent.preventDefault).toHaveBeenCalled();
expect(invalidAddressEnteredEvent).toHaveBeenTriggeredOnAndWith(this, { name: 'to', address: 'invalid' });
});
it('displays it as an invalid address token when cannot parse', function() {
this.$node.val('invalid_format, email@example.com');
- this.$node.trigger(blurEvent);
+ this.$node.trigger(focusoutEvent);
- expect(blurEvent.preventDefault).toHaveBeenCalled();
+ expect(focusoutEvent.preventDefault).toHaveBeenCalled();
expect(invalidAddressEnteredEvent.calls[0].data).toEqual({name: 'to', address: 'invalid_format'});
expect(addressEnteredEvent.calls[0].data).toEqual({name: 'to', address: 'email@example.com'});
});
it('displays it as an invalid address token when domain isn`t complete', function() {
this.$node.val('email@example');
- this.$node.trigger(blurEvent);
+ this.$node.trigger(focusoutEvent);
- expect(blurEvent.preventDefault).toHaveBeenCalled();
+ expect(focusoutEvent.preventDefault).toHaveBeenCalled();
expect(invalidAddressEnteredEvent.calls[0].data).toEqual({name: 'to', address: 'email@example'});
});
it('displays it as an invalid address token when cannonical email domain isn`t complete', function() {
this.$node.val('Invalid <email@example>');
- this.$node.trigger(blurEvent);
+ this.$node.trigger(focusoutEvent);
- expect(blurEvent.preventDefault).toHaveBeenCalled();
+ expect(focusoutEvent.preventDefault).toHaveBeenCalled();
expect(invalidAddressEnteredEvent.calls[0].data).toEqual({name: 'to', address: 'Invalid <email@example>'});
});
it('parses email with dash' , function() {
this.$node.val('team@pixelated-project.org');
- this.$node.trigger(blurEvent);
+ this.$node.trigger(focusoutEvent);
- expect(blurEvent.preventDefault).toHaveBeenCalled();
+ expect(focusoutEvent.preventDefault).toHaveBeenCalled();
expect(addressEnteredEvent.calls[0].data).toEqual({name: 'to', address: 'team@pixelated-project.org'});
});
-
+
it('parses cannonical email with dash' , function() {
this.$node.val('Pixelated <team@pixelated-project.org>');
- this.$node.trigger(blurEvent);
+ this.$node.trigger(focusoutEvent);
- expect(blurEvent.preventDefault).toHaveBeenCalled();
+ expect(focusoutEvent.preventDefault).toHaveBeenCalled();
expect(addressEnteredEvent.calls[0].data).toEqual({name: 'to', address: 'Pixelated <team@pixelated-project.org>'});
});
});