1 /*
  2  * ***** BEGIN LICENSE BLOCK *****
  3  * Zimbra Collaboration Suite Web Client
  4  * Copyright (C) 2006, 2007, 2008, 2009, 2010, 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, 2012, 2013, 2014, 2016 Synacor, Inc. All Rights Reserved.
 21  * ***** END LICENSE BLOCK *****
 22  */
 23 
 24 /**
 25  * @overview
 26  * This file contains the address book dialog class.
 27  */
 28 
 29 /**
 30  * Creates an address book dialog.
 31  * @class
 32  * This class represents the address book dialog.
 33  * 
 34  * @param	{DwtControl}	parent		the parent
 35  * @param	{String}	className		the class name
 36  * @param	{String}	title		the dialog title
 37  * @param	{constant}	type		the type
 38  * 
 39  * @extends		ZmNewOrganizerDialog
 40  */
 41 ZmNewAddrBookDialog = function(parent, className) {
 42 	var title = ZmMsg.createNewAddrBook;
 43 	var type = ZmOrganizer.ADDRBOOK;
 44 	ZmNewOrganizerDialog.call(this, parent, className, title, type);
 45 }
 46 
 47 ZmNewAddrBookDialog.prototype = new ZmNewOrganizerDialog;
 48 ZmNewAddrBookDialog.prototype.constructor = ZmNewAddrBookDialog;
 49 
 50 
 51 // Public methods
 52 
 53 /**
 54  * Returns a string representation of the object.
 55  * 
 56  * @return		{String}		a string representation of the object
 57  */
 58 ZmNewAddrBookDialog.prototype.toString =
 59 function() {
 60 	return "ZmNewAddrBookDialog";
 61 };
 62 
 63 
 64 // Protected methods
 65 
 66 /**
 67  * overload since we always want to init the color to grey.
 68  * 
 69  * @private
 70  */
 71 ZmNewAddrBookDialog.prototype._initColorSelect =
 72 function() {
 73 	var option = this._colorSelect.getOptionWithValue(ZmOrganizer.DEFAULT_COLOR[this._organizerType]);
 74 	this._colorSelect.setSelectedOption(option);
 75 };
 76 
 77 /**
 78  * overload so we dont show this.
 79  * 
 80  * @private
 81  */
 82 ZmNewAddrBookDialog.prototype._createRemoteContentHtml =
 83 function(html, idx) {
 84 	return idx;
 85 };
 86 
 87 /**
 88  * @private
 89  */
 90 ZmNewAddrBookDialog.prototype._setupFolderControl =
 91 function(){
 92     ZmNewOrganizerDialog.prototype._setupFolderControl.call(this);
 93     if (this._omit) {
 94 		this._omit[ZmFolder.ID_TRASH] = true;
 95 		this._omit[ZmFolder.ID_DLS] = true;
 96 	}
 97 	var folderTree = appCtxt.getFolderTree();
 98 	if (!folderTree) { return; }
 99 	var folders = folderTree.getByType(this._organizerType);
100 	for (var i = 0; i < folders.length; i++) {
101 		var folder = folders[i];
102 		if (folder.isReadOnly()) {
103 			this._omit[folder.id] = true;
104 		}
105 	}
106 };