1 /*
  2  * ***** BEGIN LICENSE BLOCK *****
  3  * Zimbra Collaboration Suite Web Client
  4  * Copyright (C) 2011, 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) 2011, 2013, 2014, 2016 Synacor, Inc. All Rights Reserved.
 21  * ***** END LICENSE BLOCK *****
 22  */
 23 
 24 /**
 25  * @overview
 26  */
 27 
 28 /**
 29  * Creates a new contact group dialog.
 30  * @class
 31  * This class represents a new contact group dialog.
 32  *
 33  * @param	{DwtControl}	parent		the parent
 34  * @param	{String}	className		the class name
 35  *
 36  * @extends		ZmDialog
 37  */
 38 ZmNewContactGroupDialog = function(parent, className) {
 39 	ZmDialog.call(this, {parent:parent, className:className, title:ZmMsg.createNewContactGroup, id:"CreateContactGroupDialog"});
 40 
 41 	this._setNameField(this._htmlElId+"_name");
 42 	DBG.timePt("set content");
 43 };
 44 
 45 ZmNewContactGroupDialog.prototype = new ZmDialog;
 46 ZmNewContactGroupDialog.prototype.constructor = ZmNewContactGroupDialog;
 47 
 48 ZmNewContactGroupDialog.prototype.toString =
 49 function() {
 50 	return "ZmNewContactGroupDialog";
 51 };
 52 
 53 /**
 54  * Pops-up the dialog.
 55  *
 56  * @param	{ZmOrganizer}	org		the organizer
 57  * @param	{ZmAccount}		account	the account
 58  */
 59 ZmNewContactGroupDialog.prototype.popup =
 60 function(org, account) {
 61 	if (this._accountSelect) {
 62 		var acct = account || appCtxt.getActiveAccount();
 63 		this._accountSelect.setSelectedValue(acct.id);
 64 	}
 65 
 66 	ZmDialog.prototype.popup.call(this);
 67 };
 68 
 69 ZmNewContactGroupDialog.prototype.cleanup =
 70 function(bPoppedUp) {
 71 	DwtDialog.prototype.cleanup.call(this, bPoppedUp);
 72 };
 73 
 74 
 75 ZmNewContactGroupDialog.prototype._contentHtml =
 76 function() {
 77 	return AjxTemplate.expand("share.Dialogs#ZmContactGroupDialog", {id:this._htmlElId});
 78 };
 79 
 80 ZmNewContactGroupDialog.prototype._okButtonListener =
 81 function(ev) {
 82 	var results = this._getContactGroupData();
 83 	if (results) {
 84 		DwtDialog.prototype._buttonListener.call(this, ev, results);
 85 	}
 86 };
 87 
 88 ZmNewContactGroupDialog.prototype._getContactGroupData =
 89 function() {
 90 	// check name for presence
 91 	var name = AjxStringUtil.trim(this._nameField.value);
 92 	if (name == "") {
 93 		return this._showError(ZmMsg.errorGroupName);
 94 	}
 95 
 96     var data = {name:name};
 97     return data;
 98 };
 99 
100 ZmNewContactGroupDialog.prototype._enterListener =
101 function(ev) {
102 	var results = this._getContactGroupData();
103 	if (results) {
104 		this._runEnterCallback(results);
105 	}
106 };
107 
108 ZmNewContactGroupDialog.prototype._getTabGroupMembers =
109 function() {
110 	return [this._nameField];
111 };
112