summaryrefslogtreecommitdiff
path: root/web-ui/app/js/mail_view
diff options
context:
space:
mode:
authorGiovane <giovaneliberato@gmail.com>2015-10-23 12:19:19 -0200
committerGiovane <giovaneliberato@gmail.com>2015-10-23 12:23:12 -0200
commit72e332e2969d4eb36c9cd64336c1f1d89b6185f1 (patch)
treecfa8bfe38eb2449a57ebdbe7c0bc3b96da14f075 /web-ui/app/js/mail_view
parent9bc9f6a2ecf6fbb8092a99fa9d6abbfabc0cc800 (diff)
Add invalid address sinalization on tokens #492
Diffstat (limited to 'web-ui/app/js/mail_view')
-rw-r--r--web-ui/app/js/mail_view/ui/recipients/recipient.js10
-rw-r--r--web-ui/app/js/mail_view/ui/recipients/recipients.js6
-rw-r--r--web-ui/app/js/mail_view/ui/recipients/recipients_input.js32
3 files changed, 38 insertions, 10 deletions
diff --git a/web-ui/app/js/mail_view/ui/recipients/recipient.js b/web-ui/app/js/mail_view/ui/recipients/recipient.js
index 487ca9a0..f3db5d4e 100644
--- a/web-ui/app/js/mail_view/ui/recipients/recipient.js
+++ b/web-ui/app/js/mail_view/ui/recipients/recipient.js
@@ -72,6 +72,10 @@ define(
return this.$node.find('.recipient-value').hasClass('selected');
};
+ this.sinalizeInvalid = function () {
+ this.$node.find('.recipient-value>span').addClass('invalid-format');
+ };
+
this.discoverEncryption = function () {
this.$node.addClass('discorver-encryption');
var p = $.getJSON('/keys?search=' + this.attr.address).promise();
@@ -96,8 +100,12 @@ define(
this.after('initialize', function () {
this.recipientDelActions();
- this.discoverEncryption();
this.on('dblclick', this.editRecipient);
+ if (this.attr.invalidAddress){
+ this.sinalizeInvalid();
+ } else {
+ this.discoverEncryption();
+ }
});
}
}
diff --git a/web-ui/app/js/mail_view/ui/recipients/recipients.js b/web-ui/app/js/mail_view/ui/recipients/recipients.js
index f5d51d31..7072c09e 100644
--- a/web-ui/app/js/mail_view/ui/recipients/recipients.js
+++ b/web-ui/app/js/mail_view/ui/recipients/recipients.js
@@ -70,6 +70,11 @@ define(
this.addressesUpdated();
};
+ this.invalidRecipientEntered = function(event, recipient) {
+ recipient.invalidAddress = true;
+ this.addRecipient(recipient);
+ };
+
this.deleteRecipient = function (event, recipient) {
var iter = new Iterator(this.attr.recipients, /*startingIndex=*/-1);
@@ -150,6 +155,7 @@ define(
this.on(events.ui.recipients.deleteLast, this.deleteLastRecipient);
this.on(events.ui.recipients.selectLast, this.selectLastRecipient);
this.on(events.ui.recipients.entered, this.recipientEntered);
+ this.on(events.ui.recipients.enteredInvalid, this.invalidRecipientEntered);
this.on(document, events.ui.recipients.doCompleteInput, this.doCompleteRecipients);
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 4c70e180..54c8fed9 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
@@ -42,6 +42,10 @@ define([
},
self;
+ var simpleAddressMatch = /[^<\w,;]?([^\s<;,]+@[^\s>;,]+)/;
+ var canonicalAddressMatch = /([^,;\s][^,;@]+<[^\s;,]+@[^\s;,]+>)/;
+ var emailAddressMatch = new RegExp([simpleAddressMatch.source, '|', canonicalAddressMatch.source].join(''), 'g');
+
var extractContactNames = function (response) {
return _.map(response, function(a) { return { value: a }; });
};
@@ -109,20 +113,30 @@ define([
this.recipientSelected = function (event, data) {
var value = (data && data.value) || this.$node.val();
var that = this;
- var addresses = this.extractAdresses(value);
- _.each(addresses, function(address) {
+
+ function triggerEventForEach(addresses, event) {
+ _.each(addresses, function(address) {
if (!_.isEmpty(address.trim())) {
- that.trigger(that.$node, events.ui.recipients.entered, { name: that.attr.name, address: address.trim() });
+ that.trigger(that.$node, event, { name: that.attr.name, address: address.trim() });
}
- });
+ });
+ }
+
+ var validAddresses = this.extractValidAddresses(value);
+ var invalidAddresses = this.extractInvalidAddresses(value);
+
+ triggerEventForEach(validAddresses, events.ui.recipients.entered);
+ triggerEventForEach(invalidAddresses, events.ui.recipients.enteredInvalid);
+
reset(this.$node);
};
- this.extractAdresses = function(rawAddresses){
- var simpleAddressMatch = /[^<\w,;]?([^\s<;,]+@[^\s>;,]+)/;
- var canonicalAddressMatch = /([^,;\s][^,;]+<[^\s;,]+@[^\s;,]+>)/;
- var addressMatch = new RegExp([simpleAddressMatch.source, '|', canonicalAddressMatch.source].join(''), 'g');
- return rawAddresses.match(addressMatch);
+ this.extractValidAddresses = function(rawAddresses) {
+ return rawAddresses.match(emailAddressMatch);
+ };
+
+ this.extractInvalidAddresses = function(rawAddresses) {
+ return rawAddresses.replace(emailAddressMatch, '').split(' ');
};
this.init = function () {