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';
|
2006-08-31 01:14:24 +02:00
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
function uixEarlierDate(date1, date2) {
|
|
|
|
// can this be done in a sane way?
|
2007-10-19 16:36:33 +02:00
|
|
|
// cuicui = 'year';
|
2006-06-15 21:34:10 +02:00
|
|
|
if (date1.getYear() < date2.getYear()) return date1;
|
|
|
|
if (date1.getYear() > date2.getYear()) return date2;
|
|
|
|
// same year
|
2007-10-19 16:36:33 +02:00
|
|
|
// cuicui += '/month';
|
2006-06-15 21:34:10 +02:00
|
|
|
if (date1.getMonth() < date2.getMonth()) return date1;
|
|
|
|
if (date1.getMonth() > date2.getMonth()) return date2;
|
2007-10-19 16:36:33 +02:00
|
|
|
// // same month
|
|
|
|
// cuicui += '/date';
|
2006-06-15 21:34:10 +02:00
|
|
|
if (date1.getDate() < date2.getDate()) return date1;
|
|
|
|
if (date1.getDate() > date2.getDate()) return date2;
|
|
|
|
// same day
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
function validateAptEditor() {
|
|
|
|
var e, startdate, enddate, tmpdate;
|
2006-08-31 01:14:24 +02:00
|
|
|
|
2006-10-26 02:19:23 +02:00
|
|
|
e = $('summary');
|
2006-06-15 21:34:10 +02:00
|
|
|
if (e.value.length == 0) {
|
2007-09-14 23:54:19 +02:00
|
|
|
if (!confirm(labels.validate_notitle))
|
2006-06-15 21:34:10 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-10-26 02:19:23 +02:00
|
|
|
e = $('startTime_date');
|
2006-06-15 21:34:10 +02:00
|
|
|
if (e.value.length != 10) {
|
2007-09-14 23:54:19 +02:00
|
|
|
alert(labels.validate_invalid_startdate);
|
2006-06-15 21:34:10 +02:00
|
|
|
return false;
|
|
|
|
}
|
2006-08-31 01:14:24 +02:00
|
|
|
startdate = e.calendar.prs_date(e.value);
|
2006-06-15 21:34:10 +02:00
|
|
|
if (startdate == null) {
|
2007-09-14 23:54:19 +02:00
|
|
|
alert(labels.validate_invalid_startdate);
|
2006-06-15 21:34:10 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-10-26 02:19:23 +02:00
|
|
|
e = $('endTime_date');
|
2006-06-15 21:34:10 +02:00
|
|
|
if (e.value.length != 10) {
|
2007-09-14 23:54:19 +02:00
|
|
|
alert(labels.validate_invalid_enddate);
|
2006-06-15 21:34:10 +02:00
|
|
|
return false;
|
|
|
|
}
|
2006-08-31 01:14:24 +02:00
|
|
|
enddate = e.calendar.prs_date(e.value);
|
2006-06-15 21:34:10 +02:00
|
|
|
if (enddate == null) {
|
2007-09-14 23:54:19 +02:00
|
|
|
alert(labels.validate_invalid_enddate);
|
2006-06-15 21:34:10 +02:00
|
|
|
return false;
|
|
|
|
}
|
2007-10-19 16:36:33 +02:00
|
|
|
// cuicui = '';
|
2006-06-15 21:34:10 +02:00
|
|
|
tmpdate = uixEarlierDate(startdate, enddate);
|
|
|
|
if (tmpdate == enddate) {
|
2007-10-19 16:36:33 +02:00
|
|
|
// window.alert(cuicui);
|
2007-09-14 23:54:19 +02:00
|
|
|
alert(labels.validate_endbeforestart);
|
2006-06-15 21:34:10 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if (tmpdate == null /* means: same date */) {
|
|
|
|
// TODO: check time
|
|
|
|
var start, end;
|
|
|
|
|
2006-09-05 17:08:32 +02:00
|
|
|
start = parseInt(document.forms[0]['startTime_time_hour'].value);
|
|
|
|
end = parseInt(document.forms[0]['endTime_time_hour'].value);
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
if (start > end) {
|
2007-09-14 23:54:19 +02:00
|
|
|
alert(labels.validate_endbeforestart);
|
2006-06-15 21:34:10 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if (start == end) {
|
2006-09-05 17:08:32 +02:00
|
|
|
start = parseInt(document.forms[0]['startTime_time_minute'].value);
|
|
|
|
end = parseInt(document.forms[0]['endTime_time_minute'].value);
|
2006-06-15 21:34:10 +02:00
|
|
|
if (start > end) {
|
2007-09-14 23:54:19 +02:00
|
|
|
alert(labels.validate_endbeforestart);
|
2006-06-15 21:34:10 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2006-08-14 22:32:30 +02:00
|
|
|
|
2006-08-31 01:14:24 +02:00
|
|
|
function toggleDetails() {
|
|
|
|
var div = $("details");
|
2006-09-26 20:45:34 +02:00
|
|
|
var buttons = $("buttons");
|
|
|
|
var buttonsHeight = buttons.clientHeight * 3;
|
2006-08-31 01:14:24 +02:00
|
|
|
|
|
|
|
if (div.style.visibility) {
|
|
|
|
div.style.visibility = null;
|
2006-09-26 20:45:34 +02:00
|
|
|
window.resizeBy(0, -(div.clientHeight + buttonsHeight));
|
2006-08-31 01:14:24 +02:00
|
|
|
$("detailsButton").innerHTML = labels["Show Details"];
|
|
|
|
} else {
|
|
|
|
div.style.visibility = 'visible;';
|
2006-09-26 20:45:34 +02:00
|
|
|
window.resizeBy(0, (div.clientHeight + buttonsHeight));
|
2006-08-31 01:14:24 +02:00
|
|
|
$("detailsButton").innerHTML = labels["Hide Details"];
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2006-09-28 19:27:16 +02:00
|
|
|
function toggleCycleVisibility(node, nodeName, hiddenValue) {
|
|
|
|
var spanNode = $(nodeName);
|
2006-08-31 01:14:24 +02:00
|
|
|
var newVisibility = ((node.value == hiddenValue) ? null : 'visible;');
|
2006-09-28 19:27:16 +02:00
|
|
|
spanNode.style.visibility = newVisibility;
|
|
|
|
|
|
|
|
if (nodeName == 'cycleSelectionFirstLevel') {
|
|
|
|
var otherSpanNode = $('cycleSelectionSecondLevel');
|
|
|
|
if (!newVisibility)
|
|
|
|
{
|
|
|
|
otherSpanNode.superVisibility = otherSpanNode.style.visibility;
|
|
|
|
otherSpanNode.style.visibility = null;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
otherSpanNode.style.visibility = otherSpanNode.superVisibility;
|
|
|
|
otherSpanNode.superVisibility = null;
|
|
|
|
}
|
|
|
|
}
|
2006-08-14 22:32:30 +02:00
|
|
|
}
|
2006-10-03 18:27:02 +02:00
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function addContact(tag, fullContactName, contactId, contactName, contactEmail) {
|
2006-10-03 18:27:02 +02:00
|
|
|
var uids = $('uixselector-participants-uidList');
|
|
|
|
log ("contactId: " + contactId);
|
|
|
|
if (contactId)
|
|
|
|
{
|
|
|
|
var re = new RegExp("(^|,)" + contactId + "($|,)");
|
|
|
|
|
|
|
|
log ("uids: " + uids);
|
|
|
|
if (!re.test(uids.value))
|
|
|
|
{
|
|
|
|
log ("no match... realling adding");
|
|
|
|
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="'
|
|
|
|
+ ResourcesURL + '/abcard.gif" />'
|
|
|
|
+ contactName + '</li>');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
log ("match... ignoring contact");
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2006-10-23 23:34:56 +02:00
|
|
|
|
|
|
|
function saveEvent(sender) {
|
|
|
|
if (validateAptEditor())
|
|
|
|
document.forms['editform'].submit();
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2006-10-26 02:19:23 +02:00
|
|
|
|
|
|
|
function startDayAsShortString() {
|
2006-10-30 23:43:13 +01:00
|
|
|
return $('startTime_date').valueAsShortDateString();
|
2006-10-26 02:19:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function endDayAsShortString() {
|
2006-10-30 23:43:13 +01: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) {
|
2006-11-07 17:13:03 +01:00
|
|
|
var date = window.timeWidgets[which]['date'].valueAsDate();
|
|
|
|
date.setHours( window.timeWidgets[which]['hour'].value );
|
|
|
|
date.setMinutes( window.timeWidgets[which]['minute'].value );
|
|
|
|
|
|
|
|
return date;
|
|
|
|
}
|
|
|
|
|
2007-06-11 23:23:48 +02:00
|
|
|
function _getShadowDate(which) {
|
2006-11-07 17:13:03 +01:00
|
|
|
var date = window.timeWidgets[which]['date'].getAttribute("shadow-value").asDate();
|
|
|
|
var intValue = parseInt(window.timeWidgets[which]['hour'].getAttribute("shadow-value"));
|
|
|
|
date.setHours(intValue);
|
|
|
|
intValue = parseInt(window.timeWidgets[which]['minute'].getAttribute("shadow-value"));
|
|
|
|
date.setMinutes(intValue);
|
2007-10-19 16:36:33 +02:00
|
|
|
// window.alert("shadow: " + date);
|
2006-11-07 17:13:03 +01:00
|
|
|
|
|
|
|
return date;
|
|
|
|
}
|
|
|
|
|
2007-06-11 23:23:48 +02:00
|
|
|
function getStartDate() {
|
2006-11-07 17:13:03 +01:00
|
|
|
return this._getDate('start');
|
|
|
|
}
|
|
|
|
|
2007-06-11 23:23:48 +02:00
|
|
|
function getEndDate() {
|
2006-11-07 17:13:03 +01:00
|
|
|
return this._getDate('end');
|
|
|
|
}
|
|
|
|
|
2007-06-11 23:23:48 +02:00
|
|
|
function getShadowStartDate() {
|
2006-11-07 17:13:03 +01:00
|
|
|
return this._getShadowDate('start');
|
|
|
|
}
|
|
|
|
|
2007-06-11 23:23:48 +02:00
|
|
|
function getShadowEndDate() {
|
2006-11-07 17:13:03 +01:00
|
|
|
return this._getShadowDate('end');
|
|
|
|
}
|
|
|
|
|
2007-06-11 23:23:48 +02:00
|
|
|
function _setDate(which, newDate) {
|
2006-11-07 17:13:03 +01:00
|
|
|
window.timeWidgets[which]['date'].setValueAsDate(newDate);
|
|
|
|
window.timeWidgets[which]['hour'].value = newDate.getHours();
|
|
|
|
var minutes = newDate.getMinutes();
|
|
|
|
if (minutes % 15)
|
|
|
|
minutes += (15 - minutes % 15);
|
|
|
|
window.timeWidgets[which]['minute'].value = minutes;
|
|
|
|
}
|
|
|
|
|
2007-06-11 23:23:48 +02:00
|
|
|
function setStartDate(newStartDate) {
|
2006-11-07 17:13:03 +01:00
|
|
|
this._setDate('start', newStartDate);
|
|
|
|
}
|
|
|
|
|
2007-06-11 23:23:48 +02:00
|
|
|
function setEndDate(newEndDate) {
|
2007-10-19 16:36:33 +02:00
|
|
|
// window.alert(newEndDate);
|
2006-11-07 17:13:03 +01:00
|
|
|
this._setDate('end', newEndDate);
|
|
|
|
}
|
|
|
|
|
2007-06-11 23:23:48 +02:00
|
|
|
function onAdjustEndTime(event) {
|
2006-11-07 17:13:03 +01:00
|
|
|
var dateDelta = (window.getStartDate().valueOf()
|
|
|
|
- window.getShadowStartDate().valueOf());
|
2007-10-19 16:36:33 +02:00
|
|
|
// window.alert(window.getEndDate().valueOf() + ' ' + dateDelta);
|
2006-11-07 17:13:03 +01:00
|
|
|
var newEndDate = new Date(window.getEndDate().valueOf() + dateDelta);
|
|
|
|
window.setEndDate(newEndDate);
|
|
|
|
window.timeWidgets['start']['date'].updateShadowValue();
|
|
|
|
window.timeWidgets['start']['hour'].updateShadowValue();
|
|
|
|
window.timeWidgets['start']['minute'].updateShadowValue();
|
|
|
|
}
|
|
|
|
|
2007-06-11 23:23:48 +02:00
|
|
|
function onAllDayChanged(event) {
|
2007-10-19 16:36:33 +02:00
|
|
|
for (var type in window.timeWidgets) {
|
|
|
|
window.timeWidgets[type]['hour'].disabled = this.checked;
|
|
|
|
window.timeWidgets[type]['minute'].disabled = this.checked;
|
|
|
|
}
|
2007-06-11 23:23:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function initTimeWidgets(widgets) {
|
2006-11-07 17:13:03 +01:00
|
|
|
this.timeWidgets = widgets;
|
|
|
|
|
2007-10-19 16:36:33 +02:00
|
|
|
Event.observe(widgets['start']['date'], "change",
|
|
|
|
this.onAdjustEndTime, false);
|
|
|
|
Event.observe(widgets['start']['hour'], "change",
|
|
|
|
this.onAdjustEndTime, false);
|
|
|
|
Event.observe(widgets['start']['minute'], "change",
|
|
|
|
this.onAdjustEndTime, false);
|
2007-06-11 23:23:48 +02:00
|
|
|
|
|
|
|
var allDayLabel = $("allDay");
|
|
|
|
var input = $(allDayLabel).childNodesWithTag("input")[0];
|
|
|
|
Event.observe(input, "change", onAllDayChanged.bindAsEventListener(input));
|
|
|
|
if (input.checked) {
|
2007-10-19 16:36:33 +02:00
|
|
|
for (var type in widgets) {
|
|
|
|
widgets[type]['hour'].disabled = true;
|
|
|
|
widgets[type]['minute'].disabled = true;
|
|
|
|
}
|
2007-06-11 23:23:48 +02:00
|
|
|
}
|
2006-11-07 17:13:03 +01:00
|
|
|
}
|
2007-06-11 23:23:48 +02:00
|
|
|
|
|
|
|
function onAppointmentEditorLoad() {
|
2007-10-19 16:36:33 +02:00
|
|
|
assignCalendar('startTime_date');
|
|
|
|
assignCalendar('endTime_date');
|
|
|
|
|
|
|
|
var widgets = {'start': {'date': $("startTime_date"),
|
|
|
|
'hour': $("startTime_time_hour"),
|
|
|
|
'minute': $("startTime_time_minute")},
|
|
|
|
'end': {'date': $("endTime_date"),
|
|
|
|
'hour': $("endTime_time_hour"),
|
|
|
|
'minute': $("endTime_time_minute")}};
|
|
|
|
initTimeWidgets(widgets);
|
2007-06-11 23:23:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
addEvent(window, 'load', onAppointmentEditorLoad);
|