зеркало из https://github.com/mozilla/pjs.git
Make multiday events work for all views.
bug 278423, r=stuart. npotb
This commit is contained in:
Родитель
5d558139a0
Коммит
214bba8589
|
@ -101,8 +101,6 @@ var gDisplayToDoInViewChecked ;
|
|||
// DAY VIEW VARIABLES
|
||||
var kDayViewHourLeftStart = 105;
|
||||
|
||||
var kWeekViewHourHeight = 50;
|
||||
var kWeekViewHourHeightDifference = 2;
|
||||
var kDaysInWeek = 7;
|
||||
|
||||
const kMAX_NUMBER_OF_DOTS_IN_MONTH_VIEW = "8"; //the maximum number of dots that fit in the month view
|
||||
|
@ -766,7 +764,7 @@ function jsDateToDateTime(date)
|
|||
{
|
||||
var newDate = createDateTime();
|
||||
newDate.jsDate = date;
|
||||
dump ("date: " + date + " newDate: " + newDate + " newDate.jsDate: "+ newDate.jsDate + "\n");
|
||||
debug ("date: " + date + " newDate: " + newDate + " newDate.jsDate: "+ newDate.jsDate + "\n");
|
||||
return newDate;
|
||||
}
|
||||
|
||||
|
|
|
@ -690,6 +690,69 @@ CalendarView.prototype.refresh = function calView_refresh( ShowEvent )
|
|||
this.refreshEvents()
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Create eventboxes. Calls aInteralFunction for every day the occurence
|
||||
* spans.
|
||||
* prototype: aInteralFunction(aItemOccurrence, aStartDate, aEndDate);
|
||||
* Doesn't check if the parts fall withing the view. This is up to
|
||||
* the internal function
|
||||
*/
|
||||
|
||||
CalendarView.prototype.displayTimezone = "/mozilla.org/20050126_1/Europe/Amsterdam";
|
||||
CalendarView.prototype.createEventBox = function(aItemOccurrence, aInteralFunction )
|
||||
{
|
||||
var startDate;
|
||||
var origEndDate;
|
||||
|
||||
if ("displayTimezone" in this) {
|
||||
startDate = aItemOccurrence.occurrenceStartDate.getInTimezone(this.displayTimezone).clone();
|
||||
origEndDate = aItemOccurrence.occurrenceEndDate.getInTimezone(this.displayTimezone).clone();
|
||||
} else {
|
||||
// Copy the values from jsDate. jsDate is in de users timezone
|
||||
// It's a hack, but it kind of works. It doesn't set the right
|
||||
// timezone info for the date, but that's not a real problem.
|
||||
startDate = aItemOccurrence.occurrenceStartDate.clone();
|
||||
startDate.year = startDate.jsDate.getFullYear();
|
||||
startDate.month = startDate.jsDate.getMonth();
|
||||
startDate.day = startDate.jsDate.getDate();
|
||||
startDate.hour = startDate.jsDate.getHours();
|
||||
startDate.minute = startDate.jsDate.getMinutes();
|
||||
startDate.second = startDate.jsDate.getSeconds();
|
||||
startDate.normalize();
|
||||
|
||||
origEndDate = aItemOccurrence.occurrenceEndDate.clone();
|
||||
origEndDate.year = origEndDate.jsDate.getFullYear();
|
||||
origEndDate.month = origEndDate.jsDate.getMonth();
|
||||
origEndDate.day = origEndDate.jsDate.getDate();
|
||||
origEndDate.hour = origEndDate.jsDate.getHours();
|
||||
origEndDate.minute = origEndDate.jsDate.getMinutes();
|
||||
origEndDate.second = origEndDate.jsDate.getSeconds();
|
||||
origEndDate.normalize();
|
||||
}
|
||||
|
||||
var endDate = startDate.clone();
|
||||
endDate.hour = 23;
|
||||
endDate.minute = 59;
|
||||
endDate.second = 59;
|
||||
endDate.normalize();
|
||||
while (endDate.compare(origEndDate) < 0) {
|
||||
aInteralFunction(aItemOccurrence, startDate, endDate);
|
||||
|
||||
startDate.day = startDate.day + 1;
|
||||
startDate.hour = 0;
|
||||
startDate.minute = 0;
|
||||
startDate.second = 0;
|
||||
startDate.normalize();
|
||||
|
||||
endDate.day = endDate.day + 1;
|
||||
endDate.normalize();
|
||||
}
|
||||
aInteralFunction(aItemOccurrence, startDate, origEndDate);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* PUBLIC
|
||||
* Set classes on a eventbox
|
||||
|
|
|
@ -112,32 +112,32 @@ DayView.prototype.refreshEvents = function()
|
|||
this.removeElementsByAttribute("eventbox", "dayview");
|
||||
|
||||
// Figure out the start and end days for the week we're currently viewing
|
||||
var startDate = new Date(this.calendarWindow.getSelectedDate());
|
||||
var endDate = new Date(startDate);
|
||||
endDate.setDate(endDate.getDate() + 1);
|
||||
endDate.setSeconds(endDate.getSeconds() - 1);
|
||||
this.displayStartDate = new Date(this.calendarWindow.getSelectedDate());
|
||||
this.displayEndDate = new Date(this.displayStartDate );
|
||||
this.displayEndDate.setDate(this.displayEndDate.getDate() + 1);
|
||||
this.displayEndDate.setSeconds(this.displayEndDate.getSeconds() - 1);
|
||||
|
||||
// Save this off so we can get it again in onGetResult below
|
||||
var savedThis = this;
|
||||
var eventController = this;
|
||||
var getListener = {
|
||||
onOperationComplete: function(aCalendar, aStatus, aOperationType, aId, aDetail) {
|
||||
dump("onOperationComplete\n");
|
||||
},
|
||||
onGetResult: function(aCalendar, aStatus, aItemType, aDetail, aCount, aItems) {
|
||||
for (var i = 0; i < aCount; ++i) {
|
||||
var eventBox = savedThis.createEventBox(aItems[i]);
|
||||
dump("Adding eventBox " + eventBox + "\n");
|
||||
document.getElementById("day-view-content-board").appendChild(eventBox);
|
||||
eventController.createEventBox(aItems[i],
|
||||
function(a1, a2, a3) { eventController.createEventBoxInternal(a1, a2, a3); } );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var ccalendar = getCalendar(); // XXX Should get the composite calendar here
|
||||
|
||||
dump("Fetching events from " + startDate.toString() + " to " + endDate.toString() + "\n");
|
||||
dump("Fetching events from " + this.displayStartDate.toString() + " to " + this.displayEndDate.toString() + "\n");
|
||||
|
||||
ccalendar.getItems(ccalendar.ITEM_FILTER_TYPE_EVENT | ccalendar.ITEM_FILTER_CLASS_OCCURRENCES,
|
||||
0, jsDateToDateTime(startDate), jsDateToDateTime(endDate), getListener);
|
||||
0, jsDateToDateTime(this.displayStartDate),
|
||||
jsDateToDateTime(this.displayEndDate), getListener);
|
||||
|
||||
return;
|
||||
|
||||
|
@ -350,12 +350,26 @@ DayView.prototype.createAllDayEventBox = function dayview_createAllDayEventBox(
|
|||
*
|
||||
* This creates an event box for the day view
|
||||
*/
|
||||
DayView.prototype.createEventBox = function(itemOccurrence)
|
||||
DayView.prototype.createEventBoxInternal = function(itemOccurrence, startDate, endDate)
|
||||
{
|
||||
var calEvent = itemOccurrence.item.QueryInterface(Components.interfaces.calIEvent);
|
||||
|
||||
var startDate = itemOccurrence.occurrenceStartDate;
|
||||
var endDate = itemOccurrence.occurrenceEndDate;
|
||||
// XXX Centralize this next checks
|
||||
// Check if the event is within the bounds of events to be displayed.
|
||||
if ((endDate.jsDate < this.displayStartDate) ||
|
||||
(startDate.jsDate > this.displayEndDate))
|
||||
return;
|
||||
|
||||
// XXX Should this really be done? better would be to adjust the
|
||||
// display boundaries
|
||||
if (startDate.jsDate < this.displayStartDate)
|
||||
startDate.jsDate = this.displayStartDate;
|
||||
|
||||
if (endDate.jsDate > this.displayEndDate)
|
||||
endDate.jsDate = this.displayEndDate;
|
||||
|
||||
startDate.normalize();
|
||||
endDate.normalize();
|
||||
|
||||
/*
|
||||
if (calEvent.isAllDay) {
|
||||
|
@ -441,7 +455,8 @@ DayView.prototype.createEventBox = function(itemOccurrence)
|
|||
|
||||
eventBox.appendChild( eventTitleLabel );
|
||||
eventBox.appendChild( eventDescription );
|
||||
return eventBox;
|
||||
|
||||
document.getElementById("day-view-content-board").appendChild(eventBox);
|
||||
}
|
||||
|
||||
/** PUBLIC
|
||||
|
@ -629,7 +644,7 @@ DayView.prototype.selectBoxForEvent = function dayview_selectBoxForEvent( calend
|
|||
*/
|
||||
DayView.prototype.clearSelectedEvent = function dayview_clearSelectedEvent( )
|
||||
{
|
||||
debug("clearSelectedEvent");
|
||||
daydebug("clearSelectedEvent");
|
||||
this.removeAttributeFromElements("eventselected", "true");
|
||||
}
|
||||
|
||||
|
@ -662,7 +677,7 @@ DayView.prototype.hiliteTodaysDate = function dayview_hiliteTodaysDate( )
|
|||
}
|
||||
|
||||
|
||||
function debug( Text )
|
||||
function daydebug( Text )
|
||||
{
|
||||
dump( "dayView.js: "+ Text +"\n");
|
||||
}
|
||||
|
|
|
@ -228,24 +228,15 @@ MonthView.prototype.refreshEvents = function()
|
|||
endDate.setSeconds(endDate.getSeconds() - 1);
|
||||
|
||||
// Save this off so we can get it again in onGetResult below
|
||||
var savedThis = this;
|
||||
var eventController = this;
|
||||
var getListener = {
|
||||
onOperationComplete: function(aCalendar, aStatus, aOperationType, aId, aDetail) {
|
||||
dump("onOperationComplete\n");
|
||||
},
|
||||
onGetResult: function(aCalendar, aStatus, aItemType, aDetail, aCount, aItems) {
|
||||
for (var i = 0; i < aCount; ++i) {
|
||||
dump(aItems[i] + "\n");
|
||||
var itemOccurrence = aItems[i];
|
||||
|
||||
var calEvent = itemOccurrence.item.QueryInterface(Components.interfaces.calIEvent);
|
||||
var startDate = new Date(calEvent.startDate.jsDate);
|
||||
dayBoxItem = savedThis.dayBoxItemArray[savedThis.indexOfDate(startDate)];
|
||||
|
||||
// XXX need to look at the number of children here and determine what we're supposed to do
|
||||
var eventBox = savedThis.createEventBox(itemOccurrence);
|
||||
dayBoxItem.appendChild(eventBox);
|
||||
|
||||
eventController.createEventBox(aItems[i],
|
||||
function(a1, a2, a3) { eventController.createEventBoxInternal(a1, a2, a3); } );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -258,7 +249,7 @@ MonthView.prototype.refreshEvents = function()
|
|||
0, jsDateToDateTime(startDate), jsDateToDateTime(endDate), getListener);
|
||||
}
|
||||
|
||||
MonthView.prototype.createEventBox = function(itemOccurrence)
|
||||
MonthView.prototype.createEventBoxInternal = function(itemOccurrence, startDate, endDate)
|
||||
{
|
||||
var calEvent = itemOccurrence.item.QueryInterface(Components.interfaces.calIEvent);
|
||||
|
||||
|
@ -309,9 +300,11 @@ MonthView.prototype.createEventBox = function(itemOccurrence)
|
|||
|
||||
eventBox.appendChild(eventBoxText);
|
||||
|
||||
return eventBox;
|
||||
|
||||
// XXX need to look at the number of children here and determine what we're supposed to do
|
||||
dayBoxItem = this.dayBoxItemArray[this.indexOfDate(startDate.jsDate)];
|
||||
dayBoxItem.appendChild(eventBox);
|
||||
|
||||
/*
|
||||
|
||||
// Set the numberOfEventsToShow
|
||||
if( this.numberOfEventsToShow == false )
|
||||
|
@ -468,6 +461,7 @@ MonthView.prototype.createEventBox = function(itemOccurrence)
|
|||
this.selectBoxForEvent( calendarEventDisplay.event );
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
@ -976,7 +970,7 @@ MonthView.prototype.doubleClickDay = function monthView_doubleClickDay( event )
|
|||
|
||||
MonthView.prototype.clearSelectedEvent = function monthView_clearSelectedEvent( )
|
||||
{
|
||||
debug("clearSelectedEvent");
|
||||
monthdebug("clearSelectedEvent");
|
||||
this.removeAttributeFromElements("eventselected","true");
|
||||
}
|
||||
|
||||
|
@ -1201,7 +1195,7 @@ var monthViewEventDragAndDropObserver = {
|
|||
}
|
||||
};
|
||||
|
||||
function debug( Text )
|
||||
function monthdebug( Text )
|
||||
{
|
||||
dump( "monthView.js: "+ Text +"\n");
|
||||
|
||||
|
|
|
@ -230,7 +230,7 @@ MultiweekView.prototype.refreshEvents = function multiweekView_refreshEvents( )
|
|||
this.removeElementsByAttribute("eventbox", "multiweekview");
|
||||
|
||||
//Save this so we can use it again in onGetResult below in getListener
|
||||
var savedThis = this;
|
||||
var eventController = this;
|
||||
|
||||
//Start of our getListener callback
|
||||
var getListener =
|
||||
|
@ -250,10 +250,8 @@ MultiweekView.prototype.refreshEvents = function multiweekView_refreshEvents( )
|
|||
var calEvent = itemOccurrence.item.QueryInterface(Components.interfaces.calIEvent);
|
||||
dump("calEvent.title:" + calEvent.title + "\n");
|
||||
|
||||
var DisplayDate = new Date(itemOccurrence.occurrenceStartDate.jsDate);
|
||||
dayBoxItem = savedThis.dayBoxItemArray[savedThis.indexOfDate(DisplayDate)];
|
||||
var eventbox = savedThis.createEventBox(itemOccurrence);
|
||||
dayBoxItem.appendChild(eventbox);
|
||||
eventController.createEventBox(itemOccurrence,
|
||||
function(a1, a2, a3) { eventController.createEventBoxInternal(a1, a2, a3); } );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -266,9 +264,15 @@ MultiweekView.prototype.refreshEvents = function multiweekView_refreshEvents( )
|
|||
|
||||
}
|
||||
// JT: Liberal code reuse (ie. Cut and Paste)
|
||||
// Create an eventbox and return it. Expects an ItemOccurence
|
||||
MultiweekView.prototype.createEventBox = function multiweekView_createEventBox(itemOccurrence)
|
||||
// Create an eventbox. Expects an ItemOccurence
|
||||
MultiweekView.prototype.createEventBoxInternal = function multiweekView_createEventBox(itemOccurrence, startDate, endDate)
|
||||
{
|
||||
var DisplayDate = new Date(startDate.jsDate);
|
||||
dayBoxItem = this.dayBoxItemArray[this.indexOfDate(DisplayDate)];
|
||||
// Check if the day is visible
|
||||
if (!dayBoxItem)
|
||||
return;
|
||||
|
||||
var calEvent = itemOccurrence.item.QueryInterface(Components.interfaces.calIEvent);
|
||||
// Make a box item to hold the event
|
||||
eventBox = document.createElement( "box" );
|
||||
|
@ -312,8 +316,7 @@ MultiweekView.prototype.createEventBox = function multiweekView_createEventBox(i
|
|||
// add the text to the event box
|
||||
eventBox.appendChild( eventBoxText );
|
||||
|
||||
return eventBox;
|
||||
|
||||
dayBoxItem.appendChild(eventBox);
|
||||
}
|
||||
|
||||
|
||||
|
@ -793,7 +796,7 @@ MultiweekView.prototype.doubleClickDay = function multiweekView_doubleClickDay(
|
|||
|
||||
MultiweekView.prototype.clearSelectedEvent = function multiweekView_clearSelectedEvent( )
|
||||
{
|
||||
debug("clearSelectedEvent");
|
||||
multiweekdebug("clearSelectedEvent");
|
||||
|
||||
this.removeAttributeFromElements("eventselected", "true");
|
||||
}
|
||||
|
@ -931,7 +934,7 @@ MultiweekView.prototype.setFictitiousEvents = function multiweekView_setFictitio
|
|||
}
|
||||
|
||||
|
||||
function debug( Text )
|
||||
function multiweekdebug( Text )
|
||||
{
|
||||
dump( "multiweekView.js: "+ Text +"\n");
|
||||
|
||||
|
|
|
@ -105,6 +105,7 @@ function prepareCalendarToDoUnifinder()
|
|||
|
||||
function finishCalendarToDoUnifinder()
|
||||
{
|
||||
var calendar = createCalendar();
|
||||
calendar.removeObserver(unifinderToDoDataSourceObserver);
|
||||
}
|
||||
|
||||
|
|
|
@ -141,14 +141,15 @@ WeekView.prototype.refreshEvents = function()
|
|||
this.displayEndDate.setSeconds(this.displayEndDate.getSeconds() - 1);
|
||||
|
||||
// Save this off so we can get it again in onGetResult below
|
||||
var savedThis = this;
|
||||
var eventController = this;
|
||||
var getListener = {
|
||||
onOperationComplete: function(aCalendar, aStatus, aOperationType, aId, aDetail) {
|
||||
debug("onOperationComplete\n");
|
||||
},
|
||||
onGetResult: function(aCalendar, aStatus, aItemType, aDetail, aCount, aItems) {
|
||||
for (var i = 0; i < aCount; ++i) {
|
||||
savedThis.createEventBox(aItems[i]);
|
||||
eventController.createEventBox(aItems[i],
|
||||
function(a1, a2, a3) { eventController.createEventBoxInternal(a1, a2, a3); } );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -323,62 +324,10 @@ WeekView.prototype.refreshEvents = function()
|
|||
*/
|
||||
}
|
||||
|
||||
//WeekView.prototype.displayTimezone = "/mozilla.org/20050126_1/Europe/Amsterdam";
|
||||
|
||||
/** PRIVATE
|
||||
*
|
||||
* This creates an event box for the week view
|
||||
*/
|
||||
WeekView.prototype.createEventBox = function ( itemOccurrence )
|
||||
{
|
||||
var startDate;
|
||||
var origEndDate;
|
||||
|
||||
if ("displayTimezone" in this) {
|
||||
startDate = itemOccurrence.occurrenceStartDate.getInTimezone(this.displayTimezone).clone();
|
||||
origEndDate = itemOccurrence.occurrenceEndDate.getInTimezone(this.displayTimezone).clone();
|
||||
} else {
|
||||
// Copy the values from jsDate. jsDate is in de users timezone
|
||||
// It's a hack, but it kind of works. It doesn't set the right
|
||||
// timezone info for the date, but that's not a real problem.
|
||||
startDate = itemOccurrence.occurrenceStartDate.clone();
|
||||
startDate.year = startDate.jsDate.getFullYear();
|
||||
startDate.month = startDate.jsDate.getMonth();
|
||||
startDate.day = startDate.jsDate.getDate();
|
||||
startDate.hour = startDate.jsDate.getHours();
|
||||
startDate.minute = startDate.jsDate.getMinutes();
|
||||
startDate.second = startDate.jsDate.getSeconds();
|
||||
startDate.normalize();
|
||||
|
||||
origEndDate = itemOccurrence.occurrenceEndDate.clone();
|
||||
origEndDate.year = origEndDate.jsDate.getFullYear();
|
||||
origEndDate.month = origEndDate.jsDate.getMonth();
|
||||
origEndDate.day = origEndDate.jsDate.getDate();
|
||||
origEndDate.hour = origEndDate.jsDate.getHours();
|
||||
origEndDate.minute = origEndDate.jsDate.getMinutes();
|
||||
origEndDate.second = origEndDate.jsDate.getSeconds();
|
||||
origEndDate.normalize();
|
||||
}
|
||||
|
||||
var endDate = startDate.clone();
|
||||
endDate.hour = 23;
|
||||
endDate.minute = 59;
|
||||
endDate.second = 59;
|
||||
endDate.normalize();
|
||||
while (endDate.compare(origEndDate) < 0) {
|
||||
this.createEventBoxInternal(itemOccurrence, startDate, endDate);
|
||||
|
||||
startDate.day = startDate.day + 1;
|
||||
startDate.hour = 0;
|
||||
startDate.minute = 0;
|
||||
startDate.second = 0;
|
||||
startDate.normalize();
|
||||
|
||||
endDate.day = endDate.day + 1;
|
||||
endDate.normalize();
|
||||
}
|
||||
this.createEventBoxInternal(itemOccurrence, startDate, origEndDate);
|
||||
}
|
||||
|
||||
WeekView.prototype.createEventBoxInternal = function (itemOccurrence, startDate, endDate)
|
||||
{
|
||||
|
@ -403,6 +352,8 @@ WeekView.prototype.createEventBoxInternal = function (itemOccurrence, startDate,
|
|||
endDate.hour = this.highestEndHour;
|
||||
endDate.normalize();
|
||||
}
|
||||
dump(startDate+" "+endDate+"\n");
|
||||
dump(this.displayEndDate+"\n");
|
||||
|
||||
/*
|
||||
if (calEvent.isAllDay) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче