Bug 303570 Fix regression from previous patch that broke mouseover previews. patch by gekacheka r=jminta

This commit is contained in:
jminta%gmail.com 2005-08-23 01:19:57 +00:00
Родитель 316d94d882
Коммит 1c09f673ce
2 изменённых файлов: 35 добавлений и 45 удалений

Просмотреть файл

@ -600,51 +600,6 @@ CalendarEventDataSource.prototype.orderRawEventsByDate = function calEvent_order
return( getCurrentNextOrPreviousRecurrence( eventA ).getTime() - getCurrentNextOrPreviousRecurrence( eventB ).getTime() );
}
/** If now is during an occurrence, return the ocurrence.
Else if now is before an ocurrence, return the next ocurrence.
Otherwise return the previous ocurrence. **/
function getCurrentNextOrPreviousRecurrence( calendarEvent )
{
var isValid = false;
var eventStartDate;
if( calendarEvent.recur )
{
var now = new Date();
var result = new Object();
var dur = calendarEvent.endDate.jsDate - calendarEvent.startDate.jsDate;
// To find current event when now is during event, look for occurrence
// starting duration ago.
var probeTime = now.getTime() - dur;
isValid = calendarEvent.getNextRecurrence( probeTime, result );
if( isValid )
{
eventStartDate = new Date( result.value );
}
else
{
isValid = calendarEvent.getPreviousOccurrence( probeTime, result );
if (isValid)
{
eventStartDate = new Date( result.value );
}
}
}
if( !isValid )
{
eventStartDate = new Date( calendarEvent.startDate.jsDate );
}
return eventStartDate;
}
/******************************************************************************************************
******************************************************************************************************

Просмотреть файл

@ -137,6 +137,41 @@ function isToDo(aObject)
return aObject instanceof Components.interfaces.calITodo;
}
/** If now is during an occurrence, return the ocurrence.
Else if now is before an ocurrence, return the next ocurrence.
Otherwise return the previous ocurrence. **/
function getCurrentNextOrPreviousRecurrence(calendarEvent)
{
var isValid = false;
var eventStartDate;
if (calendarEvent.recur) {
var now = new Date();
var result = new Object();
var dur = calendarEvent.endDate.jsDate - calendarEvent.startDate.jsDate;
// To find current event when now is during event, look for occurrence
// starting duration ago.
var probeTime = now.getTime() - dur;
isValid = calendarEvent.getNextRecurrence(probeTime, result);
if (isValid) {
eventStartDate = new Date(result.value);
} else {
isValid = calendarEvent.getPreviousOccurrence(probeTime, result);
if (isValid) {
eventStartDate = new Date(result.value);
}
}
}
if (!isValid) {
eventStartDate = new Date( calendarEvent.startDate.jsDate );
}
return eventStartDate;
}
//
// timezone pref bits
// XXX is this really the function we want here?