Views.MailRecipient = Views.Base.extend({ classType: "Views.MailRecipient", tagName: "div", listenEvents: function() { this.on("onrender", this.onRender); this.options.mailinput.separator = this.options.mailinput.separator ? this.options.mailinput.separator : "|"; this.options.personinput.separator = this.options.personinput.separator ? this.options.personinput.separator : "|"; this.options.actorinput.separator = this.options.actorinput.separator ? this.options.actorinput.separator : "|"; }, onRender: function() { this.mailInputTo = this.$el.find(".To input.mail"); this.mailInputCc = this.$el.find(".Cc input.mail"); this.mailInputCci = this.$el.find(".Cci input.mail"); this.actorInput = this.$el.find("input.actor"); this.personInput = this.$el.find("input.person"); this.correspondentInput = this.$el.find("input.correspondent"); this.recipientListViewTo = edManager.getViewByID(this.$el.find(".To .mailRecipientItemList").attr('id')); this.recipientListViewTo.model.on("change", $.proxy(this.onMailListUpdatedTo, this)); this.recipientListViewTo.model.on("add", $.proxy(this.onMailListUpdatedTo, this)); this.recipientListViewTo.model.on("remove", $.proxy(this.onMailListUpdatedTo, this)); this.recipientListViewCc = edManager.getViewByID(this.$el.find(".Cc .mailRecipientItemList").attr('id')); this.recipientListViewCc.model.on("change", $.proxy(this.onMailListUpdatedCc, this)); this.recipientListViewCc.model.on("add", $.proxy(this.onMailListUpdatedCc, this)); this.recipientListViewCc.model.on("remove", $.proxy(this.onMailListUpdatedCc, this)); this.recipientListViewCci = edManager.getViewByID(this.$el.find(".Cci .mailRecipientItemList").attr('id')); this.recipientListViewCci.model.on("change", $.proxy(this.onMailListUpdatedCci, this)); this.recipientListViewCci.model.on("add", $.proxy(this.onMailListUpdatedCci, this)); this.recipientListViewCci.model.on("remove", $.proxy(this.onMailListUpdatedCci, this)); if (this.options.values && this.options.values.get("To")) { this.recipientListViewTo.model.add(this.options.values.get("To")); } if (this.options.values && this.options.values.get("Cc")) { this.recipientListViewCc.model.add(this.options.values.get("Cc")); } if (this.options.values && this.options.values.get("Cci")) { this.recipientListViewCci.model.add(this.options.values.get("Cci")); } }, onMailListUpdatedTo: function () { this.onMailListUpdated(this.mailInputTo, this.recipientListViewTo); }, onMailListUpdatedCc: function () { this.onMailListUpdated(this.mailInputCc, this.recipientListViewCc); }, onMailListUpdatedCci: function () { this.onMailListUpdated(this.mailInputCci, this.recipientListViewCci); }, onMailListUpdated: function (mailInput, recipientListView) { var mailInputValues = []; var actorInputValues = []; var personInputValues = []; var correspondentInputValues = []; for (var i=0; i