2008-08-28 16:48:45 +02:00
|
|
|
/* -*- Mode: java; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: t; c-basic-offset: 2 -*- */
|
|
|
|
|
2007-03-29 20:05:23 +02:00
|
|
|
/* JavaScript for SOGoCalendar */
|
|
|
|
|
2006-08-31 01:13:18 +02:00
|
|
|
var listFilter = 'view_today';
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2006-10-12 23:05:32 +02:00
|
|
|
var listOfSelection = null;
|
2007-01-30 14:50:52 +01:00
|
|
|
var selectedCalendarCell;
|
2006-10-12 23:05:32 +02:00
|
|
|
|
2007-04-03 16:24:09 +02:00
|
|
|
var showCompletedTasks = 0;
|
2006-10-11 20:12:02 +02:00
|
|
|
|
2006-08-19 00:40:04 +02:00
|
|
|
var currentDay = '';
|
|
|
|
|
2008-07-16 04:12:18 +02:00
|
|
|
var cachedDateSelectors = [];
|
2006-09-07 17:50:03 +02:00
|
|
|
|
2006-10-14 01:37:27 +02:00
|
|
|
var contactSelectorAction = 'calendars-contacts';
|
|
|
|
|
2008-07-16 04:12:18 +02:00
|
|
|
var eventsToDelete = [];
|
|
|
|
var calendarsOfEventsToDelete = [];
|
2006-10-18 23:53:47 +02:00
|
|
|
|
2008-12-23 16:51:12 +01:00
|
|
|
var usersRightsWindowHeight = 215;
|
2007-04-28 00:06:58 +02:00
|
|
|
var usersRightsWindowWidth = 502;
|
|
|
|
|
2008-07-16 04:12:18 +02:00
|
|
|
var calendarEvents = null;
|
|
|
|
|
2008-07-16 23:48:54 +02:00
|
|
|
var userStates = [ "needs-action", "accepted", "declined", "tentative" ];
|
|
|
|
|
2006-10-11 20:12:02 +02:00
|
|
|
function newEvent(sender, type) {
|
2008-01-24 22:36:51 +01:00
|
|
|
var day = $(sender).readAttribute("day");
|
|
|
|
if (!day)
|
|
|
|
day = currentDay;
|
|
|
|
var hour = sender.readAttribute("hour");
|
|
|
|
var folder = getSelectedFolder();
|
|
|
|
var folderID = folder.readAttribute("id");
|
|
|
|
var urlstr = ApplicationBaseURL + folderID + "/new" + type;
|
2008-07-16 04:12:18 +02:00
|
|
|
var params = [];
|
2008-01-24 22:36:51 +01:00
|
|
|
if (day)
|
|
|
|
params.push("day=" + day);
|
|
|
|
if (hour)
|
|
|
|
params.push("hm=" + hour);
|
|
|
|
if (params.length > 0)
|
2008-08-25 21:13:18 +02:00
|
|
|
urlstr += "?" + params.join("&");
|
2009-03-12 22:09:14 +01:00
|
|
|
|
2008-01-24 22:36:51 +01:00
|
|
|
window.open(urlstr, "", "width=490,height=470,resizable=0");
|
2007-05-22 16:38:54 +02:00
|
|
|
|
2008-01-24 22:36:51 +01:00
|
|
|
return false; /* stop following the link */
|
2007-05-22 16:38:54 +02:00
|
|
|
}
|
2006-08-15 22:52:23 +02:00
|
|
|
|
2007-09-15 00:01:02 +02:00
|
|
|
function getSelectedFolder() {
|
|
|
|
var folder;
|
2007-11-12 22:20:18 +01:00
|
|
|
var list = $("calendarList");
|
|
|
|
var nodes = list.getSelectedRows();
|
2007-09-15 00:01:02 +02:00
|
|
|
if (nodes.length > 0)
|
2007-11-12 22:20:18 +01:00
|
|
|
folder = nodes[0];
|
2007-09-15 00:01:02 +02:00
|
|
|
else
|
2007-11-12 22:20:18 +01:00
|
|
|
folder = list.down("li");
|
2007-09-15 00:01:02 +02:00
|
|
|
|
|
|
|
return folder;
|
|
|
|
}
|
|
|
|
|
2007-05-22 16:38:54 +02:00
|
|
|
function onMenuNewEventClick(event) {
|
2008-01-24 22:36:51 +01:00
|
|
|
newEvent(this, "event");
|
2007-05-22 16:38:54 +02:00
|
|
|
}
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2007-05-22 16:38:54 +02:00
|
|
|
function onMenuNewTaskClick(event) {
|
2008-01-24 22:36:51 +01:00
|
|
|
newEvent(this, "task");
|
2006-08-22 00:36:33 +02:00
|
|
|
}
|
|
|
|
|
2008-07-17 23:12:43 +02:00
|
|
|
function _editEventId(id, calendar, recurrence) {
|
2007-06-06 23:09:39 +02:00
|
|
|
var targetname = "SOGo_edit_" + id;
|
2008-07-17 23:12:43 +02:00
|
|
|
var urlstr = ApplicationBaseURL + calendar + "/" + id;
|
|
|
|
if (recurrence) {
|
|
|
|
urlstr += "/" + recurrence;
|
|
|
|
targetname += recurrence;
|
|
|
|
}
|
2008-09-18 20:03:59 +02:00
|
|
|
urlstr += "/edit";
|
2007-06-06 23:09:39 +02:00
|
|
|
var win = window.open(urlstr, "_blank",
|
2007-04-06 23:30:13 +02:00
|
|
|
"width=490,height=470,resizable=0");
|
2007-12-05 18:07:40 +01:00
|
|
|
if (win)
|
|
|
|
win.focus();
|
2006-08-22 00:36:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function editEvent() {
|
2006-10-12 23:05:32 +02:00
|
|
|
if (listOfSelection) {
|
2006-10-17 00:35:22 +02:00
|
|
|
var nodes = listOfSelection.getSelectedRows();
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2007-12-03 15:13:10 +01:00
|
|
|
if (nodes.length == 0) {
|
|
|
|
window.alert(labels["Please select an event or a task."]);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-10-12 23:05:32 +02:00
|
|
|
for (var i = 0; i < nodes.length; i++)
|
2008-08-15 07:28:06 +02:00
|
|
|
_editEventId(nodes[i].cname,
|
2007-09-15 00:01:02 +02:00
|
|
|
nodes[i].calendar);
|
2007-01-30 14:50:52 +01:00
|
|
|
} else if (selectedCalendarCell) {
|
2009-06-15 23:19:36 +02:00
|
|
|
if (selectedCalendarCell[0].recurrenceTime && !selectedCalendarCell[0].isException)
|
2009-03-19 21:04:16 +01:00
|
|
|
_editRecurrenceDialog(selectedCalendarCell[0], "confirmEditing");
|
|
|
|
else
|
|
|
|
_editEventId(selectedCalendarCell[0].cname,
|
|
|
|
selectedCalendarCell[0].calendar);
|
2007-12-03 15:13:10 +01:00
|
|
|
} else {
|
|
|
|
window.alert(labels["Please select an event or a task."]);
|
2006-10-12 23:05:32 +02:00
|
|
|
}
|
2006-08-25 22:49:34 +02:00
|
|
|
|
|
|
|
return false; /* stop following the link */
|
|
|
|
}
|
|
|
|
|
2006-10-18 23:53:47 +02:00
|
|
|
function _batchDeleteEvents() {
|
|
|
|
var events = eventsToDelete.shift();
|
2007-09-15 00:01:02 +02:00
|
|
|
var calendar = calendarsOfEventsToDelete.shift();
|
2008-07-16 04:12:18 +02:00
|
|
|
var urlstr = (ApplicationBaseURL + calendar
|
2008-08-28 16:48:45 +02:00
|
|
|
+ "/batchDelete?ids=" + events.join('/'));
|
2006-10-18 23:53:47 +02:00
|
|
|
document.deleteEventAjaxRequest = triggerAjaxRequest(urlstr,
|
|
|
|
deleteEventCallback,
|
2008-08-28 16:48:45 +02:00
|
|
|
{ calendar: calendar,
|
|
|
|
events: events });
|
2006-10-17 00:35:22 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function deleteEvent() {
|
2006-10-12 23:05:32 +02:00
|
|
|
if (listOfSelection) {
|
2006-10-17 00:35:22 +02:00
|
|
|
var nodes = listOfSelection.getSelectedRows();
|
2006-10-12 23:05:32 +02:00
|
|
|
if (nodes.length > 0) {
|
2006-11-06 18:44:07 +01:00
|
|
|
var label = "";
|
|
|
|
if (listOfSelection == $("tasksList"))
|
2007-09-15 00:01:02 +02:00
|
|
|
label = labels["taskDeleteConfirmation"];
|
2006-11-06 18:44:07 +01:00
|
|
|
else
|
2007-09-15 00:01:02 +02:00
|
|
|
label = labels["eventDeleteConfirmation"];
|
2008-07-17 23:12:43 +02:00
|
|
|
|
|
|
|
if (nodes.length == 1
|
2008-08-28 16:48:45 +02:00
|
|
|
&& nodes[0].recurrenceTime) {
|
|
|
|
_editRecurrenceDialog(nodes[0], "confirmDeletion");
|
2008-07-17 23:12:43 +02:00
|
|
|
}
|
|
|
|
else {
|
2008-08-28 16:48:45 +02:00
|
|
|
if (confirm(label)) {
|
|
|
|
if (document.deleteEventAjaxRequest) {
|
|
|
|
document.deleteEventAjaxRequest.aborted = true;
|
|
|
|
document.deleteEventAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
var sortedNodes = [];
|
|
|
|
var calendars = [];
|
|
|
|
|
|
|
|
for (var i = 0; i < nodes.length; i++) {
|
|
|
|
var calendar = nodes[i].calendar;
|
|
|
|
if (!sortedNodes[calendar]) {
|
|
|
|
sortedNodes[calendar] = [];
|
|
|
|
calendars.push(calendar);
|
|
|
|
}
|
|
|
|
sortedNodes[calendar].push(nodes[i].cname);
|
|
|
|
}
|
|
|
|
for (var i = 0; i < calendars.length; i++) {
|
|
|
|
calendarsOfEventsToDelete.push(calendars[i]);
|
|
|
|
eventsToDelete.push(sortedNodes[calendars[i]]);
|
|
|
|
}
|
|
|
|
_batchDeleteEvents();
|
|
|
|
}
|
2006-10-12 23:05:32 +02:00
|
|
|
}
|
2007-12-03 15:13:10 +01:00
|
|
|
} else {
|
|
|
|
window.alert(labels["Please select an event or a task."]);
|
2006-08-25 22:49:34 +02:00
|
|
|
}
|
2006-08-22 00:36:33 +02:00
|
|
|
}
|
2007-01-30 14:50:52 +01:00
|
|
|
else if (selectedCalendarCell) {
|
2008-07-17 23:12:43 +02:00
|
|
|
if (selectedCalendarCell[0].recurrenceTime) {
|
|
|
|
_editRecurrenceDialog(selectedCalendarCell[0], "confirmDeletion");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var label = labels["eventDeleteConfirmation"];
|
|
|
|
if (confirm(label)) {
|
2008-08-28 16:48:45 +02:00
|
|
|
if (document.deleteEventAjaxRequest) {
|
|
|
|
document.deleteEventAjaxRequest.aborted = true;
|
|
|
|
document.deleteEventAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
eventsToDelete.push([selectedCalendarCell[0].cname]);
|
|
|
|
calendarsOfEventsToDelete.push(selectedCalendarCell[0].calendar);
|
|
|
|
_batchDeleteEvents();
|
2008-01-24 22:36:51 +01:00
|
|
|
}
|
|
|
|
}
|
2007-01-30 14:50:52 +01:00
|
|
|
}
|
2006-11-13 23:31:41 +01:00
|
|
|
else
|
2007-12-03 15:13:10 +01:00
|
|
|
window.alert(labels["Please select an event or a task."]);
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2006-08-25 22:49:34 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-11-07 19:14:29 +01:00
|
|
|
function modifyEvent(sender, modification) {
|
|
|
|
var currentLocation = '' + window.location;
|
|
|
|
var arr = currentLocation.split("/");
|
|
|
|
arr[arr.length-1] = modification;
|
2006-11-15 01:10:53 +01:00
|
|
|
|
|
|
|
document.modifyEventAjaxRequest = triggerAjaxRequest(arr.join("/"),
|
|
|
|
modifyEventCallback,
|
|
|
|
modification);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-01-04 23:30:48 +01:00
|
|
|
function closeInvitationWindow() {
|
|
|
|
var closeDiv = document.createElement("div");
|
2007-10-04 19:26:21 +02:00
|
|
|
document.body.appendChild(closeDiv);
|
2007-01-04 23:30:48 +01:00
|
|
|
closeDiv.addClassName("javascriptPopupBackground");
|
2007-10-04 19:26:21 +02:00
|
|
|
|
2007-01-04 23:30:48 +01:00
|
|
|
var closePseudoWin = document.createElement("div");
|
2007-10-04 19:26:21 +02:00
|
|
|
document.body.appendChild(closePseudoWin);
|
2007-06-05 22:29:59 +02:00
|
|
|
closePseudoWin.addClassName("javascriptMessagePseudoTopWindow");
|
2007-01-04 23:30:48 +01:00
|
|
|
closePseudoWin.style.top = "0px;";
|
|
|
|
closePseudoWin.style.left = "0px;";
|
|
|
|
closePseudoWin.style.right = "0px;";
|
2007-09-15 00:01:02 +02:00
|
|
|
closePseudoWin.appendChild(document.createTextNode(labels["closeThisWindowMessage"]));
|
2007-10-04 19:26:21 +02:00
|
|
|
|
|
|
|
var calLink = document.createElement("a");
|
|
|
|
closePseudoWin.appendChild(calLink);
|
|
|
|
calLink.href = ApplicationBaseURL;
|
|
|
|
calLink.appendChild(document.createTextNode(labels["Calendar"].toLowerCase()));
|
2007-01-04 23:30:48 +01:00
|
|
|
}
|
|
|
|
|
2006-11-15 01:10:53 +01:00
|
|
|
function modifyEventCallback(http) {
|
2007-08-24 00:10:01 +02:00
|
|
|
if (http.readyState == 4) {
|
|
|
|
if (http.status == 200) {
|
|
|
|
var mailInvitation = queryParameters["mail-invitation"];
|
|
|
|
if (mailInvitation && mailInvitation.toLowerCase() == "yes")
|
2008-08-28 16:48:45 +02:00
|
|
|
closeInvitationWindow();
|
2007-01-30 15:02:27 +01:00
|
|
|
else {
|
2008-08-28 16:48:45 +02:00
|
|
|
window.opener.setTimeout("refreshEventsAndDisplay();", 100);
|
|
|
|
window.setTimeout("window.close();", 100);
|
2007-01-30 15:02:27 +01:00
|
|
|
}
|
2007-08-24 00:10:01 +02:00
|
|
|
}
|
|
|
|
else {
|
2008-01-24 22:36:51 +01:00
|
|
|
// log("showing alert...");
|
2007-08-24 00:10:01 +02:00
|
|
|
window.alert(labels["eventPartStatModificationError"]);
|
|
|
|
}
|
|
|
|
document.modifyEventAjaxRequest = null;
|
|
|
|
}
|
2006-11-07 19:14:29 +01:00
|
|
|
}
|
|
|
|
|
2008-08-03 01:16:50 +02:00
|
|
|
function _deleteCalendarEventBlocks(calendar, cname) {
|
|
|
|
var events = calendarEvents[calendar];
|
|
|
|
if (events) {
|
|
|
|
var occurences = events[cname];
|
|
|
|
if (occurences)
|
|
|
|
for (var i = 0; i < occurences.length; i++) {
|
2008-08-28 16:48:45 +02:00
|
|
|
var nodes = occurences[i].blocks;
|
|
|
|
for (var j = 0; j < nodes.length; j++) {
|
|
|
|
var node = nodes[j];
|
|
|
|
node.parentNode.removeChild(node);
|
|
|
|
}
|
2008-08-03 01:16:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function _deleteEventFromTables(basename) {
|
|
|
|
var tables = [ $("eventsList"), $("tasksList") ];
|
|
|
|
for (var i = 0; i < 2; i++) {
|
|
|
|
var table = tables[i];
|
|
|
|
if (table.tBodies)
|
|
|
|
rows = table.tBodies[0].rows;
|
|
|
|
else
|
|
|
|
rows = $(table).childNodesWithTag("li");
|
|
|
|
for (var j = rows.length; j > 0; j--) {
|
|
|
|
var row = $(rows[j - 1]);
|
|
|
|
var id = row.getAttribute("id");
|
|
|
|
if (id.indexOf(basename) == 0)
|
2008-08-28 16:48:45 +02:00
|
|
|
row.parentNode.removeChild(row);
|
2008-08-03 01:16:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function deleteEventCallback(http) {
|
2007-09-15 01:14:51 +02:00
|
|
|
if (http.readyState == 4) {
|
|
|
|
if (isHttpStatus204(http.status)) {
|
2008-01-16 15:57:41 +01:00
|
|
|
var isTask = false;
|
2008-08-03 01:16:50 +02:00
|
|
|
var calendar = http.callbackData.calendar;
|
|
|
|
var events = http.callbackData.events;
|
|
|
|
|
2008-08-28 16:48:45 +02:00
|
|
|
// log("calendar: " + calendar + "\n");
|
|
|
|
// log("events: " + events.join(", " ) + "\n");
|
2008-08-03 01:16:50 +02:00
|
|
|
for (var i = 0; i < events.length; i++) {
|
2008-08-28 16:48:45 +02:00
|
|
|
var cname = events[i];
|
|
|
|
_deleteCalendarEventBlocks(calendar, cname);
|
|
|
|
_deleteEventFromTables(calendar + "-" + cname);
|
|
|
|
delete calendarEvents[calendar][cname];
|
2007-09-15 01:14:51 +02:00
|
|
|
}
|
2008-08-03 01:16:50 +02:00
|
|
|
|
2007-09-15 01:14:51 +02:00
|
|
|
if (eventsToDelete.length)
|
2008-08-28 16:48:45 +02:00
|
|
|
_batchDeleteEvents();
|
2007-09-15 01:14:51 +02:00
|
|
|
else {
|
2008-08-28 16:48:45 +02:00
|
|
|
document.deleteEventAjaxRequest = null;
|
2007-09-15 01:14:51 +02:00
|
|
|
}
|
2006-10-18 23:53:47 +02:00
|
|
|
}
|
2008-12-23 16:51:12 +01:00
|
|
|
else if (parseInt(http.status) == 403)
|
|
|
|
window.alert(clabels["You don't have the required privileges to perform the operation."]);
|
|
|
|
else
|
|
|
|
log ("deleteEventCallback Ajax error (" + http.status + ")");
|
2006-08-25 22:49:34 +02:00
|
|
|
}
|
2006-08-14 22:32:30 +02:00
|
|
|
}
|
|
|
|
|
2008-07-29 18:35:49 +02:00
|
|
|
function getEventById(cname, owner) {
|
|
|
|
var event = null;
|
|
|
|
|
|
|
|
if (calendarEvents) {
|
|
|
|
if (!owner)
|
|
|
|
owner = UserLogin;
|
|
|
|
var userEvents = calendarEvents[owner];
|
|
|
|
if (userEvents)
|
|
|
|
event = userEvents[cname];
|
|
|
|
}
|
|
|
|
|
|
|
|
return event;
|
|
|
|
}
|
|
|
|
|
2008-07-17 23:12:43 +02:00
|
|
|
function _editRecurrenceDialog(eventDiv, method) {
|
|
|
|
var targetname = "SOGo_edit_" + eventDiv.cname + eventDiv.recurrenceTime;
|
|
|
|
var urlstr = (ApplicationBaseURL + eventDiv.calendar + "/" + eventDiv.cname
|
2008-08-28 16:48:45 +02:00
|
|
|
+ "/occurence" + eventDiv.recurrenceTime + "/" + method);
|
2008-07-17 23:12:43 +02:00
|
|
|
var win = window.open(urlstr, "_blank",
|
|
|
|
"width=490,height=70,resizable=0");
|
|
|
|
if (win)
|
|
|
|
win.focus();
|
|
|
|
}
|
|
|
|
|
2008-08-19 00:45:59 +02:00
|
|
|
function onViewEvent(event) {
|
|
|
|
if (event.detail == 2) return;
|
2008-11-03 15:17:57 +01:00
|
|
|
var url = ApplicationBaseURL + this.calendar + "/" + this.cname;
|
2009-02-06 02:16:17 +01:00
|
|
|
|
2008-11-03 15:17:57 +01:00
|
|
|
if (typeof this.recurrenceTime != "undefined")
|
|
|
|
url += "/occurence" + this.recurrenceTime;
|
|
|
|
url += "/view";
|
2008-08-19 00:45:59 +02:00
|
|
|
if (document.viewEventAjaxRequest) {
|
|
|
|
document.viewEventAjaxRequest.aborted = true;
|
|
|
|
document.viewEventAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
document.viewEventAjaxRequest = triggerAjaxRequest(url, onViewEventCallback, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onViewEventCallback(http) {
|
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
|
|
|
if (http.responseText.length > 0) {
|
|
|
|
var data = http.responseText.evalJSON(true);
|
2008-08-28 16:48:45 +02:00
|
|
|
// $H(data).keys().each(function(key) {
|
|
|
|
// log (key + " = " + data[key]);
|
|
|
|
// });
|
2008-08-19 00:45:59 +02:00
|
|
|
var cell = http.callbackData;
|
|
|
|
var cellPosition = cell.cumulativeOffset();
|
|
|
|
var cellDimensions = cell.getDimensions();
|
|
|
|
var div = $("eventDialog");
|
|
|
|
var divDimensions = div.getDimensions();
|
|
|
|
var view;
|
|
|
|
var left = cellPosition[0];
|
|
|
|
var top = cellPosition[1];
|
|
|
|
|
|
|
|
if (currentView != "monthview") {
|
2008-08-28 16:48:45 +02:00
|
|
|
view = $("daysView");
|
|
|
|
var viewPosition = view.cumulativeOffset();
|
|
|
|
if (parseInt(data["isAllDay"]) == 0) {
|
|
|
|
top -= view.scrollTop;
|
|
|
|
if (viewPosition[1] > top + 2) {
|
|
|
|
view.stopObserving("scroll", onBodyClickHandler);
|
|
|
|
view.scrollTop = cell.offsetTop;
|
|
|
|
top = viewPosition[1];
|
|
|
|
Event.observe.delay(0.1, view, "scroll", onBodyClickHandler);
|
|
|
|
}
|
|
|
|
}
|
2008-08-19 00:45:59 +02:00
|
|
|
}
|
|
|
|
else {
|
2008-08-28 16:48:45 +02:00
|
|
|
view = $("calendarView");
|
|
|
|
top -= cell.up("DIV.day").scrollTop;
|
2008-08-19 00:45:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (left > parseInt(window.width()*0.75)) {
|
2008-08-28 16:48:45 +02:00
|
|
|
left = left - divDimensions["width"] + 10;
|
|
|
|
div.removeClassName("left");
|
|
|
|
div.addClassName("right");
|
2008-08-19 00:45:59 +02:00
|
|
|
}
|
|
|
|
else {
|
2008-08-28 16:48:45 +02:00
|
|
|
left = left + cellDimensions["width"] - parseInt(cellDimensions["width"]/3);
|
|
|
|
div.removeClassName("right");
|
|
|
|
div.addClassName("left");
|
2008-08-19 00:45:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Put the event's data in the DIV
|
|
|
|
div.down("h1").update(data["summary"]);
|
|
|
|
if (parseInt(data["isAllDay"]) == 0) {
|
2008-08-28 16:48:45 +02:00
|
|
|
div.down("P", 0).down("SPAN", 1).update(data["startTime"]);
|
|
|
|
div.down("P", 0).show();
|
2008-08-19 00:45:59 +02:00
|
|
|
} else
|
2008-08-28 16:48:45 +02:00
|
|
|
div.down("P", 0).hide();
|
2008-08-19 00:45:59 +02:00
|
|
|
if (data["location"].length) {
|
2008-08-28 16:48:45 +02:00
|
|
|
div.down("P", 1).down("SPAN", 1).update(data["location"]);
|
|
|
|
div.down("P", 1).show();
|
2008-08-19 00:45:59 +02:00
|
|
|
} else
|
2008-08-28 16:48:45 +02:00
|
|
|
div.down("P", 1).hide();
|
2008-08-19 00:45:59 +02:00
|
|
|
|
|
|
|
if (data["description"].length) {
|
2009-06-30 03:39:27 +02:00
|
|
|
div.down("P", 2).update(data["description"].replace(/\r\n/g, "<BR/>"));
|
2008-08-28 16:48:45 +02:00
|
|
|
div.down("P", 2).show();
|
2008-08-19 00:45:59 +02:00
|
|
|
} else
|
2008-08-28 16:48:45 +02:00
|
|
|
div.down("P", 2).hide();
|
2008-08-19 00:45:59 +02:00
|
|
|
|
|
|
|
div.setStyle({ left: left + "px",
|
2008-08-28 16:48:45 +02:00
|
|
|
top: top + "px" });
|
2008-08-19 00:45:59 +02:00
|
|
|
div.show();
|
|
|
|
}
|
|
|
|
}
|
2008-11-04 20:55:50 +01:00
|
|
|
else {
|
2009-02-06 02:16:17 +01:00
|
|
|
log("onViewEventCallback ajax error (" + http.status + "): " + http.url);
|
2008-11-04 20:55:50 +01:00
|
|
|
}
|
2008-08-19 00:45:59 +02:00
|
|
|
}
|
|
|
|
|
2007-06-11 23:23:48 +02:00
|
|
|
function editDoubleClickedEvent(event) {
|
2009-06-15 23:19:36 +02:00
|
|
|
if (this.recurrenceTime && !this.isException)
|
2008-07-17 23:12:43 +02:00
|
|
|
_editRecurrenceDialog(this, "confirmEditing");
|
|
|
|
else
|
|
|
|
_editEventId(this.cname, this.calendar);
|
2007-06-11 23:23:48 +02:00
|
|
|
|
2008-08-19 00:45:59 +02:00
|
|
|
Event.stop(event);
|
2006-08-22 00:36:33 +02:00
|
|
|
}
|
|
|
|
|
2008-07-17 23:12:43 +02:00
|
|
|
function performEventEdition(folder, event, recurrence) {
|
|
|
|
_editEventId(event, folder, recurrence);
|
|
|
|
}
|
|
|
|
|
|
|
|
function performEventDeletion(folder, event, recurrence) {
|
2008-11-22 08:20:22 +01:00
|
|
|
if (calendarEvents) {
|
2008-07-29 18:35:49 +02:00
|
|
|
if (recurrence) {
|
2008-11-22 08:20:22 +01:00
|
|
|
// Only one recurrence
|
|
|
|
var occurenceTime = recurrence.substring(9);
|
|
|
|
var nodes = _eventBlocksMatching(folder, event, occurenceTime);
|
|
|
|
var urlstr = ApplicationBaseURL + folder + "/" + event + "/" + recurrence + "/delete";
|
|
|
|
|
|
|
|
if (nodes)
|
|
|
|
document.deleteEventAjaxRequest = triggerAjaxRequest(urlstr,
|
|
|
|
performDeleteEventCallback,
|
|
|
|
{ nodes: nodes,
|
|
|
|
occurence: occurenceTime });
|
2008-07-29 18:35:49 +02:00
|
|
|
}
|
2008-11-22 08:20:22 +01:00
|
|
|
else {
|
|
|
|
// All recurrences
|
|
|
|
if (document.deleteEventAjaxRequest) {
|
|
|
|
document.deleteEventAjaxRequest.aborted = true;
|
|
|
|
document.deleteEventAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
eventsToDelete.push([event]);
|
|
|
|
calendarsOfEventsToDelete.push(folder);
|
|
|
|
_batchDeleteEvents();
|
|
|
|
}
|
2008-07-17 23:12:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function performDeleteEventCallback(http) {
|
|
|
|
if (http.readyState == 4) {
|
|
|
|
if (isHttpStatus204(http.status)) {
|
2008-07-29 18:35:49 +02:00
|
|
|
var occurenceTime = http.callbackData.occurence;
|
2008-07-17 23:12:43 +02:00
|
|
|
var nodes = http.callbackData.nodes;
|
2008-07-29 18:35:49 +02:00
|
|
|
var cname = nodes[0].cname;
|
|
|
|
var calendar = nodes[0].calendar;
|
|
|
|
for (var i = 0; i < nodes.length; i++) {
|
2008-08-28 16:48:45 +02:00
|
|
|
var node = nodes[i];
|
|
|
|
node.parentNode.removeChild(node);
|
2008-07-17 23:12:43 +02:00
|
|
|
}
|
2008-07-29 18:35:49 +02:00
|
|
|
var basename = calendar + "-" + cname;
|
|
|
|
if (occurenceTime) {
|
2008-08-28 16:48:45 +02:00
|
|
|
var row = $(basename + "-" + occurenceTime);
|
|
|
|
// log("rowID: " + basename + "-" + occurenceTime);
|
|
|
|
if (row)
|
|
|
|
row.parentNode.removeChild(row);
|
|
|
|
|
2008-11-22 08:20:22 +01:00
|
|
|
// Update calendar events cache
|
2008-08-28 16:48:45 +02:00
|
|
|
var occurences = calendarEvents[calendar][cname];
|
|
|
|
var newOccurences = [];
|
|
|
|
for (var i = 0; i < occurences.length; i++) {
|
|
|
|
var occurence = occurences[i];
|
2009-04-24 21:19:43 +02:00
|
|
|
if (occurence[14] != occurenceTime)
|
2008-08-28 16:48:45 +02:00
|
|
|
newOccurences.push(occurence);
|
|
|
|
}
|
|
|
|
calendarEvents[calendar][cname] = newOccurences;
|
2008-07-17 23:12:43 +02:00
|
|
|
}
|
|
|
|
else {
|
2008-08-28 16:48:45 +02:00
|
|
|
// log("basename: " + basename);
|
|
|
|
_deleteEventFromTables(basename);
|
|
|
|
delete calendarEvents[calendar][cname];
|
2008-07-17 23:12:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-25 22:49:34 +02:00
|
|
|
function onSelectAll() {
|
2007-06-08 01:23:07 +02:00
|
|
|
var list = $("eventsList");
|
|
|
|
list.selectRowsMatchingClass("eventRow");
|
2006-08-25 22:49:34 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onDaySelect(node) {
|
2007-06-12 17:43:51 +02:00
|
|
|
var day = node.getAttribute('day');
|
2006-11-15 22:54:47 +01:00
|
|
|
var needRefresh = (listFilter == 'view_selectedday'
|
|
|
|
&& day != currentDay);
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2007-06-08 23:31:25 +02:00
|
|
|
var td = $(node).getParentWithTagName("td");
|
2007-06-12 17:43:51 +02:00
|
|
|
var table = $(td).getParentWithTagName("table");
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2008-01-24 22:36:51 +01:00
|
|
|
// log ("table.selected: " + table.selected);
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
if (document.selectedDate)
|
2006-12-20 23:55:54 +01:00
|
|
|
document.selectedDate.deselect();
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2008-02-05 21:00:52 +01:00
|
|
|
td.selectElement();
|
2006-08-19 00:40:04 +02:00
|
|
|
document.selectedDate = td;
|
|
|
|
|
2006-10-11 20:12:02 +02:00
|
|
|
changeCalendarDisplay( { "day": day } );
|
2008-01-08 22:00:10 +01:00
|
|
|
currentDay = day;
|
2006-11-15 22:54:47 +01:00
|
|
|
if (needRefresh)
|
2007-06-08 01:23:07 +02:00
|
|
|
refreshEvents();
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-07-05 21:19:17 +02:00
|
|
|
function onDateSelectorGotoMonth(event) {
|
2008-01-24 22:36:51 +01:00
|
|
|
var day = this.getAttribute("date");
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2008-01-24 22:36:51 +01:00
|
|
|
changeDateSelectorDisplay(day, true);
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2008-01-24 22:36:51 +01:00
|
|
|
Event.stop(event);
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onCalendarGotoDay(node) {
|
2008-01-24 22:36:51 +01:00
|
|
|
var day = node.getAttribute("date");
|
|
|
|
var needRefresh = (listFilter == 'view_selectedday'
|
2008-01-16 16:18:41 +01:00
|
|
|
&& day != currentDay);
|
2008-02-08 22:46:05 +01:00
|
|
|
|
2008-01-24 22:36:51 +01:00
|
|
|
changeDateSelectorDisplay(day);
|
|
|
|
changeCalendarDisplay( { "day": day } );
|
|
|
|
if (needRefresh)
|
|
|
|
refreshEvents();
|
2008-02-08 22:46:05 +01:00
|
|
|
|
2008-01-24 22:36:51 +01:00
|
|
|
return false;
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function gotoToday() {
|
2006-09-07 00:27:46 +02:00
|
|
|
changeDateSelectorDisplay('');
|
2006-08-24 20:48:33 +02:00
|
|
|
changeCalendarDisplay();
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function setDateSelectorContent(content) {
|
2006-08-24 20:48:33 +02:00
|
|
|
var div = $("dateSelectorView");
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2006-09-07 17:50:03 +02:00
|
|
|
div.innerHTML = content;
|
|
|
|
if (currentDay.length > 0)
|
|
|
|
restoreCurrentDaySelection(div);
|
2007-07-05 21:19:17 +02:00
|
|
|
|
|
|
|
initDateSelectorEvents();
|
2006-09-07 17:50:03 +02:00
|
|
|
}
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function dateSelectorCallback(http) {
|
2006-08-19 00:40:04 +02:00
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
2008-01-24 22:36:51 +01:00
|
|
|
document.dateSelectorAjaxRequest = null;
|
|
|
|
var content = http.responseText;
|
|
|
|
setDateSelectorContent(content);
|
|
|
|
cachedDateSelectors[http.callbackData] = content;
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
else
|
2007-06-06 23:09:39 +02:00
|
|
|
log ("dateSelectorCallback Ajax error");
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2007-06-08 01:23:07 +02:00
|
|
|
function eventsListCallback(http) {
|
2006-08-19 00:40:04 +02:00
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
2008-01-24 22:36:51 +01:00
|
|
|
var div = $("eventsListView");
|
2007-06-08 01:23:07 +02:00
|
|
|
document.eventsListAjaxRequest = null;
|
2007-09-24 23:26:23 +02:00
|
|
|
var table = $("eventsList");
|
2007-11-05 15:37:26 +01:00
|
|
|
lastClickedRow = -1; // from generic.js
|
2007-06-08 01:23:07 +02:00
|
|
|
|
2007-11-02 20:02:24 +01:00
|
|
|
if (http.responseText.length > 0) {
|
|
|
|
var data = http.responseText.evalJSON(true);
|
|
|
|
for (var i = 0; i < data.length; i++) {
|
2008-08-28 16:48:45 +02:00
|
|
|
var row = $(document.createElement("tr"));
|
|
|
|
table.tBodies[0].appendChild(row);
|
|
|
|
row.addClassName("eventRow");
|
2009-04-24 21:19:43 +02:00
|
|
|
var rTime = data[i][14];
|
2008-08-28 16:48:45 +02:00
|
|
|
var id = escape(data[i][1] + "-" + data[i][0]);
|
|
|
|
if (rTime)
|
|
|
|
id += "-" + escape(rTime);
|
|
|
|
row.setAttribute("id", id);
|
|
|
|
row.cname = escape(data[i][0]);
|
|
|
|
row.calendar = escape(data[i][1]);
|
|
|
|
if (rTime)
|
|
|
|
row.recurrenceTime = escape(rTime);
|
2009-06-15 23:19:36 +02:00
|
|
|
row.isException = data[i][15];
|
2008-08-28 16:48:45 +02:00
|
|
|
var startDate = new Date();
|
|
|
|
startDate.setTime(data[i][4] * 1000);
|
|
|
|
row.day = startDate.getDayString();
|
|
|
|
row.hour = startDate.getHourString();
|
|
|
|
row.observe("mousedown", onRowClick);
|
|
|
|
row.observe("selectstart", listRowMouseDownHandler);
|
|
|
|
row.observe("dblclick", editDoubleClickedEvent);
|
2009-06-02 21:45:07 +02:00
|
|
|
row.attachMenu("eventsListMenu");
|
|
|
|
|
2008-08-28 16:48:45 +02:00
|
|
|
var td = $(document.createElement("td"));
|
|
|
|
row.appendChild(td);
|
|
|
|
td.observe("mousedown", listRowMouseDownHandler, true);
|
|
|
|
td.appendChild(document.createTextNode(data[i][3]));
|
|
|
|
|
|
|
|
td = $(document.createElement("td"));
|
|
|
|
row.appendChild(td);
|
|
|
|
td.observe("mousedown", listRowMouseDownHandler, true);
|
2009-06-19 01:01:15 +02:00
|
|
|
td.appendChild(document.createTextNode(data[i][16]));
|
2008-08-28 16:48:45 +02:00
|
|
|
|
|
|
|
td = $(document.createElement("td"));
|
|
|
|
row.appendChild(td);
|
|
|
|
td.observe("mousedown", listRowMouseDownHandler, true);
|
2009-06-19 01:01:15 +02:00
|
|
|
td.appendChild(document.createTextNode(data[i][17]));
|
2007-11-02 20:02:24 +01:00
|
|
|
|
2008-08-28 16:48:45 +02:00
|
|
|
td = $(document.createElement("td"));
|
|
|
|
row.appendChild(td);
|
|
|
|
td.observe("mousedown", listRowMouseDownHandler, true);
|
|
|
|
td.appendChild(document.createTextNode(data[i][6]));
|
2007-11-02 20:02:24 +01:00
|
|
|
}
|
2007-12-06 18:29:32 +01:00
|
|
|
|
|
|
|
if (sorting["attribute"] && sorting["attribute"].length > 0) {
|
2008-08-28 16:48:45 +02:00
|
|
|
var sortHeader = $(sorting["attribute"] + "Header");
|
2007-12-06 18:29:32 +01:00
|
|
|
|
2008-08-28 16:48:45 +02:00
|
|
|
if (sortHeader) {
|
|
|
|
var sortImages = $(table.tHead).select(".sortImage");
|
|
|
|
$(sortImages).each(function(item) {
|
|
|
|
item.remove();
|
|
|
|
});
|
|
|
|
|
|
|
|
var sortImage = createElement("img", "messageSortImage", "sortImage");
|
|
|
|
sortHeader.insertBefore(sortImage, sortHeader.firstChild);
|
|
|
|
if (sorting["ascending"])
|
|
|
|
sortImage.src = ResourcesURL + "/title_sortdown_12x12.png";
|
|
|
|
else
|
|
|
|
sortImage.src = ResourcesURL + "/title_sortup_12x12.png";
|
|
|
|
}
|
2007-12-06 18:29:32 +01:00
|
|
|
}
|
2007-06-08 01:23:07 +02:00
|
|
|
}
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
else
|
2007-06-08 01:23:07 +02:00
|
|
|
log ("eventsListCallback Ajax error");
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function tasksListCallback(http) {
|
2006-10-11 20:12:02 +02:00
|
|
|
var div = $("tasksListView");
|
|
|
|
|
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
|
|
|
document.tasksListAjaxRequest = null;
|
2006-11-13 23:31:41 +01:00
|
|
|
var list = $("tasksList");
|
2007-11-02 20:02:24 +01:00
|
|
|
|
|
|
|
if (http.responseText.length > 0) {
|
|
|
|
var data = http.responseText.evalJSON(true);
|
|
|
|
|
|
|
|
for (var i = 0; i < data.length; i++) {
|
2008-08-28 16:48:45 +02:00
|
|
|
var listItem = $(document.createElement("li"));
|
|
|
|
list.appendChild(listItem);
|
|
|
|
listItem.observe("mousedown", listRowMouseDownHandler);
|
|
|
|
listItem.observe("click", onRowClick);
|
|
|
|
listItem.observe("dblclick", editDoubleClickedEvent);
|
|
|
|
|
|
|
|
var calendar = escape(data[i][1]);
|
|
|
|
var cname = escape(data[i][0]);
|
|
|
|
listItem.setAttribute("id", calendar + "-" + cname);
|
|
|
|
listItem.addClassName(data[i][5]);
|
|
|
|
listItem.addClassName(data[i][6]);
|
|
|
|
listItem.calendar = calendar;
|
|
|
|
listItem.addClassName("calendarFolder" + calendar);
|
|
|
|
listItem.cname = cname;
|
|
|
|
var input = $(document.createElement("input"));
|
|
|
|
input.setAttribute("type", "checkbox");
|
|
|
|
listItem.appendChild(input);
|
|
|
|
input.observe("click", updateTaskStatus, true);
|
|
|
|
input.setAttribute("value", "1");
|
|
|
|
if (data[i][2] == 1)
|
|
|
|
input.setAttribute("checked", "checked");
|
|
|
|
$(input).addClassName("checkBox");
|
|
|
|
|
|
|
|
listItem.appendChild(document.createTextNode(data[i][3]));
|
2007-11-02 20:02:24 +01:00
|
|
|
}
|
2007-06-06 23:09:39 +02:00
|
|
|
|
2007-11-02 20:02:24 +01:00
|
|
|
list.scrollTop = list.previousScroll;
|
2007-06-06 23:09:39 +02:00
|
|
|
|
2007-11-02 20:02:24 +01:00
|
|
|
if (http.callbackData) {
|
2008-08-28 16:48:45 +02:00
|
|
|
var selectedNodesId = http.callbackData;
|
|
|
|
for (var i = 0; i < selectedNodesId.length; i++) {
|
|
|
|
// log(selectedNodesId[i] + " (" + i + ") is selected");
|
|
|
|
$(selectedNodesId[i]).selectElement();
|
|
|
|
}
|
2007-06-06 23:09:39 +02:00
|
|
|
}
|
2007-11-02 20:02:24 +01:00
|
|
|
else
|
2008-08-28 16:48:45 +02:00
|
|
|
log ("tasksListCallback: no data");
|
2006-10-11 20:12:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2007-06-06 23:09:39 +02:00
|
|
|
log ("tasksListCallback Ajax error");
|
2006-10-11 20:12:02 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function restoreCurrentDaySelection(div) {
|
2007-07-31 23:14:14 +02:00
|
|
|
var elements = $(div).getElementsByTagName("a");
|
2006-08-19 00:40:04 +02:00
|
|
|
var day = null;
|
2006-11-03 00:17:55 +01:00
|
|
|
var i = 9;
|
2006-08-19 00:40:04 +02:00
|
|
|
while (!day && i < elements.length)
|
|
|
|
{
|
2007-06-11 23:23:48 +02:00
|
|
|
day = elements[i].day;
|
2006-08-19 00:40:04 +02:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (day
|
2006-11-06 18:44:07 +01:00
|
|
|
&& day.substr(0, 6) == currentDay.substr(0, 6)) {
|
2008-01-24 22:36:51 +01:00
|
|
|
for (i = 0; i < elements.length; i++) {
|
|
|
|
day = elements[i].day;
|
|
|
|
if (day && day == currentDay) {
|
2008-08-28 16:48:45 +02:00
|
|
|
var td = $(elements[i]).getParentWithTagName("td");
|
|
|
|
if (document.selectedDate)
|
|
|
|
document.selectedDate.deselect();
|
|
|
|
$(td).selectElement();
|
|
|
|
document.selectedDate = td;
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
}
|
2008-01-24 22:36:51 +01:00
|
|
|
}
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function changeDateSelectorDisplay(day, keepCurrentDay) {
|
2007-11-16 20:38:49 +01:00
|
|
|
var url = ApplicationBaseURL + "dateselector";
|
2008-11-04 20:55:50 +01:00
|
|
|
if (day) {
|
|
|
|
if (day.length < 8)
|
|
|
|
day += "01";
|
2006-08-19 00:40:04 +02:00
|
|
|
url += "?day=" + day;
|
2008-11-04 20:55:50 +01:00
|
|
|
}
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2006-09-07 00:27:46 +02:00
|
|
|
if (day != currentDay) {
|
|
|
|
if (!keepCurrentDay)
|
|
|
|
currentDay = day;
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2006-09-07 17:50:03 +02:00
|
|
|
var month = day.substr(0, 6);
|
|
|
|
if (cachedDateSelectors[month]) {
|
2008-01-24 22:36:51 +01:00
|
|
|
// log ("restoring cached selector for month: " + month);
|
2006-09-07 17:50:03 +02:00
|
|
|
setDateSelectorContent(cachedDateSelectors[month]);
|
|
|
|
}
|
|
|
|
else {
|
2008-01-24 22:36:51 +01:00
|
|
|
// log ("loading selector for month: " + month);
|
2006-09-07 17:50:03 +02:00
|
|
|
if (document.dateSelectorAjaxRequest) {
|
|
|
|
document.dateSelectorAjaxRequest.aborted = true;
|
|
|
|
document.dateSelectorAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
document.dateSelectorAjaxRequest
|
|
|
|
= triggerAjaxRequest(url,
|
|
|
|
dateSelectorCallback,
|
|
|
|
month);
|
2006-09-07 00:27:46 +02:00
|
|
|
}
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-07 18:37:58 +01:00
|
|
|
function changeCalendarDisplay(data, newView) {
|
2008-02-08 22:46:05 +01:00
|
|
|
newView = ((newView) ? newView : currentView);
|
|
|
|
var url = ApplicationBaseURL + newView;
|
2006-10-12 18:46:24 +02:00
|
|
|
var day = null;
|
2007-11-07 18:37:58 +01:00
|
|
|
var scrollEvent = null;
|
2007-11-19 18:09:14 +01:00
|
|
|
|
2007-11-07 18:37:58 +01:00
|
|
|
if (data) {
|
|
|
|
day = data['day'];
|
|
|
|
scrollEvent = data['scrollEvent'];
|
2006-10-12 18:46:24 +02:00
|
|
|
}
|
2006-10-11 20:12:02 +02:00
|
|
|
|
2006-08-24 20:48:33 +02:00
|
|
|
if (!day)
|
2006-09-07 00:27:46 +02:00
|
|
|
day = currentDay;
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2007-11-16 20:38:49 +01:00
|
|
|
if (day) {
|
2008-08-19 00:45:59 +02:00
|
|
|
if (data) {
|
2007-11-19 18:09:14 +01:00
|
|
|
var divs = $$('div.day[day='+day+']');
|
|
|
|
if (divs.length) {
|
2008-08-28 16:48:45 +02:00
|
|
|
// Don't reload the view if the event is present in current view
|
|
|
|
|
|
|
|
// Deselect previous day
|
|
|
|
var selectedDivs = $$('div.day.selectedDay');
|
|
|
|
selectedDivs.each(function(div) {
|
|
|
|
div.removeClassName('selectedDay');
|
|
|
|
});
|
|
|
|
|
|
|
|
// Select new day
|
|
|
|
divs.each(function(div) {
|
|
|
|
div.addClassName('selectedDay');
|
|
|
|
});
|
2007-11-19 18:09:14 +01:00
|
|
|
|
2008-08-28 16:48:45 +02:00
|
|
|
// Deselect day in date selector
|
|
|
|
if (document.selectedDate)
|
|
|
|
document.selectedDate.deselect();
|
2007-11-19 18:09:14 +01:00
|
|
|
|
2008-08-28 16:48:45 +02:00
|
|
|
// Select day in date selector
|
|
|
|
var selectedLink = $$('table#dateSelectorTable a[day='+day+']');
|
|
|
|
if (selectedLink.length > 0) {
|
|
|
|
selectedCell = selectedLink[0].up(1);
|
|
|
|
selectedCell.selectElement();
|
|
|
|
document.selectedDate = selectedCell;
|
|
|
|
}
|
2007-11-19 18:09:14 +01:00
|
|
|
|
2008-08-28 16:48:45 +02:00
|
|
|
// Scroll to event
|
|
|
|
scrollDayView(scrollEvent);
|
2007-11-16 20:38:49 +01:00
|
|
|
|
2008-08-28 16:48:45 +02:00
|
|
|
return false;
|
2007-11-16 20:38:49 +01:00
|
|
|
}
|
2008-11-04 20:55:50 +01:00
|
|
|
else if (day.length == 6) {
|
|
|
|
day += "01";
|
|
|
|
}
|
2007-11-16 20:38:49 +01:00
|
|
|
}
|
|
|
|
url += "?day=" + day;
|
|
|
|
}
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2007-11-19 18:09:14 +01:00
|
|
|
selectedCalendarCell = null;
|
|
|
|
|
2006-08-19 00:40:04 +02:00
|
|
|
if (document.dayDisplayAjaxRequest) {
|
|
|
|
document.dayDisplayAjaxRequest.aborted = true;
|
|
|
|
document.dayDisplayAjaxRequest.abort();
|
|
|
|
}
|
2007-06-11 23:23:48 +02:00
|
|
|
document.dayDisplayAjaxRequest
|
2008-01-24 22:36:51 +01:00
|
|
|
= triggerAjaxRequest(url, calendarDisplayCallback,
|
2008-08-28 16:48:45 +02:00
|
|
|
{ "view": newView,
|
|
|
|
"day": day,
|
|
|
|
"scrollEvent": scrollEvent });
|
2006-08-24 20:48:33 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function _ensureView(view) {
|
|
|
|
if (currentView != view)
|
|
|
|
changeCalendarDisplay(null, view);
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onDayOverview() {
|
2006-08-24 20:48:33 +02:00
|
|
|
return _ensureView("dayview");
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onMulticolumnDayOverview() {
|
2007-02-13 23:01:02 +01:00
|
|
|
return _ensureView("multicolumndayview");
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onWeekOverview() {
|
2006-08-24 20:48:33 +02:00
|
|
|
return _ensureView("weekview");
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onMonthOverview() {
|
2006-08-24 20:48:33 +02:00
|
|
|
return _ensureView("monthview");
|
|
|
|
}
|
|
|
|
|
2007-11-07 18:37:58 +01:00
|
|
|
function scrollDayView(scrollEvent) {
|
2008-07-29 18:35:49 +02:00
|
|
|
if (scrollEvent) {
|
2008-08-19 00:45:59 +02:00
|
|
|
var contentView;
|
2008-07-29 18:35:49 +02:00
|
|
|
var eventRow = $(scrollEvent);
|
2008-08-19 00:45:59 +02:00
|
|
|
var eventBlocks = selectCalendarEvent(eventRow.calendar, eventRow.cname, eventRow.recurrenceTime);
|
|
|
|
var firstEvent = eventBlocks.first();
|
|
|
|
|
|
|
|
if (currentView == "monthview")
|
|
|
|
contentView = firstEvent.up("DIV.day");
|
|
|
|
else
|
|
|
|
contentView = $("daysView");
|
|
|
|
|
|
|
|
var top = firstEvent.cumulativeOffset()[1] - contentView.scrollTop;
|
2007-11-16 20:38:49 +01:00
|
|
|
|
2008-08-19 00:45:59 +02:00
|
|
|
// Don't scroll if the event is visible to the user
|
|
|
|
if (top < contentView.cumulativeOffset()[1])
|
|
|
|
contentView.scrollTop = firstEvent.cumulativeOffset()[1] - contentView.cumulativeOffset()[1];
|
|
|
|
else if (top > contentView.cumulativeOffset()[1] + contentView.getHeight() - firstEvent.getHeight())
|
|
|
|
contentView.scrollTop = firstEvent.cumulativeOffset()[1] - contentView.cumulativeOffset()[1];
|
|
|
|
}
|
|
|
|
else if (currentView != "monthview") {
|
|
|
|
var contentView = $("daysView");
|
|
|
|
var hours = (contentView.childNodesWithTag("div")[0]).childNodesWithTag("div");
|
|
|
|
contentView.scrollTop = hours[dayStartHour].offsetTop;
|
2007-11-07 18:37:58 +01:00
|
|
|
}
|
2006-10-04 00:59:07 +02:00
|
|
|
}
|
|
|
|
|
2006-11-15 01:53:59 +01:00
|
|
|
function onClickableCellsDblClick(event) {
|
|
|
|
newEvent(this, 'event');
|
2006-11-15 18:59:47 +01:00
|
|
|
|
2008-08-15 06:41:06 +02:00
|
|
|
Event.stop(event);
|
2006-11-15 01:53:59 +01:00
|
|
|
}
|
|
|
|
|
2007-11-16 20:38:49 +01:00
|
|
|
function refreshCalendarEvents(scrollEvent) {
|
2008-01-24 22:36:51 +01:00
|
|
|
var todayDate = new Date();
|
|
|
|
var sd;
|
|
|
|
var ed;
|
|
|
|
if (currentView == "dayview") {
|
|
|
|
if (currentDay)
|
|
|
|
sd = currentDay;
|
|
|
|
else
|
|
|
|
sd = todayDate.getDayString();
|
|
|
|
ed = sd;
|
|
|
|
}
|
|
|
|
else if (currentView == "weekview") {
|
|
|
|
var startDate;
|
|
|
|
if (currentDay)
|
|
|
|
startDate = currentDay.asDate();
|
|
|
|
else
|
|
|
|
startDate = todayDate;
|
|
|
|
startDate = startDate.beginOfWeek();
|
|
|
|
sd = startDate.getDayString();
|
|
|
|
var endDate = new Date();
|
|
|
|
endDate.setTime(startDate.getTime());
|
|
|
|
endDate.addDays(6);
|
|
|
|
ed = endDate.getDayString();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var monthDate;
|
|
|
|
if (currentDay)
|
|
|
|
monthDate = currentDay.asDate();
|
|
|
|
else
|
|
|
|
monthDate = todayDate;
|
|
|
|
monthDate.setDate(1);
|
|
|
|
sd = monthDate.beginOfWeek().getDayString();
|
|
|
|
|
|
|
|
var lastMonthDate = new Date();
|
|
|
|
lastMonthDate.setTime(monthDate.getTime());
|
|
|
|
lastMonthDate.setMonth(monthDate.getMonth() + 1);
|
|
|
|
lastMonthDate.addDays(-1);
|
|
|
|
ed = lastMonthDate.endOfWeek().getDayString();
|
|
|
|
}
|
|
|
|
if (document.refreshCalendarEventsAjaxRequest) {
|
|
|
|
document.refreshCalendarEventsAjaxRequest.aborted = true;
|
|
|
|
document.refreshCalendarEventsAjaxRequest.abort();
|
|
|
|
}
|
2008-07-16 04:12:18 +02:00
|
|
|
var url = (ApplicationBaseURL + "eventsblocks?sd=" + sd + "&ed=" + ed
|
2008-08-28 16:48:45 +02:00
|
|
|
+ "&view=" + currentView);
|
2008-01-24 22:36:51 +01:00
|
|
|
document.refreshCalendarEventsAjaxRequest
|
|
|
|
= triggerAjaxRequest(url, refreshCalendarEventsCallback,
|
2008-08-28 16:48:45 +02:00
|
|
|
{"startDate": sd, "endDate": ed,
|
|
|
|
"scrollEvent": scrollEvent});
|
2007-06-11 23:23:48 +02:00
|
|
|
}
|
|
|
|
|
2008-07-29 18:35:49 +02:00
|
|
|
function _parseEvents(list) {
|
|
|
|
var newCalendarEvents = {};
|
|
|
|
|
|
|
|
for (var i = 0; i < list.length; i++) {
|
|
|
|
var event = list[i];
|
|
|
|
var cname = event[0];
|
|
|
|
var calendar = event[1];
|
2009-04-27 17:40:13 +02:00
|
|
|
// log("parsed cname: " + cname + "; calendar: " + calendar);
|
2008-07-29 18:35:49 +02:00
|
|
|
var calendarDict = newCalendarEvents[calendar];
|
|
|
|
if (!calendarDict) {
|
|
|
|
calendarDict = {};
|
|
|
|
newCalendarEvents[calendar] = calendarDict;
|
|
|
|
}
|
|
|
|
var occurences = calendarDict[cname];
|
|
|
|
if (!occurences) {
|
|
|
|
occurences = [];
|
|
|
|
calendarDict[cname] = occurences;
|
|
|
|
}
|
|
|
|
event.blocks = [];
|
|
|
|
occurences.push(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
return newCalendarEvents;
|
|
|
|
}
|
|
|
|
|
2007-06-11 23:23:48 +02:00
|
|
|
function refreshCalendarEventsCallback(http) {
|
2008-04-15 22:12:51 +02:00
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
|
|
|
if (http.responseText.length > 0) {
|
2008-07-16 04:12:18 +02:00
|
|
|
var eventsBlocks = http.responseText.evalJSON(true);
|
2008-07-29 18:35:49 +02:00
|
|
|
calendarEvents = _parseEvents(eventsBlocks[0]);
|
2008-07-16 04:12:18 +02:00
|
|
|
if (currentView == "monthview")
|
2008-08-28 16:48:45 +02:00
|
|
|
_drawMonthCalendarEvents(eventsBlocks[2], eventsBlocks[0]);
|
2008-07-16 04:12:18 +02:00
|
|
|
else {
|
2008-08-28 16:48:45 +02:00
|
|
|
_drawCalendarAllDayEvents(eventsBlocks[1], eventsBlocks[0]);
|
|
|
|
_drawCalendarEvents(eventsBlocks[2], eventsBlocks[0]);
|
2008-04-15 22:12:51 +02:00
|
|
|
}
|
2009-06-03 23:06:06 +02:00
|
|
|
onWindowResize(null);
|
2008-07-16 04:12:18 +02:00
|
|
|
}
|
|
|
|
scrollDayView(http.callbackData["scrollEvent"]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
log("AJAX error when refreshing calendar events");
|
|
|
|
}
|
2008-04-15 22:12:51 +02:00
|
|
|
|
2008-07-17 23:12:43 +02:00
|
|
|
function newBaseEventDIV(eventRep, event, eventText) {
|
2009-06-02 21:45:07 +02:00
|
|
|
// log ("0 cname = " + event[0]);
|
|
|
|
// log ("1 calendar = " + event[1]);
|
|
|
|
// log ("2 status = " + event[2]);
|
|
|
|
// log ("3 title = " + event[3]);
|
|
|
|
// log ("4 start = " + event[4]);
|
|
|
|
// log ("5 end = " + event[5]);
|
|
|
|
// log ("6 location = " + event[6]);
|
|
|
|
// log ("7 isallday = " + event[7]);
|
|
|
|
// log ("8 classification = " + event[8]);
|
|
|
|
// log ("9 participants emails = " + event[9]);
|
|
|
|
// log ("10 participants states = " + event[10]);
|
|
|
|
// log ("11 owner = " + event[11]);
|
|
|
|
// log ("12 iscycle = " + event[12]);
|
|
|
|
// log ("13 nextalarm = " + event[13]);
|
|
|
|
// log ("14 recurrenceid = " + event[14]);
|
2009-06-15 23:19:36 +02:00
|
|
|
// log ("15 isexception = " + event[15]);
|
2009-06-02 21:45:07 +02:00
|
|
|
|
2008-07-16 23:48:54 +02:00
|
|
|
var eventDiv = $(document.createElement("div"));
|
2008-07-16 04:12:18 +02:00
|
|
|
eventDiv.cname = event[0];
|
|
|
|
eventDiv.calendar = event[1];
|
2008-07-17 23:12:43 +02:00
|
|
|
if (eventRep.recurrenceTime)
|
|
|
|
eventDiv.recurrenceTime = eventRep.recurrenceTime;
|
2009-06-15 23:19:36 +02:00
|
|
|
eventDiv.isException = event[15];
|
2008-07-16 23:48:54 +02:00
|
|
|
eventDiv.addClassName("event");
|
2009-04-24 21:19:43 +02:00
|
|
|
if (event[13] > 0)
|
|
|
|
eventDiv.addClassName("alarm");
|
2008-07-16 23:48:54 +02:00
|
|
|
|
|
|
|
var innerDiv = $(document.createElement("div"));
|
2008-07-16 04:12:18 +02:00
|
|
|
eventDiv.appendChild(innerDiv);
|
2008-07-16 23:48:54 +02:00
|
|
|
innerDiv.addClassName("eventInside");
|
|
|
|
innerDiv.addClassName("calendarFolder" + event[1]);
|
2009-04-24 21:19:43 +02:00
|
|
|
if (eventRep.userState >= 0 && userStates[eventRep.userState])
|
|
|
|
innerDiv.addClassName(userStates[eventRep.userState]);
|
2007-06-11 23:23:48 +02:00
|
|
|
|
2008-07-16 23:48:54 +02:00
|
|
|
var gradientDiv = $(document.createElement("div"));
|
2008-07-16 04:12:18 +02:00
|
|
|
innerDiv.appendChild(gradientDiv);
|
2008-07-16 23:48:54 +02:00
|
|
|
gradientDiv.addClassName("gradient");
|
2009-04-24 21:19:43 +02:00
|
|
|
|
2008-07-17 23:12:43 +02:00
|
|
|
var gradientImg = $(document.createElement("img"));
|
2008-07-16 04:12:18 +02:00
|
|
|
gradientDiv.appendChild(gradientImg);
|
|
|
|
gradientImg.src = ResourcesURL + "/event-gradient.png";
|
2007-09-15 01:37:19 +02:00
|
|
|
|
2008-07-16 23:48:54 +02:00
|
|
|
var textDiv = $(document.createElement("div"));
|
2008-07-16 04:12:18 +02:00
|
|
|
innerDiv.appendChild(textDiv);
|
2008-07-16 23:48:54 +02:00
|
|
|
textDiv.addClassName("text");
|
2008-07-17 23:12:43 +02:00
|
|
|
textDiv.appendChild(document.createTextNode(eventText));
|
2007-06-11 23:23:48 +02:00
|
|
|
|
2009-05-22 19:09:54 +02:00
|
|
|
if (event[2] != null) {
|
|
|
|
// Status field is defined -- user can read event
|
2009-02-06 02:16:17 +01:00
|
|
|
eventDiv.observe("mousedown", listRowMouseDownHandler);
|
|
|
|
eventDiv.observe("click", onCalendarSelectEvent);
|
|
|
|
eventDiv.observe("dblclick", editDoubleClickedEvent);
|
|
|
|
eventDiv.observe("click", onViewEvent);
|
|
|
|
}
|
2008-07-29 18:35:49 +02:00
|
|
|
event.blocks.push(eventDiv);
|
2007-06-13 04:47:23 +02:00
|
|
|
|
2008-07-16 04:12:18 +02:00
|
|
|
return eventDiv;
|
|
|
|
}
|
2008-07-17 23:12:43 +02:00
|
|
|
|
2008-07-29 18:35:49 +02:00
|
|
|
function _drawCalendarAllDayEvents(events, eventsData) {
|
|
|
|
var daysView = $("calendarHeader");
|
|
|
|
var subdivs = daysView.childNodesWithTag("div");
|
|
|
|
var days = subdivs[1].childNodesWithTag("div");
|
2008-10-29 17:45:45 +01:00
|
|
|
for (var i = 0; i < days.length; i++) {
|
2008-07-29 18:35:49 +02:00
|
|
|
var parentDiv = days[i];
|
|
|
|
for (var j = 0; j < events[i].length; j++) {
|
|
|
|
var eventRep = events[i][j];
|
|
|
|
var nbr = eventRep.nbr;
|
|
|
|
var eventDiv = newAllDayEventDIV(eventRep, eventsData[nbr]);
|
|
|
|
parentDiv.appendChild(eventDiv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function newAllDayEventDIV(eventRep, event) {
|
2008-08-28 16:48:45 +02:00
|
|
|
// cname, calendar, starts, lasts,
|
|
|
|
// startHour, endHour, title) {
|
2008-07-17 23:12:43 +02:00
|
|
|
var eventDiv = newBaseEventDIV(eventRep, event, event[3]);
|
|
|
|
|
|
|
|
return eventDiv;
|
|
|
|
}
|
2008-07-16 04:12:18 +02:00
|
|
|
|
2008-07-29 18:35:49 +02:00
|
|
|
function _drawCalendarEvents(events, eventsData) {
|
2008-07-16 04:12:18 +02:00
|
|
|
var daysView = $("daysView");
|
|
|
|
var subdivs = daysView.childNodesWithTag("div");
|
|
|
|
var days = subdivs[1].childNodesWithTag("div");
|
2008-10-29 17:51:30 +01:00
|
|
|
for (var i = 0; i < days.length; i++) {
|
2008-07-16 04:12:18 +02:00
|
|
|
var parentDiv = days[i].childNodesWithTag("div")[0];
|
|
|
|
for (var j = 0; j < events[i].length; j++) {
|
|
|
|
var eventRep = events[i][j];
|
2008-07-29 18:35:49 +02:00
|
|
|
var nbr = eventRep.nbr;
|
|
|
|
var eventDiv = newEventDIV(eventRep, eventsData[nbr]);
|
2008-07-16 04:12:18 +02:00
|
|
|
parentDiv.appendChild(eventDiv);
|
2008-04-15 22:12:51 +02:00
|
|
|
}
|
2008-07-16 04:12:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-29 18:35:49 +02:00
|
|
|
function newEventDIV(eventRep, event) {
|
2008-07-17 23:12:43 +02:00
|
|
|
var eventDiv = newBaseEventDIV(eventRep, event, event[3]);
|
2008-07-16 04:12:18 +02:00
|
|
|
|
|
|
|
var pc = 100 / eventRep.siblings;
|
|
|
|
eventDiv.style.width = pc + "%";
|
|
|
|
var left = eventRep.position * pc;
|
|
|
|
eventDiv.style.left = left + "%";
|
2008-07-17 23:12:43 +02:00
|
|
|
eventDiv.addClassName("starts" + eventRep.start);
|
|
|
|
eventDiv.addClassName("lasts" + eventRep.length);
|
2008-03-27 22:05:47 +01:00
|
|
|
|
2008-07-16 04:12:18 +02:00
|
|
|
return eventDiv;
|
2007-11-16 20:38:49 +01:00
|
|
|
}
|
2007-11-07 18:37:58 +01:00
|
|
|
|
2008-07-29 18:35:49 +02:00
|
|
|
function _drawMonthCalendarEvents(events, eventsData) {
|
2008-07-16 04:12:18 +02:00
|
|
|
var daysView = $("monthDaysView");
|
|
|
|
var days = daysView.childNodesWithTag("div");
|
|
|
|
for (var i = 0; i < days.length; i++) {
|
|
|
|
var parentDiv = days[i];
|
|
|
|
for (var j = 0; j < events[i].length; j++) {
|
|
|
|
var eventRep = events[i][j];
|
2008-07-29 18:35:49 +02:00
|
|
|
var nbr = eventRep.nbr;
|
|
|
|
var eventDiv = newMonthEventDIV(eventRep, eventsData[nbr]);
|
2008-07-16 04:12:18 +02:00
|
|
|
parentDiv.appendChild(eventDiv);
|
|
|
|
}
|
|
|
|
}
|
2007-06-11 23:23:48 +02:00
|
|
|
}
|
|
|
|
|
2008-07-29 18:35:49 +02:00
|
|
|
function newMonthEventDIV(eventRep, event) {
|
2008-07-16 04:12:18 +02:00
|
|
|
var eventText;
|
2009-04-22 23:02:11 +02:00
|
|
|
if (event[7]) // all-day event
|
2008-07-16 04:12:18 +02:00
|
|
|
eventText = event[3];
|
|
|
|
else
|
|
|
|
eventText = eventRep.starthour + " - " + event[3];
|
2008-01-24 22:36:51 +01:00
|
|
|
|
2008-07-29 18:35:49 +02:00
|
|
|
var eventDiv = newBaseEventDIV(eventRep, event,
|
2008-08-28 16:48:45 +02:00
|
|
|
eventText);
|
2008-07-16 04:12:18 +02:00
|
|
|
|
2008-01-24 22:36:51 +01:00
|
|
|
return eventDiv;
|
2007-06-11 23:23:48 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function calendarDisplayCallback(http) {
|
2006-08-24 20:48:33 +02:00
|
|
|
var div = $("calendarView");
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
2007-01-05 17:10:48 +01:00
|
|
|
document.dayDisplayAjaxRequest = null;
|
2007-09-24 23:26:23 +02:00
|
|
|
div.update(http.responseText);
|
2006-08-24 20:48:33 +02:00
|
|
|
if (http.callbackData["view"])
|
|
|
|
currentView = http.callbackData["view"];
|
|
|
|
if (http.callbackData["day"])
|
2006-09-07 00:27:46 +02:00
|
|
|
currentDay = http.callbackData["day"];
|
2007-06-13 21:28:59 +02:00
|
|
|
|
2006-11-15 22:54:47 +01:00
|
|
|
var contentView;
|
|
|
|
if (currentView == "monthview")
|
|
|
|
contentView = $("calendarContent");
|
2008-08-19 00:45:59 +02:00
|
|
|
else {
|
2006-11-15 22:54:47 +01:00
|
|
|
contentView = $("daysView");
|
2008-08-19 00:45:59 +02:00
|
|
|
contentView.observe("scroll", onBodyClickHandler);
|
|
|
|
}
|
|
|
|
|
2007-11-16 20:38:49 +01:00
|
|
|
refreshCalendarEvents(http.callbackData.scrollEvent);
|
|
|
|
|
2009-03-12 22:09:14 +01:00
|
|
|
var days = contentView.select("DIV.day");
|
|
|
|
|
2006-11-15 22:54:47 +01:00
|
|
|
if (currentView == "monthview")
|
|
|
|
for (var i = 0; i < days.length; i++) {
|
2008-04-15 22:47:18 +02:00
|
|
|
days[i].observe("click", onCalendarSelectDay);
|
|
|
|
days[i].observe("dblclick", onClickableCellsDblClick);
|
2008-08-28 16:48:45 +02:00
|
|
|
days[i].observe("selectstart", listRowMouseDownHandler);
|
|
|
|
//days[i].down(".dayHeader").observe("selectstart", listRowMouseDownHandler);
|
|
|
|
if (currentView == "monthview")
|
|
|
|
days[i].observe("scroll", onBodyClickHandler);
|
2006-11-15 18:59:47 +01:00
|
|
|
}
|
2007-06-11 23:23:48 +02:00
|
|
|
else {
|
2009-03-12 22:09:14 +01:00
|
|
|
var calendarHeader = $("calendarHeader");
|
|
|
|
var headerDaysLabels = calendarHeader.select("DIV.dayLabels DIV.day");
|
|
|
|
var headerDays = calendarHeader.select("DIV.days DIV.day");
|
|
|
|
for (var i = 0; i < days.length; i++) {
|
2008-08-28 16:48:45 +02:00
|
|
|
headerDays[i].hour = "allday";
|
|
|
|
headerDaysLabels[i].observe("mousedown", listRowMouseDownHandler);
|
|
|
|
headerDays[i].observe("click", onCalendarSelectDay);
|
|
|
|
headerDays[i].observe("dblclick", onClickableCellsDblClick);
|
|
|
|
days[i].observe("click", onCalendarSelectDay);
|
2009-03-12 22:09:14 +01:00
|
|
|
|
|
|
|
var clickableCells = days[i].select("DIV.clickableHourCell");
|
2008-08-28 16:48:45 +02:00
|
|
|
for (var j = 0; j < clickableCells.length; j++)
|
2009-03-12 22:09:14 +01:00
|
|
|
clickableCells[j].observe("dblclick", onClickableCellsDblClick);
|
2008-01-24 22:36:51 +01:00
|
|
|
}
|
2007-06-11 23:23:48 +02:00
|
|
|
}
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
else
|
2008-04-15 22:47:18 +02:00
|
|
|
log ("calendarDisplayCallback Ajax error ("
|
2008-08-28 16:48:45 +02:00
|
|
|
+ http.readyState + "/" + http.status + ")");
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2007-03-18 16:00:34 +01:00
|
|
|
function assignCalendar(name) {
|
2007-10-19 16:36:33 +02:00
|
|
|
if (typeof(skycalendar) != "undefined") {
|
|
|
|
var node = $(name);
|
2008-03-27 22:05:47 +01:00
|
|
|
|
2007-10-19 16:36:33 +02:00
|
|
|
node.calendar = new skycalendar(node);
|
|
|
|
node.calendar.setCalendarPage(ResourcesURL + "/skycalendar.html");
|
|
|
|
var dateFormat = node.getAttribute("dateFormat");
|
|
|
|
if (dateFormat)
|
|
|
|
node.calendar.setDateFormat(dateFormat);
|
|
|
|
}
|
2006-08-31 01:13:18 +02:00
|
|
|
}
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2007-03-18 16:00:34 +01:00
|
|
|
function popupCalendar(node) {
|
2008-04-15 22:12:51 +02:00
|
|
|
var nodeId = $(node).readAttribute("inputId");
|
|
|
|
var input = $(nodeId);
|
|
|
|
input.calendar.popup();
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2008-04-15 22:12:51 +02:00
|
|
|
return false;
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2007-06-08 01:23:07 +02:00
|
|
|
function onEventsSelectionChange() {
|
2006-11-13 23:31:41 +01:00
|
|
|
listOfSelection = this;
|
|
|
|
this.removeClassName("_unfocused");
|
2006-10-12 23:05:32 +02:00
|
|
|
$("tasksList").addClassName("_unfocused");
|
2007-12-05 18:07:40 +01:00
|
|
|
|
2009-02-19 23:16:30 +01:00
|
|
|
var rows = $(this.tBodies[0]).getSelectedNodes();
|
2007-12-05 18:07:40 +01:00
|
|
|
if (rows.length == 1) {
|
|
|
|
var row = rows[0];
|
|
|
|
changeCalendarDisplay( { "day": row.day,
|
2008-08-28 16:48:45 +02:00
|
|
|
"scrollEvent": row.getAttribute("id") } );
|
2007-12-05 18:07:40 +01:00
|
|
|
changeDateSelectorDisplay(row.day);
|
|
|
|
}
|
2006-10-12 23:05:32 +02:00
|
|
|
}
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
function onTasksSelectionChange() {
|
2006-11-13 23:31:41 +01:00
|
|
|
listOfSelection = this;
|
|
|
|
this.removeClassName("_unfocused");
|
2007-06-08 01:23:07 +02:00
|
|
|
$("eventsList").addClassName("_unfocused");
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2007-06-08 01:23:07 +02:00
|
|
|
function _loadEventHref(href) {
|
|
|
|
if (document.eventsListAjaxRequest) {
|
|
|
|
document.eventsListAjaxRequest.aborted = true;
|
|
|
|
document.eventsListAjaxRequest.abort();
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
2009-04-22 23:02:11 +02:00
|
|
|
var url = ApplicationBaseURL + href;
|
2007-06-08 01:23:07 +02:00
|
|
|
document.eventsListAjaxRequest
|
|
|
|
= triggerAjaxRequest(url, eventsListCallback, href);
|
|
|
|
|
|
|
|
var table = $("eventsList").tBodies[0];
|
2007-10-02 17:29:16 +02:00
|
|
|
while (table.rows.length > 0)
|
2008-01-24 22:36:51 +01:00
|
|
|
table.removeChild(table.rows[0]);
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-10-11 20:12:02 +02:00
|
|
|
function _loadTasksHref(href) {
|
|
|
|
if (document.tasksListAjaxRequest) {
|
|
|
|
document.tasksListAjaxRequest.aborted = true;
|
|
|
|
document.tasksListAjaxRequest.abort();
|
|
|
|
}
|
2007-11-19 20:17:44 +01:00
|
|
|
url = ApplicationBaseURL + href;
|
2006-10-11 20:12:02 +02:00
|
|
|
|
2007-06-08 01:23:07 +02:00
|
|
|
var tasksList = $("tasksList");
|
|
|
|
var selectedIds;
|
|
|
|
if (tasksList)
|
2008-01-24 22:36:51 +01:00
|
|
|
selectedIds = tasksList.getSelectedNodesId();
|
2007-06-08 01:23:07 +02:00
|
|
|
else
|
2008-01-24 22:36:51 +01:00
|
|
|
selectedIds = null;
|
2006-10-11 20:12:02 +02:00
|
|
|
document.tasksListAjaxRequest
|
|
|
|
= triggerAjaxRequest(url, tasksListCallback, selectedIds);
|
|
|
|
|
2007-06-08 01:23:07 +02:00
|
|
|
tasksList.previousScroll = tasksList.scrollTop;
|
|
|
|
while (tasksList.childNodes.length)
|
2008-01-24 22:36:51 +01:00
|
|
|
tasksList.removeChild(tasksList.childNodes[0]);
|
2007-06-08 01:23:07 +02:00
|
|
|
|
2007-06-06 23:09:39 +02:00
|
|
|
return true;
|
2006-10-11 20:12:02 +02:00
|
|
|
}
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
function onHeaderClick(event) {
|
2008-01-24 22:36:51 +01:00
|
|
|
var headerId = this.getAttribute("id");
|
2007-12-06 18:29:32 +01:00
|
|
|
var newSortAttribute;
|
|
|
|
if (headerId == "titleHeader")
|
|
|
|
newSortAttribute = "title";
|
|
|
|
else if (headerId == "startHeader")
|
|
|
|
newSortAttribute = "start";
|
|
|
|
else if (headerId == "endHeader")
|
|
|
|
newSortAttribute = "end";
|
|
|
|
else if (headerId == "locationHeader")
|
|
|
|
newSortAttribute = "location";
|
|
|
|
else
|
|
|
|
newSortAttribute = "start";
|
|
|
|
|
2008-01-24 22:36:51 +01:00
|
|
|
if (sorting["attribute"] == newSortAttribute)
|
2007-12-06 18:29:32 +01:00
|
|
|
sorting["ascending"] = !sorting["ascending"];
|
|
|
|
else {
|
|
|
|
sorting["attribute"] = newSortAttribute;
|
|
|
|
sorting["ascending"] = true;
|
|
|
|
}
|
2008-01-24 22:36:51 +01:00
|
|
|
refreshEvents();
|
2006-11-09 23:55:04 +01:00
|
|
|
|
2007-12-06 18:29:32 +01:00
|
|
|
Event.stop(event);
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2007-11-21 18:23:51 +01:00
|
|
|
function refreshCurrentFolder() {
|
|
|
|
refreshEvents();
|
|
|
|
}
|
|
|
|
|
2007-06-08 01:23:07 +02:00
|
|
|
function refreshEvents() {
|
2007-11-21 18:23:51 +01:00
|
|
|
var titleSearch;
|
|
|
|
var value = search["value"];
|
|
|
|
if (value && value.length)
|
2008-12-30 20:48:33 +01:00
|
|
|
titleSearch = "&search=" + escape(value.utf8encode());
|
2007-11-21 18:23:51 +01:00
|
|
|
else
|
|
|
|
titleSearch = "";
|
2009-04-22 23:02:11 +02:00
|
|
|
|
|
|
|
refreshAlarms();
|
|
|
|
|
2007-12-06 18:29:32 +01:00
|
|
|
return _loadEventHref("eventslist?asc=" + sorting["ascending"]
|
2008-08-28 16:48:45 +02:00
|
|
|
+ "&sort=" + sorting["attribute"]
|
|
|
|
+ "&day=" + currentDay
|
|
|
|
+ titleSearch
|
|
|
|
+ "&filterpopup=" + listFilter);
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2006-10-11 20:12:02 +02:00
|
|
|
function refreshTasks() {
|
2009-04-22 23:02:11 +02:00
|
|
|
refreshAlarms();
|
2007-04-03 16:24:09 +02:00
|
|
|
return _loadTasksHref("taskslist?show-completed=" + showCompletedTasks);
|
2006-10-11 20:12:02 +02:00
|
|
|
}
|
|
|
|
|
2007-06-08 01:23:07 +02:00
|
|
|
function refreshEventsAndDisplay() {
|
|
|
|
refreshEvents();
|
2006-10-18 23:53:47 +02:00
|
|
|
changeCalendarDisplay();
|
|
|
|
}
|
|
|
|
|
2006-08-22 00:36:33 +02:00
|
|
|
function onListFilterChange() {
|
2006-08-24 20:48:33 +02:00
|
|
|
var node = $("filterpopup");
|
2006-08-22 00:36:33 +02:00
|
|
|
|
|
|
|
listFilter = node.value;
|
2008-01-24 22:36:51 +01:00
|
|
|
// log ("listFilter = " + listFilter);
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2007-06-08 01:23:07 +02:00
|
|
|
return refreshEvents();
|
2006-08-22 00:36:33 +02:00
|
|
|
}
|
2006-08-22 21:18:30 +02:00
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function selectMonthInMenu(menu, month) {
|
2008-12-11 18:25:19 +01:00
|
|
|
var entries = $(menu).select("LI");
|
2008-01-24 22:36:51 +01:00
|
|
|
for (i = 0; i < entries.length; i++) {
|
|
|
|
var entry = entries[i];
|
|
|
|
var entryMonth = entry.getAttribute("month");
|
|
|
|
if (entryMonth == month)
|
|
|
|
entry.addClassName("currentMonth");
|
|
|
|
else
|
|
|
|
entry.removeClassName("currentMonth");
|
|
|
|
}
|
2006-08-22 21:18:30 +02:00
|
|
|
}
|
|
|
|
|
2008-12-11 18:25:19 +01:00
|
|
|
function selectYearInMenu(menu, year) {
|
|
|
|
var entries = $(menu).select("LI");
|
2006-08-22 21:18:30 +02:00
|
|
|
for (i = 0; i < entries.length; i++) {
|
|
|
|
var entry = entries[i];
|
2008-12-11 18:25:19 +01:00
|
|
|
var entryYear = entry.innerHTML.strip();
|
|
|
|
if (entryYear == year)
|
|
|
|
entry.addClassName("currentMonth");
|
|
|
|
else
|
|
|
|
entry.removeClassName("currentMonth");
|
2006-08-22 21:18:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-05 21:13:59 +02:00
|
|
|
function popupMonthMenu(event) {
|
2006-08-22 21:18:30 +02:00
|
|
|
if (event.button == 0) {
|
2007-07-05 21:13:59 +02:00
|
|
|
var id = this.getAttribute("id");
|
|
|
|
if (id == "monthLabel")
|
2008-01-24 22:36:51 +01:00
|
|
|
menuId = "monthListMenu";
|
2007-07-05 21:13:59 +02:00
|
|
|
else
|
2008-01-24 22:36:51 +01:00
|
|
|
menuId = "yearListMenu";
|
2006-08-22 21:18:30 +02:00
|
|
|
|
2006-08-24 20:48:33 +02:00
|
|
|
var popup = $(menuId);
|
2006-08-22 21:18:30 +02:00
|
|
|
if (id == "monthLabel")
|
2007-07-05 21:13:59 +02:00
|
|
|
selectMonthInMenu(popup, this.getAttribute("month"));
|
2006-08-22 21:18:30 +02:00
|
|
|
else
|
2007-07-05 21:13:59 +02:00
|
|
|
selectYearInMenu(popup, this.innerHTML);
|
2006-08-22 21:18:30 +02:00
|
|
|
|
2007-07-05 21:13:59 +02:00
|
|
|
popupToolbarMenu(this, menuId);
|
|
|
|
Event.stop(event);
|
2006-08-22 21:18:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-22 16:38:54 +02:00
|
|
|
function onMonthMenuItemClick(event) {
|
|
|
|
var month = '' + this.getAttribute("month");
|
2008-12-11 18:25:19 +01:00
|
|
|
var year = '' + $("yearLabel").innerHTML.strip();
|
2006-08-22 21:18:30 +02:00
|
|
|
|
2007-05-22 16:38:54 +02:00
|
|
|
changeDateSelectorDisplay(year + month + "01", true);
|
2006-08-22 21:18:30 +02:00
|
|
|
}
|
|
|
|
|
2007-05-22 16:38:54 +02:00
|
|
|
function onYearMenuItemClick(event) {
|
2006-08-24 20:48:33 +02:00
|
|
|
var month = '' + $("monthLabel").getAttribute("month");;
|
2008-12-11 18:25:19 +01:00
|
|
|
var year = '' + this.innerHTML.strip();
|
2006-08-22 21:18:30 +02:00
|
|
|
|
2007-05-22 16:38:54 +02:00
|
|
|
changeDateSelectorDisplay(year + month + "01", true);
|
2006-08-22 21:18:30 +02:00
|
|
|
}
|
2006-08-31 01:13:18 +02:00
|
|
|
|
2008-07-29 18:35:49 +02:00
|
|
|
function _eventBlocksMatching(calendar, cname, recurrenceTime) {
|
|
|
|
var blocks = null;
|
|
|
|
|
|
|
|
var events = calendarEvents[calendar];
|
|
|
|
if (events) {
|
|
|
|
var occurences = events[cname];
|
|
|
|
if (occurences) {
|
|
|
|
if (recurrenceTime) {
|
2008-08-28 16:48:45 +02:00
|
|
|
for (var i = 0; i < occurences.length; i++) {
|
|
|
|
var occurence = occurences[i];
|
2009-04-24 21:19:43 +02:00
|
|
|
if (occurence[14] == recurrenceTime)
|
2008-08-28 16:48:45 +02:00
|
|
|
blocks = occurence.blocks;
|
|
|
|
}
|
2008-07-29 18:35:49 +02:00
|
|
|
}
|
|
|
|
else {
|
2008-08-28 16:48:45 +02:00
|
|
|
blocks = [];
|
|
|
|
for (var i = 0; i < occurences.length; i++) {
|
|
|
|
var occurence = occurences[i];
|
|
|
|
blocks = blocks.concat(occurence.blocks);
|
|
|
|
}
|
2008-07-29 18:35:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return blocks;
|
|
|
|
}
|
|
|
|
|
|
|
|
function selectCalendarEvent(calendar, cname, recurrenceTime) {
|
2007-11-19 18:09:14 +01:00
|
|
|
// Select event in calendar view
|
2007-01-30 14:50:52 +01:00
|
|
|
if (selectedCalendarCell)
|
2008-01-24 22:36:51 +01:00
|
|
|
for (var i = 0; i < selectedCalendarCell.length; i++)
|
|
|
|
selectedCalendarCell[i].deselect();
|
2007-06-12 23:19:18 +02:00
|
|
|
|
2008-07-29 18:35:49 +02:00
|
|
|
var selection = _eventBlocksMatching(calendar, cname, recurrenceTime);
|
|
|
|
if (selection) {
|
|
|
|
for (var i = 0; i < selection.length; i++)
|
|
|
|
selection[i].selectElement();
|
|
|
|
selectedCalendarCell = selection;
|
2008-07-16 04:12:18 +02:00
|
|
|
}
|
2008-08-19 00:45:59 +02:00
|
|
|
|
|
|
|
return selection;
|
2007-11-19 18:09:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function onCalendarSelectEvent() {
|
2008-07-29 18:35:49 +02:00
|
|
|
selectCalendarEvent(this.calendar, this.cname, this.recurrenceTime);
|
2007-11-19 18:09:14 +01:00
|
|
|
|
|
|
|
// Select event in events list
|
2008-07-29 18:35:49 +02:00
|
|
|
var list = $("eventsList");
|
2007-11-19 18:09:14 +01:00
|
|
|
$(list.tBodies[0]).deselectAll();
|
2008-07-29 18:35:49 +02:00
|
|
|
var rowID = this.calendar + "-" + this.cname;
|
|
|
|
if (this.recurrenceTime)
|
|
|
|
rowID += "-" + this.recurrenceTime;
|
|
|
|
var row = $(rowID);
|
2006-11-03 00:17:55 +01:00
|
|
|
if (row) {
|
|
|
|
var div = row.parentNode.parentNode.parentNode;
|
|
|
|
div.scrollTop = row.offsetTop - (div.offsetHeight / 2);
|
2008-02-05 21:00:52 +01:00
|
|
|
row.selectElement();
|
2006-11-03 00:17:55 +01:00
|
|
|
}
|
2006-09-07 00:27:46 +02:00
|
|
|
}
|
|
|
|
|
2006-12-19 20:17:35 +01:00
|
|
|
function onCalendarSelectDay(event) {
|
2008-07-16 04:12:18 +02:00
|
|
|
var day = this.getAttribute("day");
|
2006-11-15 22:54:47 +01:00
|
|
|
var needRefresh = (listFilter == 'view_selectedday'
|
|
|
|
&& day != currentDay);
|
2006-09-07 00:27:46 +02:00
|
|
|
|
2006-11-03 00:17:55 +01:00
|
|
|
if (currentView == 'weekview')
|
2006-11-15 01:10:53 +01:00
|
|
|
changeWeekCalendarDisplayOfSelectedDay(this);
|
2006-11-03 00:17:55 +01:00
|
|
|
else if (currentView == 'monthview')
|
2006-11-15 01:10:53 +01:00
|
|
|
changeMonthCalendarDisplayOfSelectedDay(this);
|
2006-09-07 00:27:46 +02:00
|
|
|
changeDateSelectorDisplay(day);
|
|
|
|
|
2007-01-30 19:18:30 +01:00
|
|
|
if (listOfSelection) {
|
|
|
|
listOfSelection.addClassName("_unfocused");
|
|
|
|
listOfSelection = null;
|
|
|
|
}
|
|
|
|
|
2006-11-15 22:54:47 +01:00
|
|
|
if (needRefresh)
|
2007-06-08 01:23:07 +02:00
|
|
|
refreshEvents();
|
2006-09-07 00:27:46 +02:00
|
|
|
}
|
2006-10-11 20:12:02 +02:00
|
|
|
|
2006-12-19 20:17:35 +01:00
|
|
|
function changeWeekCalendarDisplayOfSelectedDay(node) {
|
2008-07-16 04:12:18 +02:00
|
|
|
var daysView = $("daysView");
|
|
|
|
var daysDiv = daysView.childNodesWithTag("div");
|
|
|
|
var days = daysDiv[1].childNodesWithTag("div");
|
2008-07-16 23:48:54 +02:00
|
|
|
var headerDiv = $($("calendarHeader").childNodesWithTag("div")[1]);
|
|
|
|
var headerDays = headerDiv.childNodesWithTag("div");
|
2006-10-31 23:59:57 +01:00
|
|
|
|
2008-07-16 04:12:18 +02:00
|
|
|
for (var i = 0; i < days.length; i++) {
|
|
|
|
if (days[i] == node
|
2008-08-28 16:48:45 +02:00
|
|
|
|| headerDays[i] == node) {
|
2008-01-24 22:36:51 +01:00
|
|
|
headerDays[i].addClassName("selectedDay");
|
|
|
|
days[i].addClassName("selectedDay");
|
|
|
|
}
|
2008-07-16 04:12:18 +02:00
|
|
|
else {
|
|
|
|
headerDays[i].removeClassName("selectedDay");
|
|
|
|
days[i].removeClassName("selectedDay");
|
|
|
|
}
|
|
|
|
}
|
2006-10-31 23:59:57 +01:00
|
|
|
}
|
|
|
|
|
2007-03-13 00:06:48 +01:00
|
|
|
function findMonthCalendarSelectedCell(daysContainer) {
|
2008-01-24 22:36:51 +01:00
|
|
|
var found = false;
|
|
|
|
var i = 0;
|
|
|
|
|
|
|
|
while (!found && i < daysContainer.childNodes.length) {
|
|
|
|
var currentNode = daysContainer.childNodes[i];
|
|
|
|
if (currentNode.tagName == 'DIV'
|
2008-08-28 16:48:45 +02:00
|
|
|
&& currentNode.hasClassName("selectedDay")) {
|
2008-01-24 22:36:51 +01:00
|
|
|
daysContainer.selectedCell = currentNode;
|
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
i++;
|
|
|
|
}
|
2006-11-03 00:17:55 +01:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function changeMonthCalendarDisplayOfSelectedDay(node) {
|
2008-01-24 22:36:51 +01:00
|
|
|
var daysContainer = node.parentNode;
|
|
|
|
if (!daysContainer.selectedCell)
|
|
|
|
findMonthCalendarSelectedCell(daysContainer);
|
2007-03-13 00:06:48 +01:00
|
|
|
|
2008-01-24 22:36:51 +01:00
|
|
|
if (daysContainer.selectedCell)
|
|
|
|
daysContainer.selectedCell.removeClassName("selectedDay");
|
|
|
|
daysContainer.selectedCell = node;
|
|
|
|
node.addClassName("selectedDay");
|
2006-11-03 00:17:55 +01:00
|
|
|
}
|
|
|
|
|
2007-06-08 01:23:07 +02:00
|
|
|
function onShowCompletedTasks(event) {
|
2008-01-24 22:36:51 +01:00
|
|
|
showCompletedTasks = (this.checked ? 1 : 0);
|
2006-10-11 20:12:02 +02:00
|
|
|
|
2008-01-24 22:36:51 +01:00
|
|
|
return refreshTasks();
|
2006-10-11 20:12:02 +02:00
|
|
|
}
|
|
|
|
|
2007-06-06 23:09:39 +02:00
|
|
|
function updateTaskStatus(event) {
|
|
|
|
var newStatus = (this.checked ? 1 : 0);
|
2006-10-11 20:12:02 +02:00
|
|
|
var http = createHTTPClient();
|
2007-10-02 17:29:16 +02:00
|
|
|
|
|
|
|
if (isSafari() && !isSafari3()) {
|
2007-08-07 20:14:39 +02:00
|
|
|
newStatus = (newStatus ? 0 : 1);
|
2007-10-02 17:29:16 +02:00
|
|
|
}
|
2008-08-10 21:08:11 +02:00
|
|
|
|
2007-11-19 20:17:44 +01:00
|
|
|
url = (ApplicationBaseURL + this.parentNode.calendar
|
2008-08-28 16:48:45 +02:00
|
|
|
+ "/" + this.parentNode.cname + "/changeStatus?status=" + newStatus);
|
2006-10-11 20:12:02 +02:00
|
|
|
|
|
|
|
if (http) {
|
|
|
|
// TODO: add parameter to signal that we are only interested in OK
|
2007-06-06 23:09:39 +02:00
|
|
|
http.open("POST", url, false /* not async */);
|
2006-10-11 20:12:02 +02:00
|
|
|
http.url = url;
|
|
|
|
http.send("");
|
2008-01-22 17:43:46 +01:00
|
|
|
http.setRequestHeader("Content-Length", 0);
|
2007-11-19 20:17:44 +01:00
|
|
|
if (isHttpStatus204(http.status))
|
2006-10-11 20:12:02 +02:00
|
|
|
refreshTasks();
|
2006-10-17 21:49:47 +02:00
|
|
|
} else
|
|
|
|
log ("no http client?");
|
2006-10-11 20:12:02 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2006-10-14 01:37:27 +02:00
|
|
|
|
2007-03-29 20:05:23 +02:00
|
|
|
function updateCalendarStatus(event) {
|
2008-07-16 04:12:18 +02:00
|
|
|
var list = [];
|
2007-10-02 17:29:16 +02:00
|
|
|
var newStatus = (this.checked ? 1 : 0);
|
|
|
|
|
|
|
|
if (isSafari() && !isSafari3()) {
|
|
|
|
newStatus = (newStatus ? 0 : 1);
|
|
|
|
this.checked = newStatus;
|
|
|
|
}
|
2006-10-14 01:37:27 +02:00
|
|
|
|
2007-03-29 20:05:23 +02:00
|
|
|
var nodes = $("calendarList").childNodesWithTag("li");
|
2006-10-14 01:37:27 +02:00
|
|
|
for (var i = 0; i < nodes.length; i++) {
|
2007-05-28 23:30:37 +02:00
|
|
|
var input = $(nodes[i]).childNodesWithTag("input")[0];
|
2007-03-29 20:05:23 +02:00
|
|
|
if (input.checked) {
|
2008-01-24 22:36:51 +01:00
|
|
|
var folderId = nodes[i].getAttribute("id");
|
|
|
|
var elems = folderId.split(":");
|
|
|
|
if (elems.length > 1)
|
2008-08-28 16:48:45 +02:00
|
|
|
list.push(elems[0]);
|
2008-01-24 22:36:51 +01:00
|
|
|
else
|
2008-08-28 16:48:45 +02:00
|
|
|
list.push(UserLogin);
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
2006-10-14 01:37:27 +02:00
|
|
|
}
|
|
|
|
|
2008-01-24 22:36:51 +01:00
|
|
|
// if (!list.length) {
|
|
|
|
// list.push(UserLogin);
|
|
|
|
// nodes[0].childNodesWithTag("input")[0].checked = true;
|
|
|
|
// }
|
2007-09-15 00:01:02 +02:00
|
|
|
|
2008-01-24 22:36:51 +01:00
|
|
|
// ApplicationBaseURL = (UserFolderURL + "Groups/_custom_"
|
|
|
|
// + list.join(",") + "/Calendar/");
|
2007-03-29 20:05:23 +02:00
|
|
|
|
|
|
|
if (event) {
|
2008-01-24 22:36:51 +01:00
|
|
|
var folderID = this.parentNode.getAttribute("id");
|
|
|
|
var urlstr = URLForFolderID(folderID);
|
|
|
|
if (newStatus)
|
|
|
|
urlstr += "/activateFolder";
|
|
|
|
else
|
|
|
|
urlstr += "/deactivateFolder";
|
|
|
|
//log("updateCalendarStatus: ajax request = " + urlstr + ", folderID = " + folderID);
|
|
|
|
triggerAjaxRequest(urlstr, calendarStatusCallback, folderID);
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
|
|
|
else {
|
2008-01-24 22:36:51 +01:00
|
|
|
updateCalendarsList();
|
|
|
|
refreshEvents();
|
|
|
|
refreshTasks();
|
|
|
|
changeCalendarDisplay();
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
2006-10-14 01:37:27 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-03-29 20:05:23 +02:00
|
|
|
function calendarStatusCallback(http) {
|
2007-06-07 21:21:24 +02:00
|
|
|
if (http.readyState == 4) {
|
2007-06-12 16:58:15 +02:00
|
|
|
if (isHttpStatus204(http.status)) {
|
2007-10-02 17:29:16 +02:00
|
|
|
refreshEvents();
|
|
|
|
refreshTasks();
|
|
|
|
changeCalendarDisplay();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var folder = $(http.callbackData);
|
|
|
|
var input = folder.childNodesWithTag("input")[0];
|
|
|
|
input.checked = (!input.checked);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
log("calendarStatusCallback Ajax error");
|
2006-10-14 01:37:27 +02:00
|
|
|
}
|
|
|
|
|
2007-03-29 20:05:23 +02:00
|
|
|
function calendarEntryCallback(http) {
|
2008-01-24 22:36:51 +01:00
|
|
|
if (http.readyState == 4) {
|
|
|
|
var denied = !isHttpStatus204(http.status);
|
|
|
|
var entry = $(http.callbackData);
|
|
|
|
if (denied)
|
|
|
|
entry.addClassName("denied");
|
|
|
|
else
|
|
|
|
entry.removeClassName("denied");
|
|
|
|
}
|
2006-12-20 17:45:52 +01:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function updateCalendarsList(method) {
|
2007-03-29 20:05:23 +02:00
|
|
|
var list = $("calendarList").childNodesWithTag("li");
|
|
|
|
for (var i = 0; i < list.length; i++) {
|
2008-01-24 22:36:51 +01:00
|
|
|
var folderID = list[i].getAttribute("id");
|
|
|
|
var url = URLForFolderID(folderID) + "/canAccessContent";
|
|
|
|
triggerAjaxRequest(url, calendarEntryCallback, folderID);
|
2006-12-19 18:06:07 +01:00
|
|
|
}
|
2006-10-14 01:37:27 +02:00
|
|
|
}
|
|
|
|
|
2006-10-23 23:37:53 +02:00
|
|
|
function validateBrowseURL(input) {
|
2006-12-14 22:20:13 +01:00
|
|
|
var button = $("browseURLBtn");
|
2006-10-23 23:37:53 +02:00
|
|
|
|
|
|
|
if (input.value.length) {
|
|
|
|
if (!button.enabled)
|
|
|
|
enableAnchor(button);
|
|
|
|
} else if (!button.disabled)
|
|
|
|
disableAnchor(button);
|
|
|
|
}
|
|
|
|
|
2006-12-14 22:20:13 +01:00
|
|
|
function browseURL(anchor, event) {
|
2006-10-23 23:37:53 +02:00
|
|
|
if (event.button == 0) {
|
|
|
|
var input = $("url");
|
|
|
|
var url = input.value;
|
|
|
|
if (url.length)
|
|
|
|
window.open(url, '_blank');
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2006-11-09 23:55:04 +01:00
|
|
|
|
2007-11-19 23:19:17 +01:00
|
|
|
function onCalendarsMenuPrepareVisibility() {
|
|
|
|
var folders = $("calendarList");
|
|
|
|
var selected = folders.getSelectedNodes();
|
|
|
|
if (selected.length > 0) {
|
|
|
|
var folderOwner = selected[0].getAttribute("owner");
|
|
|
|
var sharingOption = $(this).down("ul").childElements().last();
|
|
|
|
// Disable the "Sharing" option when calendar is not owned by user
|
2007-11-19 23:40:13 +01:00
|
|
|
if (folderOwner == UserLogin || IsSuperUser)
|
2007-11-19 23:19:17 +01:00
|
|
|
sharingOption.removeClassName("disabled");
|
|
|
|
else
|
|
|
|
sharingOption.addClassName("disabled");
|
2009-06-02 21:45:07 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2007-11-19 23:19:17 +01:00
|
|
|
}
|
|
|
|
|
2007-05-28 21:19:17 +02:00
|
|
|
function getMenus() {
|
2008-01-24 22:36:51 +01:00
|
|
|
var menus = {};
|
2007-05-28 21:19:17 +02:00
|
|
|
|
2008-07-16 04:12:18 +02:00
|
|
|
var dateMenu = [];
|
2008-01-24 22:36:51 +01:00
|
|
|
for (var i = 0; i < 12; i++)
|
|
|
|
dateMenu.push(onMonthMenuItemClick);
|
|
|
|
menus["monthListMenu"] = dateMenu;
|
2007-05-22 16:38:54 +02:00
|
|
|
|
2008-07-16 04:12:18 +02:00
|
|
|
dateMenu = [];
|
2008-01-24 22:36:51 +01:00
|
|
|
for (var i = 0; i < 11; i++)
|
|
|
|
dateMenu.push(onYearMenuItemClick);
|
|
|
|
menus["yearListMenu"] = dateMenu;
|
2007-05-22 16:38:54 +02:00
|
|
|
|
2008-01-24 22:36:51 +01:00
|
|
|
menus["eventsListMenu"] = new Array(onMenuNewEventClick, "-",
|
2008-08-28 16:48:45 +02:00
|
|
|
onMenuNewTaskClick,
|
|
|
|
editEvent, deleteEvent, "-",
|
|
|
|
onSelectAll, "-",
|
|
|
|
null, null);
|
2008-04-15 21:48:48 +02:00
|
|
|
menus["calendarsMenu"] = new Array(onCalendarModify,
|
2008-08-28 16:48:45 +02:00
|
|
|
"-",
|
|
|
|
onCalendarNew, onCalendarRemove,
|
|
|
|
"-", null, null, "-",
|
|
|
|
null, "-", onMenuSharing);
|
2008-01-24 22:36:51 +01:00
|
|
|
menus["searchMenu"] = new Array(setSearchCriteria);
|
2007-05-22 16:38:54 +02:00
|
|
|
|
2008-01-24 22:36:51 +01:00
|
|
|
var calendarsMenu = $("calendarsMenu");
|
|
|
|
if (calendarsMenu)
|
|
|
|
calendarsMenu.prepareVisibility = onCalendarsMenuPrepareVisibility;
|
2007-11-19 23:19:17 +01:00
|
|
|
|
2008-01-24 22:36:51 +01:00
|
|
|
return menus;
|
2006-12-14 22:20:13 +01:00
|
|
|
}
|
|
|
|
|
2007-05-19 03:12:23 +02:00
|
|
|
function onMenuSharing(event) {
|
2007-11-19 23:19:17 +01:00
|
|
|
if ($(this).hasClassName("disabled"))
|
|
|
|
return;
|
|
|
|
|
2007-03-29 20:05:23 +02:00
|
|
|
var folders = $("calendarList");
|
2006-12-14 22:20:13 +01:00
|
|
|
var selected = folders.getSelectedNodes()[0];
|
2007-11-19 23:19:17 +01:00
|
|
|
/* FIXME: activation of the context menu should preferably select the entry
|
2008-01-24 22:36:51 +01:00
|
|
|
above which the event has occured */
|
2007-05-22 16:38:54 +02:00
|
|
|
if (selected) {
|
2008-01-24 22:36:51 +01:00
|
|
|
var folderID = selected.getAttribute("id");
|
|
|
|
var urlstr = URLForFolderID(folderID) + "/acls";
|
2006-12-14 22:20:13 +01:00
|
|
|
|
2008-01-24 22:36:51 +01:00
|
|
|
openAclWindow(urlstr);
|
2007-05-22 16:38:54 +02:00
|
|
|
}
|
2006-12-14 22:20:13 +01:00
|
|
|
}
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
function configureDragHandles() {
|
|
|
|
var handle = $("verticalDragHandle");
|
|
|
|
if (handle) {
|
|
|
|
handle.addInterface(SOGoDragHandlesInterface);
|
2009-03-12 22:09:14 +01:00
|
|
|
handle.leftBlock = $("leftPanel");
|
|
|
|
handle.rightBlock = $("rightPanel");
|
2006-11-09 23:55:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
handle = $("rightDragHandle");
|
|
|
|
if (handle) {
|
|
|
|
handle.addInterface(SOGoDragHandlesInterface);
|
2009-03-12 22:09:14 +01:00
|
|
|
handle.upperBlock = $("eventsListView");
|
|
|
|
handle.lowerBlock = $("calendarView");
|
2006-11-09 23:55:04 +01:00
|
|
|
}
|
|
|
|
}
|
2006-12-14 22:20:13 +01:00
|
|
|
|
2007-03-29 20:05:23 +02:00
|
|
|
function initCalendarSelector() {
|
|
|
|
var selector = $("calendarSelector");
|
2006-12-14 22:20:13 +01:00
|
|
|
updateCalendarStatus();
|
|
|
|
selector.changeNotification = updateCalendarsList;
|
2006-12-19 18:06:07 +01:00
|
|
|
|
2007-10-02 17:29:16 +02:00
|
|
|
var list = $("calendarList");
|
|
|
|
list.multiselect = true;
|
|
|
|
var items = list.childNodesWithTag("li");
|
|
|
|
for (var i = 0; i < items.length; i++) {
|
|
|
|
var input = items[i].childNodesWithTag("input")[0];
|
2008-04-28 20:37:22 +02:00
|
|
|
$(input).observe("click", updateCalendarStatus);
|
2008-04-15 22:12:51 +02:00
|
|
|
items[i].observe("mousedown", listRowMouseDownHandler);
|
|
|
|
items[i].observe("selectstart", listRowMouseDownHandler);
|
|
|
|
items[i].observe("click", onRowClick);
|
2008-04-15 21:48:48 +02:00
|
|
|
items[i].observe("dblclick", onCalendarModify);
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var links = $("calendarSelectorButtons").childNodesWithTag("a");
|
2008-07-29 18:35:49 +02:00
|
|
|
$(links[0]).observe("click", onCalendarNew);
|
|
|
|
$(links[1]).observe("click", onCalendarAdd);
|
|
|
|
$(links[2]).observe("click", onCalendarRemove);
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
|
|
|
|
2008-04-15 21:48:48 +02:00
|
|
|
function onCalendarModify(event) {
|
2007-09-15 04:31:34 +02:00
|
|
|
var folders = $("calendarList");
|
|
|
|
var selected = folders.getSelectedNodes()[0];
|
2008-04-22 01:03:48 +02:00
|
|
|
var calendarID = selected.getAttribute("id");
|
2008-04-22 01:19:32 +02:00
|
|
|
var url = ApplicationBaseURL + calendarID + "/properties";
|
2008-08-09 03:53:09 +02:00
|
|
|
var windowID = sanitizeWindowName(calendarID + " properties");
|
2008-05-06 00:47:38 +02:00
|
|
|
var properties = window.open(url, windowID,
|
2008-08-28 16:48:45 +02:00
|
|
|
"width=300,height=100,resizable=0");
|
2008-04-22 01:03:48 +02:00
|
|
|
properties.focus();
|
2007-09-15 04:31:34 +02:00
|
|
|
}
|
|
|
|
|
2008-04-22 01:03:48 +02:00
|
|
|
function updateCalendarProperties(calendarID, calendarName, calendarColor) {
|
|
|
|
var idParts = calendarID.split(":");
|
2008-05-16 22:59:39 +02:00
|
|
|
var folderName = idParts[1].split("/")[1];
|
|
|
|
var nodeID;
|
2009-01-21 18:01:06 +01:00
|
|
|
|
2008-05-16 22:59:39 +02:00
|
|
|
if (idParts[0] != UserLogin)
|
2009-01-21 18:01:06 +01:00
|
|
|
nodeID = "/" + idParts[0].asCSSIdentifier() + "_" + folderName;
|
|
|
|
else {
|
2008-05-16 22:59:39 +02:00
|
|
|
nodeID = "/" + folderName;
|
2008-08-28 16:48:45 +02:00
|
|
|
// log("nodeID: " + nodeID);
|
2009-01-21 18:01:06 +01:00
|
|
|
var calendarNode = $(nodeID);
|
|
|
|
var childNodes = calendarNode.childNodes;
|
|
|
|
childNodes[childNodes.length-1].nodeValue = calendarName;
|
|
|
|
}
|
2008-04-22 01:03:48 +02:00
|
|
|
|
|
|
|
appendStyleElement(nodeID, calendarColor);
|
2007-09-15 04:31:34 +02:00
|
|
|
}
|
|
|
|
|
2007-09-15 00:01:02 +02:00
|
|
|
function onCalendarNew(event) {
|
2008-08-09 20:40:08 +02:00
|
|
|
createFolder(window.prompt(labels["Name of the Calendar"], ""),
|
2008-08-28 16:48:45 +02:00
|
|
|
appendCalendar);
|
2007-09-15 00:01:02 +02:00
|
|
|
preventDefault(event);
|
|
|
|
}
|
2007-03-29 20:05:23 +02:00
|
|
|
|
2007-09-15 00:01:02 +02:00
|
|
|
function onCalendarAdd(event) {
|
|
|
|
openUserFolderSelector(onFolderSubscribeCB, "calendar");
|
|
|
|
preventDefault(event);
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
|
|
|
|
2008-04-15 21:48:48 +02:00
|
|
|
function setEventsOnCalendar(checkBox, li) {
|
|
|
|
li.observe("mousedown", listRowMouseDownHandler);
|
|
|
|
li.observe("selectstart", listRowMouseDownHandler);
|
|
|
|
li.observe("click", onRowClick);
|
|
|
|
li.observe("dblclick", onCalendarModify);
|
|
|
|
checkBox.observe("click", updateCalendarStatus);
|
|
|
|
}
|
|
|
|
|
2007-10-23 16:39:29 +02:00
|
|
|
function appendCalendar(folderName, folderPath) {
|
|
|
|
var owner;
|
|
|
|
|
|
|
|
if (folderPath) {
|
|
|
|
owner = getSubscribedFolderOwner(folderPath);
|
|
|
|
folderPath = accessToSubscribedFolder(folderPath);
|
|
|
|
}
|
2007-09-15 00:01:02 +02:00
|
|
|
else
|
2007-10-23 16:39:29 +02:00
|
|
|
folderPath = "/" + folderName;
|
|
|
|
|
|
|
|
if (!owner)
|
|
|
|
owner = UserLogin;
|
2007-06-06 23:09:39 +02:00
|
|
|
|
2007-10-23 16:39:29 +02:00
|
|
|
//log ("append name: " + folderName + "; path: " + folderPath + "; owner: " + owner);
|
2007-08-07 20:14:39 +02:00
|
|
|
|
2007-10-23 16:39:29 +02:00
|
|
|
if ($(folderPath))
|
2007-09-15 03:54:23 +02:00
|
|
|
window.alert(clabels["You have already subscribed to that folder!"]);
|
|
|
|
else {
|
|
|
|
var calendarList = $("calendarList");
|
2008-08-09 03:53:09 +02:00
|
|
|
var items = calendarList.select("li");
|
2007-09-15 03:54:23 +02:00
|
|
|
var li = document.createElement("li");
|
2007-10-23 16:39:29 +02:00
|
|
|
|
|
|
|
// Add the calendar to the proper place
|
2007-12-06 21:50:20 +01:00
|
|
|
var i = getListIndexForFolder(items, owner, folderName);
|
|
|
|
if (i != items.length) // User is subscribed to other calendars of the same owner
|
|
|
|
calendarList.insertBefore(li, items[i]);
|
2007-10-24 17:52:08 +02:00
|
|
|
else
|
|
|
|
calendarList.appendChild(li);
|
|
|
|
|
2008-08-09 03:53:09 +02:00
|
|
|
$(li).writeAttribute("id", folderPath);
|
|
|
|
$(li).writeAttribute("owner", owner);
|
2007-09-15 03:54:23 +02:00
|
|
|
|
2008-06-23 22:44:54 +02:00
|
|
|
var checkBox = createElement("input", null, "checkBox", { checked: 1 },
|
2008-08-28 16:48:45 +02:00
|
|
|
{ type: "checkbox" }, li);
|
2009-06-02 21:45:07 +02:00
|
|
|
|
2007-09-15 03:54:23 +02:00
|
|
|
li.appendChild(document.createTextNode(" "));
|
2008-08-09 03:53:09 +02:00
|
|
|
|
2007-09-15 03:54:23 +02:00
|
|
|
var colorBox = document.createElement("div");
|
|
|
|
li.appendChild(colorBox);
|
2008-06-23 22:44:54 +02:00
|
|
|
li.appendChild(document.createTextNode(folderName
|
2008-08-28 16:48:45 +02:00
|
|
|
.replace("<", "<", "g")
|
|
|
|
.replace(">", ">", "g")));
|
2007-09-15 03:54:23 +02:00
|
|
|
colorBox.appendChild(document.createTextNode("OO"));
|
|
|
|
|
|
|
|
$(colorBox).addClassName("colorBox");
|
2007-10-24 17:52:08 +02:00
|
|
|
$(colorBox).addClassName('calendarFolder' + folderPath.substr(1));
|
2007-09-15 03:54:23 +02:00
|
|
|
|
2009-06-02 21:45:07 +02:00
|
|
|
// Check the checkbox (required for IE)
|
|
|
|
$(li).down("input.checkBox").checked = true;
|
|
|
|
|
2007-10-02 17:29:16 +02:00
|
|
|
// Register events (doesn't work with Safari)
|
2009-06-02 21:45:07 +02:00
|
|
|
setEventsOnCalendar($(checkBox), $(li));
|
2007-10-02 17:29:16 +02:00
|
|
|
|
2007-10-23 16:39:29 +02:00
|
|
|
var url = URLForFolderID(folderPath) + "/canAccessContent";
|
|
|
|
triggerAjaxRequest(url, calendarEntryCallback, folderPath);
|
2007-09-15 03:54:23 +02:00
|
|
|
|
2007-10-23 16:39:29 +02:00
|
|
|
// Update CSS for events color
|
2008-04-22 19:16:37 +02:00
|
|
|
appendStyleElement(folderPath, "#AAAAAA");
|
2008-04-22 01:03:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function appendStyleElement(folderPath, color) {
|
2008-04-22 19:16:37 +02:00
|
|
|
if (document.styleSheets) {
|
|
|
|
var fgColor = getContrastingTextColor(color);
|
2007-11-06 23:34:42 +01:00
|
|
|
var styleElement = document.createElement("style");
|
|
|
|
styleElement.type = "text/css";
|
|
|
|
var selectors = [
|
2008-08-28 16:48:45 +02:00
|
|
|
'DIV.calendarFolder' + folderPath.substr(1),
|
|
|
|
'LI.calendarFolder' + folderPath.substr(1),
|
|
|
|
'UL#calendarList DIV.calendarFolder' + folderPath.substr(1)
|
|
|
|
];
|
2007-11-06 23:34:42 +01:00
|
|
|
var rules = [
|
2008-08-28 16:48:45 +02:00
|
|
|
' { background-color: ' + color + ' !important;' + ' color: ' + fgColor + ' !important; }',
|
|
|
|
' { background-color: ' + color + ' !important;' + ' color: ' + fgColor + ' !important; }',
|
|
|
|
' { color: ' + color + ' !important; }'
|
|
|
|
];
|
2007-11-06 23:34:42 +01:00
|
|
|
for (var i = 0; i < rules.length; i++)
|
|
|
|
if (styleElement.styleSheet && styleElement.styleSheet.addRule)
|
2008-08-28 16:48:45 +02:00
|
|
|
styleElement.styleSheet.addRule(selectors[i], rules[i]); // IE
|
2007-11-06 23:34:42 +01:00
|
|
|
else
|
2009-02-06 02:16:17 +01:00
|
|
|
styleElement.appendChild(document.createTextNode(selectors[i] + rules[i])); // Mozilla + Safari
|
2007-11-06 23:34:42 +01:00
|
|
|
document.getElementsByTagName("head")[0].appendChild(styleElement);
|
2007-09-15 00:01:02 +02:00
|
|
|
}
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onFolderSubscribeCB(folderData) {
|
2007-10-02 17:29:16 +02:00
|
|
|
var folder = $(folderData["folder"]);
|
2009-05-22 19:09:54 +02:00
|
|
|
if (!folder) {
|
2009-06-02 21:45:07 +02:00
|
|
|
appendCalendar(folderData["folderName"], folderData["folder"]);
|
2009-05-22 19:09:54 +02:00
|
|
|
refreshEvents();
|
|
|
|
refreshTasks();
|
2009-06-02 21:45:07 +02:00
|
|
|
changeCalendarDisplay();
|
2009-05-22 19:09:54 +02:00
|
|
|
}
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onFolderUnsubscribeCB(folderId) {
|
2007-09-15 00:01:02 +02:00
|
|
|
var node = $(folderId);
|
|
|
|
node.parentNode.removeChild(node);
|
2007-10-23 16:39:29 +02:00
|
|
|
if (removeFolderRequestCount == 0) {
|
|
|
|
refreshEvents();
|
|
|
|
refreshTasks();
|
|
|
|
changeCalendarDisplay();
|
|
|
|
}
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onCalendarRemove(event) {
|
2007-10-23 16:39:29 +02:00
|
|
|
if (removeFolderRequestCount == 0) {
|
|
|
|
var nodes = $("calendarList").getSelectedNodes();
|
|
|
|
for (var i = 0; i < nodes.length; i++) {
|
|
|
|
nodes[i].deselect();
|
2008-05-16 22:33:55 +02:00
|
|
|
var owner = nodes[i].getAttribute("owner");
|
2008-05-21 15:44:14 +02:00
|
|
|
var folderId = nodes[i].getAttribute("id");
|
|
|
|
if (owner == UserLogin) {
|
2009-03-18 15:36:06 +01:00
|
|
|
if (folderId == "/personal") {
|
|
|
|
var label = labels["You cannot remove nor unsubscribe from your"
|
|
|
|
+ " personal calendar."];
|
|
|
|
window.alert(label);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var folderIdElements = folderId.split(":");
|
|
|
|
deletePersonalCalendar(folderIdElements[0]);
|
|
|
|
}
|
2007-10-23 16:39:29 +02:00
|
|
|
}
|
2007-10-24 17:52:08 +02:00
|
|
|
else
|
2008-08-28 16:48:45 +02:00
|
|
|
unsubscribeFromFolder(folderId, owner,
|
|
|
|
onFolderUnsubscribeCB, folderId);
|
2007-10-23 16:39:29 +02:00
|
|
|
}
|
2006-12-19 18:06:07 +01:00
|
|
|
}
|
2007-10-23 16:39:29 +02:00
|
|
|
|
2007-05-28 23:30:37 +02:00
|
|
|
preventDefault(event);
|
2006-12-14 22:20:13 +01:00
|
|
|
}
|
|
|
|
|
2007-10-24 17:52:08 +02:00
|
|
|
function deletePersonalCalendar(folderElement) {
|
|
|
|
var folderId = folderElement.substr(1);
|
2007-09-15 00:01:02 +02:00
|
|
|
var label
|
2007-10-24 17:52:08 +02:00
|
|
|
= labels["Are you sure you want to delete the calendar \"%{0}\"?"].formatted($(folderElement).lastChild.nodeValue.strip());
|
2007-09-15 00:01:02 +02:00
|
|
|
if (window.confirm(label)) {
|
2007-10-23 16:39:29 +02:00
|
|
|
removeFolderRequestCount++;
|
2009-06-01 19:19:44 +02:00
|
|
|
var url = ApplicationBaseURL + "/" + folderId + "/delete";
|
2007-10-23 16:39:29 +02:00
|
|
|
triggerAjaxRequest(url, deletePersonalCalendarCallback, folderId);
|
2007-09-15 00:01:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function deletePersonalCalendarCallback(http) {
|
|
|
|
if (http.readyState == 4) {
|
|
|
|
if (isHttpStatus204(http.status)) {
|
|
|
|
var ul = $("calendarList");
|
|
|
|
var children = ul.childNodesWithTag("li");
|
|
|
|
var i = 0;
|
|
|
|
var done = false;
|
|
|
|
while (!done && i < children.length) {
|
2008-08-28 16:48:45 +02:00
|
|
|
var currentFolderId = children[i].getAttribute("id").substr(1);
|
|
|
|
if (currentFolderId == http.callbackData) {
|
|
|
|
ul.removeChild(children[i]);
|
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
i++;
|
2007-09-15 00:01:02 +02:00
|
|
|
}
|
2007-10-23 16:39:29 +02:00
|
|
|
removeFolderRequestCount--;
|
|
|
|
if (removeFolderRequestCount == 0) {
|
2008-08-28 16:48:45 +02:00
|
|
|
refreshEvents();
|
|
|
|
refreshTasks();
|
|
|
|
changeCalendarDisplay();
|
2007-10-23 16:39:29 +02:00
|
|
|
}
|
2007-09-15 00:01:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
log ("ajax problem 5: " + http.status);
|
|
|
|
}
|
|
|
|
|
2007-06-08 01:23:07 +02:00
|
|
|
function configureLists() {
|
2008-01-24 22:36:51 +01:00
|
|
|
var list = $("tasksList");
|
|
|
|
list.multiselect = true;
|
2008-04-15 22:47:18 +02:00
|
|
|
list.observe("mousedown", onTasksSelectionChange);
|
2008-07-15 21:22:29 +02:00
|
|
|
list.observe("selectstart", listRowMouseDownHandler);
|
2007-06-08 01:23:07 +02:00
|
|
|
|
2008-01-24 22:36:51 +01:00
|
|
|
var input = $("showHideCompletedTasks");
|
2008-04-15 22:47:18 +02:00
|
|
|
input.observe("click", onShowCompletedTasks);
|
2007-06-08 01:23:07 +02:00
|
|
|
|
2008-01-24 22:36:51 +01:00
|
|
|
list = $("eventsList");
|
|
|
|
list.multiselect = true;
|
|
|
|
configureSortableTableHeaders(list);
|
|
|
|
TableKit.Resizable.init(list, {'trueResize' : true, 'keepWidth' : true});
|
2008-04-15 22:47:18 +02:00
|
|
|
list.observe("mousedown", onEventsSelectionChange);
|
2007-06-08 01:23:07 +02:00
|
|
|
}
|
|
|
|
|
2007-07-05 21:13:59 +02:00
|
|
|
function initDateSelectorEvents() {
|
2008-01-24 22:36:51 +01:00
|
|
|
var arrow = $("rightArrow");
|
2008-04-15 22:47:18 +02:00
|
|
|
arrow.observe("click", onDateSelectorGotoMonth);
|
2008-01-24 22:36:51 +01:00
|
|
|
arrow = $("leftArrow");
|
2008-04-15 22:47:18 +02:00
|
|
|
arrow.observe("click", onDateSelectorGotoMonth);
|
2008-07-16 04:12:18 +02:00
|
|
|
|
2008-01-24 22:36:51 +01:00
|
|
|
var menuButton = $("monthLabel");
|
2008-04-15 22:47:18 +02:00
|
|
|
menuButton.observe("click", popupMonthMenu);
|
2008-01-24 22:36:51 +01:00
|
|
|
menuButton = $("yearLabel");
|
2008-04-15 22:47:18 +02:00
|
|
|
menuButton.observe("click", popupMonthMenu);
|
2007-07-05 21:13:59 +02:00
|
|
|
}
|
|
|
|
|
2008-08-19 00:45:59 +02:00
|
|
|
function onBodyClickHandler(event) {
|
|
|
|
$("eventDialog").hide();
|
|
|
|
}
|
|
|
|
|
2008-09-18 20:03:59 +02:00
|
|
|
function onWindowResize(event) {
|
|
|
|
var handle = $("verticalDragHandle");
|
|
|
|
if (handle)
|
|
|
|
handle.adjust();
|
|
|
|
handle = $("rightDragHandle");
|
|
|
|
if (handle)
|
|
|
|
handle.adjust();
|
2009-06-03 23:06:06 +02:00
|
|
|
|
|
|
|
if (Prototype.Browser.IE) {
|
|
|
|
var days = $$("DIV#daysView DIV.days");
|
|
|
|
var labels = $$("DIV#calendarHeader DIV.days");
|
|
|
|
if (days.length && labels.length) {
|
|
|
|
var day = days[0];
|
|
|
|
var label = labels[0];
|
|
|
|
day.setStyle({ width: (label.getWidth()-1) + "px" });
|
|
|
|
}
|
|
|
|
}
|
2008-09-18 20:03:59 +02:00
|
|
|
}
|
|
|
|
|
2006-12-14 22:20:13 +01:00
|
|
|
function initCalendars() {
|
2008-04-15 22:12:51 +02:00
|
|
|
sorting["attribute"] = "start";
|
|
|
|
sorting["ascending"] = true;
|
2007-12-06 18:29:32 +01:00
|
|
|
|
2009-03-12 22:09:14 +01:00
|
|
|
if (!$(document.body).hasClassName("popup")) {
|
2008-04-15 22:12:51 +02:00
|
|
|
initDateSelectorEvents();
|
|
|
|
initCalendarSelector();
|
|
|
|
configureSearchField();
|
|
|
|
configureLists();
|
2009-06-02 21:45:07 +02:00
|
|
|
$("calendarList").attachMenu("calendarsMenu");
|
2008-08-19 00:45:59 +02:00
|
|
|
$(document.body).observe("click", onBodyClickHandler);
|
2008-04-15 22:12:51 +02:00
|
|
|
}
|
2008-09-18 20:03:59 +02:00
|
|
|
|
2009-03-12 22:09:14 +01:00
|
|
|
onWindowResize.defer();
|
2008-09-18 20:03:59 +02:00
|
|
|
Event.observe(window, "resize", onWindowResize);
|
2006-12-14 22:20:13 +01:00
|
|
|
}
|
|
|
|
|
2009-03-12 22:09:14 +01:00
|
|
|
document.observe("dom:loaded", initCalendars);
|