diff --git a/ChangeLog b/ChangeLog index 0ce8fefae..aeef50ee1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ 2010-02-12 Wolfgang Sourdeau + * UI/Scheduler/UIxCalMonthView.m (-currentDayId): new method. + (-currentDayNumber): new method. + + * UI/Scheduler/UIxCalDayTable.m (-currentHourId): new method. + (-currentAllDayId): new method. + (-currentDayId): new method. + (-currentHourLineId): removed method because hourlines are no + longer present in the template. + (-currentDayNumber): new accessor, used in javascript to recover + selection faster when the currently selected date is no longer + available. + * UI/WebServerResources/SchedulerUIDnD.js (ScrollController.init): enhanced scrolling by setting a limit of 6 steps rather than 2. diff --git a/UI/Scheduler/UIxCalDayTable.m b/UI/Scheduler/UIxCalDayTable.m index 85b06ae67..2082984b0 100644 --- a/UI/Scheduler/UIxCalDayTable.m +++ b/UI/Scheduler/UIxCalDayTable.m @@ -31,6 +31,7 @@ #import #import +#import #import #import #import @@ -143,9 +144,9 @@ return hoursToDisplay; } -- (NSString *) currentHourLineId +- (NSString *) currentHourId { - return [NSString stringWithFormat: @"hourLine%d", [currentTableHour intValue]]; + return [NSString stringWithFormat: @"hour%d", [currentTableHour intValue]]; } - (NSArray *) daysToDisplay @@ -200,6 +201,21 @@ return formatted; } +- (NSString *) currentAllDayId +{ + return [NSString stringWithFormat: @"allDay%@", [currentTableDay shortDateString]]; +} + +- (NSString *) currentDayId +{ + return [NSString stringWithFormat: @"day%@", [currentTableDay shortDateString]]; +} + +- (int) currentDayNumber +{ + return [daysToDisplay indexOfObject: currentTableDay]; +} + - (NSString *) currentAppointmentHour { return [NSString stringWithFormat: @"%.2d00", [currentTableHour intValue]]; @@ -326,8 +342,6 @@ [classes appendString: @" weekEndDay"]; if ([currentTableDay isToday]) [classes appendString: @" dayOfToday"]; - if ([[self selectedDate] isDateOnSameDay: currentTableDay]) - [classes appendString: @" selectedDay"]; } return classes; diff --git a/UI/Scheduler/UIxCalMonthView.m b/UI/Scheduler/UIxCalMonthView.m index b802f2031..3cd667782 100644 --- a/UI/Scheduler/UIxCalMonthView.m +++ b/UI/Scheduler/UIxCalMonthView.m @@ -214,6 +214,17 @@ return currentTableDay; } +- (NSString *) currentDayId +{ + return [NSString stringWithFormat: @"day%@", [currentTableDay shortDateString]]; +} + +- (int) currentDayNumber +{ + return ([currentWeek indexOfObject: currentTableDay] + + [weeksToDisplay indexOfObject: currentWeek] * 7); +} + - (void) setCurrentWeek: (NSArray *) newCurrentWeek { ASSIGN (currentWeek, newCurrentWeek); @@ -298,8 +309,6 @@ [classes appendString: @" dayOfAnotherMonth"]; if ([currentTableDay isToday]) [classes appendString: @" dayOfToday"]; - if ([selectedDate isDateOnSameDay: currentTableDay]) - [classes appendString: @" selectedDay"]; return classes; } diff --git a/UI/Templates/SchedulerUI/UIxCalDayTable.wox b/UI/Templates/SchedulerUI/UIxCalDayTable.wox index d90facfc4..2f4436c19 100644 --- a/UI/Templates/SchedulerUI/UIxCalDayTable.wox +++ b/UI/Templates/SchedulerUI/UIxCalDayTable.wox @@ -19,6 +19,7 @@ >
-
-
-
- -
-
+
-
+ var:id="currentDayId" + var:day-number="currentDayNumber" + var:day="currentTableDay.shortDateString"> +
-
-
+
+
diff --git a/UI/Templates/SchedulerUI/UIxCalMonthView.wox b/UI/Templates/SchedulerUI/UIxCalMonthView.wox index 42ac572b4..f6c86a07c 100644 --- a/UI/Templates/SchedulerUI/UIxCalMonthView.wox +++ b/UI/Templates/SchedulerUI/UIxCalMonthView.wox @@ -63,6 +63,8 @@ >
diff --git a/UI/WebServerResources/SchedulerUI.css b/UI/WebServerResources/SchedulerUI.css index 98b4c3b07..9c6d0a8bc 100644 --- a/UI/WebServerResources/SchedulerUI.css +++ b/UI/WebServerResources/SchedulerUI.css @@ -512,16 +512,6 @@ DIV.monthView > DIV.headerDay font-weight: bold; background-color: #E7E7E7; } -DIV.dayOfToday -{ background-color: #CCDDEC; } - -DIV.dayOfToday DIV.outOfDay -{ background-color: #d6dfe9; } - -DIV.outOfDay, DIV.weekEndDay, -DIV.weekEndDay DIV.outOfDay -{ background-color: #E6E7E6; } - DIV.dayOfAnotherMonth { background-color: #e7efef; } @@ -549,12 +539,33 @@ DIV.monthView DIV.day overflow: auto; overflow-x: hidden; } -DIV.selectedDay, +DIV.day DIV.clickableHourCell +{ cursor: pointer; + height: 39px; + background-color: #fff; + border-bottom: 1px solid #ccc; } + +DIV.day DIV.clickableHourCell.outOfDay, +DIV#calendarHeader DIV.days DIV.weekEndDay, +DIV.weekEndDay DIV.clickableHourCell, +DIV.weekEndDay DIV.clickableHourCell.outOfDay +{ background-color: #E6E7E6; } + +DIV#calendarHeader DIV.days DIV.dayOfToday, +DIV.dayOfToday DIV.clickableHourCell +{ background-color: #ccddec; } + +DIV.dayOfToday DIV.clickableHourCell.outOfDay +{ background-color: #d6dfe9; } + +DIV#calendarHeader DIV.days DIV.selectedDay, +DIV#monthDaysView DIV.selectedDay, +DIV.selectedDay DIV.clickableHourCell, DIV.selectedDay DIV.dayHeader { background-color: #ffe79c; } -DIV.selectedDay.weekEndDay, -DIV.selectedDay DIV.outOfDay +DIV.selectedDay.weekEndDay DIV.clickableHourCell, +DIV.selectedDay DIV.clickableHourCell.outOfDay { background-color: #f5dd92; } DIV.weekOf4 @@ -658,32 +669,16 @@ DIV.monthView DIV.day6, DIV.daysViewFor7Days DIV.day6 { left: 85.7142%; } -DIV#daysView > DIV.hours -{ position: absolute; +DIV#daysView DIV.hour +{ position: relative; left: 0px; top: 0px; - width: 45px; + padding-top: 2px; + padding-right: 2px; + text-align: right; + width: 48px; + height: 37px; font-weight: bold; - padding-top: 5px; - padding-right: 5px; - color: #666; - text-align: right; } - -DIV#daysView > DIV.hours > DIV.hour -{ height: 40px; } - -DIV#daysView > DIV.hourLines > DIV.hourLine -{ position: relative; - height: 0px; - left: 0px; - right: 0px; - margin-top: 39px; - background-color: transparent; - border-bottom: 1px solid #ccc; } - -DIV.clickableHourCell -{ cursor: pointer; - height: 39px; border-bottom: 1px solid #ccc; } /* "left" and "width" for #daysView DIV.event are computed in JS code */ diff --git a/UI/WebServerResources/SchedulerUI.js b/UI/WebServerResources/SchedulerUI.js index 87b353d9a..9933f80b9 100644 --- a/UI/WebServerResources/SchedulerUI.js +++ b/UI/WebServerResources/SchedulerUI.js @@ -8,6 +8,8 @@ var selectedCalendarCell; var showCompletedTasks; var currentDay = ''; +var selectedDayNumber = -1; +var selectedDayDate = ''; var cachedDateSelectors = []; @@ -659,6 +661,7 @@ function onSelectAll() { return false; } +/* in dateselector */ function onDaySelect(node) { var day = node.getAttribute('day'); var needRefresh = (listFilter == 'view_selectedday' @@ -677,6 +680,7 @@ function onDaySelect(node) { changeCalendarDisplay( { "day": day } ); currentDay = day; + selectedDayDate = day; if (needRefresh) refreshEvents(); @@ -889,6 +893,7 @@ function tasksListCallback(http) { log ("tasksListCallback Ajax error"); } +/* in dateselector */ function restoreCurrentDaySelection(div) { var elements = $(div).select("TD.activeDay SPAN"); if (elements.size()) { @@ -954,7 +959,6 @@ function changeCalendarDisplay(data, newView) { var url = ApplicationBaseURL + newView; var day = null; var scrollEvent = null; - if (data) { day = data['day']; scrollEvent = data['scrollEvent']; @@ -965,22 +969,10 @@ function changeCalendarDisplay(data, newView) { if (day) { if (data) { - var divs = $$('div.day[day='+day+']'); - if (divs.length) { + var dayDiv = $("day"+day); + if (dayDiv) { // Don't reload the view if the event is present in current view - // Deselect previous day - var selectedDivs = $$('div.day.selectedDay'); - selectedDivs.each(function(div) { - div.removeClassName('selectedDay'); - }); - - // Select new day - if (currentView != 'dayview') - divs.each(function(div) { - div.addClassName('selectedDay'); - }); - // Deselect day in date selector if (document.selectedDate) document.selectedDate.deselect(); @@ -991,7 +983,8 @@ function changeCalendarDisplay(data, newView) { selectedCell = selectedLink[0].getParentWithTagName("td"); $(selectedCell).selectElement(); document.selectedDate = selectedCell; - } + } else + document.selectedDate = null; // Scroll to event if (scrollEvent) { @@ -999,6 +992,8 @@ function changeCalendarDisplay(data, newView) { scrollDayView(scrollEvent); } + setSelectedDayDate(day); + return false; } else if (day.length == 6) { @@ -1488,6 +1483,8 @@ function calendarDisplayCallback(http) { } attachDragControllers(contentView); + restoreSelectedDay(); + refreshCalendarEvents(http.callbackData.scrollEvent); var days = contentView.select("DIV.day"); @@ -1790,13 +1787,9 @@ function onCalendarSelectEvent(event) { function onCalendarSelectDay(event) { var day = this.getAttribute("day"); - var needRefresh = (listFilter == 'view_selectedday' - && day != currentDay); + setSelectedDayDate(day); + var needRefresh = (listFilter == 'view_selectedday' && day != currentDay); - if (currentView == 'weekview') - changeWeekCalendarDisplayOfSelectedDay(this); - else if (currentView == 'monthview') - changeMonthCalendarDisplayOfSelectedDay(this); changeDateSelectorDisplay(day); if (listOfSelection) { @@ -1810,55 +1803,53 @@ function onCalendarSelectDay(event) { changeCalendarDisplay( { "day": currentDay } ); } -function changeWeekCalendarDisplayOfSelectedDay(node) { - var daysView = $("daysView"); - var daysDiv = daysView.childNodesWithTag("div"); - for (var i = 0; i < daysDiv.length; i++) { - if (daysDiv[i].hasClassName("days")) { - var days = daysDiv[i].childNodesWithTag("div"); - var headerDiv = $($("calendarHeader").childNodesWithTag("div")[1]); - var headerDays = headerDiv.childNodesWithTag("div"); +function setSelectedDayDate(dayDate) { + if (selectedDayDate != dayDate) { + var day = $("day" + selectedDayDate); + if (day) + day.removeClassName("selectedDay"); + var allDay = $("allDay" + selectedDayDate); + if (allDay) + allDay.removeClassName("selectedDay"); - for (var j = 0; j < days.length; j++) { - if (days[j] == node - || headerDays[j] == node) { - headerDays[j].addClassName("selectedDay"); - days[j].addClassName("selectedDay"); - } - else { - headerDays[j].removeClassName("selectedDay"); - days[j].removeClassName("selectedDay"); - } - } - } + selectedDayDate = dayDate; + + day = $("day" + selectedDayDate); + day.addClassName("selectedDay"); + selectedDayNumber = day.readAttribute("day-number"); + allDay = $("allDay" + selectedDayDate); + if (allDay) + allDay.addClassName("selectedDay"); } } -function findMonthCalendarSelectedCell(daysContainer) { - var found = false; - var i = 0; - - while (!found && i < daysContainer.childNodes.length) { - var currentNode = daysContainer.childNodes[i]; - if (currentNode.tagName == 'DIV' - && currentNode.hasClassName("selectedDay")) { - daysContainer.selectedCell = currentNode; - found = true; - } +/* after loading a new view, to reselect the currently selected day */ +function restoreSelectedDay() { + var day = null; + if (selectedDayDate.length > 0) + day = $("day" + selectedDayDate); + if (!day) { + if (selectedDayNumber > -1) + selectedDayDate = findDateFromDayNumber(selectedDayNumber); else - i++; + selectedDayDate = currentDay; + if (selectedDayDate.length > 0) + day = $("day" + selectedDayDate); + } + if (day) { + selectedDayDate = null; + setSelectedDayDate(day.id.substr(3)); } } -function changeMonthCalendarDisplayOfSelectedDay(node) { - var daysContainer = node.parentNode; - if (!daysContainer.selectedCell) - findMonthCalendarSelectedCell(daysContainer); - - if (daysContainer.selectedCell) - daysContainer.selectedCell.removeClassName("selectedDay"); - daysContainer.selectedCell = node; - node.addClassName("selectedDay"); +function findDateFromDayNumber(dayNumber) { + var view; + if (currentView == "monthview") + view = $("monthDaysView"); + else + view = $("daysView"); + var days = view.select(".day"); + return days[dayNumber].readAttribute("day"); } function onShowCompletedTasks(event) { diff --git a/UI/WebServerResources/SchedulerUIDnD.js b/UI/WebServerResources/SchedulerUIDnD.js index 2ae153401..d09618c71 100644 --- a/UI/WebServerResources/SchedulerUIDnD.js +++ b/UI/WebServerResources/SchedulerUIDnD.js @@ -112,10 +112,10 @@ _SOGoEventDragUtilities.prototype = { getQuarterHeight: function() { if (this.quarterHeight == -1) { - var hourLine0 = $("hourLine0"); - var hourLine23 = $("hourLine23"); - this.quarterHeight = ((hourLine23.offsetTop - hourLine0.offsetTop) - / (23 * 4)); + var hour0 = $("hour0"); + var hour23 = $("hour23"); + this.quarterHeight = ((hour23.offsetTop - hour0.offsetTop) + / (23 * 4)); } return this.quarterHeight; @@ -909,8 +909,9 @@ SOGoEventDragController.prototype = { dropCallback: null, + onDragStartBound: null, onDragStopBound: null, - moveBound: null, + onDragModeBound: null, _determineDragMode: null, @@ -924,10 +925,9 @@ SOGoEventDragController.prototype = { this.ghostController.setTitle(this.title); this.ghostController.setFolderClass(this.folderClass); - var onDragStartBound = this.onDragStart.bindAsEventListener(this); + this.onDragStartBound = this.onDragStart.bindAsEventListener(this); for (var i = 0; i < eventCells.length; i++) { - eventCells[i].observe("mousedown", onDragStartBound, - false); + eventCells[i].observe("mousedown", this.onDragStartBound, false); if (eventCells[i].editable) { eventCells[i].addClassName("draggable"); } @@ -958,9 +958,8 @@ SOGoEventDragController.prototype = { this.ghostController = new SOGoEventDragGhostController(); this.ghostController.setTitle(getLabel("New Event")); - var onDragStartBound - = this.onDragStart.bindAsEventListener(this); - dayNode.observe("mousedown", onDragStartBound, false); + this.onDragStartBound = this.onDragStart.bindAsEventListener(this); + dayNode.observe("mousedown", this.onDragStartBound, false); }, onDragStart: function SEDC_onDragStart(event) { @@ -971,7 +970,6 @@ SOGoEventDragController.prototype = { || target.hasClassName("day")) || (this.eventCells && this.eventCells[0].editable))) { var utilities = SOGoEventDragUtilities(); - utilities.reset(); utilities.setEventType(this.eventType); this.pointerHandler = new SOGoEventDragPointerHandler(); @@ -1013,8 +1011,8 @@ SOGoEventDragController.prototype = { Event.observe(window, "mouseup", this.onDragStopBound); this.onDragModeBound = this.onDragMode.bindAsEventListener(this); Event.observe(document.body, "mousemove", this.onDragModeBound); + Event.stop(event); } - Event.stop(event); } return false; @@ -1214,6 +1212,7 @@ SOGoEventDragController.prototype = { this.onDragStopBound = null; this.onDragModeBound = null; + var utilities = SOGoEventDragUtilities(); if (this.dragHasStarted) { this.ghostController.hideGhosts(); this.dragHasStarted = false; @@ -1229,7 +1228,6 @@ SOGoEventDragController.prototype = { .originalCoordinates); this.updateDropCallback(this, this.eventCells, delta); } else { - var utilities = SOGoEventDragUtilities(); var eventContainerNodes = utilities.getEventContainerNodes(); var dayNode = eventContainerNodes[this.ghostController .currentCoordinates @@ -1241,6 +1239,7 @@ SOGoEventDragController.prototype = { this.ghostController.currentCoordinates); } } + utilities.reset(); Event.stop(event); },