2014-04-14 16:29:23 +02:00
|
|
|
/* -*- Mode: js2-mode; tab-width: 4; c-label-minimum-indentation: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
|
|
|
|
/*
|
2014-05-16 16:04:37 +02:00
|
|
|
Copyright (C) 2006-2014 Inverse
|
|
|
|
|
|
|
|
This file is part of SOGo
|
|
|
|
|
|
|
|
SOGo is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU Lesser General Public License as published by the
|
|
|
|
Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
later version.
|
|
|
|
|
|
|
|
SOGo is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
|
|
|
License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with SOGo; see the file COPYING. If not, write to the
|
|
|
|
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
02111-1307, USA.
|
|
|
|
*/
|
2014-04-14 16:29:23 +02:00
|
|
|
|
2014-04-17 23:33:30 +02:00
|
|
|
/******************************** Global variables *******************************************/
|
|
|
|
var firstDayOfWeek = window.opener.firstDayOfWeek;
|
2014-04-22 23:47:29 +02:00
|
|
|
var printCompletedTasks=1;
|
|
|
|
var printNoDueDateTasks=1;
|
|
|
|
var eventsBlocks;
|
2014-06-25 23:39:48 +02:00
|
|
|
var currentPreview;
|
2014-04-26 00:04:24 +02:00
|
|
|
var currentDay = window.parentvar("currentDay");
|
2014-04-22 23:47:29 +02:00
|
|
|
var sd, ed;
|
2014-04-14 16:29:23 +02:00
|
|
|
|
2014-04-22 23:47:29 +02:00
|
|
|
/****************************************** Ajax Requests, callbacks & events/tasks drawings ***************************************************/
|
|
|
|
|
2014-04-26 00:04:24 +02:00
|
|
|
function refreshContent() {
|
2014-05-16 16:04:37 +02:00
|
|
|
refreshEvents(); // Get the eventBlocks and draw them
|
|
|
|
refreshTasks(); // Get the taskLists and draw them
|
2014-04-17 23:33:30 +02:00
|
|
|
}
|
|
|
|
|
2014-04-26 00:04:24 +02:00
|
|
|
function updateDisplayView(data, newView) {
|
2014-06-25 23:39:48 +02:00
|
|
|
newView = ((newView) ? newView : currentPreview);
|
2014-04-26 00:04:24 +02:00
|
|
|
var url = ApplicationBaseURL + "/" + newView;
|
|
|
|
var day = null;
|
|
|
|
|
|
|
|
if (data) {
|
|
|
|
day = data['day'];
|
|
|
|
}
|
|
|
|
if (!day)
|
|
|
|
day = currentDay;
|
|
|
|
|
|
|
|
if (day) {
|
|
|
|
if (data) {
|
|
|
|
var dayDiv = $("day"+day);
|
|
|
|
if (dayDiv) {
|
|
|
|
// Don't reload the view if the event is present in current view
|
|
|
|
|
|
|
|
// Deselect day in date selector
|
|
|
|
if (document.selectedDate)
|
|
|
|
document.selectedDate.deselect();
|
|
|
|
|
|
|
|
// Select day in date selector
|
|
|
|
var selectedLink = $$('table#dateSelectorTable span[day='+day+']');
|
|
|
|
if (selectedLink.length > 0) {
|
|
|
|
selectedCell = selectedLink[0].getParentWithTagName("td");
|
|
|
|
$(selectedCell).selectElement();
|
|
|
|
document.selectedDate = selectedCell;
|
|
|
|
} else
|
|
|
|
document.selectedDate = null;
|
2014-05-16 16:04:37 +02:00
|
|
|
|
2014-04-26 00:04:24 +02:00
|
|
|
setSelectedDayDate(day);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if (day.length == 6) {
|
|
|
|
day += "01";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
url += "?day=" + day;
|
|
|
|
}
|
|
|
|
|
|
|
|
selectedCalendarCell = null;
|
2014-05-16 16:04:37 +02:00
|
|
|
|
2014-04-22 23:47:29 +02:00
|
|
|
if (document.dayDisplayAjaxRequest) {
|
|
|
|
document.dayDisplayAjaxRequest.aborted = true;
|
|
|
|
document.dayDisplayAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
document.dayDisplayAjaxRequest
|
|
|
|
= triggerAjaxRequest(url, previewDisplayCallback,
|
2014-04-26 00:04:24 +02:00
|
|
|
{ "view": newView,
|
2014-05-16 16:04:37 +02:00
|
|
|
"day": day});
|
2014-04-22 23:47:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function previewDisplayCallback(http) {
|
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
2014-04-26 00:04:24 +02:00
|
|
|
$("rightFrameEvents").innerHTML = http.responseText;
|
|
|
|
$("currentViewMenu").remove();
|
|
|
|
$("listCollapse").remove();
|
|
|
|
|
2014-06-25 23:39:48 +02:00
|
|
|
if (currentPreview == "multicolumndayview") {
|
|
|
|
_drawCalendarAllDayEvents(null, null, eventsBlocks);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
allDayEventsList = eventsBlocks[1];
|
|
|
|
if (currentPreview == "monthview") {
|
|
|
|
//_drawMonthCalendarEvents(eventsList, eventsBlocks[0], null);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
_drawCalendarAllDayEvents(allDayEventsList, eventsBlocks[0], null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// This ensure the diplay working hours checkbox when switching views
|
|
|
|
var printHoursCheckBox = $("printHours");
|
|
|
|
onPrintWorkingHoursCheck(printHoursCheckBox);
|
|
|
|
|
|
|
|
// Add events color for each calendars
|
|
|
|
addCalendarsColor();
|
2014-04-22 23:47:29 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
log ("calendarDisplayCallback Ajax error ("+ http.readyState + "/" + http.status + ")");
|
2014-04-26 00:04:24 +02:00
|
|
|
|
|
|
|
return false;
|
2014-04-17 23:33:30 +02:00
|
|
|
}
|
|
|
|
|
2014-06-25 23:39:48 +02:00
|
|
|
function addCalendarsColor () {
|
|
|
|
var activeCalendarsId = [];
|
|
|
|
var allCalendars = window.parent$("calendarList");
|
|
|
|
var allColors = window.parentvar("UserSettings")['Calendar']['FolderColors'];
|
|
|
|
for (var i = 0; i < allCalendars.children.length; i++) {
|
|
|
|
if (allCalendars.children[i].down("input").checked){
|
|
|
|
folderName = allCalendars.children[i].getAttribute("id").substr(1);
|
|
|
|
color = allColors["sogo1:Calendar/" + folderName];
|
|
|
|
appendStyleElement(folderName, color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-26 00:04:24 +02:00
|
|
|
function refreshEvents() {
|
2014-04-17 23:33:30 +02:00
|
|
|
var todayDate = new Date();
|
|
|
|
|
|
|
|
if (!currentDay)
|
|
|
|
currentDay = todayDate.getDayString();
|
|
|
|
|
2014-06-25 23:39:48 +02:00
|
|
|
if (currentPreview == "dayview" || currentPreview == "multicolumndayview") { // dayView and MultiColumns View
|
2014-04-17 23:33:30 +02:00
|
|
|
sd = currentDay;
|
|
|
|
ed = sd;
|
|
|
|
}
|
2014-06-25 23:39:48 +02:00
|
|
|
else if (currentPreview == "weekview") { // WeekView
|
2014-04-17 23:33:30 +02:00
|
|
|
var startDate;
|
|
|
|
startDate = currentDay.asDate();
|
|
|
|
startDate = startDate.beginOfWeek();
|
|
|
|
sd = startDate.getDayString();
|
|
|
|
var endDate = new Date();
|
|
|
|
endDate.setTime(startDate.getTime());
|
|
|
|
endDate.addDays(6);
|
|
|
|
ed = endDate.getDayString();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var monthDate;
|
|
|
|
monthDate = currentDay.asDate();
|
|
|
|
monthDate.setDate(1);
|
|
|
|
sd = monthDate.beginOfWeek().getDayString();
|
|
|
|
|
|
|
|
var lastMonthDate = new Date();
|
|
|
|
lastMonthDate.setTime(monthDate.getTime());
|
|
|
|
lastMonthDate.setMonth(monthDate.getMonth() + 1);
|
|
|
|
lastMonthDate.addDays(-1);
|
|
|
|
ed = lastMonthDate.endOfWeek().getDayString();
|
|
|
|
}
|
2014-04-26 00:04:24 +02:00
|
|
|
if (document.refreshEventsAjaxRequest) {
|
|
|
|
document.refreshEventsAjaxRequest.aborted = true;
|
|
|
|
document.refreshEventsAjaxRequest.abort();
|
2014-04-17 23:33:30 +02:00
|
|
|
}
|
|
|
|
var url = (ApplicationBaseURL + "/eventsblocks?sd=" + sd + "&ed=" + ed
|
2014-06-25 23:39:48 +02:00
|
|
|
+ "&view=" + currentPreview);
|
2014-04-17 23:33:30 +02:00
|
|
|
|
2014-04-26 00:04:24 +02:00
|
|
|
document.refreshEventsAjaxRequest
|
|
|
|
= triggerAjaxRequest(url, refreshEventsCallback,
|
2014-04-17 23:33:30 +02:00
|
|
|
{"startDate": sd, "endDate": ed});
|
|
|
|
}
|
|
|
|
|
2014-04-26 00:04:24 +02:00
|
|
|
function refreshTasks(){
|
2014-04-22 23:47:29 +02:00
|
|
|
if (document.tasksListAjaxRequest) {
|
|
|
|
document.tasksListAjaxRequest.aborted = true;
|
|
|
|
document.tasksListAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
|
2014-06-25 23:39:48 +02:00
|
|
|
var taskListFilter = window.parentvar("taskListFilter");
|
2014-04-22 23:47:29 +02:00
|
|
|
url = window.parentvar("ApplicationBaseURL") + "/" + "taskslist?show-completed=" + printCompletedTasks
|
2014-05-16 16:04:37 +02:00
|
|
|
+ "&asc=" + sorting["task-ascending"]
|
2014-06-25 23:39:48 +02:00
|
|
|
+ "&sort=" + sorting["task-attribute"]
|
|
|
|
+ "&filterpopup=" + taskListFilter;
|
|
|
|
|
|
|
|
// TODO : Is that really necessary ?
|
2014-04-22 23:47:29 +02:00
|
|
|
var tasksList = window.parent$("tasksList");
|
|
|
|
var selectedIds;
|
|
|
|
if (tasksList)
|
|
|
|
selectedIds = tasksList.getSelectedNodesId();
|
|
|
|
else
|
|
|
|
selectedIds = null;
|
|
|
|
|
2014-04-26 00:04:24 +02:00
|
|
|
document.tasksListAjaxRequest = triggerAjaxRequest(url, refreshTasksListCallback, selectedIds);
|
2014-04-22 23:47:29 +02:00
|
|
|
}
|
|
|
|
|
2014-04-26 00:04:24 +02:00
|
|
|
function refreshEventsCallback(http) {
|
2014-04-17 23:33:30 +02:00
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
|
|
|
if (http.responseText.length > 0) {
|
2014-04-22 23:47:29 +02:00
|
|
|
eventsBlocks = http.responseText.evalJSON(true);
|
2014-04-17 23:33:30 +02:00
|
|
|
$("rightFrameEvents").innerHTML = "";
|
2014-06-25 23:39:48 +02:00
|
|
|
if ($("printLayoutList").value == "0" && eventsBlocks.length > 0) {
|
2014-04-26 00:04:24 +02:00
|
|
|
_drawEventsCells(eventsBlocks);
|
2014-06-25 23:39:48 +02:00
|
|
|
adjustFrames();
|
|
|
|
}
|
2014-04-22 23:47:29 +02:00
|
|
|
else {
|
2014-06-25 23:39:48 +02:00
|
|
|
updateDisplayView(null, currentPreview);
|
2014-04-17 23:33:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
log("AJAX error when refreshing calendar events");
|
|
|
|
}
|
|
|
|
|
2014-04-26 00:04:24 +02:00
|
|
|
function refreshTasksListCallback(http) {
|
2014-04-22 23:47:29 +02:00
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
|
|
|
if (http.responseText.length > 0) {
|
|
|
|
var tasksBlocks = http.responseText.evalJSON(true);
|
|
|
|
$("rightFrameTasks").innerHTML = "";
|
2014-06-25 23:39:48 +02:00
|
|
|
if (tasksBlocks.length > 0) {
|
|
|
|
_drawTasksCells(tasksBlocks);
|
|
|
|
adjustFrames();
|
|
|
|
}
|
2014-04-22 23:47:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
log("AJAX error when refreshing calendar events");
|
|
|
|
}
|
|
|
|
|
2014-04-26 00:04:24 +02:00
|
|
|
function _drawEventsCells(eventsBlocks) {
|
2014-05-13 16:36:26 +02:00
|
|
|
var events = _("Events");
|
|
|
|
$("rightFrameEvents").insert("<h3>"+events+"</h3>");
|
2014-06-26 16:05:48 +02:00
|
|
|
if (currentPreview == "multicolumndayview") {
|
|
|
|
for(var i=0; i < eventsBlocks.length; i++) // calendars
|
|
|
|
{
|
|
|
|
for (var j = 0; j < eventsBlocks[i][0].length; j++) {
|
|
|
|
var event = _parseEvent(eventsBlocks[i][0][j]);
|
|
|
|
$("rightFrameEvents").insert(event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for(var i=0; i < eventsBlocks[0].length; i++)
|
|
|
|
{
|
|
|
|
var event = _parseEvent(eventsBlocks[0][i]);
|
|
|
|
$("rightFrameEvents").insert(event);
|
|
|
|
}
|
2014-04-17 23:33:30 +02:00
|
|
|
}
|
|
|
|
}
|
2014-04-14 16:29:23 +02:00
|
|
|
|
2014-04-22 23:47:29 +02:00
|
|
|
function _drawTasksCells(tasksBlocks) {
|
2014-05-13 16:36:26 +02:00
|
|
|
var task = _("Tasks");
|
|
|
|
$("rightFrameTasks").insert("<h3>"+task+"</h3>");
|
2014-04-22 23:47:29 +02:00
|
|
|
for(var i=0; i < tasksBlocks.length; i++)
|
|
|
|
{
|
|
|
|
if (!(printNoDueDateTasks == 0 && tasksBlocks[i][5] == null)) {
|
|
|
|
var task = _parseTask(tasksBlocks[i]);
|
2014-05-13 16:36:26 +02:00
|
|
|
$("rightFrameTasks").insert(task);
|
2014-04-22 23:47:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-09 01:14:39 +02:00
|
|
|
// TODO : Maybe use the drawfunction from the schedulerUI.js
|
2014-04-28 19:54:29 +02:00
|
|
|
|
2014-06-25 23:39:48 +02:00
|
|
|
function _drawCalendarEvents(events, eventsData, columnsData) {
|
2014-04-22 23:47:29 +02:00
|
|
|
var daysView = $("daysView");
|
|
|
|
var subdivs = daysView.childNodesWithTag("div");
|
2014-06-25 23:39:48 +02:00
|
|
|
var printHoursCheckBox = $("printHours");
|
2014-04-22 23:47:29 +02:00
|
|
|
for (var i = 0; i < subdivs.length; i++) {
|
|
|
|
var subdiv = subdivs[i];
|
|
|
|
if (subdiv.hasClassName("days")) {
|
|
|
|
var days = subdiv.childNodesWithTag("div");
|
2014-06-25 23:39:48 +02:00
|
|
|
if (currentPreview == "multicolumndayview") {
|
|
|
|
for (var j = 0; j < days.length; j++) {
|
|
|
|
var parentDiv = days[j].childNodesWithTag("div")[0];
|
|
|
|
var calendar = columnsData[j];
|
|
|
|
var calendarEvents = calendar[2][0];
|
|
|
|
var calendarEventsData = calendar[0];
|
|
|
|
if (parentDiv.getElementsByClassName("event").length > 0) {
|
|
|
|
var oldEvents = parentDiv.getElementsByClassName("event");
|
|
|
|
var length = oldEvents.length - 1;
|
|
|
|
for (var x = length; x >= 0; x--){
|
|
|
|
oldEvents[x].remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (var k = 0; k < calendarEvents.length; k++) {
|
|
|
|
var eventRep = calendarEvents[k];
|
|
|
|
var nbr = eventRep.nbr;
|
|
|
|
|
|
|
|
if (printHoursCheckBox.checked) {
|
|
|
|
var offset = _computeOffset(parentDiv);
|
|
|
|
if ((eventRep.start - offset[0]) > 0 && (eventRep.start - offset[0]) < offset[1]) {
|
|
|
|
var eventCell = newEventDIV(eventRep, calendarEventsData[nbr], offset[0]);
|
|
|
|
parentDiv.appendChild(eventCell);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var eventCell = newEventDIV(eventRep, calendarEventsData[nbr], null);
|
|
|
|
parentDiv.appendChild(eventCell);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (var j = 0; j < days.length; j++) {
|
|
|
|
var parentDiv = days[j].childNodesWithTag("div")[0];
|
|
|
|
if (parentDiv.getElementsByClassName("event").length > 0) {
|
|
|
|
var oldEvents = parentDiv.getElementsByClassName("event");
|
|
|
|
var length = oldEvents.length - 1;
|
|
|
|
for (var x = length; x >= 0; x--){
|
|
|
|
oldEvents[x].remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (var k = 0; k < events[j].length; k++) {
|
|
|
|
var eventRep = events[j][k];
|
|
|
|
var nbr = eventRep.nbr;
|
|
|
|
if (printHoursCheckBox.checked) {
|
|
|
|
var offset = _computeOffset(parentDiv);
|
|
|
|
if ((eventRep.start - offset[0]) > 0 && (eventRep.start - offset[0]) < offset[1]) {
|
|
|
|
var eventCell = newEventDIV(eventRep, eventsData[nbr], offset[0]);
|
|
|
|
parentDiv.appendChild(eventCell);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var eventCell = newEventDIV(eventRep, eventsData[nbr], null);
|
|
|
|
parentDiv.appendChild(eventCell);
|
|
|
|
}
|
|
|
|
}
|
2014-04-22 23:47:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-04-17 23:33:30 +02:00
|
|
|
}
|
2014-04-28 19:54:29 +02:00
|
|
|
|
2014-06-25 23:39:48 +02:00
|
|
|
function _drawCalendarAllDayEvents(events, eventsData, columnsData) {
|
2014-04-28 19:54:29 +02:00
|
|
|
var headerView = $("calendarHeader");
|
|
|
|
var subdivs = headerView.childNodesWithTag("div");
|
2014-06-25 23:39:48 +02:00
|
|
|
|
|
|
|
if (currentPreview == "multicolumndayview"){
|
|
|
|
var days = subdivs[2].childNodesWithTag("div");
|
|
|
|
for (var i = 0; i < days.length; i++) {
|
|
|
|
var parentDiv = days[i];
|
|
|
|
var calendar = columnsData[i];
|
|
|
|
var calendarAllDayEvents = calendar[1][0];
|
|
|
|
var calendarAllDayEventsData = calendar[0];
|
|
|
|
for (var j = 0; j < calendarAllDayEvents.length; j++) {
|
|
|
|
var eventRep = calendarAllDayEvents[j];
|
|
|
|
var nbr = eventRep.nbr;
|
|
|
|
var eventCell = newAllDayEventDIV(eventRep, calendarAllDayEventsData[nbr]);
|
|
|
|
parentDiv.appendChild(eventCell);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var days = subdivs[1].childNodesWithTag("div");
|
|
|
|
for (var i = 0; i < days.length; i++) {
|
|
|
|
var parentDiv = days[i];
|
|
|
|
for (var j = 0; j < events[i].length; j++) {
|
|
|
|
var eventRep = events[i][j];
|
|
|
|
var nbr = eventRep.nbr;
|
|
|
|
var eventCell = newAllDayEventDIV(eventRep, eventsData[nbr]);
|
|
|
|
parentDiv.appendChild(eventCell);
|
|
|
|
}
|
2014-04-28 19:54:29 +02:00
|
|
|
}
|
|
|
|
}
|
2014-06-25 23:39:48 +02:00
|
|
|
adjustPreviewHeader();
|
2014-04-28 19:54:29 +02:00
|
|
|
}
|
|
|
|
|
2014-04-26 00:04:24 +02:00
|
|
|
// todo : month
|
2014-04-14 16:29:23 +02:00
|
|
|
|
2014-06-25 23:39:48 +02:00
|
|
|
function newEventDIV(eventRep, event, offset) {
|
2014-04-26 00:04:24 +02:00
|
|
|
var eventCell = newBaseEventDIV(eventRep, event, event[4]);
|
|
|
|
|
|
|
|
var pc = 100 / eventRep.siblings;
|
|
|
|
var left = Math.floor(eventRep.position * pc);
|
|
|
|
eventCell.style.left = left + "%";
|
|
|
|
var right = Math.floor(100 - (eventRep.position + 1) * pc);
|
|
|
|
eventCell.style.right = right + "%";
|
2014-06-25 23:39:48 +02:00
|
|
|
if (offset != null) {
|
|
|
|
eventCell.addClassName("starts" + (eventRep.start - offset));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
eventCell.addClassName("starts" + eventRep.start);
|
|
|
|
}
|
2014-04-26 00:04:24 +02:00
|
|
|
eventCell.addClassName("lasts" + eventRep.length);
|
|
|
|
|
|
|
|
if (event[7]) {
|
|
|
|
var inside = eventCell.childNodesWithTag("div")[0];
|
|
|
|
var textDiv = inside.childNodesWithTag("div")[1];
|
|
|
|
textDiv.appendChild(createElement("br"));
|
|
|
|
var span = createElement("span", null, "location");
|
|
|
|
var text = _("Location:") + " " + event[7];
|
|
|
|
span.update(text);
|
|
|
|
textDiv.appendChild(span);
|
2014-04-17 23:33:30 +02:00
|
|
|
}
|
2014-04-26 00:04:24 +02:00
|
|
|
|
|
|
|
return eventCell;
|
2014-04-17 23:33:30 +02:00
|
|
|
}
|
2014-04-14 16:29:23 +02:00
|
|
|
|
2014-04-26 00:04:24 +02:00
|
|
|
function newBaseEventDIV(eventRep, event, eventText) {
|
|
|
|
// log ("0 cname = " + event[0]);
|
|
|
|
// log ("1 calendar = " + event[1]);
|
|
|
|
// log ("2 calendar name = " + event[2]);
|
|
|
|
// log ("3 status = " + event[3]);
|
|
|
|
// log ("4 title = " + event[4]);
|
|
|
|
// log ("5 start = " + event[5]);
|
|
|
|
// log ("6 end = " + event[6]);
|
|
|
|
// log ("7 location = " + event[7]);
|
|
|
|
// log ("8 isallday = " + event[8]);
|
|
|
|
// log ("9 classification = " + event[9]); // 0 = public, 1 = private, 2 = confidential
|
|
|
|
// log ("10 category = " + event[10]);
|
|
|
|
// log ("11 participants emails = " + event[11]);
|
|
|
|
// log ("12 participants states = " + event[12]);
|
|
|
|
// log ("13 owner = " + event[13]);
|
|
|
|
// log ("14 iscycle = " + event[14]);
|
|
|
|
// log ("15 nextalarm = " + event[15]);
|
|
|
|
// log ("16 recurrenceid = " + event[16]);
|
|
|
|
// log ("17 isexception = " + event[17]);
|
|
|
|
// log ("18 editable = " + event[18]);
|
|
|
|
// log ("19 erasable = " + event[19]);
|
|
|
|
// log ("20 ownerisorganizer = " + event[20]);
|
|
|
|
|
|
|
|
var eventCell = createElement("div");
|
|
|
|
eventCell.cname = event[0];
|
|
|
|
eventCell.calendar = event[1];
|
|
|
|
var startDate = new Date(event[5]*1000);
|
|
|
|
if (startDate) {
|
|
|
|
eventCell.startDate = event[5];
|
|
|
|
eventCell.writeAttribute('day', startDate.getDayString());
|
|
|
|
eventCell.writeAttribute('hour', event[8]? 'allday' : startDate.getHourString());
|
|
|
|
}
|
|
|
|
// if (event[8] == 1)
|
|
|
|
// eventCell.addClassName("private");
|
|
|
|
// else if (event[8] == 2)
|
|
|
|
// eventCell.addClassName("confidential");
|
|
|
|
if (eventRep.recurrenceTime)
|
|
|
|
eventCell.recurrenceTime = eventRep.recurrenceTime;
|
|
|
|
//eventCell.owner = event[12];
|
|
|
|
eventCell.isException = event[17];
|
|
|
|
eventCell.editable = event[18];
|
|
|
|
eventCell.erasable = event[19] || IsSuperUser;
|
|
|
|
eventCell.ownerIsOrganizer = event[20];
|
|
|
|
eventCell.addClassName("event");
|
|
|
|
// if (event[14] > 0)
|
|
|
|
// eventCell.addClassName("alarm");
|
|
|
|
|
|
|
|
var innerDiv = createElement("div");
|
|
|
|
eventCell.appendChild(innerDiv);
|
|
|
|
innerDiv.addClassName("eventInside");
|
|
|
|
innerDiv.addClassName("calendarFolder" + event[1]);
|
|
|
|
if (eventRep.userState >= 0 && userStates[eventRep.userState])
|
|
|
|
innerDiv.addClassName(userStates[eventRep.userState]);
|
|
|
|
|
|
|
|
var gradientDiv = createElement("div");
|
|
|
|
innerDiv.appendChild(gradientDiv);
|
|
|
|
gradientDiv.addClassName("gradient");
|
|
|
|
|
|
|
|
var gradientImg = createElement("img");
|
|
|
|
gradientDiv.appendChild(gradientImg);
|
|
|
|
gradientImg.src = ResourcesURL + "/event-gradient.png";
|
|
|
|
|
|
|
|
var textDiv = createElement("div");
|
|
|
|
innerDiv.appendChild(textDiv);
|
|
|
|
textDiv.addClassName("text");
|
|
|
|
var iconSpan = createElement("span", null, "icons");
|
|
|
|
textDiv.update(eventText.replace(/(\\r)?\\n/g, "<BR/>"));
|
|
|
|
textDiv.appendChild(iconSpan);
|
|
|
|
|
|
|
|
// Add alarm and classification icons
|
|
|
|
if (event[9] == 1)
|
|
|
|
createElement("img", null, null, {src: ResourcesURL + "/private.png"}, null, iconSpan);
|
|
|
|
else if (event[9] == 2)
|
|
|
|
createElement("img", null, null, {src: ResourcesURL + "/confidential.png"}, null, iconSpan);
|
|
|
|
if (event[15] > 0)
|
|
|
|
createElement("img", null, null, {src: ResourcesURL + "/alarm.png"}, null, iconSpan);
|
|
|
|
|
|
|
|
if (event[10] != null) {
|
|
|
|
var category = event[10].decodeEntities();
|
|
|
|
var categoryStyle = categoriesStyles.get(category);
|
|
|
|
if (!categoryStyle) {
|
|
|
|
categoryStyle = 'category_' + categoriesStyles.keys().length;
|
|
|
|
categoriesStyles.set([category], categoryStyle);
|
|
|
|
}
|
|
|
|
innerDiv.addClassName(categoryStyle);
|
|
|
|
}
|
|
|
|
|
|
|
|
return eventCell;
|
2014-04-22 23:47:29 +02:00
|
|
|
}
|
|
|
|
|
2014-06-25 23:39:48 +02:00
|
|
|
function appendStyleElement(folderPath, color) {
|
|
|
|
if (document.styleSheets) {
|
|
|
|
var fgColor = getContrastingTextColor(color);
|
|
|
|
var styleElement = document.styleSheets[3];
|
|
|
|
|
2014-06-26 16:05:48 +02:00
|
|
|
styleElement.insertRule(".calendarFolder" + folderPath +
|
|
|
|
"{background-color: " + color + " !important;" +
|
|
|
|
" color: " + fgColor + " !important;}", styleElement.cssRules.length);
|
2014-06-25 23:39:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-22 23:47:29 +02:00
|
|
|
function _parseEvent(event) {
|
2014-05-13 16:36:26 +02:00
|
|
|
// Localized strings :
|
2014-05-16 20:36:51 +02:00
|
|
|
var start = _("Start:");
|
|
|
|
var end = _("End:");
|
|
|
|
var Location = _("Location:");
|
|
|
|
var Calendar = _("Calendar:");
|
2014-05-13 16:36:26 +02:00
|
|
|
|
|
|
|
|
2014-04-22 23:47:29 +02:00
|
|
|
var parsedEvent;
|
|
|
|
var startDate = new Date(event[5] *1000);
|
|
|
|
var endDate = new Date(event[6] *1000);
|
2014-05-16 16:04:37 +02:00
|
|
|
parsedEvent = "<div class=\"divEventsPreview\"><table>";
|
|
|
|
parsedEvent += "<tr><th></th><th>"+ event[4] +"</th></tr>";
|
2014-05-16 20:36:51 +02:00
|
|
|
parsedEvent += "<tr><td class=\"label\">" + start + "</td><td>" + startDate.toLocaleString() + "</td></tr>";
|
|
|
|
parsedEvent += "<tr><td class=\"label\">" + end + "</td><td>" + endDate.toLocaleString() + "</td></tr>";
|
2014-05-13 16:36:26 +02:00
|
|
|
if (event[7] != "")
|
2014-05-16 20:36:51 +02:00
|
|
|
parsedEvent += "<tr><td class=\"label\">"+ Location +"</td><td>" + event[7] + "</td></tr>";
|
|
|
|
parsedEvent += "<tr><td class=\"label\">"+ Calendar +"</td><td>" + event[2] + "</td></tr>";
|
2014-04-22 23:47:29 +02:00
|
|
|
parsedEvent += "</table></div>";
|
|
|
|
return parsedEvent;
|
2014-04-17 23:33:30 +02:00
|
|
|
}
|
|
|
|
|
2014-04-22 23:47:29 +02:00
|
|
|
function _parseTask(task) {
|
|
|
|
var parsedTask;
|
2014-05-16 20:36:51 +02:00
|
|
|
var end = _("Due Date:");
|
|
|
|
var Calendar = _("Calendar:");
|
|
|
|
var Location = _("Location:");
|
2014-05-16 16:04:37 +02:00
|
|
|
|
|
|
|
parsedTask = "<div class=\"divTasksPreview\"><table>";
|
2014-04-22 23:47:29 +02:00
|
|
|
if (task[12] == "overdue")
|
2014-05-16 16:04:37 +02:00
|
|
|
parsedTask += "<tr><th></th><th class=\"overdueTasks\">"+ task[4] +"</th></tr>";
|
2014-04-22 23:47:29 +02:00
|
|
|
else if (task[12] == "completed") {
|
2014-05-16 16:04:37 +02:00
|
|
|
parsedTask += "<tr><th></th><th class=\"completedTasks\">"+ task[4] +"</th></tr>";
|
2014-04-22 23:47:29 +02:00
|
|
|
}
|
|
|
|
else
|
2014-05-16 16:04:37 +02:00
|
|
|
parsedTask += "<tr class=\"tasksTitle\"><th></th><th>"+ task[4] +"</th></tr>";
|
2014-04-17 23:33:30 +02:00
|
|
|
|
2014-05-16 20:36:51 +02:00
|
|
|
if (task[5] != null) {
|
|
|
|
var endDate = new Date(task[5] *1000);
|
|
|
|
parsedTask += "<tr><td class=\"label\">"+ end +"</td><td>"+ endDate.toLocaleString() + "</td></tr>";
|
2014-05-13 16:36:26 +02:00
|
|
|
}
|
|
|
|
if (task[7] != "") {
|
2014-05-16 20:36:51 +02:00
|
|
|
parsedTask += "<tr><td class=\"label\">"+ Location +"</td><td>" + task[7] + "</td></tr>";
|
2014-04-22 23:47:29 +02:00
|
|
|
}
|
2014-05-16 20:36:51 +02:00
|
|
|
parsedTask += "<tr><td class=\"label\">" + Calendar + "</td><td>" + task[2] + "</td></tr>";
|
2014-04-22 23:47:29 +02:00
|
|
|
parsedTask += "</table></div>";
|
|
|
|
|
|
|
|
return parsedTask;
|
2014-04-17 23:33:30 +02:00
|
|
|
}
|
|
|
|
|
2014-06-25 23:39:48 +02:00
|
|
|
function _computeOffset(hoursCells) {
|
|
|
|
var outOfDayCells = hoursCells.getElementsByClassName("outOfDay");
|
|
|
|
var count = 1;
|
|
|
|
var offset = [];
|
|
|
|
var buffer;
|
|
|
|
var j = 1;
|
|
|
|
for (var i = 0; i < outOfDayCells.length; i++) {
|
|
|
|
hourCell1 = parseInt(outOfDayCells[i].getAttribute("hour")) + 100;
|
|
|
|
hourCell2 = parseInt(outOfDayCells[j].getAttribute("hour"));
|
|
|
|
if (hourCell1 == hourCell2) {
|
|
|
|
count += 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
j ++;
|
|
|
|
}
|
|
|
|
offset.push(count * 4);
|
|
|
|
offset.push((hourCell2 / 100 * 4) - (count * 4));
|
|
|
|
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
2014-04-26 00:04:24 +02:00
|
|
|
/************************************** Preview Navigation *****************************************/
|
|
|
|
|
|
|
|
function onCalendarGotoDay(node) {
|
|
|
|
var day = node.getAttribute("date");
|
2014-05-20 17:24:27 +02:00
|
|
|
|
2014-04-26 00:04:24 +02:00
|
|
|
changeDateSelectorDisplay(day);
|
|
|
|
updateDisplayView({ "day": day });
|
|
|
|
refreshEvents();
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function changeDateSelectorDisplay(day, keepCurrentDay) {
|
|
|
|
var url = ApplicationBaseURL + "/dateselector";
|
|
|
|
if (day) {
|
|
|
|
if (day.length < 8)
|
|
|
|
day += "01";
|
|
|
|
url += "?day=" + day;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!keepCurrentDay)
|
|
|
|
currentDay = day;
|
|
|
|
|
|
|
|
var month = day.substr(0, 6);
|
|
|
|
if (cachedDateSelectors[month]) {
|
|
|
|
// log ("restoring cached selector for month: " + month);
|
|
|
|
setDateSelectorContent(cachedDateSelectors[month]);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// log ("loading selector for month: " + month);
|
|
|
|
if (document.dateSelectorAjaxRequest) {
|
|
|
|
document.dateSelectorAjaxRequest.aborted = true;
|
|
|
|
document.dateSelectorAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
document.dateSelectorAjaxRequest
|
|
|
|
= triggerAjaxRequest(url,
|
|
|
|
dateSelectorCallback,
|
|
|
|
month);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function dateSelectorCallback(http) {
|
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
|
|
|
document.dateSelectorAjaxRequest = null;
|
|
|
|
var content = http.responseText;
|
|
|
|
setDateSelectorContent(content);
|
|
|
|
cachedDateSelectors[http.callbackData] = content;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
log ("dateSelectorCallback Ajax error");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-06-25 23:39:48 +02:00
|
|
|
/*********************** Input Field, listMenu, Checkboxes and Radio *********************************/
|
2014-04-22 23:47:29 +02:00
|
|
|
|
|
|
|
function onInputTitleChange(event){
|
|
|
|
var inputFieldTitle = $("inputFieldTitle").value;
|
|
|
|
if (inputFieldTitle)
|
|
|
|
document.getElementById("rightFrameTitle").innerHTML = inputFieldTitle + "<br />";
|
|
|
|
else
|
2014-06-25 23:39:48 +02:00
|
|
|
document.getElementById("rightFrameTitle").remove();
|
|
|
|
|
|
|
|
return false;
|
2014-04-17 23:33:30 +02:00
|
|
|
}
|
|
|
|
|
2014-04-22 23:47:29 +02:00
|
|
|
function onPrintLayoutListChange() {
|
|
|
|
var parentView = window.parentvar("currentView");
|
2014-06-25 23:39:48 +02:00
|
|
|
var selectedLayout = $("printLayoutList").value;
|
|
|
|
document.getElementById("printHours").disabled = (selectedLayout == 0);
|
2014-04-22 23:47:29 +02:00
|
|
|
switch(selectedLayout) {
|
|
|
|
case "0": // List view
|
2014-05-13 16:36:26 +02:00
|
|
|
window.resizeTo(700,500);
|
2014-06-25 23:39:48 +02:00
|
|
|
currentPreview = parentView;
|
2014-04-22 23:47:29 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case "1": // Day view
|
2014-04-28 19:54:29 +02:00
|
|
|
window.resizeTo(1010,500);
|
2014-06-25 23:39:48 +02:00
|
|
|
currentPreview = "dayview";
|
2014-04-22 23:47:29 +02:00
|
|
|
break;
|
2014-06-25 23:39:48 +02:00
|
|
|
|
|
|
|
case "2": // Multi-columns view
|
2014-04-22 23:47:29 +02:00
|
|
|
window.resizeTo(1010,500);
|
2014-06-25 23:39:48 +02:00
|
|
|
currentPreview = "multicolumndayview";
|
2014-04-22 23:47:29 +02:00
|
|
|
break;
|
|
|
|
|
2014-06-25 23:39:48 +02:00
|
|
|
case "3": // Week view
|
|
|
|
window.resizeTo(1010,500);
|
|
|
|
currentPreview = "weekview";
|
|
|
|
break;
|
|
|
|
|
|
|
|
/*case "4": // Month view
|
|
|
|
window.resizeTo(1010,500);
|
|
|
|
currentPreview = "monthview";
|
|
|
|
break;*/
|
2014-04-17 23:33:30 +02:00
|
|
|
}
|
2014-04-26 00:04:24 +02:00
|
|
|
refreshContent();
|
2014-06-25 23:39:48 +02:00
|
|
|
return false;
|
2014-04-17 23:33:30 +02:00
|
|
|
}
|
|
|
|
|
2014-06-25 23:39:48 +02:00
|
|
|
function adjustPreviewHeader() {
|
|
|
|
// 1 - Check if there is any allDay Events. If not reduce the space taken
|
|
|
|
var selectedLayout = $("printLayoutList").value;
|
|
|
|
if (selectedLayout != 0) {
|
|
|
|
var calendarHeader = $("calendarHeader");
|
|
|
|
var allDayDisplay = $("calendarHeader").getElementsByClassName("days");
|
|
|
|
var allDayEvents = $("calendarHeader").getElementsByClassName("eventInside");
|
|
|
|
var eventHeight = 22;
|
|
|
|
var headerHeight = 38;
|
|
|
|
if (selectedLayout == 1) { // Since there is only one column in day view
|
|
|
|
height = allDayEvents.length * eventHeight;
|
|
|
|
}
|
|
|
|
else { // Applies only on week view and multi-columns view
|
|
|
|
var nbEventsMax = 0
|
|
|
|
var eventClass = $("calendarHeader").getElementsByClassName("event");
|
|
|
|
for (var i = 0; i < allDayDisplay[0].childNodes.length; i++) {
|
|
|
|
if (allDayDisplay[0].childNodes[i].firstChild != null) {
|
|
|
|
count = allDayDisplay[0].childNodes[i].getElementsByClassName("event").length;
|
|
|
|
if (count > nbEventsMax) {
|
|
|
|
nbEventsMax = count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
height = nbEventsMax * eventHeight;
|
|
|
|
if (selectedLayout == 2) {
|
|
|
|
headerHeight = 58;
|
|
|
|
adjustMultiColumnCalendarHeaderDIV();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
calendarHeader.style.height = (height + headerHeight) + "px";
|
|
|
|
allDayDisplay[0].style.height = height + "px";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function adjustMultiColumnCalendarHeaderDIV() {
|
|
|
|
var ch = $("calendarHeader");
|
|
|
|
var calendarLabels = ch.getElementsByClassName("calendarLabels")[0];
|
|
|
|
var calendarsToDisplay = calendarLabels.getElementsByClassName("calendarsToDisplay");
|
|
|
|
var dayLabels = ch.getElementsByClassName("dayLabels")[0].getElementsByClassName("dayColumn")[0];
|
|
|
|
var days = ch.getElementsByClassName("days")[0].getElementsByClassName("dayColumn");
|
|
|
|
var daysView = $("daysView").getElementsByClassName("dayColumn");
|
|
|
|
|
|
|
|
var nbCalendars = calendarsToDisplay.length;
|
|
|
|
|
|
|
|
if (nbCalendars > 0) {
|
|
|
|
var width = 100/nbCalendars;
|
|
|
|
var left = 0;
|
|
|
|
var position = "absolute";
|
|
|
|
for(var i=0; i < nbCalendars; i++){
|
|
|
|
calendarsToDisplay[i].setStyle({ width: width + '%', left: left + '%', position: position}).show();
|
|
|
|
days[i].setStyle({ width: width + '%', left: left + '%'}).show();
|
|
|
|
daysView[i].setStyle({ width: width + '%', left: left + '%'}).show();
|
|
|
|
left += width;
|
|
|
|
}
|
|
|
|
dayLabels.setStyle({ width: '100%'}).show();
|
2014-05-13 16:36:26 +02:00
|
|
|
}
|
|
|
|
else {
|
2014-06-25 23:39:48 +02:00
|
|
|
$("calendarHeader").remove();
|
|
|
|
$("daysView").remove();
|
|
|
|
var htmlText = "<div class='alert-box notice'><span>" + _("notice:") + "</span>"+_("Please go ahead and select calendars")+"</div>";
|
|
|
|
$("calendarContent").innerHTML = htmlText;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function adjustFrames() {
|
|
|
|
var view = $("printLayoutList").value;
|
|
|
|
if (view == 0) {
|
|
|
|
var eventsCheckBox = $("printEvents");
|
|
|
|
var tasksCheckBox = $("printTasks");
|
|
|
|
onEventsCheck(eventsCheckBox);
|
|
|
|
onTasksCheck(tasksCheckBox);
|
2014-05-13 16:36:26 +02:00
|
|
|
document.getElementById("rightFrameTasks").style.pageBreakBefore = 'auto';
|
|
|
|
document.getElementById("rightFrameTasks").style.pageBreakInside = 'auto';
|
|
|
|
}
|
2014-06-25 23:39:48 +02:00
|
|
|
else {
|
|
|
|
document.getElementById("rightFrameEvents").style.width = '100%';
|
|
|
|
document.getElementById("rightFrameTasks").style.width = '100%';
|
|
|
|
document.getElementById("rightFrameTasks").style.pageBreakBefore = 'always';
|
|
|
|
document.getElementById("rightFrameTasks").style.pageBreakInside = 'avoid';
|
|
|
|
}
|
|
|
|
return false;
|
2014-05-13 16:36:26 +02:00
|
|
|
}
|
|
|
|
|
2014-04-17 23:33:30 +02:00
|
|
|
function onEventsCheck(checkBox) {
|
2014-06-25 23:39:48 +02:00
|
|
|
var printOptions = document.getElementById("printHours");
|
|
|
|
var selectedLayout = $("printLayoutList").value;
|
|
|
|
if (!checkBox.checked || selectedLayout == 0)
|
|
|
|
printOptions.disabled = true;
|
|
|
|
else
|
|
|
|
printOptions.disabled = false;
|
|
|
|
|
|
|
|
var events = $("rightFrameEvents").childNodesWithTag("DIV");
|
|
|
|
if(checkBox.checked && events.length > 0){
|
|
|
|
$("rightFrameEvents").style.display = 'block';
|
2014-05-13 16:36:26 +02:00
|
|
|
if ($("printLayoutList").value == 0){
|
2014-06-25 23:39:48 +02:00
|
|
|
$("rightFrameTasks").style.width = '49.5%';
|
2014-05-13 16:36:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2014-06-25 23:39:48 +02:00
|
|
|
$("rightFrameEvents").style.display = 'none';
|
2014-05-13 16:36:26 +02:00
|
|
|
if ($("printLayoutList").value == 0){
|
2014-06-25 23:39:48 +02:00
|
|
|
$("rightFrameTasks").style.width = '100%';
|
2014-05-13 16:36:26 +02:00
|
|
|
}
|
|
|
|
}
|
2014-06-25 23:39:48 +02:00
|
|
|
return false;
|
2014-04-22 23:47:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onTasksCheck(checkBox) {
|
|
|
|
var printOptions = document.getElementsByName("printOptions");
|
|
|
|
for (var i = 0; i < printOptions.length; i++)
|
|
|
|
printOptions[i].disabled = !checkBox.checked;
|
2014-05-16 16:04:37 +02:00
|
|
|
|
2014-06-25 23:39:48 +02:00
|
|
|
var tasks = $("rightFrameTasks").childNodesWithTag("DIV");
|
|
|
|
if(checkBox.checked && tasks.length > 0) {
|
|
|
|
$("rightFrameTasks").style.display = 'block';
|
2014-05-13 16:36:26 +02:00
|
|
|
if ($("printLayoutList").value == 0){
|
2014-06-25 23:39:48 +02:00
|
|
|
$("rightFrameEvents").style.width = '49.5%';
|
2014-05-13 16:36:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2014-06-25 23:39:48 +02:00
|
|
|
$("rightFrameTasks").style.display = 'none';
|
2014-05-13 16:36:26 +02:00
|
|
|
if ($("printLayoutList").value == 0){
|
2014-06-25 23:39:48 +02:00
|
|
|
$("rightFrameEvents").style.width = '100%';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function onPrintWorkingHoursCheck(checkBox) {
|
|
|
|
var isCheked = checkBox.checked;
|
|
|
|
var outOfDayCells = $$("DIV#daysView .outOfDay");
|
|
|
|
var hours = $$("DIV#daysView .hour");
|
|
|
|
var hoursOutOfDay = [];
|
|
|
|
for (var i = 0; i < outOfDayCells.length; i++) {
|
|
|
|
var buffer = outOfDayCells[i].getAttribute("hour").substr(0,1);
|
|
|
|
if (buffer != "0") {
|
|
|
|
buffer += outOfDayCells[i].getAttribute("hour").substr(1,1);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
buffer = outOfDayCells[i].getAttribute("hour").substr(1,1);
|
|
|
|
}
|
|
|
|
if(isCheked) {
|
|
|
|
outOfDayCells[i].hide();
|
|
|
|
hours[buffer].hide();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
outOfDayCells[i].show();
|
|
|
|
hours[buffer].show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (currentPreview == "multicolumndayview") {
|
|
|
|
_drawCalendarEvents(null, null, eventsBlocks);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
eventsList = eventsBlocks[2];
|
|
|
|
if (currentPreview == "monthview") {
|
|
|
|
//_drawMonthCalendarEvents(eventsList, eventsBlocks[0], null);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
_drawCalendarEvents(eventsList, eventsBlocks[0], null);
|
2014-05-13 16:36:26 +02:00
|
|
|
}
|
|
|
|
}
|
2014-06-25 23:39:48 +02:00
|
|
|
return false;
|
2014-04-17 23:33:30 +02:00
|
|
|
}
|
|
|
|
|
2014-05-09 01:14:39 +02:00
|
|
|
/*function onPrintDateCheck() {
|
2014-05-16 16:04:37 +02:00
|
|
|
var dateRange = document.getElementsByName("dateRange");
|
|
|
|
var customDate = document.getElementById("customDate");
|
|
|
|
for (var i = 0; i < dateRange.length; i++)
|
|
|
|
if (dateRange[i].children[1].children[0].disabled == customDate.checked)
|
|
|
|
dateRange[i].children[1].children[0].disabled = !customDate.checked;
|
|
|
|
}*/
|
2014-04-17 23:33:30 +02:00
|
|
|
|
2014-04-22 23:47:29 +02:00
|
|
|
function onPrintCompletedTasksCheck(checkBox) {
|
|
|
|
printCompletedTasks = (checkBox.checked ? 1 : 0);
|
2014-06-25 23:39:48 +02:00
|
|
|
refreshContent();
|
2014-04-22 23:47:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onPrintNoDueDateTasksCheck(checkBox) {
|
|
|
|
printNoDueDateTasks = (checkBox.checked ? 1 : 0);
|
2014-06-25 23:39:48 +02:00
|
|
|
refreshContent();
|
2014-04-22 23:47:29 +02:00
|
|
|
}
|
|
|
|
|
2014-05-09 01:14:39 +02:00
|
|
|
/************** Date picker functions *************
|
2014-05-16 16:04:37 +02:00
|
|
|
this.initTimeWidgets = function (widgets) {
|
|
|
|
this.timeWidgets = widgets;
|
|
|
|
|
|
|
|
jQuery(widgets['start']['date']).closest('.date').datepicker({autoclose: true, weekStart: 0});
|
|
|
|
jQuery(widgets['end']['date']).closest('.date').datepicker({autoclose: true, weekStart: 0});
|
|
|
|
|
|
|
|
//jQuery(widgets['start']['date']).change(onAdjustTime);
|
|
|
|
|
|
|
|
jQuery(widgets['startingDate']['date']).closest('.date').datepicker({autoclose: true,
|
|
|
|
weekStart: 0,
|
|
|
|
endDate: lastDay,
|
|
|
|
startDate: firstDay,
|
|
|
|
setStartDate: lastDay,
|
|
|
|
startView: 2,
|
|
|
|
position: "below-shifted-left"});
|
|
|
|
}
|
|
|
|
|
|
|
|
this.onAdjustTime = function(event) {
|
|
|
|
onAdjustDueTime(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.onAdjustDueTime = function(event) {
|
|
|
|
var dateDelta = (window.getStartDate().valueOf() - window.getShadowStartDate().valueOf());
|
|
|
|
var newDueDate = new Date(window.getDueDate().valueOf() + dateDelta);
|
|
|
|
window.setDueDate(newDueDate);
|
|
|
|
|
|
|
|
window.timeWidgets['start']['date'].updateShadowValue();
|
|
|
|
}
|
|
|
|
/****************************************************/
|
2014-04-22 23:47:29 +02:00
|
|
|
|
2014-04-17 23:33:30 +02:00
|
|
|
/******************************* Buttons ***********************************************/
|
2014-04-14 16:29:23 +02:00
|
|
|
|
|
|
|
function onPrintCancelClick(event) {
|
|
|
|
this.blur();
|
|
|
|
onCloseButtonClick(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onPrintClick(event) {
|
|
|
|
this.blur();
|
|
|
|
window.print();
|
|
|
|
}
|
2014-04-17 23:33:30 +02:00
|
|
|
/**************************** Initialization *******************************************/
|
2014-04-14 16:29:23 +02:00
|
|
|
|
|
|
|
function init() {
|
2014-04-22 23:47:29 +02:00
|
|
|
initializePrintSettings();
|
2014-05-09 01:14:39 +02:00
|
|
|
//initializeWhatToPrint();
|
2014-04-22 23:47:29 +02:00
|
|
|
//initializeOptions();
|
2014-04-14 16:29:23 +02:00
|
|
|
$("cancelButton").observe("click", onPrintCancelClick);
|
|
|
|
$("printButton").observe("click", onPrintClick);
|
|
|
|
|
2014-05-09 01:14:39 +02:00
|
|
|
/* TODO : Selected and custom date must be implemented and finished.
|
2014-05-16 16:04:37 +02:00
|
|
|
document.getElementById("eventsTasks").disabled=true;
|
|
|
|
document.getElementById("customDate").disabled=true;*/
|
2014-04-28 19:54:29 +02:00
|
|
|
|
2014-04-22 23:47:29 +02:00
|
|
|
onPrintLayoutListChange();
|
|
|
|
}
|
|
|
|
|
|
|
|
function initializePrintSettings() {
|
|
|
|
$("inputFieldTitle").observe("change", onInputTitleChange);
|
|
|
|
$("printLayoutList").observe("change", onPrintLayoutListChange);
|
|
|
|
}
|
|
|
|
|
2014-05-09 01:14:39 +02:00
|
|
|
/*function initializeWhatToPrint() {
|
2014-05-16 16:04:37 +02:00
|
|
|
var widgets = {'start': {'date': $("startingDate")},
|
|
|
|
'end': {'date': $("endingDate")}};
|
|
|
|
initTimeWidgets(widgets);
|
|
|
|
onPrintDateCheck();
|
|
|
|
|
|
|
|
}*/
|
2014-04-14 16:29:23 +02:00
|
|
|
|
2014-04-22 23:47:29 +02:00
|
|
|
/*function initializeOptions() {
|
2014-06-25 23:39:48 +02:00
|
|
|
}*/
|
2014-04-22 23:47:29 +02:00
|
|
|
|
2014-04-14 16:29:23 +02:00
|
|
|
document.observe("dom:loaded", init);
|