1 /* 2 * ***** BEGIN LICENSE BLOCK ***** 3 * Zimbra Collaboration Suite Web Client 4 * Copyright (C) 2011, 2013, 2014, 2015, 2016 Synacor, Inc. 5 * 6 * The contents of this file are subject to the Common Public Attribution License Version 1.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at: https://www.zimbra.com/license 9 * The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 10 * have been added to cover use of software over a computer network and provide for limited attribution 11 * for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B. 12 * 13 * Software distributed under the License is distributed on an "AS IS" basis, 14 * WITHOUT WARRANTY OF ANY KIND, either express or implied. 15 * See the License for the specific language governing rights and limitations under the License. 16 * The Original Code is Zimbra Open Source Web Client. 17 * The Initial Developer of the Original Code is Zimbra, Inc. All rights to the Original Code were 18 * transferred by Zimbra, Inc. to Synacor, Inc. on September 14, 2015. 19 * 20 * All portions of the code are Copyright (C) 2011, 2013, 2014, 2015, 2016 Synacor, Inc. All Rights Reserved. 21 * ***** END LICENSE BLOCK ***** 22 */ 23 24 /** 25 * @overview 26 */ 27 28 /** 29 * Creates a Mail Redirect dialog. 30 * @class 31 * This class represents a Mail Redirect dialog. 32 * 33 * @param {DwtControl} parent the parent 34 * @param {String} className the class name 35 * 36 * @extends DwtDialog 37 */ 38 ZmMailRedirectDialog = function(parent, className) { 39 className = className || "ZmFolderPropsDialog"; 40 41 DwtDialog.call(this, {parent:parent, className:className, title:ZmMsg.mailRedirect, id:"RedirectDialog"}); 42 43 this.setButtonListener(DwtDialog.CANCEL_BUTTON, this._handleCancelButton.bind(this)); 44 45 var recipParams = {}; 46 recipParams.enableContainerInputs = this.enableInputs.bind(this); 47 recipParams.contactPopdownListener = this.contactPopdownListener.bind(this); 48 recipParams.contextId = this.toString(); 49 this._recipients = new ZmRecipients(recipParams); 50 51 this._fieldNames = [AjxEmailAddress.TO]; 52 var data = { id : this._htmlElId }; 53 54 for (var i = 0; i < this._fieldNames.length; i++) { 55 var typeStr = AjxEmailAddress.TYPE_STRING[this._fieldNames[i]]; 56 var ids = this._recipients.createRecipientIds(this._htmlElId, typeStr) 57 data[typeStr + "RowId"] = ids.row; 58 data[typeStr + "PickerId"] = ids.picker; 59 data[typeStr + "InputId"] = ids.control; 60 data[typeStr + "CellId"] = ids.cell; 61 } 62 63 var html = AjxTemplate.expand("mail.Message#RedirectDialog", data); 64 this.setContent(html); 65 66 67 this._recipients.createRecipientHtml(this, this._htmlElId, this._htmlElId, this._fieldNames); 68 this._tabGroup.addMember(this._recipients.getField(AjxEmailAddress.TO), 0); 69 }; 70 71 ZmMailRedirectDialog.prototype = new DwtDialog; 72 ZmMailRedirectDialog.prototype.constructor = ZmMailRedirectDialog; 73 74 ZmMailRedirectDialog.prototype.isZmMailRedirectDialog = true; 75 ZmMailRedirectDialog.prototype.toString = function() { return "ZmMailRedirectDialog"; }; 76 77 78 79 ZmMailRedirectDialog.prototype.getAddrs = 80 function() { 81 return this._recipients.collectAddrs(); 82 }; 83 84 85 /** 86 * Pops-up the properties dialog. 87 * 88 * @param {ZmOrganizer} organizer the organizer 89 */ 90 ZmMailRedirectDialog.prototype.popup = 91 function(mail) { 92 this._recipients.setup(); 93 94 DwtDialog.prototype.popup.call(this); 95 }; 96 97 ZmMailRedirectDialog.prototype._resetTabFocus = 98 function(){ 99 this._tabGroup.setFocusMember(this._recipients.getField(AjxEmailAddress.TO), true); 100 }; 101 102 103 ZmMailRedirectDialog.prototype.popdown = 104 function() { 105 this._recipients.reset(); 106 DwtDialog.prototype.popdown.call(this); 107 }; 108 109 110 // Miscellaneous methods 111 112 ZmMailRedirectDialog.prototype.enableInputs = 113 function(bEnable) { 114 this._recipients.enableInputs(bEnable); 115 }; 116 117 /** 118 * Handles re-enabling inputs if the pop shield is dismissed via 119 * Esc. Otherwise, the handling is done explicitly by a callback. 120 */ 121 // *** NEEDED??? **** // 122 ZmMailRedirectDialog.prototype.contactPopdownListener = 123 function() { 124 this.enableInputs(true); 125 appCtxt.getAppViewMgr().showPendingView(false); 126 }; 127 128 ZmMailRedirectDialog.prototype._handleCancelButton = 129 function(event) { 130 this.popdown(); 131 }; 132