function uixEarlierDate(date1, date2) {
// can this be done in a sane way?
- // cuicui = 'year';
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
alert(labels.validate_invalid_enddate);
return false;
}
- // cuicui = '';
tmpdate = uixEarlierDate(startdate, enddate);
if (tmpdate == enddate) {
- // window.alert(cuicui);
alert(labels.validate_endbeforestart);
return false;
}
function addContact(tag, fullContactName, contactId, contactName, contactEmail) {
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
+ ResourcesURL + '/abcard.gif" />'
+ contactName + '</li>');
}
- else
- log ("match... ignoring contact");
}
return false;
date.setHours(intValue);
intValue = parseInt(window.timeWidgets[which]['minute'].getAttribute("shadow-value"));
date.setMinutes(intValue);
- // window.alert("shadow: " + date);
return date;
}
}
function setEndDate(newEndDate) {
- // window.alert(newEndDate);
this._setDate('end', newEndDate);
}
-function onAdjustEndTime(event) {
- var dateDelta = (window.getStartDate().valueOf()
- - window.getShadowStartDate().valueOf());
- // window.alert(window.getEndDate().valueOf() + ' ' + dateDelta);
- 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();
+function onAdjustTime(event) {
+ var endDate = window.getEndDate();
+ var startDate = window.getStartDate();
+
+ 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);
+
+ window.timeWidgets['end']['date'].updateShadowValue();
+ window.timeWidgets['end']['hour'].updateShadowValue();
+ window.timeWidgets['end']['minute'].updateShadowValue();
+ window.timeWidgets['start']['date'].updateShadowValue();
+ window.timeWidgets['start']['hour'].updateShadowValue();
+ window.timeWidgets['start']['minute'].updateShadowValue();
+ }
+ 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();
+ window.timeWidgets['end']['hour'].updateShadowValue();
+ window.timeWidgets['end']['minute'].updateShadowValue();
+ }
+ }
}
function onAllDayChanged(event) {
this.timeWidgets = widgets;
Event.observe(widgets['start']['date'], "change",
- this.onAdjustEndTime, false);
+ this.onAdjustTime, false);
Event.observe(widgets['start']['hour'], "change",
- this.onAdjustEndTime, false);
+ this.onAdjustTime, false);
Event.observe(widgets['start']['minute'], "change",
- this.onAdjustEndTime, false);
+ this.onAdjustTime, false);
+
+ Event.observe(widgets['end']['date'], "change",
+ this.onAdjustTime, false);
+ Event.observe(widgets['end']['hour'], "change",
+ this.onAdjustTime, false);
+ Event.observe(widgets['end']['minute'], "change",
+ this.onAdjustTime, false);
var allDayLabel = $("allDay");
var input = $(allDayLabel).childNodesWithTag("input")[0];
initTimeWidgets(widgets);
}
-addEvent(window, 'load', onAppointmentEditorLoad);
+FastInit.addOnLoad(onAppointmentEditorLoad);