1 /*
  2  * ***** BEGIN LICENSE BLOCK *****
  3  * Zimbra Collaboration Suite Web Client
  4  * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 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, 2012, 2013, 2014, 2015, 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 Dan Villiom Podlaski Christiansen
 30  * @param parent			the element that created this view
 31  * 
 32  * @extends		DwtOptionDialog
 33  * 
 34  * @private
 35  */
 36 ZmCalItemTypeDialog = function() {
 37 	var params = Dwt.getParams(arguments, ZmCalItemTypeDialog.PARAMS);
 38 
 39 	params.options = [
 40 		{
 41 			name: ZmCalItemTypeDialog.INSTANCE
 42 		},
 43 		{
 44 			name: ZmCalItemTypeDialog.SERIES
 45 		}
 46 	];
 47 	DwtOptionDialog.call(this, params);
 48 };
 49 
 50 ZmCalItemTypeDialog.PARAMS = ["parent"];
 51 
 52 ZmCalItemTypeDialog.prototype = new DwtOptionDialog;
 53 ZmCalItemTypeDialog.prototype.constructor = ZmCalItemTypeDialog;
 54 ZmCalItemTypeDialog.prototype.isZmCalItemTypeDialog = true;
 55 
 56 ZmCalItemTypeDialog.prototype.role = 'alertdialog';
 57 
 58 ZmCalItemTypeDialog.INSTANCE = 'INSTANCE';
 59 ZmCalItemTypeDialog.SERIES = 'SERIES';
 60 
 61 // Public methods
 62 
 63 ZmCalItemTypeDialog.prototype.toString =
 64 function() {
 65 	return "ZmCalItemTypeDialog";
 66 };
 67 
 68 ZmCalItemTypeDialog.prototype.initialize =
 69 function(calItem, mode, type) {
 70 	this.calItem = calItem;
 71 	this.mode = mode;
 72 
 73 	var m;
 74 	if (type == ZmItem.APPT) {
 75 		m = (calItem instanceof Array)
 76 			? ZmMsg.isRecurringApptList
 77 			: AjxMessageFormat.format(ZmMsg.isRecurringAppt, [AjxStringUtil.htmlEncode(calItem.getName())]);
 78 	} else {
 79 		m = AjxMessageFormat.format(ZmMsg.isRecurringTask, [AjxStringUtil.htmlEncode(calItem.getName())]);
 80 	}
 81 
 82 	var title, question, seriesMsg, instanceMsg;
 83 
 84 	if (mode == ZmCalItem.MODE_EDIT) {
 85 		title = ZmMsg.openRecurringItem;
 86 		question = m + " " + ZmMsg.editApptQuestion;
 87 		instanceMsg = ZmMsg.openInstance;
 88 		seriesMsg = ZmMsg.openSeries;
 89 	} else if (mode == ZmAppt.MODE_DRAG_OR_SASH) {
 90 		title = ZmMsg.modifyRecurringItem;
 91 		question = m + " " + ZmMsg.modifyApptQuestion;
 92 		instanceMsg = ZmMsg.modifyInstance;
 93 		seriesMsg = ZmMsg.modifySeries;
 94 	} else {
 95 		title = ZmMsg.deleteRecurringItem;
 96 		seriesMsg = ZmMsg.deleteSeries;
 97 		if (calItem instanceof Array) {
 98 			question = m + " " + ZmMsg.deleteApptListQuestion;
 99 			instanceMsg = ZmMsg.deleteInstances;
100 		} else {
101 			question = m + " " + ZmMsg.deleteApptQuestion;
102 			instanceMsg = ZmMsg.deleteInstance;
103 		}
104 	}
105 
106 	this.setMessage(question, null, title);
107 
108 	this.getButton(ZmCalItemTypeDialog.INSTANCE).setText(instanceMsg);
109 	this.getButton(ZmCalItemTypeDialog.SERIES).setText(seriesMsg);
110 
111 	this.setSelection(ZmCalItemTypeDialog.INSTANCE);
112 };
113 
114 ZmCalItemTypeDialog.prototype.isInstance =
115 function() {
116 	return this.getSelection() === ZmCalItemTypeDialog.INSTANCE;
117 };
118