2009-07-19 18:41:42 +02:00
|
|
|
/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2008-08-28 16:48:45 +02:00
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
/*
|
2007-10-19 16:36:33 +02:00
|
|
|
Copyright (C) 2005 SKYRIX Software AG
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2007-10-19 16:36:33 +02:00
|
|
|
This file is part of OpenGroupware.org.
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2007-10-19 16:36:33 +02:00
|
|
|
OGo is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU Lesser General Public License as published by the
|
|
|
|
Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
later version.
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2007-10-19 16:36:33 +02:00
|
|
|
OGo is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
|
|
|
License for more details.
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2007-10-19 16:36:33 +02:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with OGo; see the file COPYING. If not, write to the
|
|
|
|
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
02111-1307, USA.
|
2006-06-15 21:34:10 +02:00
|
|
|
*/
|
|
|
|
|
2006-10-18 23:53:47 +02:00
|
|
|
var contactSelectorAction = 'calendars-contacts';
|
2008-01-08 21:29:51 +01:00
|
|
|
var AppointmentEditor = {
|
2009-08-07 17:21:14 +02:00
|
|
|
attendeesMenu: null
|
2008-01-08 21:29:51 +01:00
|
|
|
};
|
2006-08-31 01:14:24 +02:00
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
function uixEarlierDate(date1, date2) {
|
2009-08-07 17:21:14 +02:00
|
|
|
// can this be done in a sane way?
|
|
|
|
if (date1.getYear() < date2.getYear()) return date1;
|
|
|
|
if (date1.getYear() > date2.getYear()) return date2;
|
|
|
|
// same year
|
|
|
|
if (date1.getMonth() < date2.getMonth()) return date1;
|
|
|
|
if (date1.getMonth() > date2.getMonth()) return date2;
|
|
|
|
// // same month
|
|
|
|
if (date1.getDate() < date2.getDate()) return date1;
|
|
|
|
if (date1.getDate() > date2.getDate()) return date2;
|
|
|
|
// same day
|
|
|
|
return null;
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function validateAptEditor() {
|
2009-08-07 17:21:14 +02:00
|
|
|
var e, startdate, enddate, tmpdate;
|
2006-08-31 01:14:24 +02:00
|
|
|
|
2009-08-07 17:21:14 +02:00
|
|
|
e = $('summary');
|
|
|
|
if (e.value.length == 0) {
|
|
|
|
if (!confirm(labels.validate_notitle))
|
|
|
|
return false;
|
|
|
|
}
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2009-08-07 17:21:14 +02:00
|
|
|
e = $('startTime_date');
|
|
|
|
if (e.value.length != 10) {
|
|
|
|
alert(labels.validate_invalid_startdate);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
startdate = e.calendar.prs_date(e.value);
|
|
|
|
if (startdate == null) {
|
|
|
|
alert(labels.validate_invalid_startdate);
|
|
|
|
return false;
|
|
|
|
}
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2009-08-07 17:21:14 +02:00
|
|
|
e = $('endTime_date');
|
|
|
|
if (e.value.length != 10) {
|
|
|
|
alert(labels.validate_invalid_enddate);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
enddate = e.calendar.prs_date(e.value);
|
|
|
|
if (enddate == null) {
|
|
|
|
alert(labels.validate_invalid_enddate);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
tmpdate = uixEarlierDate(startdate, enddate);
|
|
|
|
if (tmpdate == enddate) {
|
|
|
|
alert(labels.validate_endbeforestart);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if (tmpdate == null /* means: same date */) {
|
|
|
|
// TODO: check time
|
2011-06-13 22:28:10 +02:00
|
|
|
var startHour, startMinute, endHour, endMinute;
|
|
|
|
var matches;
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2011-06-13 22:28:10 +02:00
|
|
|
matches = document.forms[0]['startTime_time'].value.match(/([0-9]+):([0-9]+)/);
|
|
|
|
if (matches) {
|
|
|
|
startHour = parseInt(matches[1]);
|
|
|
|
startMinute = parseInt(matches[2]);
|
|
|
|
matches = document.forms[0]['endTime_time'].value.match(/([0-9]+):([0-9]+)/);
|
|
|
|
if (matches) {
|
|
|
|
endHour = parseInt(matches[1]);
|
|
|
|
endMinute = parseInt(matches[2]);
|
|
|
|
|
|
|
|
if (startHour > endHour) {
|
|
|
|
alert(labels.validate_endbeforestart);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if (startHour == endHour) {
|
|
|
|
if (startMinute > endMinute) {
|
|
|
|
alert(labels.validate_endbeforestart);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
alert(labels.validate_invalid_enddate);
|
2009-08-07 17:21:14 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2011-06-13 22:28:10 +02:00
|
|
|
else {
|
|
|
|
alert(labels.validate_invalid_startdate);
|
|
|
|
return false;
|
|
|
|
}
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2011-04-25 12:31:08 +02:00
|
|
|
AIM.submit($(document.editform), {'onComplete' : onEventPostComplete});
|
|
|
|
|
2009-08-07 17:21:14 +02:00
|
|
|
return true;
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
2006-08-14 22:32:30 +02:00
|
|
|
|
2008-01-08 21:29:51 +01:00
|
|
|
function onAttendeesMenuPrepareVisibility()
|
|
|
|
{
|
2009-08-07 17:21:14 +02:00
|
|
|
var composeToUndecidedAttendees = $('composeToUndecidedAttendees');
|
2009-09-14 16:06:20 +02:00
|
|
|
var attendeesStates = $('attendeesMenu').innerHTML;
|
2008-01-08 21:29:51 +01:00
|
|
|
|
2009-08-07 17:21:14 +02:00
|
|
|
if (attendeesStates.indexOf("needs-action") < 0)
|
|
|
|
composeToUndecidedAttendees.addClassName("disabled");
|
|
|
|
else
|
|
|
|
composeToUndecidedAttendees.removeClassName("disabled");
|
2008-01-08 21:29:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function onComposeToAllAttendees()
|
|
|
|
{
|
2009-08-07 17:21:14 +02:00
|
|
|
var attendees = $$("DIV#attendeesMenu LI.attendee");
|
|
|
|
var addresses = new Array();
|
|
|
|
attendees.each(function(item) {
|
2010-07-15 18:40:26 +02:00
|
|
|
var textChild = null;
|
|
|
|
var childNodes = item.childNodes;
|
|
|
|
for (var i = 0; !textChild && i < childNodes.length; i++) {
|
|
|
|
if (childNodes[i].nodeType == 3) {
|
|
|
|
textChild = childNodes[i];
|
|
|
|
var address = textChild.nodeValue.trim() + " <" + item.readAttribute("email") + ">";
|
|
|
|
addresses.push(address);
|
|
|
|
}
|
|
|
|
}
|
2010-05-28 14:34:42 +02:00
|
|
|
});
|
2009-08-07 17:21:14 +02:00
|
|
|
if (window.opener)
|
|
|
|
window.opener.openMailTo(addresses.join(","));
|
2008-01-08 21:29:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function onComposeToUndecidedAttendees()
|
|
|
|
{
|
2009-08-07 17:21:14 +02:00
|
|
|
if ($(this).hasClassName("disabled"))
|
|
|
|
return;
|
2008-01-08 21:29:51 +01:00
|
|
|
|
2009-08-07 17:21:14 +02:00
|
|
|
var attendees = $$("DIV#attendeesMenu LI.attendee.needs-action");
|
|
|
|
var addresses = new Array();
|
|
|
|
attendees.each(function(item) {
|
2010-07-15 19:10:46 +02:00
|
|
|
var textChild = null;
|
|
|
|
var childNodes = item.childNodes;
|
|
|
|
for (var i = 0; !textChild && i < childNodes.length; i++) {
|
|
|
|
if (childNodes[i].nodeType == 3) {
|
|
|
|
textChild = childNodes[i];
|
|
|
|
var address = textChild.nodeValue.trim() + " <" + item.readAttribute("email") + ">";
|
|
|
|
addresses.push(address);
|
|
|
|
}
|
|
|
|
}
|
2010-05-28 14:34:42 +02:00
|
|
|
});
|
2009-08-07 17:21:14 +02:00
|
|
|
if (window.opener)
|
|
|
|
window.opener.openMailTo(addresses.join(","));
|
2008-01-08 21:29:51 +01:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function addContact(tag, fullContactName, contactId, contactName, contactEmail) {
|
2009-08-07 17:21:14 +02:00
|
|
|
var uids = $('uixselector-participants-uidList');
|
2007-11-27 22:58:36 +01:00
|
|
|
|
2009-08-07 17:21:14 +02:00
|
|
|
if (contactId)
|
2006-10-03 18:27:02 +02:00
|
|
|
{
|
2009-08-07 17:21:14 +02:00
|
|
|
var re = new RegExp("(^|,)" + contactId + "($|,)");
|
|
|
|
|
|
|
|
if (!re.test(uids.value))
|
|
|
|
{
|
|
|
|
if (uids.value.length > 0)
|
|
|
|
uids.value += ',' + contactId;
|
|
|
|
else
|
|
|
|
uids.value = contactId;
|
|
|
|
|
|
|
|
var names = $('uixselector-participants-display');
|
|
|
|
names.innerHTML += ('<li onmousedown="return false;"'
|
|
|
|
+ ' onclick="onRowClick(event);"><img src="'
|
2010-06-02 21:05:48 +02:00
|
|
|
+ ResourcesURL + '/abcard.png" />'
|
2009-08-07 17:21:14 +02:00
|
|
|
+ contactName + '</li>');
|
|
|
|
}
|
2006-10-03 18:27:02 +02:00
|
|
|
}
|
|
|
|
|
2009-08-07 17:21:14 +02:00
|
|
|
return false;
|
2006-10-03 18:27:02 +02:00
|
|
|
}
|
2006-10-23 23:34:56 +02:00
|
|
|
|
2011-04-25 12:31:08 +02:00
|
|
|
function onEventPostComplete(response) {
|
|
|
|
if (response && response.length > 0) {
|
|
|
|
var jsonResponse = response.evalJSON();
|
|
|
|
if (jsonResponse["status"] == "success") {
|
|
|
|
if (window.opener)
|
|
|
|
window.opener.refreshEventsAndDisplay();
|
|
|
|
window.close();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var message = jsonResponse["message"];
|
|
|
|
alert(jsonResponse["message"]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-23 23:34:56 +02:00
|
|
|
function saveEvent(sender) {
|
2009-09-10 20:31:20 +02:00
|
|
|
if (validateAptEditor()) {
|
2010-07-08 06:13:56 +02:00
|
|
|
document.forms['editform'].attendees.value = Object.toJSON($(attendees));
|
2009-08-07 17:21:14 +02:00
|
|
|
document.forms['editform'].submit();
|
2009-09-10 20:31:20 +02:00
|
|
|
}
|
2006-10-23 23:34:56 +02:00
|
|
|
|
2009-08-07 17:21:14 +02:00
|
|
|
return false;
|
2006-10-23 23:34:56 +02:00
|
|
|
}
|
2006-10-26 02:19:23 +02:00
|
|
|
|
|
|
|
function startDayAsShortString() {
|
2009-08-07 17:21:14 +02:00
|
|
|
return $('startTime_date').valueAsShortDateString();
|
2006-10-26 02:19:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function endDayAsShortString() {
|
2009-08-07 17:21:14 +02:00
|
|
|
return $('endTime_date').valueAsShortDateString();
|
2006-10-26 02:19:23 +02:00
|
|
|
}
|
2006-11-07 17:13:03 +01:00
|
|
|
|
2007-06-11 23:23:48 +02:00
|
|
|
function _getDate(which) {
|
2010-07-07 17:37:29 +02:00
|
|
|
var date = window.timeWidgets[which]['date'].inputAsDate();
|
2011-06-20 23:17:49 +02:00
|
|
|
var time = window.timeWidgets[which]['time'].value.match(/([0-9]{1,2}):?([0-9]{2})/);
|
|
|
|
if (time) {
|
|
|
|
date.setHours(time[1]);
|
|
|
|
date.setMinutes(time[2]);
|
|
|
|
}
|
2006-11-07 17:13:03 +01:00
|
|
|
|
2009-08-07 17:21:14 +02:00
|
|
|
return date;
|
2006-11-07 17:13:03 +01:00
|
|
|
}
|
|
|
|
|
2007-06-11 23:23:48 +02:00
|
|
|
function _getShadowDate(which) {
|
2009-08-07 17:21:14 +02:00
|
|
|
var date = window.timeWidgets[which]['date'].getAttribute("shadow-value").asDate();
|
2011-06-13 22:28:10 +02:00
|
|
|
var time = window.timeWidgets[which]['time'].getAttribute("shadow-value").split(":");
|
|
|
|
date.setHours(time[0]);
|
|
|
|
date.setMinutes(time[1]);
|
2006-11-07 17:13:03 +01:00
|
|
|
|
2009-08-07 17:21:14 +02:00
|
|
|
return date;
|
2006-11-07 17:13:03 +01:00
|
|
|
}
|
|
|
|
|
2007-06-11 23:23:48 +02:00
|
|
|
function getStartDate() {
|
2009-08-07 17:21:14 +02:00
|
|
|
return this._getDate('start');
|
2006-11-07 17:13:03 +01:00
|
|
|
}
|
|
|
|
|
2007-06-11 23:23:48 +02:00
|
|
|
function getEndDate() {
|
2009-08-07 17:21:14 +02:00
|
|
|
return this._getDate('end');
|
2006-11-07 17:13:03 +01:00
|
|
|
}
|
|
|
|
|
2007-06-11 23:23:48 +02:00
|
|
|
function getShadowStartDate() {
|
2009-08-07 17:21:14 +02:00
|
|
|
return this._getShadowDate('start');
|
2006-11-07 17:13:03 +01:00
|
|
|
}
|
|
|
|
|
2007-06-11 23:23:48 +02:00
|
|
|
function getShadowEndDate() {
|
2009-08-07 17:21:14 +02:00
|
|
|
return this._getShadowDate('end');
|
2006-11-07 17:13:03 +01:00
|
|
|
}
|
|
|
|
|
2007-06-11 23:23:48 +02:00
|
|
|
function _setDate(which, newDate) {
|
2010-07-07 17:37:29 +02:00
|
|
|
window.timeWidgets[which]['date'].setInputAsDate(newDate);
|
2011-06-13 22:28:10 +02:00
|
|
|
window.timeWidgets[which]['time'].value = newDate.getDisplayHoursString();
|
2006-11-07 17:13:03 +01:00
|
|
|
}
|
|
|
|
|
2007-06-11 23:23:48 +02:00
|
|
|
function setStartDate(newStartDate) {
|
2009-08-07 17:21:14 +02:00
|
|
|
this._setDate('start', newStartDate);
|
2006-11-07 17:13:03 +01:00
|
|
|
}
|
|
|
|
|
2007-06-11 23:23:48 +02:00
|
|
|
function setEndDate(newEndDate) {
|
2009-08-07 17:21:14 +02:00
|
|
|
this._setDate('end', newEndDate);
|
2006-11-07 17:13:03 +01:00
|
|
|
}
|
|
|
|
|
2007-11-27 22:58:36 +01:00
|
|
|
function onAdjustTime(event) {
|
2009-08-07 17:21:14 +02:00
|
|
|
var endDate = window.getEndDate();
|
|
|
|
var startDate = window.getStartDate();
|
2007-11-27 22:58:36 +01:00
|
|
|
|
2009-08-07 17:21:14 +02:00
|
|
|
if ($(this).readAttribute("id").startsWith("start")) {
|
|
|
|
// Start date was changed
|
|
|
|
var delta = window.getShadowStartDate().valueOf() -
|
|
|
|
startDate.valueOf();
|
|
|
|
var newEndDate = new Date(endDate.valueOf() - delta);
|
|
|
|
window.setEndDate(newEndDate);
|
2007-11-27 22:58:36 +01:00
|
|
|
|
2009-08-07 17:21:14 +02:00
|
|
|
window.timeWidgets['end']['date'].updateShadowValue();
|
2011-06-13 22:28:10 +02:00
|
|
|
window.timeWidgets['end']['time'].updateShadowValue();
|
2009-08-07 17:21:14 +02:00
|
|
|
window.timeWidgets['start']['date'].updateShadowValue();
|
2011-06-13 22:28:10 +02:00
|
|
|
window.timeWidgets['start']['time'].updateShadowValue();
|
2011-06-15 14:32:54 +02:00
|
|
|
if (window.timeWidgets['end']['time'].onChange) window.timeWidgets['end']['time'].onChange(); // method from SOGoTimePicker
|
2009-08-07 17:21:14 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// End date was changed
|
|
|
|
var delta = endDate.valueOf() - startDate.valueOf();
|
|
|
|
if (delta < 0) {
|
|
|
|
alert(labels.validate_endbeforestart);
|
|
|
|
var oldEndDate = window.getShadowEndDate();
|
|
|
|
window.setEndDate(oldEndDate);
|
|
|
|
|
|
|
|
window.timeWidgets['end']['date'].updateShadowValue();
|
2011-06-13 22:28:10 +02:00
|
|
|
window.timeWidgets['end']['time'].updateShadowValue();
|
|
|
|
window.timeWidgets['end']['time'].onChange(); // method from SOGoTimePicker
|
2009-08-07 17:21:14 +02:00
|
|
|
}
|
2007-11-27 22:58:36 +01:00
|
|
|
}
|
2006-11-07 17:13:03 +01:00
|
|
|
}
|
|
|
|
|
2007-06-11 23:23:48 +02:00
|
|
|
function onAllDayChanged(event) {
|
2011-06-13 22:28:10 +02:00
|
|
|
for (var type in window.timeWidgets)
|
|
|
|
window.timeWidgets[type]['time'].disabled = this.checked;
|
2007-06-11 23:23:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function initTimeWidgets(widgets) {
|
2009-08-07 17:21:14 +02:00
|
|
|
this.timeWidgets = widgets;
|
|
|
|
|
|
|
|
if (widgets['start']['date']) {
|
|
|
|
widgets['start']['date'].observe("change", this.onAdjustTime, false);
|
2011-06-13 22:28:10 +02:00
|
|
|
widgets['start']['time'].observe("time:change", this.onAdjustTime, false);
|
|
|
|
widgets['start']['time'].addInterface(SOGoTimePickerInterface);
|
2009-08-07 17:21:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (widgets['end']['date']) {
|
|
|
|
widgets['end']['date'].observe("change", this.onAdjustTime, false);
|
2011-06-13 22:28:10 +02:00
|
|
|
widgets['end']['time'].observe("time:change", this.onAdjustTime, false);
|
|
|
|
widgets['end']['time'].addInterface(SOGoTimePickerInterface);
|
2009-08-07 17:21:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var allDayLabel = $("allDay");
|
|
|
|
if (allDayLabel) {
|
|
|
|
var input = $(allDayLabel).childNodesWithTag("input")[0];
|
|
|
|
input.observe("change", onAllDayChanged.bindAsEventListener(input));
|
|
|
|
if (input.checked) {
|
2011-06-13 22:28:10 +02:00
|
|
|
for (var type in widgets)
|
|
|
|
widgets[type]['time'].disabled = true;
|
2009-08-07 17:21:14 +02:00
|
|
|
}
|
2007-10-19 16:36:33 +02:00
|
|
|
}
|
2006-11-07 17:13:03 +01:00
|
|
|
}
|
2007-06-11 23:23:48 +02:00
|
|
|
|
2010-05-05 16:40:53 +02:00
|
|
|
function refreshAttendeesRO() {
|
2009-08-07 17:21:14 +02:00
|
|
|
var attendeesMenu = $("attendeesMenu");
|
|
|
|
var attendeesLabel = $("attendeesLabel");
|
2009-09-10 20:31:20 +02:00
|
|
|
var attendeesDiv = $("attendeesDiv");
|
|
|
|
|
2010-01-14 16:26:10 +01:00
|
|
|
if (attendeesLabel)
|
|
|
|
attendeesLabel.setStyle({display: "block"});
|
2010-05-04 19:24:13 +02:00
|
|
|
if (attendeesDiv)
|
|
|
|
attendeesDiv.setStyle({display: "block"});
|
2009-09-10 20:31:20 +02:00
|
|
|
|
2010-05-04 19:24:13 +02:00
|
|
|
if (attendeesMenu) {
|
|
|
|
// Register "click" event on each attendee's email
|
|
|
|
var attendees = attendeesMenu.getElementsByTagName('a');
|
|
|
|
$A(attendees).each(function(attendee) {
|
2010-05-28 14:34:42 +02:00
|
|
|
$(attendee).observe("click", onMailTo);
|
|
|
|
});
|
2010-05-04 19:24:13 +02:00
|
|
|
}
|
2009-07-27 14:48:27 +02:00
|
|
|
}
|
|
|
|
|
2009-09-10 20:31:20 +02:00
|
|
|
function refreshAttendees(newAttendees) {
|
2009-08-07 17:21:14 +02:00
|
|
|
var attendeesLabel = $("attendeesLabel");
|
|
|
|
var attendeesHref = $("attendeesHref");
|
|
|
|
var attendeesMenu = $("attendeesMenu");
|
|
|
|
|
|
|
|
if (!attendeesHref)
|
2010-05-05 16:40:53 +02:00
|
|
|
return refreshAttendeesRO();
|
2010-07-08 06:13:56 +02:00
|
|
|
|
2009-08-07 17:21:14 +02:00
|
|
|
if (attendeesMenu)
|
|
|
|
attendeesMenu = $("attendeesMenu").down("ul");
|
2008-01-08 21:29:51 +01:00
|
|
|
|
2009-08-07 17:21:14 +02:00
|
|
|
// Remove link of attendees
|
|
|
|
for (var i = 0; i < attendeesHref.childNodes.length; i++)
|
|
|
|
attendeesHref.removeChild(attendeesHref.childNodes[i]);
|
|
|
|
|
|
|
|
// Remove attendees from menu
|
|
|
|
var menuItems = $$("DIV#attendeesMenu LI.attendee");
|
|
|
|
if (menuItems && attendeesMenu)
|
|
|
|
for (var i = 0; i < menuItems.length; i++)
|
|
|
|
attendeesMenu.removeChild(menuItems[i]);
|
2010-07-08 06:13:56 +02:00
|
|
|
|
|
|
|
if (newAttendees)
|
|
|
|
// Update global variable
|
2010-05-05 16:40:53 +02:00
|
|
|
attendees = $H(newAttendees.evalJSON());
|
2009-09-10 20:31:20 +02:00
|
|
|
|
2010-07-08 06:13:56 +02:00
|
|
|
if (attendees.keys().length > 0) {
|
2009-08-07 17:21:14 +02:00
|
|
|
// Update attendees link and show label
|
2011-06-13 22:28:10 +02:00
|
|
|
var names = new Array();
|
2009-09-10 20:31:20 +02:00
|
|
|
attendees.values().each(function(attendee) {
|
2010-05-28 14:34:18 +02:00
|
|
|
attendee = $H(attendee);
|
|
|
|
var name = attendee.get('name') || attendee.get('email');
|
2011-06-13 22:28:10 +02:00
|
|
|
var delegatedTo = attendee.get('delegated-to');
|
|
|
|
if (!delegatedTo)
|
2010-05-28 14:34:18 +02:00
|
|
|
names.push(name);
|
|
|
|
|
|
|
|
if (attendeesMenu) {
|
|
|
|
if (!attendee.get('delegated-from') || delegatedTo) {
|
|
|
|
var node = createElement("li");
|
|
|
|
attendeesMenu.appendChild(node);
|
|
|
|
setupAttendeeNode(node, attendee);
|
2009-09-10 20:31:20 +02:00
|
|
|
}
|
2010-05-28 14:34:18 +02:00
|
|
|
if (delegatedTo) {
|
|
|
|
var delegate = attendees.get(delegatedTo);
|
|
|
|
var node = createElement("li");
|
|
|
|
attendeesMenu.appendChild(node);
|
|
|
|
setupAttendeeNode(node, $H(delegate), true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2009-09-10 20:31:20 +02:00
|
|
|
attendeesHref.appendChild(document.createTextNode(names.join(", ")));
|
2009-08-07 17:21:14 +02:00
|
|
|
attendeesLabel.setStyle({ display: "block" });
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Hide link of attendees
|
|
|
|
attendeesLabel.setStyle({ display: "none" });
|
2008-01-08 21:29:51 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-10 20:31:20 +02:00
|
|
|
function setupAttendeeNode(aNode, aAttendee, isDelegate) {
|
|
|
|
// Construct the display string from common name and/or email address.
|
|
|
|
var name = aAttendee.get('name');
|
|
|
|
var email = aAttendee.get('email');
|
|
|
|
// if (name)
|
|
|
|
// name += ' <' + email + '>';
|
|
|
|
// else
|
|
|
|
// name = email;
|
|
|
|
name = name || email;
|
|
|
|
|
2010-05-05 16:40:53 +02:00
|
|
|
aNode.writeAttribute("email", email);
|
|
|
|
aNode.addClassName("attendee");
|
|
|
|
var partstat = aAttendee.get('partstat');
|
|
|
|
if (!partstat)
|
|
|
|
partstat = "no-partstat";
|
|
|
|
aNode.addClassName(partstat);
|
2009-09-10 20:31:20 +02:00
|
|
|
if (isDelegate)
|
2010-05-05 16:40:53 +02:00
|
|
|
aNode.addClassName("delegate");
|
|
|
|
var statusIconNode = createElement("div", null, "statusIcon");
|
|
|
|
aNode.appendChild(statusIconNode);
|
2009-09-10 20:31:20 +02:00
|
|
|
aNode.appendChild(document.createTextNode(name));
|
2010-05-05 16:40:53 +02:00
|
|
|
aNode.observe("click", onMailTo);
|
2009-09-10 20:31:20 +02:00
|
|
|
}
|
|
|
|
|
2008-01-08 21:29:51 +01:00
|
|
|
function initializeAttendeesHref() {
|
2009-08-07 17:21:14 +02:00
|
|
|
var attendeesHref = $("attendeesHref");
|
|
|
|
var attendeesLabel = $("attendeesLabel");
|
|
|
|
var attendeesNames = $("attendeesNames");
|
2008-01-08 21:29:51 +01:00
|
|
|
|
2009-08-07 17:21:14 +02:00
|
|
|
if (attendeesHref && !attendeesHref.hasClassName ("nomenu"))
|
|
|
|
attendeesHref.observe("click", onAttendeesHrefClick, false);
|
|
|
|
refreshAttendees();
|
2008-01-08 21:29:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function onAttendeesHrefClick(event) {
|
2009-08-07 17:21:14 +02:00
|
|
|
popupToolbarMenu(this, 'attendeesMenu');
|
|
|
|
preventDefault(event);
|
|
|
|
return false;
|
2008-01-08 21:29:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function onMailTo(event) {
|
2010-05-05 16:40:53 +02:00
|
|
|
var target = $(getTarget(event));
|
|
|
|
var address = target.lastChild.nodeValue.trim() + " <" + target.readAttribute("email") + ">";
|
2009-08-07 17:21:14 +02:00
|
|
|
openMailTo(address);
|
2009-09-10 20:31:20 +02:00
|
|
|
Event.stop(event);
|
|
|
|
return false;
|
2008-01-08 21:29:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function getMenus() {
|
2009-08-07 17:21:14 +02:00
|
|
|
AppointmentEditor.attendeesMenu = new Array(onPopupAttendeesWindow,
|
|
|
|
"-",
|
|
|
|
onComposeToAllAttendees,
|
|
|
|
onComposeToUndecidedAttendees,
|
|
|
|
"-",
|
|
|
|
null);
|
2008-01-08 21:29:51 +01:00
|
|
|
|
2009-08-07 17:21:14 +02:00
|
|
|
var attendeesMenu = $('attendeesMenu');
|
|
|
|
if (attendeesMenu)
|
|
|
|
attendeesMenu.prepareVisibility = onAttendeesMenuPrepareVisibility;
|
2008-01-08 21:29:51 +01:00
|
|
|
|
2009-08-07 17:21:14 +02:00
|
|
|
return { "attendeesMenu": AppointmentEditor.attendeesMenu };
|
2008-01-08 21:29:51 +01:00
|
|
|
}
|
|
|
|
|
2007-06-11 23:23:48 +02:00
|
|
|
function onAppointmentEditorLoad() {
|
2009-08-07 18:01:14 +02:00
|
|
|
if (readOnly == false) {
|
|
|
|
assignCalendar('startTime_date');
|
|
|
|
assignCalendar('endTime_date');
|
|
|
|
|
|
|
|
var widgets = {'start': {'date': $("startTime_date"),
|
2011-06-13 22:28:10 +02:00
|
|
|
'time': $("startTime_time")},
|
2009-08-07 18:01:14 +02:00
|
|
|
'end': {'date': $("endTime_date"),
|
2011-06-13 22:28:10 +02:00
|
|
|
'time': $("endTime_time")}};
|
2009-08-07 18:01:14 +02:00
|
|
|
initTimeWidgets(widgets);
|
|
|
|
}
|
2009-09-10 20:31:20 +02:00
|
|
|
|
|
|
|
// Extend JSON representation of attendees
|
|
|
|
attendees = $H(attendees);
|
|
|
|
|
2009-08-07 17:21:14 +02:00
|
|
|
initializeAttendeesHref();
|
2007-06-11 23:23:48 +02:00
|
|
|
}
|
|
|
|
|
2009-03-12 22:09:14 +01:00
|
|
|
document.observe("dom:loaded", onAppointmentEditorLoad);
|