2007-03-29 20:05:23 +02:00
|
|
|
/* JavaScript for SOGoCalendar */
|
|
|
|
|
2006-08-19 00:40:04 +02:00
|
|
|
var sortOrder = '';
|
|
|
|
var sortKey = '';
|
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 = '';
|
2007-06-29 23:53:56 +02:00
|
|
|
var currentView = "weekview";
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2006-09-07 17:50:03 +02:00
|
|
|
var cachedDateSelectors = new Array();
|
|
|
|
|
2006-10-14 01:37:27 +02:00
|
|
|
var contactSelectorAction = 'calendars-contacts';
|
|
|
|
|
2006-10-18 23:53:47 +02:00
|
|
|
var eventsToDelete = new Array();
|
2007-09-15 00:01:02 +02:00
|
|
|
var calendarsOfEventsToDelete = new Array();
|
2006-10-18 23:53:47 +02:00
|
|
|
|
2007-04-28 00:06:58 +02:00
|
|
|
var usersRightsWindowHeight = 250;
|
|
|
|
var usersRightsWindowWidth = 502;
|
|
|
|
|
2006-10-11 20:12:02 +02:00
|
|
|
function newEvent(sender, type) {
|
2007-06-11 23:23:48 +02:00
|
|
|
var day = sender.day;
|
2007-05-22 16:38:54 +02:00
|
|
|
if (!day)
|
|
|
|
day = currentDay;
|
|
|
|
|
2007-06-11 23:23:48 +02:00
|
|
|
var hour = sender.hour;
|
|
|
|
if (!hour)
|
|
|
|
hour = sender.getAttribute("hour");
|
2007-09-15 00:01:02 +02:00
|
|
|
var folderID = getSelectedFolder();
|
|
|
|
var urlstr = ApplicationBaseURL + folderID + "/new" + type;
|
2007-05-22 16:38:54 +02:00
|
|
|
var params = new Array();
|
|
|
|
if (day)
|
|
|
|
params.push("day=" + day);
|
|
|
|
if (hour)
|
|
|
|
params.push("hm=" + hour);
|
|
|
|
if (params.length > 0)
|
|
|
|
urlstr += "?" + params.join("&");
|
|
|
|
|
|
|
|
window.open(urlstr, "", "width=490,height=470,resizable=0");
|
|
|
|
|
|
|
|
return false; /* stop following the link */
|
|
|
|
}
|
2006-08-15 22:52:23 +02:00
|
|
|
|
2007-09-15 00:01:02 +02:00
|
|
|
function getSelectedFolder() {
|
|
|
|
var folder;
|
|
|
|
|
|
|
|
var nodes = $("calendarList").getSelectedRows();
|
|
|
|
if (nodes.length > 0)
|
|
|
|
folder = nodes[0].getAttribute("id");
|
|
|
|
else
|
|
|
|
folder = "/personal";
|
|
|
|
|
|
|
|
return folder;
|
|
|
|
}
|
|
|
|
|
2007-05-22 16:38:54 +02:00
|
|
|
function onMenuNewEventClick(event) {
|
|
|
|
newEvent(this, "event");
|
|
|
|
}
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2007-05-22 16:38:54 +02:00
|
|
|
function onMenuNewTaskClick(event) {
|
|
|
|
newEvent(this, "task");
|
2006-08-22 00:36:33 +02:00
|
|
|
}
|
|
|
|
|
2007-09-15 00:01:02 +02:00
|
|
|
function _editEventId(id, calendar) {
|
|
|
|
var urlstr = ApplicationBaseURL + "/" + calendar + "/" + id + "/edit";
|
2007-06-06 23:09:39 +02:00
|
|
|
var targetname = "SOGo_edit_" + id;
|
|
|
|
var win = window.open(urlstr, "_blank",
|
2007-04-06 23:30:13 +02:00
|
|
|
"width=490,height=470,resizable=0");
|
2006-08-22 00:36:33 +02:00
|
|
|
win.focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
2006-10-12 23:05:32 +02:00
|
|
|
for (var i = 0; i < nodes.length; i++)
|
2006-10-27 17:03:48 +02:00
|
|
|
_editEventId(nodes[i].getAttribute("id"),
|
2007-09-15 00:01:02 +02:00
|
|
|
nodes[i].calendar);
|
2007-01-30 14:50:52 +01:00
|
|
|
} else if (selectedCalendarCell) {
|
2007-06-12 23:19:18 +02:00
|
|
|
_editEventId(selectedCalendarCell[0].cname,
|
2007-09-15 00:01:02 +02:00
|
|
|
selectedCalendarCell[0].calendar);
|
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();
|
|
|
|
var urlstr = (ApplicationBaseURL + "/" + calendar
|
|
|
|
+ "/batchDelete?ids=" + events.join('/'));
|
2006-10-18 23:53:47 +02:00
|
|
|
document.deleteEventAjaxRequest = triggerAjaxRequest(urlstr,
|
|
|
|
deleteEventCallback,
|
|
|
|
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"];
|
2006-11-06 18:44:07 +01:00
|
|
|
|
|
|
|
if (confirm(label)) {
|
2006-10-18 23:53:47 +02:00
|
|
|
if (document.deleteEventAjaxRequest) {
|
|
|
|
document.deleteEventAjaxRequest.aborted = true;
|
|
|
|
document.deleteEventAjaxRequest.abort();
|
|
|
|
}
|
2006-10-17 00:35:22 +02:00
|
|
|
var sortedNodes = new Array();
|
2007-09-15 00:01:02 +02:00
|
|
|
var calendars = new Array();
|
2006-10-17 00:35:22 +02:00
|
|
|
|
|
|
|
for (var i = 0; i < nodes.length; i++) {
|
2007-09-15 00:01:02 +02:00
|
|
|
var calendar = nodes[i].calendar;
|
|
|
|
if (!sortedNodes[calendar]) {
|
|
|
|
sortedNodes[calendar] = new Array();
|
|
|
|
calendars.push(calendar);
|
2006-10-18 23:53:47 +02:00
|
|
|
}
|
2007-09-15 00:01:02 +02:00
|
|
|
sortedNodes[calendar].push(nodes[i].cname);
|
2006-10-17 00:35:22 +02:00
|
|
|
}
|
2007-09-15 00:01:02 +02:00
|
|
|
for (var i = 0; i < calendars.length; i++) {
|
|
|
|
calendarsOfEventsToDelete.push(calendars[i]);
|
|
|
|
eventsToDelete.push(sortedNodes[calendars[i]]);
|
2006-10-18 23:53:47 +02:00
|
|
|
}
|
|
|
|
_batchDeleteEvents();
|
2006-10-12 23:05:32 +02:00
|
|
|
}
|
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) {
|
2007-09-15 00:01:02 +02:00
|
|
|
var label = labels["eventDeleteConfirmation"];
|
2007-01-30 14:50:52 +01:00
|
|
|
if (confirm(label)) {
|
|
|
|
if (document.deleteEventAjaxRequest) {
|
|
|
|
document.deleteEventAjaxRequest.aborted = true;
|
|
|
|
document.deleteEventAjaxRequest.abort();
|
|
|
|
}
|
2007-06-12 23:19:18 +02:00
|
|
|
eventsToDelete.push([selectedCalendarCell[0].cname]);
|
2007-09-15 00:01:02 +02:00
|
|
|
calendarsOfEventsToDelete.push(selectedCalendarCell[0].calendar);
|
2007-01-30 14:50:52 +01:00
|
|
|
_batchDeleteEvents();
|
|
|
|
}
|
|
|
|
}
|
2006-11-13 23:31:41 +01:00
|
|
|
else
|
|
|
|
window.alert("no selection");
|
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")
|
|
|
|
closeInvitationWindow();
|
2007-01-30 15:02:27 +01:00
|
|
|
else {
|
2007-08-24 00:10:01 +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 {
|
|
|
|
// log("showing alert...");
|
|
|
|
window.alert(labels["eventPartStatModificationError"]);
|
|
|
|
}
|
|
|
|
document.modifyEventAjaxRequest = null;
|
|
|
|
}
|
2006-11-07 19:14:29 +01: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)) {
|
|
|
|
var nodes = http.callbackData;
|
|
|
|
for (var i = 0; i < nodes.length; i++) {
|
|
|
|
var node = $(nodes[i]);
|
|
|
|
if (node)
|
|
|
|
node.parentNode.removeChild(node);
|
|
|
|
}
|
|
|
|
if (eventsToDelete.length)
|
|
|
|
_batchDeleteEvents();
|
|
|
|
else {
|
|
|
|
document.deleteEventAjaxRequest = null;
|
|
|
|
refreshEvents();
|
|
|
|
refreshTasks();
|
|
|
|
changeCalendarDisplay();
|
|
|
|
}
|
2006-10-18 23:53:47 +02:00
|
|
|
}
|
2007-09-15 01:14:51 +02:00
|
|
|
else
|
|
|
|
log ("deleteEventCallback Ajax error");
|
2006-08-25 22:49:34 +02:00
|
|
|
}
|
2006-08-14 22:32:30 +02:00
|
|
|
}
|
|
|
|
|
2007-06-11 23:23:48 +02:00
|
|
|
function editDoubleClickedEvent(event) {
|
2007-09-15 00:01:02 +02:00
|
|
|
_editEventId(this.cname, this.calendar);
|
2007-06-11 23:23:48 +02:00
|
|
|
|
2007-06-12 15:40:40 +02:00
|
|
|
preventDefault(event);
|
2007-06-11 23:23:48 +02:00
|
|
|
event.cancelBubble = true;
|
2006-08-22 00:36:33 +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
|
|
|
|
|
|
|
// log ("table.selected: " + table.selected);
|
|
|
|
|
|
|
|
if (document.selectedDate)
|
2006-12-20 23:55:54 +01:00
|
|
|
document.selectedDate.deselect();
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2006-12-20 23:55:54 +01:00
|
|
|
td.select();
|
2006-08-19 00:40:04 +02:00
|
|
|
document.selectedDate = td;
|
|
|
|
|
2006-10-11 20:12:02 +02:00
|
|
|
changeCalendarDisplay( { "day": 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) {
|
|
|
|
var day = this.getAttribute("date");
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2007-07-05 21:19:17 +02:00
|
|
|
changeDateSelectorDisplay(day, true);
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2007-07-05 21:19:17 +02:00
|
|
|
Event.stop(event);
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onCalendarGotoDay(node) {
|
2007-07-05 21:19:17 +02:00
|
|
|
var day = node.getAttribute("date");
|
|
|
|
|
|
|
|
changeDateSelectorDisplay(day);
|
|
|
|
changeCalendarDisplay( { "day": day } );
|
|
|
|
|
|
|
|
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) {
|
2007-07-05 21:13:59 +02: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) {
|
2007-06-11 23:23:48 +02: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");
|
2006-08-19 00:40:04 +02:00
|
|
|
var params = parseQueryParameters(http.callbackData);
|
|
|
|
sortKey = params["sort"];
|
|
|
|
sortOrder = params["desc"];
|
2007-10-02 17:29:16 +02:00
|
|
|
lastClickedRow = null; // from generic.js
|
2007-06-08 01:23:07 +02:00
|
|
|
|
|
|
|
var data = http.responseText.evalJSON(true);
|
|
|
|
for (var i = 0; i < data.length; i++) {
|
|
|
|
var row = document.createElement("tr");
|
2007-09-24 23:26:23 +02:00
|
|
|
table.tBodies[0].appendChild(row);
|
2007-06-08 01:23:07 +02:00
|
|
|
$(row).addClassName("eventRow");
|
2007-08-20 21:13:05 +02:00
|
|
|
row.setAttribute("id", escape(data[i][0]));
|
|
|
|
row.cname = escape(data[i][0]);
|
2007-09-15 00:01:02 +02:00
|
|
|
row.calendar = data[i][1];
|
2007-06-08 01:23:07 +02:00
|
|
|
|
|
|
|
var startDate = new Date();
|
|
|
|
startDate.setTime(data[i][4] * 1000);
|
|
|
|
row.day = startDate.getDayString();
|
|
|
|
row.hour = startDate.getHourString();
|
2007-06-13 21:28:59 +02:00
|
|
|
Event.observe(row, "click",
|
|
|
|
onEventClick.bindAsEventListener(row));
|
|
|
|
Event.observe(row, "dblclick",
|
|
|
|
editDoubleClickedEvent.bindAsEventListener(row));
|
2007-06-08 01:23:07 +02:00
|
|
|
Event.observe(row, "contextmenu",
|
|
|
|
onEventContextMenu.bindAsEventListener(row));
|
|
|
|
|
|
|
|
var td = document.createElement("td");
|
|
|
|
row.appendChild(td);
|
2007-06-08 23:31:25 +02:00
|
|
|
Event.observe(td, "mousedown", listRowMouseDownHandler, true);
|
2007-06-08 01:23:07 +02:00
|
|
|
td.appendChild(document.createTextNode(data[i][3]));
|
|
|
|
|
|
|
|
td = document.createElement("td");
|
|
|
|
row.appendChild(td);
|
2007-06-08 23:31:25 +02:00
|
|
|
Event.observe(td, "mousedown", listRowMouseDownHandler, true);
|
2007-06-11 23:23:48 +02:00
|
|
|
td.appendChild(document.createTextNode(data[i][8]));
|
2007-06-08 01:23:07 +02:00
|
|
|
|
|
|
|
td = document.createElement("td");
|
|
|
|
row.appendChild(td);
|
2007-06-08 23:31:25 +02:00
|
|
|
Event.observe(td, "mousedown", listRowMouseDownHandler, true);
|
2007-06-11 23:23:48 +02:00
|
|
|
td.appendChild(document.createTextNode(data[i][9]));
|
2007-06-08 01:23:07 +02:00
|
|
|
|
|
|
|
td = document.createElement("td");
|
|
|
|
row.appendChild(td);
|
2007-06-08 23:31:25 +02:00
|
|
|
Event.observe(td, "mousedown", listRowMouseDownHandler, true);
|
2007-06-08 01:23:07 +02:00
|
|
|
td.appendChild(document.createTextNode(data[i][6]));
|
|
|
|
}
|
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-06-06 23:09:39 +02:00
|
|
|
var data = http.responseText.evalJSON(true);
|
|
|
|
|
|
|
|
for (var i = 0; i < data.length; i++) {
|
|
|
|
//log(i + " = " + data[i][3]);
|
|
|
|
var listItem = document.createElement("li");
|
2007-06-08 01:23:07 +02:00
|
|
|
list.appendChild(listItem);
|
2007-10-02 17:29:16 +02:00
|
|
|
Event.observe(listItem, "mousedown", listRowMouseDownHandler);
|
2007-06-06 23:09:39 +02:00
|
|
|
Event.observe(listItem, "click", onRowClick);
|
|
|
|
Event.observe(listItem, "dblclick", editDoubleClickedEvent.bindAsEventListener(listItem));
|
|
|
|
listItem.setAttribute("id", data[i][0]);
|
2007-06-08 01:23:07 +02:00
|
|
|
$(listItem).addClassName(data[i][5]);
|
2007-09-15 00:01:02 +02:00
|
|
|
listItem.calendar = data[i][1];
|
|
|
|
$(listItem).addClassName("calendarFolder" + data[i][1]);
|
2007-08-21 16:44:40 +02:00
|
|
|
listItem.cname = escape(data[i][0]);
|
2007-06-06 23:09:39 +02:00
|
|
|
var input = document.createElement("input");
|
|
|
|
input.setAttribute("type", "checkbox");
|
|
|
|
listItem.appendChild(input);
|
|
|
|
Event.observe(input, "click", updateTaskStatus.bindAsEventListener(input), 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-06-08 01:23:07 +02:00
|
|
|
list.scrollTop = list.previousScroll;
|
2007-06-06 23:09:39 +02:00
|
|
|
|
2006-10-11 20:12:02 +02:00
|
|
|
if (http.callbackData) {
|
|
|
|
var selectedNodesId = http.callbackData;
|
2007-06-06 23:09:39 +02:00
|
|
|
for (var i = 0; i < selectedNodesId.length; i++) {
|
2007-06-11 23:23:48 +02:00
|
|
|
// log(selectedNodesId[i] + " (" + i + ") is selected");
|
2006-12-20 23:55:54 +01:00
|
|
|
$(selectedNodesId[i]).select();
|
2007-06-06 23:09:39 +02:00
|
|
|
}
|
2006-10-11 20:12:02 +02:00
|
|
|
}
|
2007-06-06 23:09:39 +02:00
|
|
|
else
|
|
|
|
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)) {
|
2006-08-19 00:40:04 +02:00
|
|
|
for (i = 0; i < elements.length; i++) {
|
2007-06-11 23:23:48 +02:00
|
|
|
day = elements[i].day;
|
2006-08-19 00:40:04 +02:00
|
|
|
if (day && day == currentDay) {
|
2007-07-31 23:14:14 +02:00
|
|
|
var td = $(elements[i]).getParentWithTagName("td");
|
2006-08-19 00:40:04 +02:00
|
|
|
if (document.selectedDate)
|
2006-12-20 23:55:54 +01:00
|
|
|
document.selectedDate.deselect();
|
2007-07-31 23:14:14 +02:00
|
|
|
$(td).select();
|
2006-08-19 00:40:04 +02:00
|
|
|
document.selectedDate = td;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function changeDateSelectorDisplay(day, keepCurrentDay) {
|
2007-09-15 00:01:02 +02:00
|
|
|
var url = ApplicationBaseURL + "/dateselector";
|
2006-08-19 00:40:04 +02:00
|
|
|
if (day)
|
|
|
|
url += "?day=" + day;
|
|
|
|
|
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]) {
|
2006-10-17 00:35:22 +02:00
|
|
|
// log ("restoring cached selector for month: " + month);
|
2006-09-07 17:50:03 +02:00
|
|
|
setDateSelectorContent(cachedDateSelectors[month]);
|
|
|
|
}
|
|
|
|
else {
|
2006-10-17 00:35:22 +02: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-03-19 15:31:49 +01:00
|
|
|
function changeCalendarDisplay(time, newView) {
|
2007-09-15 00:01:02 +02:00
|
|
|
var url = ApplicationBaseURL + "/" + ((newView) ? newView : currentView);
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2007-01-30 14:50:52 +01:00
|
|
|
selectedCalendarCell = null;
|
|
|
|
|
2006-10-12 18:46:24 +02:00
|
|
|
var day = null;
|
|
|
|
var hour = null;
|
|
|
|
if (time) {
|
|
|
|
day = time['day'];
|
|
|
|
hour = time['hour'];
|
|
|
|
}
|
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
|
|
|
if (day)
|
|
|
|
url += "?day=" + day;
|
|
|
|
|
2006-11-06 18:44:07 +01:00
|
|
|
// if (newView)
|
2006-10-17 00:35:22 +02:00
|
|
|
// log ("switching to view: " + newView);
|
2006-08-24 20:48:33 +02:00
|
|
|
// log ("changeCalendarDisplay: " + url);
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2006-08-19 00:40:04 +02:00
|
|
|
if (document.dayDisplayAjaxRequest) {
|
2006-08-22 00:36:33 +02:00
|
|
|
// log ("aborting day ajaxrq");
|
2006-08-19 00:40:04 +02:00
|
|
|
document.dayDisplayAjaxRequest.aborted = true;
|
|
|
|
document.dayDisplayAjaxRequest.abort();
|
|
|
|
}
|
2007-06-11 23:23:48 +02:00
|
|
|
document.dayDisplayAjaxRequest
|
|
|
|
= triggerAjaxRequest(url, calendarDisplayCallback,
|
|
|
|
{ "view": newView, "day": day, "hour": hour });
|
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-03-19 15:31:49 +01:00
|
|
|
function scrollDayView(hour) {
|
2006-10-11 20:12:02 +02:00
|
|
|
var rowNumber;
|
|
|
|
if (hour) {
|
|
|
|
if (hour.length == 3)
|
|
|
|
rowNumber = parseInt(hour.substr(0, 1));
|
|
|
|
else {
|
|
|
|
if (hour.substr(0, 1) == "0")
|
|
|
|
rowNumber = parseInt(hour.substr(1, 1));
|
|
|
|
else
|
|
|
|
rowNumber = parseInt(hour.substr(0, 2));
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
rowNumber = 8;
|
|
|
|
|
2006-11-15 01:10:53 +01:00
|
|
|
var daysView = $("daysView");
|
2007-06-11 23:23:48 +02:00
|
|
|
var hours =
|
2007-06-12 17:43:51 +02:00
|
|
|
$(daysView.childNodesWithTag("div")[0]).childNodesWithTag("div");
|
2006-11-15 01:10:53 +01:00
|
|
|
if (hours.length > 0)
|
2007-06-11 23:23:48 +02:00
|
|
|
daysView.scrollTop = hours[rowNumber].offsetTop;
|
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
|
|
|
|
|
|
|
event.cancelBubble = true;
|
|
|
|
event.returnValue = false;
|
2006-11-15 01:53:59 +01:00
|
|
|
}
|
|
|
|
|
2007-06-11 23:23:48 +02:00
|
|
|
function refreshCalendarEvents() {
|
2007-06-12 22:05:57 +02:00
|
|
|
var todayDate = new Date();
|
|
|
|
var sd;
|
2007-06-11 23:23:48 +02:00
|
|
|
var ed;
|
2007-06-12 22:05:57 +02:00
|
|
|
if (currentView == "dayview") {
|
|
|
|
if (currentDay)
|
|
|
|
sd = currentDay;
|
|
|
|
else
|
|
|
|
sd = todayDate.getDayString();
|
2007-06-11 23:23:48 +02:00
|
|
|
ed = sd;
|
2007-06-12 22:05:57 +02:00
|
|
|
}
|
2007-06-11 23:23:48 +02:00
|
|
|
else if (currentView == "weekview") {
|
2007-06-12 22:05:57 +02:00
|
|
|
var startDate;
|
|
|
|
if (currentDay)
|
|
|
|
startDate = currentDay.asDate();
|
|
|
|
else
|
|
|
|
startDate = todayDate;
|
|
|
|
startDate = startDate.beginOfWeek();
|
|
|
|
sd = startDate.getDayString();
|
|
|
|
var endDate = new Date();
|
|
|
|
endDate.setTime(startDate.getTime());
|
2007-06-11 23:23:48 +02:00
|
|
|
endDate.addDays(6);
|
|
|
|
ed = endDate.getDayString();
|
|
|
|
}
|
|
|
|
else {
|
2007-06-12 22:59:32 +02:00
|
|
|
var monthDate;
|
|
|
|
if (currentDay)
|
|
|
|
monthDate = currentDay.asDate();
|
2007-06-11 23:23:48 +02:00
|
|
|
else
|
2007-06-12 22:59:32 +02:00
|
|
|
monthDate = todayDate;
|
|
|
|
monthDate.setDate(1);
|
|
|
|
sd = monthDate.beginOfWeek().getDayString();
|
2007-06-11 23:23:48 +02:00
|
|
|
|
2007-06-12 22:59:32 +02:00
|
|
|
var lastMonthDate = new Date();
|
|
|
|
lastMonthDate.setTime(monthDate.getTime());
|
|
|
|
lastMonthDate.setMonth(monthDate.getMonth() + 1);
|
|
|
|
lastMonthDate.addDays(-1);
|
|
|
|
ed = lastMonthDate.endOfWeek().getDayString();
|
2007-06-11 23:23:48 +02:00
|
|
|
}
|
|
|
|
if (document.refreshCalendarEventsAjaxRequest) {
|
|
|
|
document.refreshCalendarEventsAjaxRequest.aborted = true;
|
|
|
|
document.refreshCalendarEventsAjaxRequest.abort();
|
|
|
|
}
|
2007-09-15 00:01:02 +02:00
|
|
|
var url = ApplicationBaseURL + "/eventslist?sd=" + sd + "&ed=" + ed;
|
2007-06-11 23:23:48 +02:00
|
|
|
document.refreshCalendarEventsAjaxRequest
|
|
|
|
= triggerAjaxRequest(url, refreshCalendarEventsCallback,
|
|
|
|
{"startDate": sd, "endDate": ed});
|
|
|
|
}
|
|
|
|
|
|
|
|
function refreshCalendarEventsCallback(http) {
|
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
|
|
|
var data = http.responseText.evalJSON(true);
|
|
|
|
// log("refresh calendar events: " + data.length);
|
|
|
|
for (var i = 0; i < data.length; i++)
|
|
|
|
drawCalendarEvent(data[i],
|
|
|
|
http.callbackData["startDate"],
|
|
|
|
http.callbackData["endDate"]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
log("AJAX error when refreshing calendar events");
|
|
|
|
}
|
|
|
|
|
|
|
|
function drawCalendarEvent(eventData, sd, ed) {
|
|
|
|
var viewStartDate = sd.asDate();
|
|
|
|
var viewEndDate = ed.asDate();
|
|
|
|
|
|
|
|
var startDate = new Date();
|
|
|
|
var endDate = new Date();
|
2007-09-15 01:37:19 +02:00
|
|
|
if (eventData[7] == 0) {
|
|
|
|
startDate.setTime(eventData[4] * 1000 + (1000 * UTCOffset));
|
|
|
|
endDate.setTime(eventData[5] * 1000 + (1000 * UTCOffset));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
startDate.setTime(eventData[4] * 1000);
|
|
|
|
endDate.setTime(eventData[5] * 1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
// log ("s: " + startDate+ "; e: " + endDate);
|
2007-06-11 23:23:48 +02:00
|
|
|
|
|
|
|
var days = startDate.daysUpTo(endDate);
|
|
|
|
|
|
|
|
var divs = new Array();
|
|
|
|
|
2007-06-13 04:47:23 +02:00
|
|
|
var title;
|
|
|
|
if (currentView == "monthview"
|
|
|
|
&& (eventData[7] == 0))
|
|
|
|
title = startDate.getDisplayHoursString() + " " + eventData[3];
|
|
|
|
else
|
|
|
|
title = eventData[3];
|
|
|
|
|
2007-06-12 22:59:32 +02:00
|
|
|
// log("title: " + title);
|
|
|
|
// log("viewS: " + viewStartDate);
|
2007-06-11 23:23:48 +02:00
|
|
|
var startHour = null;
|
|
|
|
var endHour = null;
|
2007-06-12 23:19:18 +02:00
|
|
|
|
|
|
|
var siblings = new Array();
|
2007-06-12 22:59:32 +02:00
|
|
|
for (var i = 0; i < days.length; i++)
|
2007-06-11 23:23:48 +02:00
|
|
|
if (days[i].earlierDate(viewStartDate) == viewStartDate
|
|
|
|
&& days[i].laterDate(viewEndDate) == viewEndDate) {
|
|
|
|
var starts;
|
2007-06-12 22:59:32 +02:00
|
|
|
|
|
|
|
// log("day: " + days[i]);
|
2007-06-11 23:23:48 +02:00
|
|
|
if (i == 0) {
|
2007-09-15 00:01:02 +02:00
|
|
|
var quarters = (startDate.getUTCHours() * 4
|
|
|
|
+ Math.floor(startDate.getUTCMinutes() / 15));
|
2007-06-11 23:23:48 +02:00
|
|
|
starts = quarters;
|
|
|
|
startHour = startDate.getDisplayHoursString();
|
|
|
|
endHour = endDate.getDisplayHoursString();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
starts = 0;
|
|
|
|
|
|
|
|
var ends;
|
|
|
|
var lasts;
|
|
|
|
if (i == days.length - 1) {
|
2007-09-15 00:01:02 +02:00
|
|
|
var quarters = (endDate.getUTCHours() * 4
|
|
|
|
+ Math.ceil(endDate.getUTCMinutes() / 15));
|
2007-06-11 23:23:48 +02:00
|
|
|
ends = quarters;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ends = 96;
|
|
|
|
lasts = ends - starts;
|
2007-06-12 22:05:57 +02:00
|
|
|
if (!lasts)
|
|
|
|
lasts = 1;
|
2007-06-12 20:55:31 +02:00
|
|
|
|
2007-07-27 22:04:45 +02:00
|
|
|
var eventDiv = newEventDIV(eventData[0], eventData[1], starts, lasts,
|
|
|
|
null, null, title);
|
2007-06-12 23:19:18 +02:00
|
|
|
siblings.push(eventDiv);
|
|
|
|
eventDiv.siblings = siblings;
|
2007-06-12 20:55:31 +02:00
|
|
|
var dayString = days[i].getDayString();
|
2007-06-12 22:59:32 +02:00
|
|
|
// log("day: " + dayString);
|
|
|
|
var parentDiv = null;
|
2007-06-11 23:23:48 +02:00
|
|
|
if (currentView == "monthview") {
|
|
|
|
var dayDivs = $("monthDaysView").childNodesWithTag("div");
|
2007-06-12 20:55:31 +02:00
|
|
|
var j = 0;
|
2007-06-11 23:23:48 +02:00
|
|
|
while (!parentDiv && j < dayDivs.length) {
|
|
|
|
if (dayDivs[j].getAttribute("day") == dayString)
|
|
|
|
parentDiv = dayDivs[j];
|
|
|
|
else
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2007-06-12 20:55:31 +02:00
|
|
|
if (eventData[7] == 0) {
|
|
|
|
var daysView = $("daysView");
|
|
|
|
var eventsDiv = $(daysView).childNodesWithTag("div")[1];
|
|
|
|
var dayDivs = $(eventsDiv).childNodesWithTag("div");
|
|
|
|
var j = 0;
|
|
|
|
while (!parentDiv && j < dayDivs.length) {
|
|
|
|
if (dayDivs[j].getAttribute("day") == dayString)
|
|
|
|
parentDiv = dayDivs[j].childNodesWithTag("div")[0];
|
|
|
|
else
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var header = $("calendarHeader");
|
|
|
|
var daysDiv = $(header).childNodesWithTag("div")[1];
|
|
|
|
var dayDivs = $(daysDiv).childNodesWithTag("div");
|
|
|
|
var j = 0;
|
|
|
|
while (!parentDiv && j < dayDivs.length) {
|
|
|
|
if (dayDivs[j].getAttribute("day") == dayString)
|
|
|
|
parentDiv = dayDivs[j];
|
|
|
|
else
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
2007-06-11 23:23:48 +02:00
|
|
|
}
|
2007-06-12 20:55:31 +02:00
|
|
|
if (parentDiv)
|
2007-08-07 20:14:39 +02:00
|
|
|
parentDiv.appendChild(eventDiv);
|
2007-06-11 23:23:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-15 00:01:02 +02:00
|
|
|
function newEventDIV(cname, calendar, starts, lasts,
|
2007-06-12 20:55:31 +02:00
|
|
|
startHour, endHour, title) {
|
2007-06-11 23:23:48 +02:00
|
|
|
var eventDiv = document.createElement("div");
|
2007-08-21 16:44:40 +02:00
|
|
|
eventDiv.cname = escape(cname);
|
2007-09-15 00:01:02 +02:00
|
|
|
eventDiv.calendar = calendar;
|
2007-08-07 20:14:39 +02:00
|
|
|
$(eventDiv).addClassName("event");
|
|
|
|
$(eventDiv).addClassName("starts" + starts);
|
|
|
|
$(eventDiv).addClassName("lasts" + lasts);
|
2007-06-11 23:23:48 +02:00
|
|
|
for (var i = 1; i < 5; i++) {
|
|
|
|
var shadowDiv = document.createElement("div");
|
|
|
|
eventDiv.appendChild(shadowDiv);
|
2007-08-07 20:14:39 +02:00
|
|
|
$(shadowDiv).addClassName("shadow");
|
|
|
|
$(shadowDiv).addClassName("shadow" + i);
|
2007-06-11 23:23:48 +02:00
|
|
|
}
|
|
|
|
var innerDiv = document.createElement("div");
|
|
|
|
eventDiv.appendChild(innerDiv);
|
2007-08-07 20:14:39 +02:00
|
|
|
$(innerDiv).addClassName("eventInside");
|
2007-09-15 00:01:02 +02:00
|
|
|
$(innerDiv).addClassName("calendarFolder" + calendar);
|
2007-06-11 23:23:48 +02:00
|
|
|
|
|
|
|
var gradientDiv = document.createElement("div");
|
|
|
|
innerDiv.appendChild(gradientDiv);
|
2007-08-07 20:14:39 +02:00
|
|
|
$(gradientDiv).addClassName("gradient");
|
2007-06-11 23:23:48 +02:00
|
|
|
var gradientImg = document.createElement("img");
|
|
|
|
gradientDiv.appendChild(gradientImg);
|
|
|
|
gradientImg.src = ResourcesURL + "/event-gradient.png";
|
|
|
|
|
|
|
|
var textDiv = document.createElement("div");
|
|
|
|
innerDiv.appendChild(textDiv);
|
2007-08-07 20:14:39 +02:00
|
|
|
$(textDiv).addClassName("text");
|
2007-06-11 23:23:48 +02:00
|
|
|
if (startHour) {
|
|
|
|
var headerSpan = document.createElement("span");
|
|
|
|
textDiv.appendChild(headerSpan);
|
2007-08-07 20:14:39 +02:00
|
|
|
$(headerSpan).addClassName("eventHeader");
|
2007-06-11 23:23:48 +02:00
|
|
|
headerSpan.appendChild(document.createTextNode(startHour + " - "
|
|
|
|
+ endHour));
|
|
|
|
textDiv.appendChild(document.createElement("br"));
|
|
|
|
}
|
|
|
|
textDiv.appendChild(document.createTextNode(title));
|
|
|
|
|
|
|
|
Event.observe(eventDiv, "mousedown", listRowMouseDownHandler);
|
|
|
|
Event.observe(eventDiv, "click",
|
|
|
|
onCalendarSelectEvent.bindAsEventListener(eventDiv));
|
|
|
|
Event.observe(eventDiv, "dblclick",
|
|
|
|
editDoubleClickedEvent.bindAsEventListener(eventDiv));
|
|
|
|
|
|
|
|
return eventDiv;
|
|
|
|
}
|
|
|
|
|
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-10-11 20:12:02 +02:00
|
|
|
var hour = null;
|
|
|
|
if (http.callbackData["hour"])
|
2006-10-18 23:53:47 +02:00
|
|
|
hour = http.callbackData["hour"];
|
2006-11-15 22:54:47 +01:00
|
|
|
var contentView;
|
|
|
|
if (currentView == "monthview")
|
|
|
|
contentView = $("calendarContent");
|
|
|
|
else {
|
2006-11-03 00:17:55 +01:00
|
|
|
scrollDayView(hour);
|
2006-11-15 22:54:47 +01:00
|
|
|
contentView = $("daysView");
|
|
|
|
}
|
2007-06-11 23:23:48 +02:00
|
|
|
refreshCalendarEvents();
|
2006-11-15 22:54:47 +01:00
|
|
|
var days = document.getElementsByClassName("day", contentView);
|
|
|
|
if (currentView == "monthview")
|
|
|
|
for (var i = 0; i < days.length; i++) {
|
2007-05-29 20:07:29 +02:00
|
|
|
Event.observe(days[i], "click", onCalendarSelectDay.bindAsEventListener(days[i]));
|
|
|
|
Event.observe(days[i], "dblclick", onClickableCellsDblClick.bindAsEventListener(days[i]));
|
2006-11-15 18:59:47 +01:00
|
|
|
}
|
2007-06-11 23:23:48 +02:00
|
|
|
else {
|
|
|
|
var headerDivs = $("calendarHeader").childNodesWithTag("div");
|
|
|
|
var headerDaysLabels = document.getElementsByClassName("day", headerDivs[0]);
|
|
|
|
var headerDays = document.getElementsByClassName("day", headerDivs[1]);
|
|
|
|
for (var i = 0; i < days.length; i++) {
|
|
|
|
headerDays[i].hour = "allday";
|
|
|
|
Event.observe(headerDaysLabels[i], "mousedown", listRowMouseDownHandler);
|
|
|
|
Event.observe(headerDays[i], "click",
|
|
|
|
onCalendarSelectDay.bindAsEventListener(days[i]));
|
|
|
|
Event.observe(headerDays[i], "dblclick",
|
|
|
|
onClickableCellsDblClick.bindAsEventListener(headerDays[i]));
|
|
|
|
Event.observe(days[i], "click",
|
|
|
|
onCalendarSelectDay.bindAsEventListener(days[i]));
|
|
|
|
var clickableCells = document.getElementsByClassName("clickableHourCell",
|
|
|
|
days[i]);
|
|
|
|
for (var j = 0; j < clickableCells.length; j++)
|
|
|
|
Event.observe(clickableCells[j], "dblclick",
|
|
|
|
onClickableCellsDblClick.bindAsEventListener(clickableCells[j]));
|
|
|
|
}
|
|
|
|
}
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
else
|
2007-06-06 23:09:39 +02:00
|
|
|
log ("calendarDisplayCallback Ajax error (" + 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);
|
2007-03-18 16:00:34 +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) {
|
|
|
|
var nodeId = node.getAttribute("inputId");
|
|
|
|
var input = $(nodeId);
|
|
|
|
input.calendar.popup();
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2007-03-18 16:00:34 +01:00
|
|
|
return false;
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2007-06-08 01:23:07 +02:00
|
|
|
function onEventContextMenu(event) {
|
|
|
|
var topNode = $("eventsList");
|
2006-10-17 00:35:22 +02:00
|
|
|
// log(topNode);
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2007-06-08 01:23:07 +02:00
|
|
|
var menu = $("eventsListMenu");
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2007-06-08 01:23:07 +02:00
|
|
|
Event.observe(menu, "hideMenu", onEventContextMenuHide);
|
|
|
|
popupMenu(event, "eventsListMenu", this);
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2007-06-08 01:23:07 +02:00
|
|
|
var topNode = $("eventsList");
|
2006-08-22 00:36:33 +02:00
|
|
|
var selectedNodes = topNode.getSelectedRows();
|
|
|
|
topNode.menuSelectedRows = selectedNodes;
|
|
|
|
for (var i = 0; i < selectedNodes.length; i++)
|
2006-12-20 23:55:54 +01:00
|
|
|
selectedNodes[i].deselect();
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2007-06-08 01:23:07 +02:00
|
|
|
topNode.menuSelectedEntry = this;
|
|
|
|
this.select();
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2007-06-08 01:23:07 +02:00
|
|
|
function onEventContextMenuHide(event) {
|
|
|
|
var topNode = $("eventsList");
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
if (topNode.menuSelectedEntry) {
|
2006-12-20 23:55:54 +01:00
|
|
|
topNode.menuSelectedEntry.deselect();
|
2006-08-19 00:40:04 +02:00
|
|
|
topNode.menuSelectedEntry = null;
|
|
|
|
}
|
|
|
|
if (topNode.menuSelectedRows) {
|
|
|
|
var nodeIds = topNode.menuSelectedRows;
|
|
|
|
for (var i = 0; i < nodeIds.length; i++) {
|
2006-08-24 20:48:33 +02:00
|
|
|
var node = $(nodeIds[i]);
|
2006-12-20 23:55:54 +01:00
|
|
|
node.select();
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
topNode.menuSelectedRows = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
2007-09-15 00:01:02 +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)
|
|
|
|
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-09-15 00:01:02 +02: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)
|
|
|
|
selectedIds = tasksList.getSelectedNodesId();
|
|
|
|
else
|
|
|
|
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)
|
|
|
|
tasksList.removeChild(tasksList.childNodes[0]);
|
|
|
|
|
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) {
|
2007-09-24 23:26:23 +02:00
|
|
|
//log("onHeaderClick: " + this.link);
|
|
|
|
//_loadEventHref(this.link);
|
2006-11-09 23:55:04 +01:00
|
|
|
|
2007-05-28 23:30:37 +02:00
|
|
|
preventDefault(event);
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2007-06-08 01:23:07 +02:00
|
|
|
function refreshEvents() {
|
|
|
|
return _loadEventHref("eventslist?desc=" + sortOrder
|
|
|
|
+ "&sort=" + sortKey
|
|
|
|
+ "&day=" + currentDay
|
|
|
|
+ "&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() {
|
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;
|
|
|
|
// log ("listFilter = " + listFilter);
|
|
|
|
|
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-10-04 19:26:21 +02:00
|
|
|
function onEventClick(event) { log ("onEventClick");
|
2007-06-13 21:28:59 +02:00
|
|
|
var day = this.day;
|
|
|
|
var hour = this.hour;
|
2006-09-07 00:27:46 +02:00
|
|
|
|
2006-10-11 20:12:02 +02:00
|
|
|
changeCalendarDisplay( { "day": day, "hour": hour} );
|
2006-09-07 00:27:46 +02:00
|
|
|
changeDateSelectorDisplay(day);
|
2006-08-22 21:18:30 +02:00
|
|
|
|
|
|
|
return onRowClick(event);
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function selectMonthInMenu(menu, month) {
|
2007-07-05 21:13:59 +02:00
|
|
|
var entries = menu.childNodes[1].childNodesWithTag("LI");
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function selectYearInMenu(menu, month) {
|
2006-08-22 21:18:30 +02:00
|
|
|
var entries = menu.childNodes[1].childNodes;
|
|
|
|
for (i = 0; i < entries.length; i++) {
|
|
|
|
var entry = entries[i];
|
2007-10-18 19:19:05 +02:00
|
|
|
if (entry.tagName == "LI") {
|
2006-08-22 21:18:30 +02:00
|
|
|
var entryMonth = entry.innerHTML;
|
|
|
|
if (entryMonth == month)
|
|
|
|
entry.addClassName("currentMonth");
|
|
|
|
else
|
|
|
|
entry.removeClassName("currentMonth");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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")
|
|
|
|
menuId = "monthListMenu";
|
|
|
|
else
|
|
|
|
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");
|
2006-08-24 20:48:33 +02:00
|
|
|
var year = '' + $("yearLabel").innerHTML;
|
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");;
|
2007-05-22 16:38:54 +02:00
|
|
|
var year = '' + this.innerHTML;
|
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
|
|
|
|
2006-12-19 20:17:35 +01:00
|
|
|
function onSearchFormSubmit() {
|
2006-08-31 01:13:18 +02:00
|
|
|
log ("search not implemented");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2006-09-07 00:27:46 +02:00
|
|
|
|
2007-06-08 01:23:07 +02:00
|
|
|
function onCalendarSelectEvent() {
|
|
|
|
var list = $("eventsList");
|
2007-10-04 19:26:21 +02:00
|
|
|
list.tBodies[0].deselectAll();
|
2006-09-07 00:27:46 +02:00
|
|
|
|
2007-01-30 14:50:52 +01:00
|
|
|
if (selectedCalendarCell)
|
2007-06-12 23:19:18 +02:00
|
|
|
for (var i = 0; i < selectedCalendarCell.length; i++)
|
|
|
|
selectedCalendarCell[i].deselect();
|
|
|
|
|
|
|
|
for (var i = 0; i < this.siblings.length; i++)
|
|
|
|
this.siblings[i].select();
|
|
|
|
selectedCalendarCell = this.siblings;
|
2007-06-11 23:23:48 +02:00
|
|
|
var row = $(this.cname);
|
2006-11-03 00:17:55 +01:00
|
|
|
if (row) {
|
|
|
|
var div = row.parentNode.parentNode.parentNode;
|
|
|
|
div.scrollTop = row.offsetTop - (div.offsetHeight / 2);
|
2006-12-20 23:55:54 +01:00
|
|
|
row.select();
|
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) {
|
2007-02-13 23:01:02 +01:00
|
|
|
var day;
|
|
|
|
if (currentView == "multicolumndayview")
|
2007-06-11 23:23:48 +02:00
|
|
|
day = this.getAttribute("day");
|
2007-02-13 23:01:02 +01:00
|
|
|
else
|
|
|
|
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) {
|
2006-11-15 01:10:53 +01:00
|
|
|
var days = document.getElementsByClassName("day", node.parentNode);
|
2007-06-11 23:23:48 +02:00
|
|
|
var headerDiv = $("calendarHeader").childNodesWithTag("div")[1];
|
|
|
|
var headerDays = document.getElementsByClassName("day", headerDiv);
|
2006-10-31 23:59:57 +01:00
|
|
|
|
2007-06-11 23:23:48 +02:00
|
|
|
// log ("days: " + days.length + "; headerDays: " + headerDays.length);
|
2006-11-15 01:10:53 +01:00
|
|
|
for (var i = 0; i < days.length; i++)
|
2007-06-11 23:23:48 +02:00
|
|
|
if (days[i] != node) {
|
|
|
|
// log("unselect day : " + i);
|
|
|
|
headerDays[i].removeClassName("selectedDay");
|
|
|
|
days[i].removeClassName("selectedDay");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// log("selected day : " + i);
|
|
|
|
headerDays[i].addClassName("selectedDay");
|
|
|
|
days[i].addClassName("selectedDay");
|
|
|
|
}
|
2006-10-31 23:59:57 +01:00
|
|
|
}
|
|
|
|
|
2007-03-13 00:06:48 +01:00
|
|
|
function findMonthCalendarSelectedCell(daysContainer) {
|
|
|
|
var found = false;
|
|
|
|
var i = 0;
|
|
|
|
|
|
|
|
while (!found && i < daysContainer.childNodes.length) {
|
|
|
|
var currentNode = daysContainer.childNodes[i];
|
2007-08-07 20:14:39 +02:00
|
|
|
if (currentNode.tagName == 'DIV'
|
2007-03-13 00:06:48 +01:00
|
|
|
&& currentNode.hasClassName("selectedDay")) {
|
|
|
|
daysContainer.selectedCell = currentNode;
|
|
|
|
found = true;
|
|
|
|
}
|
2006-11-03 00:17:55 +01:00
|
|
|
else
|
2007-03-13 00:06:48 +01:00
|
|
|
i++;
|
|
|
|
}
|
2006-11-03 00:17:55 +01:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function changeMonthCalendarDisplayOfSelectedDay(node) {
|
2007-03-13 00:06:48 +01:00
|
|
|
var daysContainer = node.parentNode;
|
|
|
|
if (!daysContainer.selectedCell)
|
|
|
|
findMonthCalendarSelectedCell(daysContainer);
|
|
|
|
|
|
|
|
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) {
|
|
|
|
showCompletedTasks = (this.checked ? 1 : 0);
|
2006-10-11 20:12:02 +02:00
|
|
|
|
2007-06-08 01:23:07 +02:00
|
|
|
return refreshTasks();
|
2006-10-11 20:12:02 +02:00
|
|
|
}
|
|
|
|
|
2007-06-06 23:09:39 +02:00
|
|
|
function updateTaskStatus(event) {
|
|
|
|
var taskId = this.parentNode.getAttribute("id");
|
|
|
|
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
|
|
|
}
|
2007-06-06 23:09:39 +02:00
|
|
|
|
2007-09-15 00:01:02 +02:00
|
|
|
url = (ApplicationBaseURL + "/" + this.parentNode.calendar
|
|
|
|
+ "/" + taskId + "/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("");
|
|
|
|
if (http.status == 200)
|
|
|
|
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) {
|
2006-10-14 01:37:27 +02:00
|
|
|
var list = new Array();
|
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) {
|
|
|
|
var folderId = nodes[i].getAttribute("id");
|
|
|
|
var elems = folderId.split(":");
|
|
|
|
if (elems.length > 1)
|
|
|
|
list.push(elems[0]);
|
|
|
|
else
|
|
|
|
list.push(UserLogin);
|
|
|
|
}
|
2006-10-14 01:37:27 +02:00
|
|
|
}
|
|
|
|
|
2007-09-15 00:01:02 +02:00
|
|
|
// if (!list.length) {
|
|
|
|
// list.push(UserLogin);
|
|
|
|
// nodes[0].childNodesWithTag("input")[0].checked = true;
|
|
|
|
// }
|
|
|
|
|
2006-12-19 18:06:07 +01:00
|
|
|
// ApplicationBaseURL = (UserFolderURL + "Groups/_custom_"
|
2007-03-29 20:05:23 +02:00
|
|
|
// + list.join(",") + "/Calendar/");
|
|
|
|
|
|
|
|
if (event) {
|
|
|
|
var folderID = this.parentNode.getAttribute("id");
|
|
|
|
var urlstr = URLForFolderID(folderID);
|
2007-10-02 17:29:16 +02:00
|
|
|
if (newStatus)
|
2007-06-07 21:21:24 +02:00
|
|
|
urlstr += "/activateFolder";
|
2007-03-29 20:05:23 +02:00
|
|
|
else
|
2007-06-06 23:09:39 +02:00
|
|
|
urlstr += "/deactivateFolder";
|
2007-06-07 21:21:24 +02:00
|
|
|
//log("updateCalendarStatus: ajax request = " + urlstr + ", folderID = " + folderID);
|
2007-03-29 20:05:23 +02:00
|
|
|
triggerAjaxRequest(urlstr, calendarStatusCallback, folderID);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
updateCalendarsList();
|
2007-06-08 01:23:07 +02:00
|
|
|
refreshEvents();
|
2007-03-29 20:05:23 +02:00
|
|
|
refreshTasks();
|
|
|
|
changeCalendarDisplay();
|
|
|
|
}
|
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) {
|
2007-09-15 00:01:02 +02:00
|
|
|
if (http.readyState == 4) {
|
2007-06-13 20:59:17 +02:00
|
|
|
var denied = !isHttpStatus204(http.status);
|
2007-03-29 20:05:23 +02:00
|
|
|
var entry = $(http.callbackData);
|
2007-06-01 22:35:51 +02:00
|
|
|
if (denied)
|
|
|
|
entry.addClassName("denied");
|
2007-03-29 20:05:23 +02:00
|
|
|
else
|
2007-06-01 22:35:51 +02:00
|
|
|
entry.removeClassName("denied");
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
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++) {
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function addContact(tag, fullContactName, contactId, contactName, contactEmail) {
|
2006-12-19 18:06:07 +01:00
|
|
|
var uids = $("uixselector-calendarsList-uidList");
|
2006-10-17 00:35:22 +02:00
|
|
|
// log("addContact");
|
2006-10-14 01:37:27 +02:00
|
|
|
if (contactId)
|
|
|
|
{
|
|
|
|
var re = new RegExp("(^|,)" + contactId + "($|,)");
|
|
|
|
|
|
|
|
if (!re.test(uids.value))
|
|
|
|
{
|
|
|
|
if (uids.value.length > 0)
|
|
|
|
uids.value += ',' + contactId;
|
|
|
|
else
|
|
|
|
uids.value = contactId;
|
2007-03-29 20:05:23 +02:00
|
|
|
var names = $("calendarList");
|
2006-12-19 18:06:07 +01:00
|
|
|
var listElems = names.childNodesWithTag("li");
|
2006-12-20 17:45:52 +01:00
|
|
|
var colorDef = indexColor(listElems.length);
|
|
|
|
names.appendChild(userCalendarEntry(contactId, colorDef));
|
2006-10-17 00:35:22 +02:00
|
|
|
|
2006-10-14 01:37:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2006-10-19 16:41:32 +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-05-28 21:19:17 +02:00
|
|
|
function getMenus() {
|
|
|
|
var menus = {};
|
|
|
|
|
2007-05-22 16:38:54 +02:00
|
|
|
var dateMenu = new Array();
|
|
|
|
for (var i = 0; i < 12; i++)
|
|
|
|
dateMenu.push(onMonthMenuItemClick);
|
|
|
|
menus["monthListMenu"] = dateMenu;
|
|
|
|
|
|
|
|
dateMenu = new Array();
|
|
|
|
for (var i = 0; i < 11; i++)
|
|
|
|
dateMenu.push(onYearMenuItemClick);
|
|
|
|
menus["yearListMenu"] = dateMenu;
|
|
|
|
|
2007-06-08 01:23:07 +02:00
|
|
|
menus["eventsListMenu"] = new Array(onMenuNewEventClick, "-",
|
2007-07-05 21:13:59 +02:00
|
|
|
onMenuNewTaskClick,
|
|
|
|
editEvent, deleteEvent, "-",
|
|
|
|
onSelectAll, "-",
|
|
|
|
null, null);
|
2007-09-15 04:31:34 +02:00
|
|
|
menus["calendarsMenu"] = new Array(onMenuModify,
|
|
|
|
"-",
|
|
|
|
onCalendarNew, onCalendarRemove,
|
2007-09-15 00:50:14 +02:00
|
|
|
"-", null, null, "-",
|
2007-05-22 16:38:54 +02:00
|
|
|
null, "-", onMenuSharing);
|
|
|
|
menus["searchMenu"] = new Array(setSearchCriteria);
|
|
|
|
|
2007-05-28 21:19:17 +02:00
|
|
|
return menus;
|
2006-12-14 22:20:13 +01:00
|
|
|
}
|
|
|
|
|
2007-05-19 03:12:23 +02:00
|
|
|
function onMenuSharing(event) {
|
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-05-22 16:38:54 +02:00
|
|
|
/* FIXME: activation of the context menu should preferable select the entry
|
|
|
|
above which the event has occured */
|
|
|
|
if (selected) {
|
|
|
|
var folderID = selected.getAttribute("id");
|
|
|
|
var urlstr = URLForFolderID(folderID) + "/acls";
|
2006-12-14 22:20:13 +01:00
|
|
|
|
2007-05-22 16:38:54 +02:00
|
|
|
openAclWindow(urlstr);
|
|
|
|
}
|
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);
|
|
|
|
handle.leftBlock=$("leftPanel");
|
|
|
|
handle.rightBlock=$("rightPanel");
|
|
|
|
}
|
|
|
|
|
|
|
|
handle = $("rightDragHandle");
|
|
|
|
if (handle) {
|
|
|
|
handle.addInterface(SOGoDragHandlesInterface);
|
2007-06-08 01:23:07 +02:00
|
|
|
handle.upperBlock=$("eventsListView");
|
2006-11-09 23:55:04 +01:00
|
|
|
handle.lowerBlock=$("calendarView");
|
|
|
|
}
|
|
|
|
}
|
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];
|
|
|
|
Event.observe(input, "click", updateCalendarStatus.bindAsEventListener(input));
|
|
|
|
Event.observe(items[i], "mousedown", listRowMouseDownHandler);
|
|
|
|
Event.observe(items[i], "selectstart", listRowMouseDownHandler);
|
|
|
|
Event.observe(items[i], "click", onRowClick);
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var links = $("calendarSelectorButtons").childNodesWithTag("a");
|
2007-09-15 00:01:02 +02:00
|
|
|
Event.observe(links[0], "click", onCalendarNew);
|
|
|
|
Event.observe(links[1], "click", onCalendarAdd);
|
|
|
|
Event.observe(links[2], "click", onCalendarRemove);
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
|
|
|
|
2007-09-15 04:31:34 +02:00
|
|
|
function onMenuModify(event) {
|
|
|
|
var folders = $("calendarList");
|
|
|
|
var selected = folders.getSelectedNodes()[0];
|
|
|
|
|
|
|
|
if (UserLogin == selected.getAttribute("owner")) {
|
|
|
|
var node = selected.childNodes[4];
|
|
|
|
var currentName = node.nodeValue.trim();
|
|
|
|
var newName = window.prompt(labels["Address Book Name"],
|
|
|
|
currentName);
|
|
|
|
if (newName && newName.length > 0
|
|
|
|
&& newName != currentName) {
|
|
|
|
var url = (URLForFolderID(selected.getAttribute("id"))
|
|
|
|
+ "/renameFolder?name=" + escape(newName.utf8encode()));
|
|
|
|
triggerAjaxRequest(url, folderRenameCallback,
|
|
|
|
{node: node, name: " " + newName});
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
window.alert(clabels["Unable to rename that folder!"]);
|
|
|
|
}
|
|
|
|
|
|
|
|
function folderRenameCallback(http) {
|
|
|
|
if (http.readyState == 4) {
|
|
|
|
if (isHttpStatus204(http.status)) {
|
|
|
|
var dict = http.callbackData;
|
|
|
|
dict["node"].nodeValue = dict["name"];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-15 00:01:02 +02:00
|
|
|
function onCalendarNew(event) {
|
|
|
|
createFolder(window.prompt(labels["Name of the Calendar"]),
|
|
|
|
appendCalendar);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
function appendCalendar(folderName, folder) {
|
2007-09-15 00:01:02 +02:00
|
|
|
if (folder)
|
|
|
|
folder = accessToSubscribedFolder(folder);
|
|
|
|
else
|
|
|
|
folder = "/" + folderName;
|
2007-06-06 23:09:39 +02:00
|
|
|
|
2007-09-15 00:01:02 +02:00
|
|
|
// log ("append: " + folderName + "; folder: " + folder);
|
2007-08-07 20:14:39 +02:00
|
|
|
|
2007-09-15 03:54:23 +02:00
|
|
|
if ($(folder))
|
|
|
|
window.alert(clabels["You have already subscribed to that folder!"]);
|
|
|
|
else {
|
|
|
|
var calendarList = $("calendarList");
|
|
|
|
var lis = calendarList.childNodesWithTag("li");
|
|
|
|
var color = indexColor(lis.length + 100);
|
|
|
|
//log ("color: " + color);
|
|
|
|
|
|
|
|
var li = document.createElement("li");
|
|
|
|
calendarList.appendChild(li);
|
2007-10-02 17:29:16 +02:00
|
|
|
li.setAttribute("id", folder);
|
2007-09-15 03:54:23 +02:00
|
|
|
|
|
|
|
var checkBox = document.createElement("input");
|
|
|
|
checkBox.setAttribute("type", "checkbox");
|
|
|
|
li.appendChild(checkBox);
|
|
|
|
li.appendChild(document.createTextNode(" "));
|
2007-10-02 17:29:16 +02:00
|
|
|
$(checkBox).addClassName("checkBox");
|
2007-09-15 03:54:23 +02:00
|
|
|
|
|
|
|
var colorBox = document.createElement("div");
|
|
|
|
li.appendChild(colorBox);
|
2007-10-11 22:31:42 +02:00
|
|
|
li.appendChild(document.createTextNode(" " + folderName));
|
2007-09-15 03:54:23 +02:00
|
|
|
colorBox.appendChild(document.createTextNode("OO"));
|
|
|
|
|
|
|
|
$(colorBox).addClassName("colorBox");
|
|
|
|
if (color)
|
|
|
|
$(colorBox).setStyle({color: color,
|
|
|
|
backgroundColor: color});
|
|
|
|
|
2007-10-02 17:29:16 +02:00
|
|
|
// Register events (doesn't work with Safari)
|
|
|
|
Event.observe(li, "mousedown", listRowMouseDownHandler);
|
|
|
|
Event.observe(li, "selectstart", listRowMouseDownHandler);
|
|
|
|
Event.observe(li, "click", onRowClick);
|
|
|
|
Event.observe(checkBox, "click",
|
|
|
|
updateCalendarStatus.bindAsEventListener(checkBox));
|
|
|
|
|
2007-09-15 03:54:23 +02:00
|
|
|
var url = URLForFolderID(folder) + "/canAccessContent";
|
|
|
|
triggerAjaxRequest(url, calendarEntryCallback, folder);
|
|
|
|
|
|
|
|
if (!document.styleSheets) return;
|
|
|
|
var theRules = new Array();
|
|
|
|
var lastSheet = document.styleSheets[document.styleSheets.length - 1];
|
|
|
|
if (lastSheet.insertRule) { // Mozilla
|
|
|
|
lastSheet.insertRule('.calendarFolder' + folder.substr(1) + ' {'
|
|
|
|
+ ' background-color: '
|
|
|
|
+ color
|
|
|
|
+ ' !important; }', 0);
|
|
|
|
}
|
|
|
|
else { // IE
|
|
|
|
lastSheet.addRule('.calendarFolder' + folder.substr(1),
|
|
|
|
' background-color: '
|
|
|
|
+ color
|
|
|
|
+ ' !important; }');
|
|
|
|
}
|
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"]);
|
2007-03-29 20:05:23 +02:00
|
|
|
if (!folder)
|
2007-09-15 00:01:02 +02:00
|
|
|
appendCalendar(folderData["folderName"], folderData["folder"]);
|
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);
|
|
|
|
refreshEvents();
|
|
|
|
refreshTasks();
|
|
|
|
changeCalendarDisplay();
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onCalendarRemove(event) {
|
|
|
|
var nodes = $("calendarList").getSelectedNodes();
|
|
|
|
if (nodes.length > 0) {
|
|
|
|
nodes[0].deselect();
|
|
|
|
var folderId = nodes[0].getAttribute("id");
|
2007-09-15 00:01:02 +02:00
|
|
|
var folderIdElements = folderId.split("_");
|
2007-03-29 20:05:23 +02:00
|
|
|
if (folderIdElements.length > 1) {
|
2007-09-15 00:01:02 +02:00
|
|
|
unsubscribeFromFolder(folderId, onFolderUnsubscribeCB, folderId);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var calId = folderIdElements[0].substr(1);
|
|
|
|
deletePersonalCalendar(calId);
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
2006-12-19 18:06:07 +01:00
|
|
|
}
|
2007-03-29 20:05:23 +02:00
|
|
|
|
2007-05-28 23:30:37 +02:00
|
|
|
preventDefault(event);
|
2006-12-14 22:20:13 +01:00
|
|
|
}
|
|
|
|
|
2007-09-15 00:01:02 +02:00
|
|
|
function deletePersonalCalendar(folderId) {
|
|
|
|
var label
|
|
|
|
= labels["Are you sure you want to delete the selected calendar?"];
|
|
|
|
if (window.confirm(label)) {
|
|
|
|
if (document.deletePersonalCalendarAjaxRequest) {
|
|
|
|
document.deletePersonalCalendarAjaxRequest.aborted = true;
|
|
|
|
document.deletePersonalCalendarAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
var url = ApplicationBaseURL + "/" + folderId + "/deleteFolder";
|
|
|
|
document.deletePersonalCalendarAjaxRequest
|
|
|
|
= triggerAjaxRequest(url, deletePersonalCalendarCallback, folderId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
|
|
|
var currentFolderId = children[i].getAttribute("id").substr(1);
|
|
|
|
if (currentFolderId == http.callbackData) {
|
|
|
|
ul.removeChild(children[i]);
|
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
refreshEvents();
|
|
|
|
refreshTasks();
|
|
|
|
changeCalendarDisplay();
|
|
|
|
}
|
|
|
|
document.deletePersonalCalendarAjaxRequest = null;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
log ("ajax problem 5: " + http.status);
|
|
|
|
}
|
|
|
|
|
2007-06-08 01:23:07 +02:00
|
|
|
function configureLists() {
|
|
|
|
var list = $("tasksList");
|
|
|
|
list.multiselect = true;
|
|
|
|
Event.observe(list, "mousedown",
|
|
|
|
onTasksSelectionChange.bindAsEventListener(list));
|
|
|
|
|
|
|
|
var input = $("showHideCompletedTasks");
|
2007-06-08 23:31:25 +02:00
|
|
|
Event.observe(input, "click",
|
2007-06-08 01:23:07 +02:00
|
|
|
onShowCompletedTasks.bindAsEventListener(input));
|
|
|
|
|
|
|
|
list = $("eventsList");
|
|
|
|
list.multiselect = true;
|
2007-09-24 23:26:23 +02:00
|
|
|
//configureSortableTableHeaders(list);
|
|
|
|
TableKit.Resizable.init(list, {'trueResize' : true, 'keepWidth' : true});
|
2007-06-08 01:23:07 +02:00
|
|
|
Event.observe(list, "mousedown",
|
|
|
|
onEventsSelectionChange.bindAsEventListener(list));
|
|
|
|
var div = list.parentNode;
|
|
|
|
Event.observe(div, "contextmenu",
|
|
|
|
onEventContextMenu.bindAsEventListener(div));
|
|
|
|
}
|
|
|
|
|
2007-07-05 21:13:59 +02:00
|
|
|
function initDateSelectorEvents() {
|
|
|
|
var arrow = $("rightArrow");
|
|
|
|
Event.observe(arrow, "click",
|
|
|
|
onDateSelectorGotoMonth.bindAsEventListener(arrow));
|
|
|
|
arrow = $("leftArrow");
|
|
|
|
Event.observe(arrow, "click",
|
|
|
|
onDateSelectorGotoMonth.bindAsEventListener(arrow));
|
|
|
|
|
|
|
|
var menuButton = $("monthLabel");
|
|
|
|
Event.observe(menuButton, "click",
|
|
|
|
popupMonthMenu.bindAsEventListener(menuButton));
|
|
|
|
menuButton = $("yearLabel");
|
|
|
|
Event.observe(menuButton, "click",
|
|
|
|
popupMonthMenu.bindAsEventListener(menuButton));
|
|
|
|
}
|
|
|
|
|
2006-12-14 22:20:13 +01:00
|
|
|
function initCalendars() {
|
2007-03-22 22:14:17 +01:00
|
|
|
if (!document.body.hasClassName("popup")) {
|
2007-07-05 21:13:59 +02:00
|
|
|
initDateSelectorEvents();
|
2007-03-29 20:05:23 +02:00
|
|
|
initCalendarSelector();
|
2007-03-22 22:14:17 +01:00
|
|
|
configureSearchField();
|
2007-06-08 01:23:07 +02:00
|
|
|
configureLists();
|
2007-05-28 21:19:17 +02:00
|
|
|
var selector = $("calendarSelector");
|
|
|
|
if (selector)
|
|
|
|
selector.attachMenu("calendarsMenu");
|
2007-03-22 22:14:17 +01:00
|
|
|
}
|
2006-12-14 22:20:13 +01:00
|
|
|
}
|
|
|
|
|
2007-05-28 23:30:37 +02:00
|
|
|
addEvent(window, 'load', initCalendars);
|