diff options
author | Jefferson Stachelski <jstachel@thoughtworks.com> | 2015-10-28 17:19:54 -0200 |
---|---|---|
committer | Jefferson Stachelski <jstachel@thoughtworks.com> | 2015-10-28 17:21:51 -0200 |
commit | 2199e5ec5f81ddbfe5eaa0ae17443dc2864783f9 (patch) | |
tree | fee03360e6efb984687171844763e68e60fdeb93 /web-ui/app/js/mail_view | |
parent | 9068cf5c52c589c9228cca7d2ebb1ecec9129a0d (diff) |
Issue #493 - Fixed some bug and did some refactors
Fixed the nagivation mode when used click to edit recipients and also
refactored the code to split the responsability
Diffstat (limited to 'web-ui/app/js/mail_view')
-rw-r--r-- | web-ui/app/js/mail_view/ui/recipients/recipient.js | 16 | ||||
-rw-r--r-- | web-ui/app/js/mail_view/ui/recipients/recipients.js | 25 | ||||
-rw-r--r-- | web-ui/app/js/mail_view/ui/recipients/recipients_iterator.js | 4 |
3 files changed, 31 insertions, 14 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 2985a9ab..66577f51 100644 --- a/web-ui/app/js/mail_view/ui/recipients/recipient.js +++ b/web-ui/app/js/mail_view/ui/recipients/recipient.js @@ -89,18 +89,18 @@ define( }.bind(this)); }; - this.editRecipient = function(evt) { - var mailAddr = this.$node.find('input[type=hidden]').val(); - // TODO: refactor the code bellow - $('#recipients-to-area').find('input.tt-input').val(mailAddr); - $('#recipients-to-area').find('input.tt-input').focus(); - this.destroy(); - // TODO: fix the bug when edit recipient and click out of the input + this.getMailAddress = function() { + return this.$node.find('input[type=hidden]').val(); }; + this.triggerEditRecipient = function(event, element) { + this.trigger(this.$node.closest('.recipients-area'), events.ui.recipients.clickToEdit, this); + } + this.after('initialize', function () { this.recipientDelActions(); - this.on('click', this.editRecipient); + this.on('click', this.triggerEditRecipient); + if (this.attr.invalidAddress){ this.sinalizeInvalid(); } else { 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 7072c09e..3dfd6661 100644 --- a/web-ui/app/js/mail_view/ui/recipients/recipients.js +++ b/web-ui/app/js/mail_view/ui/recipients/recipients.js @@ -46,11 +46,31 @@ define( this.addressesUpdated(); } - function editCurrentRecipient() { - this.attr.iterator.editCurrent(); + function editCurrentRecipient(event, recipient) { + var mailAddr = this.attr.iterator.current().getMailAddress(); + this.attr.iterator.deleteCurrent(); + this.attr.input.$node.val(mailAddr).focus(); + this.unselectAllRecipients(); this.addressesUpdated(); } + this.clickToEditRecipient = function(event, recipient) { + this.attr.iterator = null; + var mailAddr = recipient.getMailAddress(); + + var position = recipient.$node.closest('.recipients-area').find('.fixed-recipient').index(recipient.$node); + this.attr.recipients.splice(position, 1); + recipient.destroy(); + + this.addressesUpdated(); + this.unselectAllRecipients(); + this.attr.input.$node.val(mailAddr).focus(); + }; + + this.unselectAllRecipients = function() { + this.$node.find('.recipient-value.selected').removeClass('selected'); + } + var SPECIAL_KEYS_ACTIONS = { 8: deleteCurrentRecipient, 46: deleteCurrentRecipient, @@ -156,6 +176,7 @@ define( 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(events.ui.recipients.clickToEdit, this.clickToEditRecipient); this.on(document, events.ui.recipients.doCompleteInput, this.doCompleteRecipients); diff --git a/web-ui/app/js/mail_view/ui/recipients/recipients_iterator.js b/web-ui/app/js/mail_view/ui/recipients/recipients_iterator.js index 35741bb7..6c52c52e 100644 --- a/web-ui/app/js/mail_view/ui/recipients/recipients_iterator.js +++ b/web-ui/app/js/mail_view/ui/recipients/recipients_iterator.js @@ -54,10 +54,6 @@ define(['helpers/iterator'], function (Iterator) { this.input.focus(); } }; - - this.editCurrent = function() { - this.iterator.removeCurrent().editRecipient(); - }; } }); |