1 /* 2 * ***** BEGIN LICENSE BLOCK ***** 3 * Zimbra Collaboration Suite Web Client 4 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 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) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Synacor, Inc. All Rights Reserved. 21 * ***** END LICENSE BLOCK ***** 22 */ 23 24 /** 25 * @overview 26 */ 27 28 /** 29 * Creates an "decline share" dialog. 30 * @class 31 * This class represents "decline share" dialog. 32 * 33 * @param {DwtControl} shell the parent 34 * @param {String} className the class name 35 * 36 * @extends DwtDialog 37 */ 38 ZmDeclineShareDialog = function(parent, className) { 39 className = className || "ZmDeclineShareDialog"; 40 var title = ZmMsg.declineShare; 41 var buttons = [ DwtDialog.YES_BUTTON, DwtDialog.NO_BUTTON ]; 42 DwtDialog.call(this, {parent:parent, className:className, title:title, standardButtons:buttons}); 43 this.setButtonListener(DwtDialog.YES_BUTTON, new AjxListener(this, this._handleYesButton)); 44 45 // create controls 46 this._confirmMsgEl = document.createElement("DIV"); 47 this._confirmMsgEl.style.fontWeight = "bold"; 48 this._confirmMsgEl.style.marginBottom = "0.25em"; 49 this._reply = new ZmShareReply(this); 50 51 // create view 52 var view = new DwtComposite(this); 53 var element = view.getHtmlElement(); 54 element.appendChild(this._confirmMsgEl); 55 element.appendChild(this._reply.getHtmlElement()); 56 this.setView(view); 57 58 // create formatters 59 this._formatter = new AjxMessageFormat(ZmMsg.declineShareConfirm); 60 this._tabGroup.addMember(this._reply.getTabGroupMember()); 61 }; 62 63 ZmDeclineShareDialog.prototype = new DwtDialog; 64 ZmDeclineShareDialog.prototype.constructor = ZmDeclineShareDialog; 65 66 // Public methods 67 68 /** 69 * Pops-up the dialog. 70 * 71 * @param {ZmShare} share the share 72 * @param {String} fromAddr the from address 73 */ 74 ZmDeclineShareDialog.prototype.popup = 75 function(share, fromAddr) { 76 this._share = share; 77 var isGuestShare = share.isGuest(); 78 this._fromAddr = fromAddr; 79 var message = this._formatter.format([share.grantor.name, share.link.name]); 80 this._confirmMsgEl.innerHTML = AjxStringUtil.htmlEncode(message); 81 82 this._reply.setReplyType(ZmShareReply.STANDARD); 83 this._reply.setReplyNote(""); 84 if (isGuestShare) { 85 this._reply.setReplyOptions(ZmShareReply.EXTERNAL_USER_OPTIONS); 86 } 87 else { 88 this._reply.setReplyOptions(ZmShareReply.DEFAULT_OPTIONS); 89 } 90 DwtDialog.prototype.popup.call(this); 91 }; 92 93 /** 94 * Sets the decline listener. 95 * 96 * @param {AjxListener} listener the listener 97 */ 98 ZmDeclineShareDialog.prototype.setDeclineListener = 99 function(listener) { 100 this.removeAllListeners(ZmShare.DECLINE); 101 if (listener) { 102 this.addListener(ZmShare.DECLINE, listener); 103 } 104 }; 105 106 // Protected methods 107 108 ZmDeclineShareDialog.prototype._handleYesButton = 109 function(event) { 110 // send mail 111 var replyType = this._reply.getReplyType(); 112 113 if (replyType != ZmShareReply.NONE) { 114 this._share.notes = (replyType == ZmShareReply.QUICK) ? this._reply.getReplyNote(): ""; 115 116 this._share.sendMessage(ZmShare.DECLINE, null, this._fromAddr); 117 } 118 119 // notify decline listener and clear 120 this.notifyListeners(ZmShare.DECLINE, event); 121 this.setDeclineListener(null); 122 123 this.popdown(); 124 }; 125 126 ZmDeclineShareDialog.prototype._getSeparatorTemplate = 127 function() { 128 return ""; 129 }; 130