2008-08-28 16:48:45 +02:00
|
|
|
/* -*- Mode: java; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: t; c-basic-offset: 2 -*- */
|
|
|
|
|
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;
|
2007-10-19 16:36:33 +02:00
|
|
|
// same year
|
|
|
|
// cuicui += '/month';
|
2006-10-23 16:56:58 +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-10-23 16:56:58 +02:00
|
|
|
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) {
|
2007-09-14 23:54:19 +02:00
|
|
|
alert(label);
|
2006-10-23 16:56:58 +02:00
|
|
|
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
|
2007-09-14 23:54:19 +02:00
|
|
|
&& !confirm(labels.validate_notitle))
|
2006-10-23 16:56:58 +02:00
|
|
|
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);
|
2007-09-14 23:54:19 +02:00
|
|
|
alert(labels.validate_endbeforestart);
|
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) {
|
2007-09-14 23:54:19 +02:00
|
|
|
alert(labels.validate_endbeforestart);
|
2006-10-23 16:56:58 +02:00
|
|
|
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) {
|
2007-09-14 23:54:19 +02:00
|
|
|
alert(labels.validate_endbeforestart);
|
2006-10-23 16:56:58 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01: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) {
|
2008-08-28 16:48:45 +02:00
|
|
|
var date = window.timeWidgets[which]['date'].valueAsDate();
|
|
|
|
date.setHours( window.timeWidgets[which]['hour'].value );
|
|
|
|
date.setMinutes( window.timeWidgets[which]['minute'].value );
|
2008-03-27 22:05:47 +01:00
|
|
|
|
2008-08-28 16:48:45 +02:00
|
|
|
return date;
|
2008-03-27 22:05:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
this._getShadowDate = function(which) {
|
2008-08-28 16:48:45 +02: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);
|
|
|
|
// window.alert("shadow: " + date);
|
2008-03-27 22:05:47 +01:00
|
|
|
|
2008-08-28 16:48:45 +02:00
|
|
|
return date;
|
2008-03-27 22:05:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
this.getStartDate = function() {
|
2008-08-28 16:48:45 +02:00
|
|
|
return this._getDate('start');
|
2008-03-27 22:05:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
this.getDueDate = function() {
|
2008-08-28 16:48:45 +02:00
|
|
|
return this._getDate('due');
|
2008-03-27 22:05:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
this.getShadowStartDate = function() {
|
2008-08-28 16:48:45 +02:00
|
|
|
return this._getShadowDate('start');
|
2008-03-27 22:05:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
this.getShadowDueDate = function() {
|
2008-08-28 16:48:45 +02:00
|
|
|
return this._getShadowDate('due');
|
2008-03-27 22:05:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
this._setDate = function(which, newDate) {
|
2008-08-28 16:48:45 +02:00
|
|
|
window.timeWidgets[which]['date'].setValueAsDate(newDate);
|
|
|
|
window.timeWidgets[which]['hour'].value = newDate.getHours();
|
|
|
|
var minutes = newDate.getMinutes();
|
|
|
|
if (minutes % 15)
|
2007-10-19 16:36:33 +02:00
|
|
|
minutes += (15 - minutes % 15);
|
2008-08-28 16:48:45 +02:00
|
|
|
window.timeWidgets[which]['minute'].value = minutes;
|
2008-03-27 22:05:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
this.setStartDate = function(newStartDate) {
|
2008-08-28 16:48:45 +02:00
|
|
|
this._setDate('start', newStartDate);
|
2008-03-27 22:05:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
this.setDueDate = function(newDueDate) {
|
2008-08-28 16:48:45 +02:00
|
|
|
// window.alert(newDueDate);
|
|
|
|
this._setDate('due', newDueDate);
|
2008-03-27 22:05:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
this.onAdjustTime = function(event) {
|
2008-08-28 16:48:45 +02:00
|
|
|
onAdjustDueTime(event);
|
2008-03-27 22:05:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
this.onAdjustDueTime = function(event) {
|
|
|
|
if (!window.timeWidgets['due']['date'].disabled) {
|
2008-08-28 16:48:45 +02:00
|
|
|
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();
|
2008-03-27 22:05:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
this.initTimeWidgets = function (widgets) {
|
2008-08-28 16:48:45 +02:00
|
|
|
this.timeWidgets = widgets;
|
2008-03-27 22:05:47 +01:00
|
|
|
|
2008-08-28 16:48:45 +02:00
|
|
|
widgets['start']['date'].observe("change", this.onAdjustDueTime, false);
|
|
|
|
widgets['start']['hour'].observe("change", this.onAdjustDueTime, false);
|
|
|
|
widgets['start']['minute'].observe("change", this.onAdjustDueTime, false);
|
2008-03-27 22:05:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
function onStatusListChange(event) {
|
2008-08-28 16:48:45 +02:00
|
|
|
var value = $("statusList").value;
|
|
|
|
var statusTimeDate = $("statusTime_date");
|
|
|
|
var statusPercent = $("statusPercent");
|
2008-03-27 22:05:47 +01:00
|
|
|
|
2008-08-28 16:48:45 +02:00
|
|
|
if (value == "WONoSelectionString") {
|
|
|
|
statusTimeDate.disabled = true;
|
|
|
|
statusPercent.disabled = true;
|
|
|
|
statusPercent.value = "";
|
|
|
|
}
|
|
|
|
else if (value == "0") {
|
|
|
|
statusTimeDate.disabled = true;
|
|
|
|
statusPercent.disabled = false;
|
|
|
|
}
|
|
|
|
else if (value == "1") {
|
|
|
|
statusTimeDate.disabled = true;
|
|
|
|
statusPercent.disabled = false;
|
|
|
|
}
|
|
|
|
else if (value == "2") {
|
|
|
|
statusTimeDate.disabled = false;
|
|
|
|
statusPercent.disabled = false;
|
|
|
|
statusPercent.value = "100";
|
|
|
|
}
|
|
|
|
else if (value == "3") {
|
|
|
|
statusTimeDate.disabled = true;
|
|
|
|
statusPercent.disabled = true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
statusTimeDate.disabled = true;
|
|
|
|
}
|
2008-03-27 22:05:47 +01:00
|
|
|
}
|
2007-03-18 16:00:34 +01:00
|
|
|
|
|
|
|
function initializeStatusLine() {
|
2007-10-19 16:36:33 +02:00
|
|
|
var statusList = $("statusList");
|
2008-04-15 22:12:51 +02:00
|
|
|
statusList.observe("mouseup", onStatusListChange, false);
|
2007-03-18 16:00:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function onTaskEditorLoad() {
|
2008-08-28 16:48:45 +02:00
|
|
|
assignCalendar('startTime_date');
|
|
|
|
assignCalendar('dueTime_date');
|
|
|
|
assignCalendar('statusTime_date');
|
|
|
|
|
|
|
|
var widgets = {'start': {'date': $("startTime_date"),
|
|
|
|
'hour': $("startTime_time_hour"),
|
|
|
|
'minute': $("startTime_time_minute")},
|
|
|
|
'due': {'date': $("dueTime_date"),
|
|
|
|
'hour': $("dueTime_time_hour"),
|
|
|
|
'minute': $("dueTime_time_minute")}};
|
|
|
|
initTimeWidgets(widgets);
|
2008-03-27 22:05:47 +01:00
|
|
|
|
2007-10-19 16:36:33 +02:00
|
|
|
initializeStatusLine();
|
2007-03-18 16:00:34 +01:00
|
|
|
}
|
2007-07-10 16:13:44 +02:00
|
|
|
|
2009-03-12 22:09:14 +01:00
|
|
|
document.observe("dom:loaded", onTaskEditorLoad);
|