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 = '';
|
2006-11-15 22:54:47 +01:00
|
|
|
var currentView = "dayview";
|
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();
|
|
|
|
var ownersOfEventsToDelete = new Array();
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
var user = UserLogin;
|
|
|
|
if (sender.parentNode.getAttribute("id") != "toolbar"
|
|
|
|
&& currentView == "multicolumndayview" && type == "event")
|
|
|
|
user = sender.parentNode.parentNode.getAttribute("user");
|
|
|
|
|
2007-06-11 23:23:48 +02:00
|
|
|
var hour = sender.hour;
|
|
|
|
if (!hour)
|
|
|
|
hour = sender.getAttribute("hour");
|
2007-05-22 16:38:54 +02:00
|
|
|
var urlstr = UserFolderURL + "../" + user + "/Calendar/new" + type;
|
|
|
|
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-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
|
|
|
}
|
|
|
|
|
2006-10-17 00:35:22 +02:00
|
|
|
function _editEventId(id, owner) {
|
|
|
|
var urlBase;
|
|
|
|
if (owner)
|
|
|
|
urlBase = UserFolderURL + "../" + owner + "/";
|
|
|
|
urlBase += "Calendar/"
|
|
|
|
|
|
|
|
var urlstr = urlBase + 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-06-08 01:23:07 +02:00
|
|
|
nodes[i].owner);
|
2007-01-30 14:50:52 +01:00
|
|
|
} else if (selectedCalendarCell) {
|
2007-06-12 23:19:18 +02:00
|
|
|
_editEventId(selectedCalendarCell[0].cname,
|
|
|
|
selectedCalendarCell[0].owner);
|
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();
|
|
|
|
var owner = ownersOfEventsToDelete.shift();
|
2006-10-17 00:35:22 +02:00
|
|
|
var urlstr = (UserFolderURL + "../" + owner + "/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"))
|
|
|
|
label = labels["taskDeleteConfirmation"].decodeEntities();
|
|
|
|
else
|
2007-06-08 01:23:07 +02:00
|
|
|
label = labels["eventDeleteConfirmation"].decodeEntities();
|
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();
|
|
|
|
var owners = new Array();
|
|
|
|
|
|
|
|
for (var i = 0; i < nodes.length; i++) {
|
2007-06-08 01:23:07 +02:00
|
|
|
var owner = nodes[i].owner;
|
2006-10-18 23:53:47 +02:00
|
|
|
if (!sortedNodes[owner]) {
|
2006-10-17 00:35:22 +02:00
|
|
|
sortedNodes[owner] = new Array();
|
|
|
|
owners.push(owner);
|
2006-10-18 23:53:47 +02:00
|
|
|
}
|
2007-06-12 20:55:31 +02:00
|
|
|
sortedNodes[owner].push(nodes[i].cname);
|
2006-10-17 00:35:22 +02:00
|
|
|
}
|
2006-10-18 23:53:47 +02:00
|
|
|
for (var i = 0; i < owners.length; i++) {
|
|
|
|
ownersOfEventsToDelete.push(owners[i]);
|
|
|
|
eventsToDelete.push(sortedNodes[owners[i]]);
|
|
|
|
}
|
|
|
|
_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-06-08 01:23:07 +02:00
|
|
|
var label = labels["eventDeleteConfirmation"].decodeEntities();
|
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]);
|
|
|
|
ownersOfEventsToDelete.push(selectedCalendarCell[0].owner);
|
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");
|
|
|
|
closeDiv.addClassName("javascriptPopupBackground");
|
|
|
|
var closePseudoWin = document.createElement("div");
|
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;";
|
|
|
|
closePseudoWin.appendChild(document.createTextNode(labels["closeThisWindowMessage"].decodeEntities()));
|
|
|
|
document.body.appendChild(closeDiv);
|
|
|
|
document.body.appendChild(closePseudoWin);
|
|
|
|
}
|
|
|
|
|
2006-11-15 01:10:53 +01:00
|
|
|
function modifyEventCallback(http) {
|
2007-06-05 20:07:08 +02:00
|
|
|
if (http.readyState == 4) {
|
|
|
|
if (http.status == 200) {
|
|
|
|
if (queryParameters["mail-invitation"].toLowerCase() == "yes")
|
|
|
|
closeInvitationWindow();
|
|
|
|
else {
|
2007-06-08 01:23:07 +02:00
|
|
|
window.opener.setTimeout("refreshEventsAndDisplay();", 100);
|
2007-06-05 20:07:08 +02:00
|
|
|
window.setTimeout("window.close();", 100);
|
|
|
|
}
|
|
|
|
}
|
2007-01-30 15:02:27 +01:00
|
|
|
else {
|
2007-06-11 23:23:48 +02:00
|
|
|
// log("showing alert...");
|
2007-06-05 20:07:08 +02:00
|
|
|
window.alert(labels["eventPartStatModificationError"]);
|
2007-01-30 15:02:27 +01:00
|
|
|
}
|
2007-06-05 20:07:08 +02:00
|
|
|
document.modifyEventAjaxRequest = null;
|
|
|
|
}
|
2006-11-07 19:14:29 +01:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function deleteEventCallback(http) {
|
2006-08-25 22:49:34 +02:00
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
2007-01-30 19:18:30 +01:00
|
|
|
var nodes = http.callbackData;
|
2006-10-12 23:05:32 +02:00
|
|
|
for (var i = 0; i < nodes.length; i++) {
|
|
|
|
var node = $(nodes[i]);
|
2007-01-30 19:18:30 +01:00
|
|
|
if (node)
|
|
|
|
node.parentNode.removeChild(node);
|
2006-10-12 23:05:32 +02:00
|
|
|
}
|
2006-10-18 23:53:47 +02:00
|
|
|
if (eventsToDelete.length)
|
|
|
|
_batchDeleteEvents();
|
|
|
|
else {
|
|
|
|
document.deleteEventAjaxRequest = null;
|
2007-06-08 01:23:07 +02:00
|
|
|
refreshEvents();
|
2006-10-18 23:53:47 +02:00
|
|
|
refreshTasks();
|
|
|
|
changeCalendarDisplay();
|
|
|
|
}
|
2006-08-25 22:49:34 +02:00
|
|
|
}
|
|
|
|
else
|
2007-06-06 23:09:39 +02:00
|
|
|
log ("deleteEventCallback Ajax error");
|
2006-08-14 22:32:30 +02:00
|
|
|
}
|
|
|
|
|
2007-06-11 23:23:48 +02:00
|
|
|
function editDoubleClickedEvent(event) {
|
|
|
|
_editEventId(this.cname, this.owner);
|
|
|
|
|
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-03-19 15:31:49 +01:00
|
|
|
function onDateSelectorGotoMonth(node) {
|
2006-08-19 00:40:04 +02:00
|
|
|
var day = node.getAttribute("date");
|
|
|
|
|
2006-09-07 00:27:46 +02:00
|
|
|
changeDateSelectorDisplay(day, true);
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onCalendarGotoDay(node) {
|
2006-08-19 00:40:04 +02:00
|
|
|
var day = node.getAttribute("date");
|
|
|
|
|
2006-09-07 00:27:46 +02:00
|
|
|
changeDateSelectorDisplay(day);
|
2006-10-11 20:12:02 +02:00
|
|
|
changeCalendarDisplay( { "day": day } );
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
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) {
|
|
|
|
document.dateSelectorAjaxRequest = null;
|
2006-09-07 17:50:03 +02:00
|
|
|
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;
|
|
|
|
var table = $("eventsList").tBodies[0];
|
2006-08-19 00:40:04 +02:00
|
|
|
var params = parseQueryParameters(http.callbackData);
|
|
|
|
sortKey = params["sort"];
|
|
|
|
sortOrder = params["desc"];
|
2006-11-09 23:55:04 +01:00
|
|
|
configureSortableTableHeaders();
|
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");
|
|
|
|
table.appendChild(row);
|
|
|
|
$(row).addClassName("eventRow");
|
|
|
|
row.setAttribute("id", data[i][0]);
|
2007-06-11 23:23:48 +02:00
|
|
|
row.cname = data[i][0];
|
2007-06-08 01:23:07 +02:00
|
|
|
row.owner = data[i][1];
|
|
|
|
|
|
|
|
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-06-11 23:23:48 +02:00
|
|
|
Event.observe(listItem, "mousedown", listRowMouseDownHandler); // causes problem with Safari
|
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]);
|
|
|
|
var owner = data[i][1];
|
|
|
|
listItem.owner = owner;
|
|
|
|
$(listItem).addClassName("ownerIs" + owner);
|
2007-06-12 15:40:40 +02:00
|
|
|
listItem.cname = 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) {
|
2006-08-19 00:40:04 +02:00
|
|
|
var elements = div.getElementsByTagName("a");
|
|
|
|
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) {
|
|
|
|
var td = elements[i].getParentWithTagName("td");
|
|
|
|
if (document.selectedDate)
|
2006-12-20 23:55:54 +01:00
|
|
|
document.selectedDate.deselect();
|
|
|
|
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) {
|
2006-08-19 00:40:04 +02:00
|
|
|
var url = ApplicationBaseURL + "dateselector";
|
|
|
|
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) {
|
2006-12-19 18:06:07 +01: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();
|
|
|
|
}
|
|
|
|
var url = ApplicationBaseURL + "eventslist?sd=" + sd + "&ed=" + ed;
|
|
|
|
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();
|
|
|
|
startDate.setTime(eventData[4] * 1000);
|
|
|
|
var endDate = new Date();
|
|
|
|
endDate.setTime(eventData[5] * 1000);
|
|
|
|
|
|
|
|
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) {
|
|
|
|
var quarters = (startDate.getHours() * 4
|
|
|
|
+ Math.floor(startDate.getMinutes() / 15));
|
|
|
|
starts = quarters;
|
|
|
|
startHour = startDate.getDisplayHoursString();
|
|
|
|
endHour = endDate.getDisplayHoursString();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
starts = 0;
|
|
|
|
|
|
|
|
var ends;
|
|
|
|
var lasts;
|
|
|
|
if (i == days.length - 1) {
|
|
|
|
var quarters = (endDate.getHours() * 4
|
|
|
|
+ Math.ceil(endDate.getMinutes() / 15));
|
|
|
|
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
|
|
|
|
|
|
|
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)
|
|
|
|
parentDiv.appendChild(eventDiv);
|
2007-06-11 23:23:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-12 20:55:31 +02:00
|
|
|
function newEventDIV(cname, owner, starts, lasts,
|
|
|
|
startHour, endHour, title) {
|
2007-06-11 23:23:48 +02:00
|
|
|
var eventDiv = document.createElement("div");
|
|
|
|
eventDiv.cname = cname;
|
|
|
|
eventDiv.owner = owner;
|
|
|
|
eventDiv.addClassName("event");
|
|
|
|
eventDiv.addClassName("starts" + starts);
|
|
|
|
eventDiv.addClassName("lasts" + lasts);
|
|
|
|
for (var i = 1; i < 5; i++) {
|
|
|
|
var shadowDiv = document.createElement("div");
|
|
|
|
eventDiv.appendChild(shadowDiv);
|
|
|
|
shadowDiv.addClassName("shadow");
|
|
|
|
shadowDiv.addClassName("shadow" + i);
|
|
|
|
}
|
|
|
|
var innerDiv = document.createElement("div");
|
|
|
|
eventDiv.appendChild(innerDiv);
|
|
|
|
innerDiv.addClassName("eventInside");
|
|
|
|
innerDiv.addClassName("ownerIs" + owner);
|
|
|
|
|
|
|
|
var gradientDiv = document.createElement("div");
|
|
|
|
innerDiv.appendChild(gradientDiv);
|
|
|
|
gradientDiv.addClassName("gradient");
|
|
|
|
var gradientImg = document.createElement("img");
|
|
|
|
gradientDiv.appendChild(gradientImg);
|
|
|
|
gradientImg.src = ResourcesURL + "/event-gradient.png";
|
|
|
|
|
|
|
|
var textDiv = document.createElement("div");
|
|
|
|
innerDiv.appendChild(textDiv);
|
|
|
|
textDiv.addClassName("text");
|
|
|
|
if (startHour) {
|
|
|
|
var headerSpan = document.createElement("span");
|
|
|
|
textDiv.appendChild(headerSpan);
|
|
|
|
headerSpan.addClassName("eventHeader");
|
|
|
|
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;
|
2006-08-19 00:40:04 +02:00
|
|
|
div.innerHTML = 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) {
|
|
|
|
if (typeof(skycalendar) != "undefined") {
|
|
|
|
var node = $(name);
|
|
|
|
|
|
|
|
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
|
|
|
}
|
2006-12-19 18:06:07 +01:00
|
|
|
var url = ApplicationBaseURL + href;
|
2007-06-08 01:23:07 +02:00
|
|
|
document.eventsListAjaxRequest
|
|
|
|
= triggerAjaxRequest(url, eventsListCallback, href);
|
|
|
|
|
|
|
|
var table = $("eventsList").tBodies[0];
|
|
|
|
while (table.rows.length > 1)
|
|
|
|
table.removeChild(table.rows[1]);
|
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();
|
|
|
|
}
|
2006-12-19 18:06:07 +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)
|
|
|
|
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) {
|
2006-12-14 22:20:13 +01:00
|
|
|
// log("onHeaderClick: " + this.link);
|
2007-06-08 01:23:07 +02:00
|
|
|
_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-06-08 01:23:07 +02:00
|
|
|
function onEventClick(event) {
|
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) {
|
2006-10-17 00:35:22 +02:00
|
|
|
var entries = menu.childNodes[1].childNodesWithTag("LI");
|
2006-08-22 21:18:30 +02:00
|
|
|
for (i = 0; i < entries.length; i++) {
|
|
|
|
var entry = entries[i];
|
2006-10-17 00:35:22 +02:00
|
|
|
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];
|
|
|
|
if (entry instanceof HTMLLIElement) {
|
|
|
|
var entryMonth = entry.innerHTML;
|
|
|
|
if (entryMonth == month)
|
|
|
|
entry.addClassName("currentMonth");
|
|
|
|
else
|
|
|
|
entry.removeClassName("currentMonth");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function popupMonthMenu(event, menuId) {
|
2006-08-22 21:18:30 +02:00
|
|
|
var node = event.target;
|
|
|
|
|
|
|
|
if (event.button == 0) {
|
|
|
|
event.cancelBubble = true;
|
|
|
|
event.returnValue = false;
|
|
|
|
|
|
|
|
if (document.currentPopupMenu)
|
|
|
|
hideMenu(event, document.currentPopupMenu);
|
|
|
|
|
2006-08-24 20:48:33 +02:00
|
|
|
var popup = $(menuId);
|
2006-08-22 21:18:30 +02:00
|
|
|
var id = node.getAttribute("id");
|
|
|
|
if (id == "monthLabel")
|
|
|
|
selectMonthInMenu(popup, node.getAttribute("month"));
|
|
|
|
else
|
|
|
|
selectYearInMenu(popup, node.innerHTML);
|
|
|
|
|
|
|
|
var diff = (popup.offsetWidth - node.offsetWidth) /2;
|
|
|
|
|
|
|
|
popup.style.top = (node.offsetTop + 95) + "px";
|
|
|
|
popup.style.left = (node.offsetLeft - diff) + "px";
|
|
|
|
popup.style.visibility = "visible";
|
|
|
|
|
|
|
|
bodyOnClick = "" + document.body.getAttribute("onclick");
|
|
|
|
document.body.setAttribute("onclick", "onBodyClick('" + menuId + "');");
|
|
|
|
document.currentPopupMenu = popup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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");
|
2006-09-07 00:27:46 +02:00
|
|
|
list.deselectAll();
|
|
|
|
|
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];
|
|
|
|
if (currentNode instanceof HTMLDivElement
|
|
|
|
&& 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");
|
2007-06-08 01:23:07 +02:00
|
|
|
var taskOwner = this.parentNode.owner;
|
2007-06-06 23:09:39 +02:00
|
|
|
var newStatus = (this.checked ? 1 : 0);
|
2006-10-11 20:12:02 +02:00
|
|
|
var http = createHTTPClient();
|
2007-06-06 23:09:39 +02:00
|
|
|
|
2007-06-11 23:23:48 +02:00
|
|
|
// log("update task status: " + taskId + " to " + this.checked);
|
2007-06-06 23:09:39 +02:00
|
|
|
event.cancelBubble = true;
|
|
|
|
|
2007-06-07 21:21:24 +02:00
|
|
|
url = (UserFolderURL + "../" + taskOwner
|
|
|
|
+ "/Calendar/" + taskId
|
|
|
|
+ "/changeStatus?status=" + newStatus);
|
2006-10-11 20:12:02 +02:00
|
|
|
|
|
|
|
if (http) {
|
2006-10-17 21:49:47 +02:00
|
|
|
// log ("url: " + url);
|
2006-10-11 20:12:02 +02:00
|
|
|
// 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-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
|
|
|
}
|
|
|
|
|
2006-10-17 17:50:43 +02:00
|
|
|
if (!list.length) {
|
2007-03-29 20:05:23 +02:00
|
|
|
list.push(UserLogin);
|
|
|
|
nodes[0].childNodesWithTag("input")[0].checked = true;
|
2006-10-17 17:50:43 +02:00
|
|
|
}
|
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);
|
|
|
|
if (this.checked)
|
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-06-08 01:23:07 +02:00
|
|
|
refreshEvents();
|
2007-03-29 20:05:23 +02:00
|
|
|
refreshTasks();
|
2007-06-11 23:23:48 +02:00
|
|
|
changeCalendarDisplay();
|
2006-10-14 01:37:27 +02:00
|
|
|
}
|
2007-03-29 20:05:23 +02:00
|
|
|
else {
|
2007-06-12 16:58:15 +02:00
|
|
|
var folder = $(http.callbackData);
|
|
|
|
var input = folder.childNodesWithTag("input")[0];
|
|
|
|
input.checked = (!input.checked);
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
|
|
|
}
|
2007-06-07 21:21:24 +02:00
|
|
|
else
|
2007-06-12 16:58:15 +02:00
|
|
|
log("calendarStatusCallback Ajax error");
|
2006-10-14 01:37:27 +02:00
|
|
|
}
|
|
|
|
|
2007-03-29 20:05:23 +02:00
|
|
|
function calendarEntryCallback(http) {
|
2007-06-01 22:35:51 +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-05-22 16:38:54 +02:00
|
|
|
onMenuNewTaskClick,
|
|
|
|
editEvent, deleteEvent, "-",
|
|
|
|
onSelectAll, "-",
|
|
|
|
null, null);
|
2007-05-22 17:19:52 +02:00
|
|
|
menus["calendarsMenu"] = new Array(null, null, "-", 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-03-29 20:05:23 +02:00
|
|
|
var list = $("calendarList").childNodesWithTag("li");
|
2006-12-19 18:06:07 +01:00
|
|
|
for (var i = 0; i < list.length; i++) {
|
|
|
|
var input = list[i].childNodesWithTag("input")[0];
|
2007-06-06 23:09:39 +02:00
|
|
|
Event.observe(input, "click", updateCalendarStatus.bindAsEventListener(input)); // not registered in IE?
|
2007-06-07 21:21:24 +02:00
|
|
|
//Event.observe(list[i], "mousedown", listRowMouseDownHandler, true); // problem with Safari
|
2007-05-28 23:30:37 +02:00
|
|
|
Event.observe(list[i], "click", onRowClick);
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var links = $("calendarSelectorButtons").childNodesWithTag("a");
|
2007-05-25 16:36:43 +02:00
|
|
|
Event.observe(links[0], "click", onCalendarAdd);
|
|
|
|
Event.observe(links[1], "click", onCalendarRemove);
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onCalendarAdd(event) {
|
|
|
|
openUserFolderSelector(onFolderSubscribeCB, "calendar");
|
|
|
|
|
2007-05-28 23:30:37 +02:00
|
|
|
preventDefault(event);
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function appendCalendar(folderName, folder) {
|
|
|
|
var calendarList = $("calendarList");
|
|
|
|
var lis = calendarList.childNodesWithTag("li");
|
|
|
|
var color = indexColor(lis.length);
|
|
|
|
log ("color: " + color);
|
2007-06-06 23:09:39 +02:00
|
|
|
|
2007-03-29 20:05:23 +02:00
|
|
|
var li = document.createElement("li");
|
2007-06-06 23:09:39 +02:00
|
|
|
calendarList.appendChild(li);
|
|
|
|
|
2007-03-29 20:05:23 +02:00
|
|
|
var checkBox = document.createElement("input");
|
|
|
|
li.appendChild(checkBox);
|
2007-06-07 21:21:24 +02:00
|
|
|
|
2007-04-26 03:15:26 +02:00
|
|
|
li.appendChild(document.createTextNode(" "));
|
2007-06-06 23:09:39 +02:00
|
|
|
|
2007-03-29 20:05:23 +02:00
|
|
|
var colorBox = document.createElement("div");
|
2007-06-06 23:09:39 +02:00
|
|
|
li.appendChild(colorBox);
|
|
|
|
li.appendChild(document.createTextNode(" " + folderName));
|
2007-03-29 20:05:23 +02:00
|
|
|
colorBox.appendChild(document.createTextNode("OO"));
|
2007-06-06 23:09:39 +02:00
|
|
|
|
|
|
|
li.setAttribute("id", folder);
|
|
|
|
Event.observe(li, "mousedown", listRowMouseDownHandler);
|
|
|
|
Event.observe(li, "click", onRowClick);
|
|
|
|
checkBox.addClassName("checkBox");
|
|
|
|
checkBox.type = "checkbox";
|
|
|
|
Event.observe(checkBox, "click", updateCalendarStatus.bindAsEventListener(checkBox));
|
2007-06-07 21:21:24 +02:00
|
|
|
|
2007-03-29 20:05:23 +02:00
|
|
|
colorBox.addClassName("colorBox");
|
|
|
|
if (color) {
|
2007-05-28 23:30:37 +02:00
|
|
|
colorBox.setStyle({ color: color,
|
|
|
|
backgroundColor: color });
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var contactId = folder.split(":")[0];
|
|
|
|
var styles = document.getElementsByTagName("style");
|
2007-04-26 03:15:26 +02:00
|
|
|
|
|
|
|
var url = URLForFolderID(folder) + "/canAccessContent";
|
|
|
|
triggerAjaxRequest(url, calendarEntryCallback, folder);
|
|
|
|
|
2007-03-29 20:05:23 +02:00
|
|
|
styles[0].innerHTML += ('.ownerIs' + contactId + ' {'
|
|
|
|
+ ' background-color: '
|
|
|
|
+ color
|
|
|
|
+ ' !important; }');
|
|
|
|
}
|
|
|
|
|
|
|
|
function onFolderSubscribeCB(folderData) {
|
|
|
|
var folder = $(folderData["folder"]);
|
|
|
|
if (!folder)
|
|
|
|
appendCalendar(folderData["folderName"], folderData["folder"]);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onFolderUnsubscribeCB(folderId) {
|
|
|
|
var node = $(folderId);
|
|
|
|
node.parentNode.removeChild(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onCalendarRemove(event) {
|
|
|
|
var nodes = $("calendarList").getSelectedNodes();
|
|
|
|
if (nodes.length > 0) {
|
|
|
|
nodes[0].deselect();
|
|
|
|
var folderId = nodes[0].getAttribute("id");
|
|
|
|
var folderIdElements = folderId.split(":");
|
|
|
|
if (folderIdElements.length > 1) {
|
|
|
|
unsubscribeFromFolder(folderId, onFolderUnsubscribeCB, folderId);
|
|
|
|
}
|
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-03-22 22:14:17 +01:00
|
|
|
function configureSearchField() {
|
|
|
|
var searchValue = $("searchValue");
|
|
|
|
|
2007-06-13 04:47:23 +02:00
|
|
|
Event.observe(searchValue, "mousedown",
|
|
|
|
onSearchMouseDown.bindAsEventListener(searchValue));
|
|
|
|
Event.observe(searchValue, "click",
|
|
|
|
popupSearchMenu.bindAsEventListener(searchValue));
|
|
|
|
Event.observe(searchValue, "blur",
|
|
|
|
onSearchBlur.bindAsEventListener(searchValue));
|
|
|
|
Event.observe(searchValue, "focus",
|
|
|
|
onSearchFocus.bindAsEventListener(searchValue));
|
|
|
|
Event.observe(searchValue, "keydown",
|
|
|
|
onSearchKeyDown.bindAsEventListener(searchValue));
|
2007-03-22 22:14:17 +01:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
Event.observe(list, "mousedown",
|
|
|
|
onEventsSelectionChange.bindAsEventListener(list));
|
|
|
|
var div = list.parentNode;
|
|
|
|
Event.observe(div, "contextmenu",
|
|
|
|
onEventContextMenu.bindAsEventListener(div));
|
|
|
|
}
|
|
|
|
|
2006-12-14 22:20:13 +01:00
|
|
|
function initCalendars() {
|
2007-03-22 22:14:17 +01:00
|
|
|
if (!document.body.hasClassName("popup")) {
|
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);
|