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
|
|
|
|
2010-05-05 16:40:53 +02:00
|
|
|
var OwnerLogin = "";
|
|
|
|
|
2006-10-26 01:58:29 +02:00
|
|
|
var resultsDiv;
|
|
|
|
var address;
|
2007-03-18 16:00:34 +01:00
|
|
|
var additionalDays = 2;
|
|
|
|
|
2009-06-05 18:55:26 +02:00
|
|
|
var isAllDay = parent$("isAllDay").checked + 0;
|
|
|
|
var displayStartHour = 0;
|
|
|
|
var displayEndHour = 23;
|
2009-06-04 22:59:48 +02:00
|
|
|
|
2007-12-12 18:48:19 +01:00
|
|
|
var attendeesEditor = {
|
2009-09-09 16:45:43 +02:00
|
|
|
delay: 500,
|
2009-09-10 20:31:20 +02:00
|
|
|
selectedIndex: -1
|
2007-12-12 18:48:19 +01:00
|
|
|
};
|
2006-10-26 01:58:29 +02:00
|
|
|
|
2009-06-04 20:50:23 +02:00
|
|
|
function handleAllDay () {
|
2009-09-09 16:45:43 +02:00
|
|
|
window.timeWidgets['end']['hour'].value = 17;
|
|
|
|
window.timeWidgets['end']['minute'].value = 0;
|
|
|
|
window.timeWidgets['start']['hour'].value = 9;
|
|
|
|
window.timeWidgets['start']['minute'].value = 0;
|
2009-06-04 20:50:23 +02:00
|
|
|
|
2009-09-09 16:45:43 +02:00
|
|
|
$("startTime_time_hour").disabled = true;
|
|
|
|
$("startTime_time_minute").disabled = true;
|
|
|
|
$("endTime_time_hour").disabled = true;
|
|
|
|
$("endTime_time_minute").disabled = true;
|
2009-06-04 20:50:23 +02:00
|
|
|
}
|
|
|
|
|
2008-07-04 11:43:28 +02:00
|
|
|
/* address completion */
|
|
|
|
|
2010-05-05 20:49:29 +02:00
|
|
|
function resolveListAttendees(input, append) {
|
|
|
|
var urlstr = (UserFolderURL
|
|
|
|
+ "Contacts/"
|
|
|
|
+ escape(input.container) + "/"
|
|
|
|
+ escape(input.cname) + "/properties");
|
|
|
|
triggerAjaxRequest(urlstr, resolveListAttendeesCallback,
|
|
|
|
{ "input": input, "append": append });
|
|
|
|
}
|
|
|
|
|
|
|
|
function resolveListAttendeesCallback(http) {
|
|
|
|
if (http.readyState == 4 && http.status == 200) {
|
|
|
|
var input = http.callbackData["input"];
|
|
|
|
var append = http.callbackData["append"];
|
|
|
|
var contacts = http.responseText.evalJSON(true);
|
|
|
|
for (var i = 0; i < contacts.length; i++) {
|
|
|
|
var contact = contacts[i];
|
|
|
|
var fullName = contact[1];
|
|
|
|
if (fullName && fullName.length > 0) {
|
|
|
|
fullName += " <" + contact[2] + ">";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fullName = contact[2];
|
|
|
|
}
|
|
|
|
input.uid = null;
|
|
|
|
input.cname = null;
|
|
|
|
input.container = null;
|
|
|
|
input.isList = false;
|
|
|
|
input.value = contact[2];
|
|
|
|
input.confirmedValue = null;
|
|
|
|
input.hasfreebusy = false;
|
|
|
|
input.modified = true;
|
|
|
|
// input.focussed = true;
|
|
|
|
// input.activate();
|
|
|
|
input.checkAfterLookup = true;
|
|
|
|
performSearch(input);
|
|
|
|
if (i < (contacts.length - 1)) {
|
|
|
|
var nextRow = newAttendee(input.parentNode.parentNode);
|
|
|
|
input = nextRow.down("input");
|
|
|
|
} else if (append) {
|
|
|
|
var row = input.parentNode.parentNode;
|
|
|
|
var tBody = row.parentNode;
|
|
|
|
if (row.rowIndex == (tBody.rows.length - 3)) {
|
|
|
|
if (input.selectText) {
|
|
|
|
input.selectText(0, 0);
|
|
|
|
} else if (input.createTextRange) {
|
|
|
|
input.createTextRange().moveStart();
|
|
|
|
}
|
|
|
|
newAttendee();
|
|
|
|
} else {
|
|
|
|
var nextRow = tBody.rows[row.rowIndex + 1];
|
|
|
|
var input = nextRow.down("input");
|
|
|
|
input.selectText(0, input.value.length);
|
|
|
|
input.focussed = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (input.selectText) {
|
|
|
|
input.selectText(0, 0);
|
|
|
|
} else if (input.createTextRange) {
|
|
|
|
input.createTextRange().moveStart();
|
|
|
|
}
|
|
|
|
input.blur();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-11-13 19:46:00 +01:00
|
|
|
function onContactKeydown(event) {
|
2009-09-09 16:45:43 +02:00
|
|
|
if (event.ctrlKey || event.metaKey) {
|
|
|
|
this.focussed = true;
|
|
|
|
return;
|
|
|
|
}
|
2010-05-05 20:49:29 +02:00
|
|
|
if (event.keyCode == 9 || event.keyCode == 13) { // Tab
|
2009-09-09 16:45:43 +02:00
|
|
|
preventDefault(event);
|
|
|
|
if (this.confirmedValue)
|
|
|
|
this.value = this.confirmedValue;
|
|
|
|
this.hasfreebusy = false;
|
|
|
|
var row = $(this).up("tr").next();
|
2010-05-05 20:49:29 +02:00
|
|
|
if (this.isList) {
|
|
|
|
resolveListAttendees(this, true);
|
|
|
|
event.stop();
|
|
|
|
} else {
|
|
|
|
checkAttendee(this);
|
|
|
|
// this.blur(); // triggers checkAttendee function call
|
|
|
|
var input = row.down("input");
|
|
|
|
if (input) {
|
|
|
|
input.focussed = true;
|
|
|
|
input.activate();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
newAttendee();
|
2009-09-09 16:45:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (event.keyCode == 0
|
|
|
|
|| event.keyCode == 8 // Backspace
|
|
|
|
|| event.keyCode == 32 // Space
|
|
|
|
|| event.keyCode > 47) {
|
2010-05-05 20:49:29 +02:00
|
|
|
this.modified = true;
|
2009-09-09 16:45:43 +02:00
|
|
|
this.confirmedValue = null;
|
2010-05-05 20:49:29 +02:00
|
|
|
this.cname = null;
|
2009-09-09 16:45:43 +02:00
|
|
|
this.uid = null;
|
2010-05-05 20:49:29 +02:00
|
|
|
this.container = null;
|
2009-09-09 16:45:43 +02:00
|
|
|
this.hasfreebusy = false;
|
2010-05-05 20:49:29 +02:00
|
|
|
if (this.searchTimeout) {
|
|
|
|
window.clearTimeout(this.searchTimeout);
|
|
|
|
}
|
|
|
|
if (this.value.length > 0) {
|
|
|
|
var thisInput = this;
|
|
|
|
this.searchTimeout = setTimeout(function()
|
|
|
|
{performSearch(thisInput);
|
|
|
|
thisInput = null;},
|
|
|
|
attendeesEditor.delay);
|
2009-09-09 16:45:43 +02:00
|
|
|
}
|
|
|
|
else if (this.value.length == 0) {
|
|
|
|
if (document.currentPopupMenu)
|
|
|
|
hideMenu(document.currentPopupMenu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($('attendeesMenu').getStyle('visibility') == 'visible') {
|
|
|
|
if (event.keyCode == Event.KEY_UP) { // Up arrow
|
|
|
|
if (attendeesEditor.selectedIndex > 0) {
|
|
|
|
var attendees = $('attendeesMenu').select("li");
|
|
|
|
attendees[attendeesEditor.selectedIndex--].removeClassName("selected");
|
2010-05-05 20:49:29 +02:00
|
|
|
var attendee = attendees[attendeesEditor.selectedIndex];
|
|
|
|
attendee.addClassName("selected");
|
|
|
|
this.value = this.confirmedValue = attendee.address;
|
|
|
|
this.uid = attendee.uid;
|
|
|
|
this.isList = attendee.isList;
|
|
|
|
this.cname = attendee.cname;
|
|
|
|
this.container = attendee.container;
|
2009-09-09 16:45:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (event.keyCode == Event.KEY_DOWN) { // Down arrow
|
|
|
|
var attendees = $('attendeesMenu').select("li");
|
|
|
|
if (attendees.size() - 1 > attendeesEditor.selectedIndex) {
|
|
|
|
if (attendeesEditor.selectedIndex >= 0)
|
|
|
|
attendees[attendeesEditor.selectedIndex].removeClassName("selected");
|
|
|
|
attendeesEditor.selectedIndex++;
|
2010-05-05 20:49:29 +02:00
|
|
|
var attendee = attendees[attendeesEditor.selectedIndex];
|
|
|
|
attendee.addClassName("selected");
|
|
|
|
this.value = this.confirmedValue = attendee.address;
|
|
|
|
this.isList = attendee.isList;
|
|
|
|
this.uid = attendee.uid;
|
|
|
|
this.cname = attendee.cname;
|
|
|
|
this.container = attendee.container;
|
2009-09-09 16:45:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-10-26 01:58:29 +02:00
|
|
|
}
|
|
|
|
|
2010-05-05 20:49:29 +02:00
|
|
|
function performSearch(input) {
|
2009-09-09 16:45:43 +02:00
|
|
|
// Perform address completion
|
2010-05-05 20:49:29 +02:00
|
|
|
if (input.value.trim().length > 0) {
|
|
|
|
var urlstr = (UserFolderURL
|
|
|
|
+ "Contacts/allContactSearch?excludeGroups=1&search="
|
|
|
|
+ escape(input.value));
|
|
|
|
triggerAjaxRequest(urlstr, performSearchCallback, input);
|
2008-07-04 11:43:28 +02:00
|
|
|
}
|
2010-05-05 20:49:29 +02:00
|
|
|
input.searchTimeout = null;
|
2006-10-26 01:58:29 +02:00
|
|
|
}
|
|
|
|
|
2007-12-12 18:48:19 +01:00
|
|
|
function performSearchCallback(http) {
|
2009-09-09 16:45:43 +02:00
|
|
|
if (http.readyState == 4) {
|
|
|
|
var menu = $('attendeesMenu');
|
|
|
|
var list = menu.down("ul");
|
2007-12-12 18:48:19 +01:00
|
|
|
|
2009-09-09 16:45:43 +02:00
|
|
|
var input = http.callbackData;
|
2007-11-13 23:51:32 +01:00
|
|
|
|
2009-09-09 16:45:43 +02:00
|
|
|
if (http.status == 200) {
|
|
|
|
var start = input.value.length;
|
|
|
|
var data = http.responseText.evalJSON(true);
|
2008-07-04 11:43:28 +02:00
|
|
|
|
2009-09-09 16:45:43 +02:00
|
|
|
if (data.contacts.length > 1) {
|
2010-05-05 20:49:29 +02:00
|
|
|
list.input = input;
|
2009-09-09 16:45:43 +02:00
|
|
|
$(list.childNodesWithTag("li")).each(function(item) {
|
|
|
|
item.remove();
|
|
|
|
});
|
2007-11-13 23:51:32 +01:00
|
|
|
|
2009-09-09 16:45:43 +02:00
|
|
|
// Populate popup menu
|
|
|
|
for (var i = 0; i < data.contacts.length; i++) {
|
|
|
|
var contact = data.contacts[i];
|
2010-05-05 20:49:29 +02:00
|
|
|
var isList = (contact["c_component"] &&
|
|
|
|
contact["c_component"] == "vlist");
|
|
|
|
var completeEmail = contact["c_cn"].trim();
|
|
|
|
if (!isList) {
|
|
|
|
if (completeEmail)
|
|
|
|
completeEmail += " <" + contact["c_mail"] + ">";
|
|
|
|
else
|
|
|
|
completeEmail = contact["c_mail"];
|
|
|
|
}
|
|
|
|
var node = createElement('li');
|
|
|
|
list.appendChild(node);
|
|
|
|
node.address = completeEmail;
|
|
|
|
log("node.address: " + node.address);
|
|
|
|
node.uid = contact["c_uid"];
|
|
|
|
node.isList = isList;
|
|
|
|
if (isList) {
|
|
|
|
node.cname = contact["c_name"];
|
|
|
|
node.container = contact["container"];
|
|
|
|
}
|
2009-09-09 16:45:43 +02:00
|
|
|
var matchPosition = completeEmail.toLowerCase().indexOf(data.searchText.toLowerCase());
|
|
|
|
var matchBefore = completeEmail.substring(0, matchPosition);
|
|
|
|
var matchText = completeEmail.substring(matchPosition, matchPosition + data.searchText.length);
|
|
|
|
var matchAfter = completeEmail.substring(matchPosition + data.searchText.length);
|
|
|
|
node.appendChild(document.createTextNode(matchBefore));
|
|
|
|
node.appendChild(new Element('strong').update(matchText));
|
|
|
|
node.appendChild(document.createTextNode(matchAfter));
|
|
|
|
if (contact["contactInfo"])
|
2010-05-05 20:49:29 +02:00
|
|
|
node.appendChild(document.createTextNode(" (" +
|
|
|
|
contact["contactInfo"] + ")"));
|
|
|
|
node.observe("mousedown",
|
|
|
|
onAttendeeResultClick.bindAsEventListener(node));
|
2009-09-09 16:45:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Show popup menu
|
2010-05-05 20:49:29 +02:00
|
|
|
var offsetScroll = Element.cumulativeScrollOffset(input);
|
|
|
|
var offset = Element.cumulativeOffset(input);
|
2009-09-09 16:45:43 +02:00
|
|
|
var top = offset[1] - offsetScroll[1] + node.offsetHeight + 3;
|
|
|
|
var height = 'auto';
|
|
|
|
var heightDiff = window.height() - offset[1];
|
|
|
|
var nodeHeight = node.getHeight();
|
|
|
|
|
|
|
|
if ((data.contacts.length * nodeHeight) > heightDiff)
|
|
|
|
// Limit the size of the popup to the window height, minus 12 pixels
|
|
|
|
height = parseInt(heightDiff/nodeHeight) * nodeHeight - 12 + 'px';
|
|
|
|
|
|
|
|
menu.setStyle({ top: top + "px",
|
|
|
|
left: offset[0] + "px",
|
|
|
|
height: height,
|
|
|
|
visibility: "visible" });
|
|
|
|
menu.scrollTop = 0;
|
|
|
|
|
|
|
|
document.currentPopupMenu = menu;
|
|
|
|
$(document.body).observe("click", onBodyClickMenuHandler);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (document.currentPopupMenu)
|
|
|
|
hideMenu(document.currentPopupMenu);
|
|
|
|
|
|
|
|
if (data.contacts.length == 1) {
|
|
|
|
// Single result
|
|
|
|
var contact = data.contacts[0];
|
2010-05-05 20:49:29 +02:00
|
|
|
input.uid = contact["c_uid"];
|
|
|
|
var row = $(input.parentNode.parentNode);
|
|
|
|
if (input.uid == OwnerLogin) {
|
|
|
|
row.removeAttribute("role");
|
|
|
|
row.setAttribute("partstat", "accepted");
|
|
|
|
row.addClassName("organizer-row");
|
|
|
|
row.removeClassName("attendee-row");
|
|
|
|
row.isOrganizer = true;
|
|
|
|
} else {
|
|
|
|
row.removeAttribute("partstat");
|
|
|
|
row.setAttribute("role", "req-participant");
|
|
|
|
row.addClassName("attendee-row");
|
|
|
|
row.removeClassName("organizer-row");
|
|
|
|
row.isOrganizer = false;
|
|
|
|
}
|
|
|
|
var isList = (contact["c_component"] &&
|
|
|
|
contact["c_component"] == "vlist");
|
|
|
|
if (isList) {
|
|
|
|
input.cname = contact["c_name"];
|
|
|
|
input.container = contact["container"];
|
2010-05-05 16:40:53 +02:00
|
|
|
}
|
2010-05-05 20:49:29 +02:00
|
|
|
var completeEmail = contact["c_cn"].trim();
|
|
|
|
if (!isList) {
|
|
|
|
if (completeEmail)
|
|
|
|
completeEmail += " <" + contact["c_mail"] + ">";
|
|
|
|
else
|
|
|
|
completeEmail = contact["c_mail"];
|
|
|
|
}
|
|
|
|
if ((input.value == contact["c_mail"])
|
|
|
|
|| (contact["c_cn"].substring(0, input.value.length).toUpperCase()
|
|
|
|
== input.value.toUpperCase())) {
|
2009-09-09 16:45:43 +02:00
|
|
|
input.value = completeEmail;
|
2010-05-05 20:49:29 +02:00
|
|
|
}
|
2009-09-09 16:45:43 +02:00
|
|
|
else
|
|
|
|
// The result matches email address, not user name
|
|
|
|
input.value += ' >> ' + completeEmail;
|
2010-05-05 20:49:29 +02:00
|
|
|
input.isList = isList;
|
2009-09-09 16:45:43 +02:00
|
|
|
input.confirmedValue = completeEmail;
|
|
|
|
var end = input.value.length;
|
|
|
|
$(input).selectText(start, end);
|
|
|
|
|
|
|
|
attendeesEditor.selectedIndex = -1;
|
2010-05-05 20:49:29 +02:00
|
|
|
|
|
|
|
if (input.checkAfterLookup) {
|
|
|
|
input.checkAfterLookup = false;
|
|
|
|
input.modified = true;
|
|
|
|
input.hasfreebusy = false;
|
|
|
|
checkAttendee(input);
|
|
|
|
}
|
2009-09-09 16:45:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (document.currentPopupMenu)
|
|
|
|
hideMenu(document.currentPopupMenu);
|
|
|
|
}
|
2006-10-26 01:58:29 +02:00
|
|
|
}
|
|
|
|
|
2007-11-13 23:51:32 +01:00
|
|
|
function onAttendeeResultClick(event) {
|
2010-05-05 20:49:29 +02:00
|
|
|
var input = this.parentNode.input;
|
|
|
|
input.uid = this.uid;
|
|
|
|
input.cname = this.cname;
|
|
|
|
input.container = this.container;
|
|
|
|
input.isList = this.isList;
|
|
|
|
input.confirmedValue = input.value = this.address;
|
|
|
|
checkAttendee(input);
|
|
|
|
this.parentNode.input = null;
|
2007-11-13 23:51:32 +01:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function resetFreeBusyZone() {
|
2009-09-09 16:45:43 +02:00
|
|
|
var table = $("freeBusyHeader");
|
|
|
|
var row = table.rows[2];
|
|
|
|
for (var i = 0; i < row.cells.length; i++) {
|
|
|
|
var nodes = $(row.cells[i]).childNodesWithTag("span");
|
|
|
|
for (var j = 0; j < nodes.length; j++)
|
|
|
|
nodes[j].removeClassName("busy");
|
|
|
|
}
|
2006-10-26 01:58:29 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function redisplayFreeBusyZone() {
|
2009-09-09 16:45:43 +02:00
|
|
|
var table = $("freeBusyHeader");
|
|
|
|
var row = table.rows[2];
|
|
|
|
var stDay = $("startTime_date").valueAsDate();
|
|
|
|
var etDay = $("endTime_date").valueAsDate();
|
|
|
|
|
|
|
|
var days = stDay.daysUpTo(etDay);
|
|
|
|
var addDays = days.length - 1;
|
|
|
|
var stHour = parseInt($("startTime_time_hour").value);
|
|
|
|
var stMinute = parseInt($("startTime_time_minute").value) / 15;
|
|
|
|
var etHour = parseInt($("endTime_time_hour").value);
|
|
|
|
var etMinute = parseInt($("endTime_time_minute").value) / 15;
|
2009-10-21 20:07:09 +02:00
|
|
|
|
2009-09-09 16:45:43 +02:00
|
|
|
if (stHour < displayStartHour) {
|
|
|
|
stHour = displayStartHour;
|
|
|
|
stMinute = 0;
|
|
|
|
}
|
|
|
|
if (stHour > displayEndHour + 1) {
|
|
|
|
stHour = displayEndHour + 1;
|
|
|
|
stMinute = 0;
|
|
|
|
}
|
|
|
|
if (etHour < displayStartHour) {
|
|
|
|
etHour = displayStartHour;
|
|
|
|
etMinute = 0;
|
|
|
|
}
|
|
|
|
if (etHour > displayEndHour + 1) {
|
|
|
|
etHour = displayEndHour;
|
|
|
|
etMinute = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
var deltaCells = (etHour - stHour) + ((displayEndHour - displayStartHour + 1) * addDays);
|
|
|
|
var deltaSpans = (deltaCells * 4 ) + (etMinute - stMinute);
|
|
|
|
var currentCellNbr = stHour - displayStartHour;
|
|
|
|
var currentCell = row.cells[currentCellNbr];
|
|
|
|
var currentSpanNbr = stMinute;
|
|
|
|
var spans = $(currentCell).childNodesWithTag("span");
|
|
|
|
resetFreeBusyZone();
|
|
|
|
while (deltaSpans > 0) {
|
|
|
|
var currentSpan = spans[currentSpanNbr];
|
|
|
|
currentSpan.addClassName("busy");
|
|
|
|
currentSpanNbr++;
|
|
|
|
if (currentSpanNbr > 3) {
|
|
|
|
currentSpanNbr = 0;
|
|
|
|
currentCellNbr++;
|
|
|
|
currentCell = row.cells[currentCellNbr];
|
|
|
|
spans = $(currentCell).childNodesWithTag("span");
|
|
|
|
}
|
|
|
|
deltaSpans--;
|
|
|
|
}
|
2009-10-21 20:07:09 +02:00
|
|
|
scrollToEvent();
|
2006-10-26 01:58:29 +02:00
|
|
|
}
|
|
|
|
|
2010-05-05 16:40:53 +02:00
|
|
|
function onAttendeeStatusClick(event) {
|
|
|
|
rotateAttendeeStatus(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
function rotateAttendeeStatus(row) {
|
|
|
|
var values;
|
|
|
|
var attributeName;
|
|
|
|
if (row.isOrganizer) {
|
|
|
|
values = [ "accepted", "declined", "tentative", "needs-action" ];
|
|
|
|
attributeName = "partstat";
|
|
|
|
} else {
|
|
|
|
values = [ "req-participant", "opt-participant",
|
|
|
|
"chair", "non-participant" ];
|
|
|
|
attributeName = "role";
|
|
|
|
}
|
|
|
|
var value = row.getAttribute(attributeName);
|
|
|
|
var idx = (value ? values.indexOf(value) : -1);
|
|
|
|
if (idx == -1 || idx > (values.length - 2)) {
|
|
|
|
idx = 0;
|
|
|
|
} else {
|
|
|
|
idx++;
|
|
|
|
}
|
|
|
|
row.setAttribute(attributeName, values[idx]);
|
|
|
|
if (Prototype.Browser.IE) {
|
|
|
|
/* This hack enables a refresh of the row element right after the
|
|
|
|
click. Otherwise, this occurs only when leaving the element with
|
|
|
|
them mouse cursor. */
|
|
|
|
row.className = row.className;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-05 20:49:29 +02:00
|
|
|
function onNewAttendeeClick(event) {
|
|
|
|
newAttendee();
|
|
|
|
event.stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
function newAttendee(previousAttendee) {
|
2009-09-09 16:45:43 +02:00
|
|
|
var table = $("freeBusyAttendees");
|
|
|
|
var tbody = table.tBodies[0];
|
|
|
|
var model = tbody.rows[tbody.rows.length - 1];
|
2010-05-05 20:49:29 +02:00
|
|
|
var nextRowIndex = tbody.rows.length - 2;
|
|
|
|
if (previousAttendee) {
|
|
|
|
nextRowIndex = previousAttendee.rowIndex + 1;
|
|
|
|
}
|
|
|
|
var nextRow = tbody.rows[nextRowIndex];
|
2010-05-05 16:40:53 +02:00
|
|
|
var newRow = $(model.cloneNode(true));
|
2010-05-05 20:49:29 +02:00
|
|
|
tbody.insertBefore(newRow, nextRow);
|
|
|
|
var result = newRow;
|
2010-05-05 16:40:53 +02:00
|
|
|
|
|
|
|
var statusTD = newRow.down(".attendeeStatus");
|
|
|
|
if (statusTD) {
|
|
|
|
var boundOnStatusClick = onAttendeeStatusClick.bindAsEventListener(newRow);
|
|
|
|
statusTD.observe("click", boundOnStatusClick, false);
|
|
|
|
}
|
|
|
|
|
2009-09-09 16:45:43 +02:00
|
|
|
$(newRow).removeClassName("attendeeModel");
|
2007-12-12 18:48:19 +01:00
|
|
|
|
2010-05-05 16:40:53 +02:00
|
|
|
var input = newRow.down("input");
|
2010-05-05 20:49:29 +02:00
|
|
|
input.observe("keydown", onContactKeydown.bindAsEventListener(input));
|
|
|
|
input.observe("blur", onInputBlur);
|
2009-09-09 16:45:43 +02:00
|
|
|
|
|
|
|
input.focussed = true;
|
|
|
|
input.activate();
|
|
|
|
|
|
|
|
table = $("freeBusyData");
|
|
|
|
tbody = table.tBodies[0];
|
|
|
|
model = tbody.rows[tbody.rows.length - 1];
|
2010-05-05 20:49:29 +02:00
|
|
|
nextRow = tbody.rows[nextRowIndex];
|
2010-05-05 16:40:53 +02:00
|
|
|
newRow = $(model.cloneNode(true));
|
2010-05-05 20:49:29 +02:00
|
|
|
tbody.insertBefore(newRow, nextRow);
|
2010-05-05 16:40:53 +02:00
|
|
|
newRow.removeClassName("dataModel");
|
2009-09-09 16:45:43 +02:00
|
|
|
|
|
|
|
var attendeesDiv = $$('TABLE#freeBusy TD.freeBusyAttendees DIV').first();
|
|
|
|
var dataDiv = $$('TABLE#freeBusy TD.freeBusyData DIV').first();
|
2008-01-04 21:58:52 +01:00
|
|
|
|
2009-09-09 16:45:43 +02:00
|
|
|
dataDiv.scrollTop = attendeesDiv.scrollTop;
|
2006-10-26 01:58:29 +02:00
|
|
|
|
2010-05-05 20:49:29 +02:00
|
|
|
return result;
|
|
|
|
}
|
2009-09-09 16:45:43 +02:00
|
|
|
|
2010-05-05 20:49:29 +02:00
|
|
|
function checkAttendee(input) {
|
|
|
|
var row = $(input.parentNode.parentNode);
|
2009-09-09 16:45:43 +02:00
|
|
|
var tbody = row.parentNode;
|
2010-05-05 20:49:29 +02:00
|
|
|
if (tbody && input.value.trim().length == 0) {
|
2009-09-09 16:45:43 +02:00
|
|
|
var dataTable = $("freeBusyData").tBodies[0];
|
|
|
|
var dataRow = dataTable.rows[row.sectionRowIndex];
|
|
|
|
tbody.removeChild(row);
|
|
|
|
dataTable.removeChild(dataRow);
|
2010-05-05 16:40:53 +02:00
|
|
|
}
|
2010-05-05 20:49:29 +02:00
|
|
|
else if (input.modified) {
|
|
|
|
if (!row.hasClassName("needs-action")) {
|
|
|
|
row.addClassName("needs-action");
|
|
|
|
row.removeClassName("declined");
|
|
|
|
row.removeClassName("accepted");
|
2009-09-09 16:45:43 +02:00
|
|
|
}
|
2010-05-05 20:49:29 +02:00
|
|
|
if (!input.hasfreebusy) {
|
|
|
|
if (input.uid && input.confirmedValue) {
|
|
|
|
input.value = input.confirmedValue;
|
|
|
|
}
|
|
|
|
displayFreeBusyForNode(input);
|
|
|
|
input.hasfreebusy = true;
|
|
|
|
}
|
|
|
|
input.modified = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onInputBlur(event) {
|
|
|
|
if (document.currentPopupMenu && !this.confirmedValue) {
|
|
|
|
// Hack for IE7; blur event is triggered on input field when
|
|
|
|
// selecting a menu item
|
|
|
|
var visible = $(document.currentPopupMenu).getStyle('visibility') != 'hidden';
|
|
|
|
if (visible) {
|
|
|
|
log("XXX we return");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (document.currentPopupMenu)
|
|
|
|
hideMenu(document.currentPopupMenu);
|
|
|
|
|
|
|
|
if (this.isList) {
|
|
|
|
resolveListAttendees(this, false);
|
|
|
|
} else {
|
|
|
|
checkAttendee(this);
|
2009-09-09 16:45:43 +02:00
|
|
|
}
|
2006-10-26 01:58:29 +02:00
|
|
|
}
|
|
|
|
|
2008-01-04 21:58:52 +01:00
|
|
|
function displayFreeBusyForNode(input) {
|
2009-09-09 16:45:43 +02:00
|
|
|
var rowIndex = input.parentNode.parentNode.sectionRowIndex;
|
2010-05-05 16:40:53 +02:00
|
|
|
var nodes = $("freeBusyData").tBodies[0].rows[rowIndex].cells;
|
|
|
|
log ("displayFreeBusyForNode index " + rowIndex + " (" + nodes.length + " cells)");
|
2009-09-09 16:45:43 +02:00
|
|
|
if (input.uid) {
|
2010-05-05 20:49:29 +02:00
|
|
|
for (var i = 0; i < nodes.length; i++) {
|
|
|
|
var node = $(nodes[i]);
|
|
|
|
node.removeClassName("noFreeBusy");
|
|
|
|
while (node.firstChild) {
|
|
|
|
node.removeChild(node.firstChild);
|
|
|
|
}
|
|
|
|
for (var j = 0; j < 4; j++) {
|
|
|
|
createElement("span", null, "freeBusyZoneElement",
|
|
|
|
null, null, node);
|
2009-09-09 16:45:43 +02:00
|
|
|
}
|
|
|
|
}
|
2010-05-05 20:49:29 +02:00
|
|
|
var sd = $('startTime_date').valueAsShortDateString();
|
|
|
|
var ed = $('endTime_date').valueAsShortDateString();
|
|
|
|
var urlstr = (UserFolderURL + "../" + input.uid
|
|
|
|
+ "/freebusy.ifb/ajaxRead?"
|
|
|
|
+ "sday=" + sd + "&eday=" + ed + "&additional=" +
|
|
|
|
additionalDays);
|
|
|
|
triggerAjaxRequest(urlstr,
|
|
|
|
updateFreeBusyDataCallback,
|
|
|
|
input);
|
2009-09-09 16:45:43 +02:00
|
|
|
} else {
|
|
|
|
for (var i = 0; i < nodes.length; i++) {
|
2010-05-05 20:49:29 +02:00
|
|
|
var node = $(nodes[i]);
|
|
|
|
node.addClassName("noFreeBusy");
|
|
|
|
while (node.firstChild) {
|
|
|
|
node.removeChild(node.firstChild);
|
|
|
|
}
|
2009-09-09 16:45:43 +02:00
|
|
|
}
|
|
|
|
}
|
2006-10-26 01:58:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function setSlot(tds, nbr, status) {
|
2009-09-09 16:45:43 +02:00
|
|
|
var tdnbr = Math.floor(nbr / 4);
|
|
|
|
var spannbr = nbr - (tdnbr * 4);
|
|
|
|
var days = 0;
|
|
|
|
if (tdnbr > 24) {
|
|
|
|
days = Math.floor(tdnbr / 24);
|
|
|
|
tdnbr -= (days * 24);
|
|
|
|
}
|
|
|
|
if (tdnbr > (displayStartHour - 1) && tdnbr < (displayEndHour + 1)) {
|
|
|
|
var i = (days * (displayEndHour - displayStartHour + 1) + tdnbr - (displayStartHour - 1));
|
|
|
|
var td = tds[i - 1];
|
|
|
|
var spans = $(td).childNodesWithTag("span");
|
|
|
|
if (status == '2')
|
|
|
|
$(spans[spannbr]).addClassName("maybe-busy");
|
|
|
|
else
|
|
|
|
$(spans[spannbr]).addClassName("busy");
|
|
|
|
}
|
2006-10-26 01:58:29 +02:00
|
|
|
}
|
|
|
|
|
2007-12-12 18:48:19 +01:00
|
|
|
function updateFreeBusyDataCallback(http) {
|
2009-09-09 16:45:43 +02:00
|
|
|
if (http.readyState == 4) {
|
|
|
|
if (http.status == 200) {
|
|
|
|
var input = http.callbackData;
|
|
|
|
var slots = http.responseText.split(",");
|
|
|
|
var rowIndex = input.parentNode.parentNode.sectionRowIndex;
|
|
|
|
var nodes = $("freeBusyData").tBodies[0].rows[rowIndex].cells;
|
2010-05-05 20:49:29 +02:00
|
|
|
// log ("received " + slots.length + " slots for " + rowIndex + " with " + nodes.length + " cells");
|
2009-09-09 16:45:43 +02:00
|
|
|
for (var i = 0; i < slots.length; i++) {
|
|
|
|
if (slots[i] != '0')
|
|
|
|
setSlot(nodes, i, slots[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-10-26 01:58:29 +02:00
|
|
|
}
|
2006-10-26 18:43:50 +02:00
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function resetAllFreeBusys() {
|
2009-09-09 16:45:43 +02:00
|
|
|
var table = $("freeBusy");
|
|
|
|
var inputs = table.getElementsByTagName("input");
|
2006-10-26 18:43:50 +02:00
|
|
|
|
2009-10-21 20:07:09 +02:00
|
|
|
for (var i = 0; i < inputs.length - 1; i++) {
|
2010-05-05 20:49:29 +02:00
|
|
|
var currentInput = inputs[i];
|
|
|
|
currentInput.hasfreebusy = false;
|
2010-03-25 16:42:52 +01:00
|
|
|
displayFreeBusyForNode(currentInput);
|
2009-09-09 16:45:43 +02:00
|
|
|
}
|
2006-10-26 18:43:50 +02:00
|
|
|
}
|
2006-10-30 23:43:13 +01:00
|
|
|
|
2007-03-18 16:00:34 +01:00
|
|
|
function initializeWindowButtons() {
|
2009-09-09 16:45:43 +02:00
|
|
|
var okButton = $("okButton");
|
|
|
|
var cancelButton = $("cancelButton");
|
|
|
|
|
|
|
|
okButton.observe("click", onEditorOkClick, false);
|
|
|
|
cancelButton.observe("click", onEditorCancelClick, false);
|
|
|
|
|
|
|
|
$("previousSlot").observe ("click", onPreviousSlotClick, false);
|
|
|
|
$("nextSlot").observe ("click", onNextSlotClick, false);
|
2007-03-18 16:00:34 +01:00
|
|
|
}
|
2006-11-07 17:13:03 +01:00
|
|
|
|
2010-05-05 16:40:53 +02:00
|
|
|
function findSlot(direction) {
|
2009-09-09 16:45:43 +02:00
|
|
|
var userList = UserLogin;
|
|
|
|
var table = $("freeBusy");
|
|
|
|
var inputs = table.getElementsByTagName("input");
|
|
|
|
var sd = window.timeWidgets['start']['date'].valueAsShortDateString();
|
|
|
|
var st = window.timeWidgets['start']['hour'].value
|
|
|
|
+ ":" + window.timeWidgets['start']['minute'].value;
|
|
|
|
var ed = window.timeWidgets['end']['date'].valueAsShortDateString();
|
|
|
|
var et = window.timeWidgets['end']['hour'].value
|
|
|
|
+ ":" + window.timeWidgets['end']['minute'].value;
|
|
|
|
|
2009-10-21 20:07:09 +02:00
|
|
|
for (var i = 0; i < inputs.length - 1; i++) {
|
|
|
|
if (inputs[i].uid)
|
2009-09-09 16:45:43 +02:00
|
|
|
userList += "," + inputs[i].uid;
|
2009-10-21 20:07:09 +02:00
|
|
|
}
|
2009-09-09 16:45:43 +02:00
|
|
|
|
|
|
|
// Abort any pending request
|
|
|
|
if (document.findSlotAjaxRequest) {
|
|
|
|
document.findSlotAjaxRequest.aborted = true;
|
|
|
|
document.findSlotAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
var urlstr = (ApplicationBaseURL
|
2009-10-21 20:07:09 +02:00
|
|
|
+ "findPossibleSlot?direction=" + direction
|
|
|
|
+ "&uids=" + escape(userList)
|
|
|
|
+ "&startDate=" + escape(sd)
|
|
|
|
+ "&startTime=" + escape(st)
|
|
|
|
+ "&endDate=" + escape(ed)
|
|
|
|
+ "&endTime=" + escape(et)
|
2009-09-09 16:45:43 +02:00
|
|
|
+ "&isAllDay=" + isAllDay
|
|
|
|
+ "&onlyOfficeHours=" + ($("onlyOfficeHours").checked + 0));
|
|
|
|
document.findSlotAjaxRequest = triggerAjaxRequest(urlstr,
|
|
|
|
updateSlotDisplayCallback,
|
|
|
|
userList);
|
2009-06-04 16:57:50 +02:00
|
|
|
}
|
|
|
|
|
2009-06-05 19:36:39 +02:00
|
|
|
function cleanInt(data) {
|
2009-09-09 16:45:43 +02:00
|
|
|
var rc = data;
|
|
|
|
if (rc.substr (0, 1) == "0")
|
|
|
|
rc = rc.substr (1, rc.length - 1);
|
|
|
|
return parseInt (rc);
|
2009-06-04 16:57:50 +02:00
|
|
|
}
|
|
|
|
|
2009-06-04 22:59:48 +02:00
|
|
|
function scrollToEvent () {
|
2009-09-09 16:45:43 +02:00
|
|
|
var headerDiv = $$('TABLE#freeBusy TD.freeBusyHeader DIV').first();
|
|
|
|
var dataDiv = $$('TABLE#freeBusy TD.freeBusyData DIV').first();
|
2009-06-05 18:55:26 +02:00
|
|
|
|
2009-09-09 16:45:43 +02:00
|
|
|
var scroll = 0;
|
|
|
|
var spans = $$('TR#currentEventPosition TH SPAN');
|
|
|
|
for (var i = 0; i < spans.length; i++) {
|
|
|
|
scroll += spans[i].getWidth (spans[i]);
|
2009-10-21 20:07:09 +02:00
|
|
|
if (spans[i].hasClassName("busy")) {
|
2009-09-09 16:45:43 +02:00
|
|
|
scroll -= 20 * spans[i].getWidth (spans[i]);
|
|
|
|
break;
|
|
|
|
}
|
2009-06-04 22:59:48 +02:00
|
|
|
}
|
2009-06-05 18:55:26 +02:00
|
|
|
|
2009-09-09 16:45:43 +02:00
|
|
|
headerDiv.scrollLeft = scroll;
|
|
|
|
dataDiv.scrollLeft = headerDiv.scrollLeft;
|
2009-06-05 18:55:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function toggleOfficeHours () {
|
2009-09-09 16:45:43 +02:00
|
|
|
var endDate = window.getEndDate();
|
|
|
|
var startDate = window.getStartDate();
|
2009-06-05 18:55:26 +02:00
|
|
|
|
2009-09-09 16:45:43 +02:00
|
|
|
if (startDate.getHours () < dayStartHour
|
|
|
|
|| startDate.getHours () > dayEndHour
|
|
|
|
|| endDate.getHours () > dayEndHour
|
|
|
|
|| endDate.getHours () < dayStartHour)
|
|
|
|
$("onlyOfficeHours").checked = false;
|
2009-06-04 22:59:48 +02:00
|
|
|
}
|
|
|
|
|
2009-06-05 19:36:39 +02:00
|
|
|
function updateSlotDisplayCallback(http) {
|
2009-10-21 20:07:09 +02:00
|
|
|
var data = http.responseText.evalJSON(true);
|
|
|
|
var start = new Date();
|
|
|
|
var end = new Date();
|
2009-09-09 16:45:43 +02:00
|
|
|
var cb = redisplayFreeBusyZone;
|
|
|
|
|
2009-10-21 20:07:09 +02:00
|
|
|
start.setFullYear(parseInt (data[0]['startDate'].substr(0, 4)),
|
|
|
|
parseInt (data[0]['startDate'].substr(4, 2)) - 1,
|
|
|
|
parseInt (data[0]['startDate'].substr(6, 2)));
|
|
|
|
end.setFullYear(parseInt (data[0]['endDate'].substr(0, 4)),
|
|
|
|
parseInt (data[0]['endDate'].substr(4, 2)) - 1,
|
|
|
|
parseInt (data[0]['endDate'].substr(6, 2)));
|
|
|
|
|
|
|
|
window.timeWidgets['end']['date'].setValueAsDate(end);
|
|
|
|
window.timeWidgets['end']['hour'].value = cleanInt(data[0]['endHour']);
|
|
|
|
window.timeWidgets['end']['minute'].value = cleanInt(data[0]['endMinute']);
|
2009-06-04 16:57:50 +02:00
|
|
|
|
2009-10-21 20:07:09 +02:00
|
|
|
if (window.timeWidgets['start']['date'].valueAsShortDateString() !=
|
|
|
|
data[0]['startDate']) {
|
|
|
|
cb = onTimeDateWidgetChange;
|
|
|
|
}
|
2009-06-04 16:57:50 +02:00
|
|
|
|
2009-10-21 20:07:09 +02:00
|
|
|
window.timeWidgets['start']['date'].setValueAsDate(start);
|
|
|
|
window.timeWidgets['start']['hour'].value = cleanInt(data[0]['startHour']);
|
|
|
|
window.timeWidgets['start']['minute'].value = cleanInt(data[0]['startMinute']);
|
|
|
|
|
|
|
|
cb();
|
2009-06-04 16:57:50 +02:00
|
|
|
}
|
|
|
|
|
2009-11-04 23:13:20 +01:00
|
|
|
function onPreviousSlotClick(event) {
|
|
|
|
findSlot(-1);
|
|
|
|
this.blur(); // required by IE
|
2009-06-04 16:57:50 +02:00
|
|
|
}
|
|
|
|
|
2009-11-04 23:13:20 +01:00
|
|
|
function onNextSlotClick(event) {
|
|
|
|
findSlot(1);
|
|
|
|
this.blur(); // required by IE
|
2009-06-04 16:57:50 +02:00
|
|
|
}
|
|
|
|
|
2007-03-18 16:00:34 +01:00
|
|
|
function onEditorOkClick(event) {
|
2009-09-09 16:45:43 +02:00
|
|
|
preventDefault(event);
|
2010-05-05 16:40:53 +02:00
|
|
|
|
2009-09-10 20:31:20 +02:00
|
|
|
var attendees = window.opener.attendees;
|
|
|
|
var newAttendees = new Hash();
|
2009-09-09 16:45:43 +02:00
|
|
|
var table = $("freeBusy");
|
|
|
|
var inputs = table.getElementsByTagName("input");
|
2009-09-10 20:31:20 +02:00
|
|
|
for (var i = 0; i < inputs.length - 1; i++) {
|
2009-09-09 16:45:43 +02:00
|
|
|
var row = $(inputs[i]).up("tr");
|
|
|
|
var name = extractEmailName(inputs[i].value);
|
|
|
|
var email = extractEmailAddress(inputs[i].value);
|
|
|
|
var uid = "";
|
|
|
|
if (inputs[i].uid)
|
|
|
|
uid = inputs[i].uid;
|
|
|
|
if (!(name && name.length > 0))
|
2010-05-05 20:49:29 +02:00
|
|
|
if (uid.length > 0)
|
|
|
|
name = uid;
|
2009-09-09 16:45:43 +02:00
|
|
|
else
|
|
|
|
name = email;
|
2010-05-05 16:40:53 +02:00
|
|
|
var attendee = attendees["email"];
|
|
|
|
if (!attendee) {
|
|
|
|
attendee = {"email": email,
|
|
|
|
"name": name,
|
|
|
|
"role": "req-participant",
|
|
|
|
"partstat": "needs-action",
|
|
|
|
"uid": uid};
|
|
|
|
}
|
|
|
|
var partstat = row.getAttribute("partstat");
|
|
|
|
if (partstat)
|
|
|
|
attendee["partstat"] = partstat;
|
|
|
|
var role = row.getAttribute("role");
|
|
|
|
if (role)
|
|
|
|
attendee["role"] = role;
|
2009-09-10 20:31:20 +02:00
|
|
|
newAttendees.set(email, attendee);
|
2009-09-09 16:45:43 +02:00
|
|
|
}
|
2009-09-10 20:31:20 +02:00
|
|
|
window.opener.refreshAttendees(newAttendees.toJSON());
|
2009-09-09 16:45:43 +02:00
|
|
|
|
|
|
|
updateParentDateFields("startTime", "startTime");
|
|
|
|
updateParentDateFields("endTime", "endTime");
|
|
|
|
|
|
|
|
window.close();
|
2006-10-30 23:43:13 +01:00
|
|
|
}
|
|
|
|
|
2007-03-18 16:00:34 +01:00
|
|
|
function onEditorCancelClick(event) {
|
2009-09-09 16:45:43 +02:00
|
|
|
preventDefault(event);
|
|
|
|
window.close();
|
2007-03-18 16:00:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function synchronizeWithParent(srcWidgetName, dstWidgetName) {
|
2009-09-09 16:45:43 +02:00
|
|
|
var srcDate = parent$(srcWidgetName + "_date");
|
|
|
|
var dstDate = $(dstWidgetName + "_date");
|
|
|
|
dstDate.value = srcDate.value;
|
|
|
|
dstDate.updateShadowValue(srcDate);
|
2007-03-18 16:00:34 +01:00
|
|
|
|
2009-09-09 16:45:43 +02:00
|
|
|
var srcHour = parent$(srcWidgetName + "_time_hour");
|
|
|
|
var dstHour = $(dstWidgetName + "_time_hour");
|
|
|
|
dstHour.value = srcHour.value;
|
|
|
|
dstHour.updateShadowValue(srcHour);
|
2006-10-30 23:43:13 +01:00
|
|
|
|
2009-09-09 16:45:43 +02:00
|
|
|
var srcMinute = parent$(srcWidgetName + "_time_minute");
|
|
|
|
var dstMinute = $(dstWidgetName + "_time_minute");
|
|
|
|
dstMinute.value = srcMinute.value;
|
|
|
|
dstMinute.updateShadowValue(dstMinute);
|
2006-10-30 23:43:13 +01:00
|
|
|
}
|
|
|
|
|
2007-03-19 17:07:11 +01:00
|
|
|
function updateParentDateFields(srcWidgetName, dstWidgetName) {
|
2009-09-09 16:45:43 +02:00
|
|
|
var srcDate = $(srcWidgetName + "_date");
|
|
|
|
var dstDate = parent$(dstWidgetName + "_date");
|
|
|
|
dstDate.value = srcDate.value;
|
2007-03-19 17:07:11 +01:00
|
|
|
|
2009-09-09 16:45:43 +02:00
|
|
|
var srcHour = $(srcWidgetName + "_time_hour");
|
|
|
|
var dstHour = parent$(dstWidgetName + "_time_hour");
|
|
|
|
dstHour.value = srcHour.value;
|
2007-03-19 17:07:11 +01:00
|
|
|
|
2009-09-09 16:45:43 +02:00
|
|
|
var srcMinute = $(srcWidgetName + "_time_minute");
|
|
|
|
var dstMinute = parent$(dstWidgetName + "_time_minute");
|
|
|
|
dstMinute.value = srcMinute.value;
|
2007-03-19 17:07:11 +01:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onTimeWidgetChange() {
|
2009-09-09 16:45:43 +02:00
|
|
|
redisplayFreeBusyZone();
|
2007-03-18 16:00:34 +01:00
|
|
|
}
|
|
|
|
|
2008-03-27 22:05:47 +01:00
|
|
|
function onTimeDateWidgetChange() {
|
2009-09-09 16:45:43 +02:00
|
|
|
var table = $("freeBusyHeader");
|
|
|
|
var rows = table.select("tr");
|
|
|
|
for (var i = 0; i < rows.length; i++) {
|
|
|
|
for (var j = rows[i].cells.length - 1; j > -1; j--) {
|
|
|
|
rows[i].deleteCell(j);
|
|
|
|
}
|
|
|
|
}
|
2008-03-27 22:05:47 +01:00
|
|
|
|
2009-09-09 16:45:43 +02:00
|
|
|
table = $("freeBusyData");
|
|
|
|
rows = table.select("tr");
|
|
|
|
for (var i = 0; i < rows.length; i++) {
|
|
|
|
for (var j = rows[i].cells.length - 1; j > -1; j--) {
|
|
|
|
rows[i].deleteCell(j);
|
|
|
|
}
|
|
|
|
}
|
2007-03-18 16:00:34 +01:00
|
|
|
|
2009-09-09 16:45:43 +02:00
|
|
|
prepareTableHeaders();
|
|
|
|
prepareTableRows();
|
|
|
|
redisplayFreeBusyZone();
|
|
|
|
resetAllFreeBusys();
|
2007-03-18 16:00:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function prepareTableHeaders() {
|
2009-09-09 16:45:43 +02:00
|
|
|
var startTimeDate = $("startTime_date");
|
|
|
|
var startDate = startTimeDate.valueAsDate();
|
|
|
|
|
|
|
|
var endTimeDate = $("endTime_date");
|
|
|
|
var endDate = endTimeDate.valueAsDate();
|
|
|
|
endDate.setTime(endDate.getTime() + (additionalDays * 86400000));
|
|
|
|
|
|
|
|
var rows = $("freeBusyHeader").rows;
|
|
|
|
var days = startDate.daysUpTo(endDate);
|
|
|
|
for (var i = 0; i < days.length; i++) {
|
|
|
|
var header1 = document.createElement("th");
|
|
|
|
header1.colSpan = ((displayEndHour - displayStartHour) + 1)/2;
|
|
|
|
header1.appendChild(document.createTextNode(days[i].toLocaleDateString()));
|
|
|
|
rows[0].appendChild(header1);
|
|
|
|
var header1b = document.createElement("th");
|
|
|
|
header1b.colSpan = ((displayEndHour - displayStartHour) + 1)/2;
|
|
|
|
header1b.appendChild(document.createTextNode(days[i].toLocaleDateString()));
|
|
|
|
rows[0].appendChild(header1b);
|
|
|
|
for (var hour = displayStartHour; hour < (displayEndHour + 1); hour++) {
|
|
|
|
var header2 = document.createElement("th");
|
|
|
|
var text = hour + ":00";
|
|
|
|
if (hour < 10)
|
|
|
|
text = "0" + text;
|
|
|
|
if (hour >= dayStartHour && hour <= dayEndHour)
|
|
|
|
$(header2).addClassName ("officeHour");
|
|
|
|
header2.appendChild(document.createTextNode(text));
|
|
|
|
rows[1].appendChild(header2);
|
|
|
|
|
|
|
|
var header3 = document.createElement("th");
|
|
|
|
for (var span = 0; span < 4; span++) {
|
|
|
|
var spanElement = document.createElement("span");
|
|
|
|
$(spanElement).addClassName("freeBusyZoneElement");
|
|
|
|
header3.appendChild(spanElement);
|
|
|
|
}
|
|
|
|
rows[2].appendChild(header3);
|
|
|
|
}
|
|
|
|
}
|
2007-03-18 16:00:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function prepareTableRows() {
|
2009-09-09 16:45:43 +02:00
|
|
|
var startTimeDate = $("startTime_date");
|
|
|
|
var startDate = startTimeDate.valueAsDate();
|
2007-03-18 16:00:34 +01:00
|
|
|
|
2009-09-09 16:45:43 +02:00
|
|
|
var endTimeDate = $("endTime_date");
|
|
|
|
var endDate = endTimeDate.valueAsDate();
|
|
|
|
endDate.setTime(endDate.getTime() + (additionalDays * 86400000));
|
2007-03-18 16:00:34 +01:00
|
|
|
|
2009-09-09 16:45:43 +02:00
|
|
|
var rows = $("freeBusyData").tBodies[0].rows;
|
|
|
|
var days = startDate.daysUpTo(endDate);
|
|
|
|
var width = $('freeBusyHeader').getWidth();
|
|
|
|
$("freeBusyData").setStyle({ width: width + 'px' });
|
|
|
|
for (var i = 0; i < days.length; i++)
|
|
|
|
for (var rowNbr = 0; rowNbr < rows.length; rowNbr++)
|
|
|
|
for (var hour = displayStartHour; hour < (displayEndHour + 1); hour++)
|
|
|
|
rows[rowNbr].appendChild(document.createElement("td"));
|
2007-03-18 16:00:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function prepareAttendees() {
|
2009-09-09 16:45:43 +02:00
|
|
|
var tableAttendees = $("freeBusyAttendees");
|
|
|
|
var tableData = $("freeBusyData");
|
2009-09-10 20:31:20 +02:00
|
|
|
var attendees = window.opener.attendees;
|
2009-09-09 16:45:43 +02:00
|
|
|
|
2009-09-10 20:31:20 +02:00
|
|
|
if (attendees && attendees.keys()) {
|
2009-09-09 16:45:43 +02:00
|
|
|
var tbodyAttendees = tableAttendees.tBodies[0];
|
|
|
|
var modelAttendee = tbodyAttendees.rows[tbodyAttendees.rows.length - 1];
|
|
|
|
var newAttendeeRow = tbodyAttendees.rows[tbodyAttendees.rows.length - 2];
|
|
|
|
|
|
|
|
var tbodyData = tableData.tBodies[0];
|
|
|
|
var modelData = tbodyData.rows[tbodyData.rows.length - 1];
|
|
|
|
var newDataRow = tbodyData.rows[tbodyData.rows.length - 2];
|
|
|
|
|
2010-05-05 16:40:53 +02:00
|
|
|
attendees.keys().each(function(atKey) {
|
|
|
|
var attendee = attendees.get(atKey);
|
|
|
|
var row = $(modelAttendee.cloneNode(true));
|
|
|
|
tbodyAttendees.insertBefore(row, newAttendeeRow);
|
|
|
|
row.removeClassName("attendeeModel");
|
|
|
|
row.setAttribute("partstat", attendee["partstat"]);
|
|
|
|
row.setAttribute("role", attendee["role"]);
|
|
|
|
var uid = attendee["uid"];
|
|
|
|
if (uid && uid == OwnerLogin) {
|
|
|
|
row.addClassName("organizer-row");
|
|
|
|
row.removeClassName("attendee-row");
|
|
|
|
row.isOrganizer = true;
|
|
|
|
} else {
|
|
|
|
row.addClassName("attendee-row");
|
|
|
|
row.removeClassName("organizer-row");
|
|
|
|
row.isOrganizer = false;
|
|
|
|
}
|
|
|
|
var statusTD = row.down(".attendeeStatus");
|
|
|
|
if (statusTD) {
|
|
|
|
var boundOnStatusClick
|
|
|
|
= onAttendeeStatusClick.bindAsEventListener(row);
|
|
|
|
statusTD.observe("click", boundOnStatusClick, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
var input = row.down("input");
|
|
|
|
var value = attendee["name"];
|
|
|
|
if (value)
|
|
|
|
value += " ";
|
|
|
|
else
|
|
|
|
value = "";
|
|
|
|
value += "<" + attendee["email"] + ">";
|
|
|
|
input.value = value;
|
2010-05-05 20:49:29 +02:00
|
|
|
input.uid = attendee["uid"];
|
|
|
|
input.cname = attendee["cname"];
|
2010-05-05 16:40:53 +02:00
|
|
|
input.setAttribute("name", "");
|
2010-05-05 20:49:29 +02:00
|
|
|
input.modified = false;
|
|
|
|
input.observe("blur", onInputBlur);
|
|
|
|
input.observe("keydown", onContactKeydown.bindAsEventListener(input)
|
|
|
|
);
|
|
|
|
|
2010-05-05 16:40:53 +02:00
|
|
|
row = $(modelData.cloneNode(true));
|
|
|
|
tbodyData.insertBefore(row, newDataRow);
|
|
|
|
row.removeClassName("dataModel");
|
|
|
|
displayFreeBusyForNode(input);
|
|
|
|
});
|
2009-09-09 16:45:43 +02:00
|
|
|
}
|
2006-11-13 19:46:00 +01:00
|
|
|
|
2009-09-10 20:31:20 +02:00
|
|
|
// Activate "Add attendee" button
|
|
|
|
var links = tableAttendees.select("TR.futureAttendee TD A");
|
2010-05-05 20:49:29 +02:00
|
|
|
links.first().observe("click", onNewAttendeeClick);
|
2007-05-10 21:02:16 +02:00
|
|
|
}
|
|
|
|
|
2008-01-04 21:58:52 +01:00
|
|
|
function onWindowResize(event) {
|
2009-09-09 16:45:43 +02:00
|
|
|
var view = $('freeBusyView');
|
|
|
|
var attendeesCell = $$('TABLE#freeBusy TD.freeBusyAttendees').first();
|
|
|
|
var headerDiv = $$('TABLE#freeBusy TD.freeBusyHeader DIV').first();
|
|
|
|
var attendeesDiv = $$('TABLE#freeBusy TD.freeBusyAttendees DIV').first();
|
|
|
|
var dataDiv = $$('TABLE#freeBusy TD.freeBusyData DIV').first();
|
|
|
|
var width = view.getWidth() - attendeesCell.getWidth();
|
|
|
|
var height = view.getHeight() - headerDiv.getHeight();
|
2008-01-04 21:58:52 +01:00
|
|
|
|
2009-09-09 16:45:43 +02:00
|
|
|
attendeesDiv.setStyle({ height: (height - 20) + 'px' });
|
|
|
|
headerDiv.setStyle({ width: (width - 20) + 'px' });
|
|
|
|
dataDiv.setStyle({ width: (width - 4) + 'px',
|
|
|
|
height: (height - 2) + 'px' });
|
2008-01-04 21:58:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function onScroll(event) {
|
2009-09-09 16:45:43 +02:00
|
|
|
var headerDiv = $$('TABLE#freeBusy TD.freeBusyHeader DIV').first();
|
|
|
|
var attendeesDiv = $$('TABLE#freeBusy TD.freeBusyAttendees DIV').first();
|
|
|
|
var dataDiv = $$('TABLE#freeBusy TD.freeBusyData DIV').first();
|
2008-01-04 21:58:52 +01:00
|
|
|
|
2009-09-09 16:45:43 +02:00
|
|
|
headerDiv.scrollLeft = dataDiv.scrollLeft;
|
|
|
|
attendeesDiv.scrollTop = dataDiv.scrollTop;
|
2008-01-04 21:58:52 +01:00
|
|
|
}
|
|
|
|
|
2006-11-13 19:46:00 +01:00
|
|
|
function onFreeBusyLoadHandler() {
|
2009-09-09 16:45:43 +02:00
|
|
|
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")}};
|
|
|
|
|
2010-05-05 16:40:53 +02:00
|
|
|
OwnerLogin = window.opener.getOwnerLogin();
|
|
|
|
|
2009-09-09 16:45:43 +02:00
|
|
|
synchronizeWithParent("startTime", "startTime");
|
|
|
|
synchronizeWithParent("endTime", "endTime");
|
|
|
|
|
|
|
|
initTimeWidgets(widgets);
|
|
|
|
initializeWindowButtons();
|
|
|
|
prepareTableHeaders();
|
|
|
|
prepareTableRows();
|
|
|
|
redisplayFreeBusyZone();
|
|
|
|
prepareAttendees();
|
|
|
|
onWindowResize(null);
|
|
|
|
Event.observe(window, "resize", onWindowResize);
|
|
|
|
$$('TABLE#freeBusy TD.freeBusyData DIV').first().observe("scroll", onScroll);
|
|
|
|
scrollToEvent ();
|
|
|
|
toggleOfficeHours ();
|
2006-11-13 19:46:00 +01:00
|
|
|
}
|
|
|
|
|
2009-03-12 22:09:14 +01:00
|
|
|
document.observe("dom:loaded", onFreeBusyLoadHandler);
|
2008-03-27 22:05:47 +01:00
|
|
|
|
|
|
|
/* Functions related to UIxTimeDateControl widget */
|
|
|
|
|
|
|
|
function initTimeWidgets(widgets) {
|
2009-09-09 16:45:43 +02:00
|
|
|
this.timeWidgets = widgets;
|
|
|
|
|
|
|
|
assignCalendar('startTime_date');
|
|
|
|
assignCalendar('endTime_date');
|
|
|
|
|
|
|
|
widgets['start']['date'].observe("change",
|
|
|
|
this.onAdjustTime, false);
|
|
|
|
widgets['start']['hour'].observe("change",
|
|
|
|
this.onAdjustTime, false);
|
|
|
|
widgets['start']['minute'].observe("change",
|
|
|
|
this.onAdjustTime, false);
|
|
|
|
|
|
|
|
widgets['end']['date'].observe("change",
|
|
|
|
this.onAdjustTime, false);
|
|
|
|
widgets['end']['hour'].observe("change",
|
|
|
|
this.onAdjustTime, false);
|
|
|
|
widgets['end']['minute'].observe("change",
|
|
|
|
this.onAdjustTime, false);
|
|
|
|
|
|
|
|
var allDayLabel = $("allDay");
|
|
|
|
if (allDayLabel) {
|
|
|
|
var input = $(allDayLabel).childNodesWithTag("input")[0];
|
|
|
|
input.observe("change", onAllDayChanged.bindAsEventListener(input));
|
|
|
|
if (input.checked) {
|
|
|
|
for (var type in widgets) {
|
|
|
|
widgets[type]['hour'].disabled = true;
|
|
|
|
widgets[type]['minute'].disabled = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isAllDay)
|
|
|
|
handleAllDay ();
|
2008-03-27 22:05:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function onAdjustTime(event) {
|
2009-09-09 16:45:43 +02:00
|
|
|
var endDate = window.getEndDate();
|
|
|
|
var startDate = window.getStartDate();
|
2010-05-05 20:49:29 +02:00
|
|
|
if (this.id.startsWith("start")) {
|
2009-09-09 16:45:43 +02:00
|
|
|
// 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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Specific function for the attendees editor
|
|
|
|
onTimeDateWidgetChange();
|
|
|
|
toggleOfficeHours ();
|
2008-03-27 22:05:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function _getDate(which) {
|
2009-09-09 16:45:43 +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
|
|
|
|
2009-09-09 16:45:43 +02:00
|
|
|
return date;
|
2008-03-27 22:05:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function getStartDate() {
|
2009-09-09 16:45:43 +02:00
|
|
|
return this._getDate('start');
|
2008-03-27 22:05:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function getEndDate() {
|
2009-09-09 16:45:43 +02:00
|
|
|
return this._getDate('end');
|
2008-03-27 22:05:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function _getShadowDate(which) {
|
2009-09-09 16:45:43 +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);
|
2008-03-27 22:05:47 +01:00
|
|
|
|
2009-09-09 16:45:43 +02:00
|
|
|
return date;
|
2008-03-27 22:05:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function getShadowStartDate() {
|
2009-09-09 16:45:43 +02:00
|
|
|
return this._getShadowDate('start');
|
2008-03-27 22:05:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function getShadowEndDate() {
|
2009-09-09 16:45:43 +02:00
|
|
|
return this._getShadowDate('end');
|
2008-03-27 22:05:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function _setDate(which, newDate) {
|
2009-09-09 16:45:43 +02: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;
|
2008-03-27 22:05:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function setStartDate(newStartDate) {
|
2009-09-09 16:45:43 +02:00
|
|
|
this._setDate('start', newStartDate);
|
2008-03-27 22:05:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function setEndDate(newEndDate) {
|
2009-09-09 16:45:43 +02:00
|
|
|
this._setDate('end', newEndDate);
|
2008-03-27 22:05:47 +01:00
|
|
|
}
|