1 /*
  2  * ***** BEGIN LICENSE BLOCK *****
  3  * Zimbra Collaboration Suite Web Client
  4  * Copyright (C) 2005, 2006, 2007, 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) 2005, 2006, 2007, 2009, 2010, 2011, 2012, 2013, 2014, 2016 Synacor, Inc. All Rights Reserved.
 21  * ***** END LICENSE BLOCK *****
 22  */
 23 
 24 ZmNewCalendarDialog = function(parent, className) {
 25     if (arguments.length == 0) { return; }
 26 	var title = ZmMsg.createNewCalendar;
 27 	var type = ZmOrganizer.CALENDAR;
 28     var back = new DwtDialog_ButtonDescriptor(ZmNewCalendarDialog.BACK_BUTTON, ZmMsg.back , DwtDialog.ALIGN_LEFT);
 29 	ZmNewOrganizerDialog.call(this, parent, className, title, type, [back]);
 30     this.setButtonListener(ZmNewCalendarDialog.BACK_BUTTON, this._backButtonListener.bind(this));
 31     this.getButton(ZmNewCalendarDialog.BACK_BUTTON).setVisibility(false);
 32 };
 33 
 34 ZmNewCalendarDialog.prototype = new ZmNewOrganizerDialog;
 35 ZmNewCalendarDialog.prototype.constructor = ZmNewCalendarDialog;
 36 
 37 
 38 
 39 
 40 ZmNewCalendarDialog.BACK_BUTTON = ++DwtDialog.LAST_BUTTON;
 41 
 42 ZmNewCalendarDialog.prototype.toString = 
 43 function() {
 44 	return "ZmNewCalendarDialog";
 45 };
 46 
 47 // Public methods
 48 
 49 
 50 ZmNewCalendarDialog.prototype.reset =
 51 function(account) {
 52 	ZmNewOrganizerDialog.prototype.reset.apply(this, arguments);
 53 	this._excludeFbCheckbox.checked = false;
 54 };
 55 
 56 // Protected methods
 57 
 58 ZmNewCalendarDialog.prototype._getRemoteLabel =
 59 function() {
 60 	return ZmMsg.addRemoteAppts;
 61 };
 62 
 63 ZmNewCalendarDialog.prototype._createExtraContentHtml =
 64 function(html, idx) {
 65 	idx = this._createFreeBusyContentHtml(html, idx);
 66 	return ZmNewOrganizerDialog.prototype._createExtraContentHtml.call(this, html, idx);
 67 };
 68 
 69 ZmNewCalendarDialog.prototype._createFreeBusyContentHtml =
 70 function(html, idx) {
 71 	this._excludeFbCheckboxId = this._htmlElId + "_excludeFbCheckbox";
 72 	html[idx++] = AjxTemplate.expand("share.Dialogs#ZmNewCalDialogFreeBusy", {id:this._htmlElId});
 73 	return idx;
 74 };
 75 
 76 // NOTE: new calendar dialog doesn't show overview
 77 ZmNewCalendarDialog.prototype._createFolderContentHtml =
 78 function(html, idx) {
 79 	return idx;
 80 };
 81 
 82 ZmNewCalendarDialog.prototype._setupExtraControls =
 83 function() {
 84 	ZmNewOrganizerDialog.prototype._setupExtraControls.call(this);
 85 	this._setupFreeBusyControl();
 86 };
 87 
 88 ZmNewCalendarDialog.prototype._setupFreeBusyControl =
 89 function() {
 90 	this._excludeFbCheckbox = document.getElementById(this._excludeFbCheckboxId);
 91 };
 92 
 93 /*
 94 *   Overwritten the parent class method to include application specific params.
 95 */
 96 ZmNewCalendarDialog.prototype._setupColorControl =
 97 function() {
 98     var el = document.getElementById(this._colorSelectId);
 99 	this._colorSelect = new ZmColorButton({parent:this,parentElement:el,hideNone:true});
100 };
101 
102 /** 
103  * Checks the input for validity and returns the following array of values:
104  * <ul>
105  * <li> parentFolder
106  * <li> name
107  * <li> color
108  * <li> URL
109  * <li> excludeFB
110  * </ul>
111  * 
112  * @private
113  */
114 ZmNewCalendarDialog.prototype._getFolderData =
115 function() {
116 	var data = ZmNewOrganizerDialog.prototype._getFolderData.call(this);
117 	if (data) {
118 		data.f = this._excludeFbCheckbox.checked ? "b#" : "#";
119         var url =  this._iCalData ? this._iCalData.url : "";
120         if(url) {
121             data.url = url;
122             this._iCalData = null;
123             delete this._iCalData;
124         }
125 	}
126 	return data;
127 };
128 
129 ZmNewCalendarDialog.prototype._createRemoteContentHtml =
130 function(html, idx) {
131 	return idx;
132 };
133 
134 ZmNewCalendarDialog.prototype.setICalData =
135 function(iCalData) {
136 	this._iCalData = iCalData;
137 };
138 
139 
140 /**
141  * @Override Added for tabindexing checkboxes.
142  * 
143  * @private
144  */
145 //For bug 21985
146 ZmNewCalendarDialog.prototype._getTabGroupMembers =
147 function() {
148 	var list = ZmNewOrganizerDialog.prototype._getTabGroupMembers.call(this);
149     if (this._excludeFbCheckbox) {
150 		list.push(this._excludeFbCheckbox);
151 	}
152     if (this._remoteCheckboxField) {
153 		list.push(this._remoteCheckboxField);
154 	}
155     return list;
156 };
157 
158 ZmNewCalendarDialog.prototype._backButtonListener =
159 function() {
160     this.popdown();
161 };
162