2006-10-11 20:13:11 +02:00
|
|
|
/*
|
2006-10-23 16:56:58 +02:00
|
|
|
Copyright (C) 2005 SKYRIX Software AG
|
2006-10-11 20:13:11 +02:00
|
|
|
|
2006-10-23 16:56:58 +02:00
|
|
|
This file is part of SOGo.
|
2006-10-11 20:13:11 +02:00
|
|
|
|
2006-10-23 16:56:58 +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-10-11 20:13:11 +02:00
|
|
|
|
2006-10-23 16:56:58 +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-10-11 20:13:11 +02:00
|
|
|
|
2006-10-23 16:56:58 +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-10-11 20:13:11 +02:00
|
|
|
*/
|
|
|
|
|
2006-10-18 23:53:47 +02:00
|
|
|
var contactSelectorAction = 'calendars-contacts';
|
2006-10-11 20:13:11 +02:00
|
|
|
|
|
|
|
function uixEarlierDate(date1, date2) {
|
2006-10-23 16:56:58 +02:00
|
|
|
// can this be done in a sane way?
|
|
|
|
// cuicui = 'year';
|
|
|
|
if (date1 && date2) {
|
|
|
|
if (date1.getYear() < date2.getYear()) return date1;
|
|
|
|
if (date1.getYear() > date2.getYear()) return date2;
|
|
|
|
// same year
|
|
|
|
// cuicui += '/month';
|
|
|
|
if (date1.getMonth() < date2.getMonth()) return date1;
|
|
|
|
if (date1.getMonth() > date2.getMonth()) return date2;
|
|
|
|
// // same month
|
|
|
|
// cuicui += '/date';
|
|
|
|
if (date1.getDate() < date2.getDate()) return date1;
|
|
|
|
if (date1.getDate() > date2.getDate()) return date2;
|
|
|
|
}
|
|
|
|
// same day
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
function validateDate(date, label) {
|
|
|
|
var result, dateValue;
|
|
|
|
|
|
|
|
dateValue = date.calendar.prs_date(date.value);
|
|
|
|
if (date.value.length != 10 || !dateValue) {
|
|
|
|
alert(label.decodeEntities());
|
|
|
|
result = false;
|
|
|
|
} else
|
|
|
|
result = dateValue;
|
|
|
|
|
|
|
|
return result;
|
2006-10-11 20:13:11 +02:00
|
|
|
}
|
|
|
|
|
2006-10-23 23:34:56 +02:00
|
|
|
function validateTaskEditor() {
|
2006-10-23 16:56:58 +02:00
|
|
|
var e, startdate, enddate, tmpdate;
|
|
|
|
|
|
|
|
e = document.getElementById('summary');
|
|
|
|
if (e.value.length == 0
|
|
|
|
&& !confirm(labels.validate_notitle.decodeEntities()))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
e = document.getElementById('startTime_date');
|
|
|
|
if (!e.disabled) {
|
|
|
|
startdate = validateDate(e, labels.validate_invalid_startdate);
|
|
|
|
if (!startdate)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
e = document.getElementById('dueTime_date');
|
|
|
|
if (!e.disabled) {
|
|
|
|
enddate = validateDate(e, labels.validate_invalid_enddate);
|
|
|
|
if (!enddate)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (startdate && enddate) {
|
|
|
|
tmpdate = uixEarlierDate(startdate, enddate);
|
|
|
|
if (tmpdate == enddate) {
|
2006-10-19 16:40:24 +02:00
|
|
|
// window.alert(cuicui);
|
2006-10-12 23:03:17 +02:00
|
|
|
alert(labels.validate_endbeforestart.decodeEntities());
|
2006-10-11 20:13:11 +02:00
|
|
|
return false;
|
2006-10-23 16:56:58 +02:00
|
|
|
}
|
|
|
|
else if (tmpdate == null /* means: same date */) {
|
2006-10-19 16:40:24 +02:00
|
|
|
// TODO: check time
|
|
|
|
var start, end;
|
|
|
|
|
|
|
|
start = parseInt(document.forms[0]['startTime_time_hour'].value);
|
|
|
|
end = parseInt(document.forms[0]['dueTime_time_hour'].value);
|
2006-10-23 16:56:58 +02:00
|
|
|
|
2006-10-11 20:13:11 +02:00
|
|
|
if (start > end) {
|
2006-10-23 16:56:58 +02:00
|
|
|
alert(labels.validate_endbeforestart.decodeEntities());
|
|
|
|
return false;
|
2006-10-19 16:40:24 +02:00
|
|
|
}
|
|
|
|
else if (start == end) {
|
2006-10-23 16:56:58 +02:00
|
|
|
start = parseInt(document.forms[0]['startTime_time_minute'].value);
|
|
|
|
end = parseInt(document.forms[0]['dueTime_time_minute'].value);
|
|
|
|
if (start > end) {
|
|
|
|
alert(labels.validate_endbeforestart.decodeEntities());
|
|
|
|
return false;
|
|
|
|
}
|
2006-10-11 20:13:11 +02:00
|
|
|
}
|
2006-10-23 16:56:58 +02:00
|
|
|
}
|
|
|
|
}
|
2006-10-11 20:13:11 +02:00
|
|
|
|
2006-10-23 16:56:58 +02:00
|
|
|
return true;
|
2006-10-11 20:13:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function toggleDetails() {
|
2006-10-23 16:56:58 +02:00
|
|
|
var div = $("details");
|
|
|
|
var buttons = $("buttons");
|
|
|
|
var buttonsHeight = buttons.clientHeight * 3;
|
|
|
|
|
|
|
|
if (div.style.visibility) {
|
|
|
|
div.style.visibility = null;
|
|
|
|
window.resizeBy(0, -(div.clientHeight + buttonsHeight));
|
|
|
|
$("detailsButton").innerHTML = labels["Show Details"];
|
|
|
|
} else {
|
|
|
|
div.style.visibility = 'visible;';
|
|
|
|
window.resizeBy(0, (div.clientHeight + buttonsHeight));
|
|
|
|
$("detailsButton").innerHTML = labels["Hide Details"];
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2006-10-11 20:13:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function toggleCycleVisibility(node, nodeName, hiddenValue) {
|
2006-10-23 16:56:58 +02:00
|
|
|
var spanNode = $(nodeName);
|
|
|
|
var newVisibility = ((node.value == hiddenValue) ? null : 'visible;');
|
|
|
|
spanNode.style.visibility = newVisibility;
|
2006-10-11 20:13:11 +02:00
|
|
|
|
2006-10-23 16:56:58 +02:00
|
|
|
if (nodeName == 'cycleSelectionFirstLevel') {
|
|
|
|
var otherSpanNode = $('cycleSelectionSecondLevel');
|
|
|
|
if (!newVisibility)
|
2006-10-11 20:13:11 +02:00
|
|
|
{
|
2006-10-23 16:56:58 +02:00
|
|
|
otherSpanNode.superVisibility = otherSpanNode.style.visibility;
|
|
|
|
otherSpanNode.style.visibility = null;
|
2006-10-11 20:13:11 +02:00
|
|
|
}
|
2006-10-23 16:56:58 +02:00
|
|
|
else
|
2006-10-11 20:13:11 +02:00
|
|
|
{
|
2006-10-23 16:56:58 +02:00
|
|
|
otherSpanNode.style.visibility = otherSpanNode.superVisibility;
|
|
|
|
otherSpanNode.superVisibility = null;
|
2006-10-11 20:13:11 +02:00
|
|
|
}
|
2006-10-23 16:56:58 +02:00
|
|
|
}
|
2006-10-11 20:13:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function addContact(tag, fullContactName, contactId, contactName, contactEmail)
|
|
|
|
{
|
2006-10-23 16:56:58 +02:00
|
|
|
var uids = $('uixselector-participants-uidList');
|
|
|
|
log ("contactId: " + contactId);
|
|
|
|
if (contactId)
|
|
|
|
{
|
2006-10-11 20:13:11 +02:00
|
|
|
var re = new RegExp("(^|,)" + contactId + "($|,)");
|
|
|
|
|
|
|
|
log ("uids: " + uids);
|
|
|
|
if (!re.test(uids.value))
|
2006-10-23 16:56:58 +02:00
|
|
|
{
|
|
|
|
log ("no match... realling adding");
|
|
|
|
if (uids.value.length > 0)
|
2006-10-11 20:13:11 +02:00
|
|
|
uids.value += ',' + contactId;
|
2006-10-23 16:56:58 +02:00
|
|
|
else
|
2006-10-11 20:13:11 +02:00
|
|
|
uids.value = contactId;
|
|
|
|
|
2006-10-23 16:56:58 +02:00
|
|
|
var names = $('uixselector-participants-display');
|
|
|
|
names.innerHTML += ('<li onmousedown="return false;"'
|
|
|
|
+ ' onclick="onRowClick(event);"><img src="'
|
|
|
|
+ ResourcesURL + '/abcard.gif" />'
|
|
|
|
+ contactName + '</li>');
|
|
|
|
}
|
2006-10-11 20:13:11 +02:00
|
|
|
else
|
2006-10-23 16:56:58 +02:00
|
|
|
log ("match... ignoring contact");
|
|
|
|
}
|
2006-10-19 16:40:24 +02:00
|
|
|
|
2006-10-23 16:56:58 +02:00
|
|
|
return false;
|
2006-10-19 16:40:24 +02:00
|
|
|
}
|
2006-10-11 20:13:11 +02:00
|
|
|
|
2006-10-19 16:40:24 +02:00
|
|
|
function onTimeControlCheck(checkBox) {
|
2006-10-23 16:56:58 +02:00
|
|
|
var inputs = checkBox.parentNode.getElementsByTagName("input");
|
|
|
|
var selects = checkBox.parentNode.getElementsByTagName("select");
|
|
|
|
for (var i = 0; i < inputs.length; i++)
|
|
|
|
if (inputs[i] != checkBox)
|
|
|
|
inputs[i].disabled = !checkBox.checked;
|
|
|
|
for (var i = 0; i < selects.length; i++)
|
|
|
|
if (selects[i] != checkBox)
|
|
|
|
selects[i].disabled = !checkBox.checked;
|
2006-10-11 20:13:11 +02:00
|
|
|
}
|
2006-10-23 23:34:56 +02:00
|
|
|
|
|
|
|
function saveEvent(sender) {
|
|
|
|
if (validateTaskEditor())
|
|
|
|
document.forms['editform'].submit();
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2006-10-27 00:00:54 +02:00
|
|
|
|
|
|
|
function startDayAsShortString() {
|
|
|
|
return dayAsShortDateString($('startTime_date'));
|
|
|
|
}
|
|
|
|
|
|
|
|
function dueDayAsShortString() {
|
|
|
|
return dayAsShortDateString($('dueTime_date'));
|
|
|
|
}
|
2006-11-07 17:13:03 +01:00
|
|
|
|
|
|
|
this._getDate = function(which) {
|
|
|
|
var date = window.timeWidgets[which]['date'].valueAsDate();
|
|
|
|
date.setHours( window.timeWidgets[which]['hour'].value );
|
|
|
|
date.setMinutes( window.timeWidgets[which]['minute'].value );
|
|
|
|
|
|
|
|
return date;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._getShadowDate = function(which) {
|
|
|
|
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);
|
|
|
|
// window.alert("shadow: " + date);
|
|
|
|
|
|
|
|
return date;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.getStartDate = function() {
|
|
|
|
return this._getDate('start');
|
|
|
|
}
|
|
|
|
|
|
|
|
this.getDueDate = function() {
|
|
|
|
return this._getDate('due');
|
|
|
|
}
|
|
|
|
|
|
|
|
this.getShadowStartDate = function() {
|
|
|
|
return this._getShadowDate('start');
|
|
|
|
}
|
|
|
|
|
|
|
|
this.getShadowDueDate = function() {
|
|
|
|
return this._getShadowDate('due');
|
|
|
|
}
|
|
|
|
|
|
|
|
this._setDate = function(which, newDate) {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setStartDate = function(newStartDate) {
|
|
|
|
this._setDate('start', newStartDate);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setDueDate = function(newDueDate) {
|
|
|
|
// window.alert(newDueDate);
|
|
|
|
this._setDate('due', newDueDate);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.onAdjustDueTime = function(event) {
|
|
|
|
if (!window.timeWidgets['due']['date'].disabled) {
|
|
|
|
var dateDelta = (window.getStartDate().valueOf()
|
|
|
|
- window.getShadowStartDate().valueOf());
|
|
|
|
var newDueDate = new Date(window.getDueDate().valueOf() + dateDelta);
|
|
|
|
window.setDueDate(newDueDate);
|
|
|
|
}
|
|
|
|
window.timeWidgets['start']['date'].updateShadowValue();
|
|
|
|
window.timeWidgets['start']['hour'].updateShadowValue();
|
|
|
|
window.timeWidgets['start']['minute'].updateShadowValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.initTimeWidgets = function (widgets) {
|
|
|
|
this.timeWidgets = widgets;
|
|
|
|
|
|
|
|
widgets['start']['date'].addEventListener("change", this.onAdjustDueTime, false);
|
|
|
|
widgets['start']['hour'].addEventListener("change", this.onAdjustDueTime, false);
|
|
|
|
widgets['start']['minute'].addEventListener("change", this.onAdjustDueTime, false);
|
|
|
|
}
|