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
|
|
|
|
2006-10-26 01:58:29 +02:00
|
|
|
var resultsDiv;
|
|
|
|
var address;
|
2006-10-26 18:43:50 +02:00
|
|
|
var awaitingFreeBusyRequests = new Array();
|
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,
|
|
|
|
delayedSearch: false,
|
|
|
|
currentField: null,
|
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 */
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
if (event.keyCode == 9) { // Tab
|
|
|
|
preventDefault(event);
|
|
|
|
if (this.confirmedValue)
|
|
|
|
this.value = this.confirmedValue;
|
|
|
|
this.hasfreebusy = false;
|
|
|
|
var row = $(this).up("tr").next();
|
|
|
|
this.blur(); // triggers checkAttendee function call
|
|
|
|
var input = row.down("input");
|
2009-09-10 20:31:20 +02:00
|
|
|
if (input) {
|
2009-09-09 16:45:43 +02:00
|
|
|
input.focussed = true;
|
|
|
|
input.activate();
|
|
|
|
}
|
2009-09-10 20:31:20 +02:00
|
|
|
else
|
|
|
|
newAttendee(null);
|
2009-09-09 16:45:43 +02:00
|
|
|
}
|
|
|
|
else if (event.keyCode == 0
|
|
|
|
|| event.keyCode == 8 // Backspace
|
|
|
|
|| event.keyCode == 32 // Space
|
|
|
|
|| event.keyCode > 47) {
|
|
|
|
this.setAttribute("modified", "1");
|
|
|
|
this.confirmedValue = null;
|
|
|
|
this.uid = null;
|
|
|
|
this.hasfreebusy = false;
|
|
|
|
attendeesEditor.currentField = this;
|
|
|
|
if (this.value.length > 0 && !attendeesEditor.delayedSearch) {
|
|
|
|
attendeesEditor.delayedSearch = true;
|
|
|
|
setTimeout("performSearch()", attendeesEditor.delay);
|
|
|
|
}
|
|
|
|
else if (this.value.length == 0) {
|
|
|
|
if (document.currentPopupMenu)
|
|
|
|
hideMenu(document.currentPopupMenu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (event.keyCode == 13) {
|
|
|
|
preventDefault(event);
|
|
|
|
if (this.confirmedValue)
|
|
|
|
this.value = this.confirmedValue;
|
|
|
|
$(this).selectText(0, this.value.length);
|
|
|
|
if (document.currentPopupMenu)
|
|
|
|
hideMenu(document.currentPopupMenu);
|
|
|
|
attendeesEditor.selectedIndex = -1;
|
|
|
|
if (this.uid) {
|
|
|
|
this.hasfreebusy = false;
|
|
|
|
this.setAttribute ("modified", "1");
|
|
|
|
this.blur(); // triggers checkAttendee function call
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($('attendeesMenu').getStyle('visibility') == 'visible') {
|
|
|
|
attendeesEditor.currentField = this;
|
|
|
|
if (event.keyCode == Event.KEY_UP) { // Up arrow
|
|
|
|
if (attendeesEditor.selectedIndex > 0) {
|
|
|
|
var attendees = $('attendeesMenu').select("li");
|
|
|
|
attendees[attendeesEditor.selectedIndex--].removeClassName("selected");
|
|
|
|
attendees[attendeesEditor.selectedIndex].addClassName("selected");
|
|
|
|
this.value = this.confirmedValue = attendees[attendeesEditor.selectedIndex].readAttribute("address");
|
|
|
|
this.uid = attendees[attendeesEditor.selectedIndex].uid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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++;
|
|
|
|
attendees[attendeesEditor.selectedIndex].addClassName("selected");
|
|
|
|
this.value = this.confirmedValue = attendees[attendeesEditor.selectedIndex].readAttribute("address");
|
|
|
|
this.uid = attendees[attendeesEditor.selectedIndex].uid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-10-26 01:58:29 +02:00
|
|
|
}
|
|
|
|
|
2007-12-12 18:48:19 +01:00
|
|
|
function performSearch() {
|
2009-09-09 16:45:43 +02:00
|
|
|
// Perform address completion
|
|
|
|
if (attendeesEditor.currentField) {
|
|
|
|
if (document.contactLookupAjaxRequest) {
|
|
|
|
// Abort any pending request
|
|
|
|
document.contactLookupAjaxRequest.aborted = true;
|
|
|
|
document.contactLookupAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
if (attendeesEditor.currentField.value.trim().length > 0) {
|
|
|
|
var urlstr = ( UserFolderURL + "Contacts/contactSearch?search="
|
|
|
|
+ escape(attendeesEditor.currentField.value) );
|
|
|
|
document.contactLookupAjaxRequest =
|
|
|
|
triggerAjaxRequest(urlstr, performSearchCallback, attendeesEditor.currentField);
|
|
|
|
}
|
2008-07-04 11:43:28 +02:00
|
|
|
}
|
2009-09-09 16:45:43 +02:00
|
|
|
attendeesEditor.delayedSearch = false;
|
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) {
|
|
|
|
$(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];
|
|
|
|
var completeEmail = contact["name"] + " <" + contact["email"] + ">";
|
|
|
|
var node = new Element('li', { 'address': completeEmail });
|
|
|
|
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);
|
|
|
|
list.appendChild(node);
|
|
|
|
node.uid = contact["uid"];
|
|
|
|
node.appendChild(document.createTextNode(matchBefore));
|
|
|
|
node.appendChild(new Element('strong').update(matchText));
|
|
|
|
node.appendChild(document.createTextNode(matchAfter));
|
|
|
|
if (contact["contactInfo"])
|
|
|
|
node.appendChild(document.createTextNode(" (" + contact["contactInfo"] + ")"));
|
|
|
|
$(node).observe("mousedown", onAttendeeResultClick);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Show popup menu
|
|
|
|
var offsetScroll = Element.cumulativeScrollOffset(attendeesEditor.currentField);
|
|
|
|
var offset = Element.cumulativeOffset(attendeesEditor.currentField);
|
|
|
|
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];
|
|
|
|
if (contact["uid"].length > 0)
|
|
|
|
input.uid = contact["uid"];
|
|
|
|
var completeEmail = contact["name"] + " <" + contact["email"] + ">";
|
|
|
|
if (contact["name"].substring(0, input.value.length).toUpperCase()
|
|
|
|
== input.value.toUpperCase())
|
|
|
|
input.value = completeEmail;
|
|
|
|
else
|
|
|
|
// The result matches email address, not user name
|
|
|
|
input.value += ' >> ' + completeEmail;
|
|
|
|
input.confirmedValue = completeEmail;
|
|
|
|
var end = input.value.length;
|
|
|
|
$(input).selectText(start, end);
|
|
|
|
|
|
|
|
attendeesEditor.selectedIndex = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (document.currentPopupMenu)
|
|
|
|
hideMenu(document.currentPopupMenu);
|
|
|
|
document.contactLookupAjaxRequest = null;
|
|
|
|
}
|
2006-10-26 01:58:29 +02:00
|
|
|
}
|
|
|
|
|
2007-11-13 23:51:32 +01:00
|
|
|
function onAttendeeResultClick(event) {
|
2009-09-09 16:45:43 +02:00
|
|
|
if (attendeesEditor.currentField) {
|
|
|
|
attendeesEditor.currentField.uid = this.uid;
|
|
|
|
attendeesEditor.currentField.value = $(this).readAttribute("address");
|
|
|
|
attendeesEditor.currentField.confirmedValue = attendeesEditor.currentField.value;
|
|
|
|
attendeesEditor.currentField.blur(); // triggers checkAttendee function call
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function newAttendee(event) {
|
2009-09-09 16:45:43 +02:00
|
|
|
var table = $("freeBusyAttendees");
|
|
|
|
var tbody = table.tBodies[0];
|
|
|
|
var model = tbody.rows[tbody.rows.length - 1];
|
|
|
|
var futureRow = tbody.rows[tbody.rows.length - 2];
|
|
|
|
var newRow = model.cloneNode(true);
|
|
|
|
tbody.insertBefore(newRow, futureRow);
|
2007-08-02 23:12:42 +02:00
|
|
|
|
2009-09-09 16:45:43 +02:00
|
|
|
$(newRow).removeClassName("attendeeModel");
|
2007-12-12 18:48:19 +01:00
|
|
|
|
2009-09-09 16:45:43 +02:00
|
|
|
var input = $(newRow).down("input");
|
|
|
|
input.observe("keydown", onContactKeydown);
|
|
|
|
input.observe("blur", checkAttendee);
|
|
|
|
|
|
|
|
input.focussed = true;
|
|
|
|
input.activate();
|
|
|
|
|
|
|
|
table = $("freeBusyData");
|
|
|
|
tbody = table.tBodies[0];
|
|
|
|
model = tbody.rows[tbody.rows.length - 1];
|
|
|
|
futureRow = tbody.rows[tbody.rows.length - 2];
|
|
|
|
newRow = model.cloneNode(true);
|
|
|
|
tbody.insertBefore(newRow, futureRow);
|
|
|
|
$(newRow).removeClassName("dataModel");
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2007-08-07 20:14:39 +02:00
|
|
|
function checkAttendee() {
|
2009-09-09 16:45:43 +02:00
|
|
|
if (document.currentPopupMenu)
|
|
|
|
hideMenu(document.currentPopupMenu);
|
|
|
|
|
|
|
|
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)
|
|
|
|
return;
|
|
|
|
}
|
2007-12-12 18:48:19 +01:00
|
|
|
|
2009-09-09 16:45:43 +02:00
|
|
|
this.focussed = false;
|
|
|
|
var row = this.parentNode.parentNode;
|
|
|
|
var tbody = row.parentNode;
|
|
|
|
if (tbody && this.value.trim().length == 0) {
|
|
|
|
var dataTable = $("freeBusyData").tBodies[0];
|
|
|
|
var dataRow = dataTable.rows[row.sectionRowIndex];
|
|
|
|
tbody.removeChild(row);
|
|
|
|
dataTable.removeChild(dataRow);
|
|
|
|
}
|
|
|
|
else if (this.readAttribute("modified") == "1") {
|
|
|
|
if (!$(row).hasClassName("needs-action")) {
|
|
|
|
$(row).addClassName("needs-action");
|
|
|
|
$(row).removeClassName("declined");
|
|
|
|
$(row).removeClassName("accepted");
|
|
|
|
}
|
|
|
|
if (!this.hasfreebusy) {
|
|
|
|
if (this.uid && this.confirmedValue)
|
|
|
|
this.value = this.confirmedValue;
|
|
|
|
displayFreeBusyForNode(this);
|
|
|
|
this.hasfreebusy = true;
|
|
|
|
}
|
|
|
|
this.setAttribute("modified", "0");
|
|
|
|
}
|
2007-12-12 18:48:19 +01:00
|
|
|
|
2009-09-09 16:45:43 +02:00
|
|
|
attendeesEditor.currentField = null;
|
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;
|
|
|
|
var nodes = $("freeBusyData").tBodies[0].rows[rowIndex].cells;
|
|
|
|
if (input.uid) {
|
|
|
|
if (document.contactFreeBusyAjaxRequest)
|
|
|
|
awaitingFreeBusyRequests.push(input);
|
|
|
|
else {
|
|
|
|
for (var i = 0; i < nodes.length; i++) {
|
|
|
|
$(nodes[i]).removeClassName("noFreeBusy");
|
|
|
|
$(nodes[i]).innerHTML = ('<span class="freeBusyZoneElement"></span>'
|
|
|
|
+ '<span class="freeBusyZoneElement"></span>'
|
|
|
|
+ '<span class="freeBusyZoneElement"></span>'
|
|
|
|
+ '<span class="freeBusyZoneElement"></span>');
|
|
|
|
}
|
|
|
|
if (document.contactFreeBusyAjaxRequest) {
|
|
|
|
// Abort any pending request
|
|
|
|
document.contactFreeBusyAjaxRequest.aborted = true;
|
|
|
|
document.contactFreeBusyAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
var sd = $('startTime_date').valueAsShortDateString();
|
|
|
|
var ed = $('endTime_date').valueAsShortDateString();
|
|
|
|
var urlstr = ( UserFolderURL + "../" + input.uid
|
|
|
|
+ "/freebusy.ifb/ajaxRead?"
|
|
|
|
+ "sday=" + sd + "&eday=" + ed + "&additional=" +
|
|
|
|
additionalDays );
|
|
|
|
document.contactFreeBusyAjaxRequest
|
|
|
|
= triggerAjaxRequest(urlstr,
|
|
|
|
updateFreeBusyDataCallback,
|
|
|
|
input);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (var i = 0; i < nodes.length; i++) {
|
|
|
|
$(nodes[i]).addClassName("noFreeBusy");
|
|
|
|
$(nodes[i]).update();
|
|
|
|
}
|
|
|
|
}
|
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;
|
|
|
|
for (var i = 0; i < slots.length; i++) {
|
|
|
|
if (slots[i] != '0')
|
|
|
|
setSlot(nodes, i, slots[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
document.contactFreeBusyAjaxRequest = null;
|
|
|
|
if (awaitingFreeBusyRequests.length > 0)
|
|
|
|
displayFreeBusyForNode(awaitingFreeBusyRequests.shift());
|
|
|
|
}
|
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++) {
|
2009-09-09 16:45:43 +02:00
|
|
|
var currentInput = inputs[i];
|
|
|
|
currentInput.hasfreebusy = false;
|
|
|
|
displayFreeBusyForNode(inputs[i]);
|
|
|
|
}
|
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
|
|
|
|
2009-06-04 16:57:50 +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);
|
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))
|
|
|
|
if (inputs[i].uid)
|
|
|
|
name = inputs[i].uid;
|
|
|
|
else
|
|
|
|
name = email;
|
2009-09-10 20:31:20 +02:00
|
|
|
var attendee = attendees.get(email);
|
|
|
|
if (!attendee)
|
|
|
|
attendee = new Hash({'email': email,
|
|
|
|
'name': name,
|
|
|
|
'uid': uid,
|
|
|
|
'partstat': 'needs-action'});
|
|
|
|
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];
|
|
|
|
|
2009-09-10 20:31:20 +02:00
|
|
|
attendees.values().each(function(attendee) {
|
|
|
|
attendee = $H(attendee);
|
|
|
|
var row = modelAttendee.cloneNode(true);
|
|
|
|
tbodyAttendees.insertBefore(row, newAttendeeRow);
|
|
|
|
$(row).removeClassName("attendeeModel");
|
|
|
|
$(row).addClassName(attendee.get('partstat'));
|
|
|
|
var input = $(row).down("input");
|
|
|
|
var value = attendee.get('name');
|
|
|
|
if (value)
|
|
|
|
value += " ";
|
|
|
|
else
|
|
|
|
value = "";
|
|
|
|
value += "<" + attendee.get('email') + ">";
|
|
|
|
input.value = value;
|
|
|
|
if (attendee.get('uid'))
|
|
|
|
input.uid = attendee.get('uid');
|
|
|
|
input.setAttribute("name", "");
|
|
|
|
input.setAttribute("modified", "0");
|
|
|
|
input.observe("blur", checkAttendee);
|
|
|
|
input.observe("keydown", onContactKeydown);
|
2008-01-04 21:58:52 +01:00
|
|
|
|
2009-09-10 20:31:20 +02:00
|
|
|
row = modelData.cloneNode(true);
|
|
|
|
tbodyData.insertBefore(row, newDataRow);
|
|
|
|
$(row).removeClassName("dataModel");
|
2008-01-04 21:58:52 +01:00
|
|
|
|
2009-09-10 20:31:20 +02:00
|
|
|
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");
|
|
|
|
links.first().observe("click", newAttendee);
|
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")}};
|
|
|
|
|
|
|
|
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();
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
|
|
}
|