1 /* 2 * ***** BEGIN LICENSE BLOCK ***** 3 * Zimbra Collaboration Suite Web Client 4 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 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) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2016 Synacor, Inc. All Rights Reserved. 21 * ***** END LICENSE BLOCK ***** 22 */ 23 24 /** 25 * Simple dialog allowing user to choose between an Instance or Series for an appointment 26 * @constructor 27 * @class 28 * 29 * @author Parag Shah 30 * @param parent the element that created this view 31 * 32 * 33 * @extends DwtDialog 34 * @private 35 */ 36 ZmApptNotifyDialog = function(parent) { 37 38 DwtDialog.call(this, {parent:parent, id:"SEND_NOTIFY_DIALOG"}); 39 40 this.setTitle(ZmMsg.sendUpdateTitle); 41 this.setContent(this._setHtml()); 42 this._cacheFields(); 43 }; 44 45 ZmApptNotifyDialog.prototype = new DwtDialog; 46 ZmApptNotifyDialog.prototype.constructor = ZmApptNotifyDialog; 47 48 // Public methods 49 50 ZmApptNotifyDialog.prototype.toString = 51 function() { 52 return "ZmApptNotifyDialog"; 53 }; 54 55 ZmApptNotifyDialog.prototype.initialize = 56 function(appt, attId, addedAttendees, removedAttendees) { 57 this._appt = appt; 58 this._attId = attId; 59 this._defaultRadio.checked = true; 60 61 var aCount = addedAttendees.length; 62 var rCount = removedAttendees.length; 63 Dwt.setSize(Dwt.byId(this._containerId), 275, Dwt.CLEAR); 64 65 this._addedList.innerHTML = this._getAttedeeHtml(addedAttendees, ZmMsg.added); 66 this._removedList.innerHTML = this._getAttedeeHtml(removedAttendees, ZmMsg.removed); 67 }; 68 69 // helper method - has no use for this dialog 70 ZmApptNotifyDialog.prototype.getAppt = 71 function() { 72 return this._appt; 73 }; 74 75 // helper method - has no use for this dialog 76 ZmApptNotifyDialog.prototype.getAttId = 77 function() { 78 return this._attId; 79 }; 80 81 ZmApptNotifyDialog.prototype.notifyNew = 82 function() { 83 return this._defaultRadio.checked; 84 }; 85 86 ZmApptNotifyDialog.prototype.addSelectionListener = 87 function(buttonId, listener) { 88 this._button[buttonId].addSelectionListener(listener); 89 }; 90 91 92 // Private / protected methods 93 94 ZmApptNotifyDialog.prototype._setHtml = 95 function() { 96 this._defaultRadioId = Dwt.getNextId(); 97 this._notifyChoiceName = Dwt.getNextId(); 98 this._addedListId = Dwt.getNextId(); 99 this._removedListId = Dwt.getNextId(); 100 this._containerId = Dwt.getNextId(); 101 102 var html = new Array(); 103 var i = 0; 104 105 html[i++] = "<div style='width:275px; overflow: auto;' id='"+this._containerId+"'>"; 106 html[i++] = ZmMsg.attendeeListChanged; 107 html[i++] = "<br><div id='"; 108 html[i++] = this._addedListId; 109 html[i++] = "'></div>"; 110 html[i++] = "<div id='"; 111 html[i++] = this._removedListId; 112 html[i++] = "'></div>"; 113 html[i++] = "</div><p>"; 114 html[i++] = "<table align=center border=0 width=1%>"; 115 html[i++] = "<tr><td width=1%><input checked value='1' type='radio' id='"; 116 html[i++] = this._defaultRadioId; 117 html[i++] = "' name='"; 118 html[i++] = this._notifyChoiceName; 119 html[i++] = "'></td><td style='white-space:nowrap'>"; 120 html[i++] = "<label for='" + this._defaultRadioId + "'>"; 121 html[i++] = ZmMsg.sendUpdatesNew; 122 html[i++] = "</label>"; 123 html[i++] = "</td></tr>"; 124 html[i++] = "<tr><td width=1%><input value='2' type='radio'" + "id='" + this._defaultRadioId + this._notifyChoiceName + "' name='"; // Applying unique Id. Fix for bug: 77590 & bug: 76533 125 html[i++] = this._notifyChoiceName; 126 html[i++] = "'></td><td style='white-space:nowrap'>"; 127 html[i++] = "<label for='" + this._defaultRadioId + this._notifyChoiceName + "'>"; // Applying unique Id. Fix for bug: 77590 & bug: 76533 128 html[i++] = ZmMsg.sendUpdatesAll; 129 html[i++] = "</label>"; 130 html[i++] = "</td></tr>"; 131 html[i++] = "</table>"; 132 133 return html.join(""); 134 }; 135 136 ZmApptNotifyDialog.prototype._getAttedeeHtml = 137 function(attendeeList, attendeeLabel) { 138 var html = new Array(); 139 var j = 0; 140 141 if (attendeeList.length) { 142 html[j++] = "<table border=0><tr>"; 143 html[j++] = "<td valign=top> <b>"; 144 html[j++] = attendeeLabel; 145 html[j++] = "</b></td><td>"; 146 html[j++] = AjxStringUtil.htmlEncode(attendeeList.join(", ")); 147 html[j++] = "</td></tr></table>"; 148 } 149 return html.join(""); 150 }; 151 152 ZmApptNotifyDialog.prototype._cacheFields = 153 function() { 154 this._defaultRadio = document.getElementById(this._defaultRadioId); delete this._defaultRadioId; 155 this._addedList = document.getElementById(this._addedListId); delete this._addedListId; 156 this._removedList = document.getElementById(this._removedListId); delete this._removedListId; 157 158 }; 159