2004-10-26 22:25:41 +04:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is OEone Calendar Code, released October 31st, 2001.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* OEone Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2001
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s): Garth Smedley <garths@oeone.com>
|
|
|
|
* Mike Potter <mikep@oeone.com>
|
|
|
|
* Chris Charabaruk <coldacid@meldstar.com>
|
|
|
|
* Colin Phillips <colinp@oeone.com>
|
2007-07-04 21:07:26 +04:00
|
|
|
* Karl Guertin <grayrest@grayrest.com>
|
2004-10-26 22:25:41 +04:00
|
|
|
* Mike Norton <xor@ivwnet.com>
|
2007-07-04 21:07:26 +04:00
|
|
|
* ArentJan Banck <ajbanck@planet.nl>
|
2004-10-26 22:25:41 +04:00
|
|
|
* Eric Belhaire <belhaire@ief.u-psud.fr>
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
2007-07-04 21:07:26 +04:00
|
|
|
/**
|
|
|
|
* Code which generates event and task (todo) preview tooltips/titletips
|
|
|
|
* when the mouse hovers over either the event list, the task list, or
|
|
|
|
* an event or task box in one of the grid views.
|
|
|
|
*
|
|
|
|
* (Portions of this code were previously in calendar.js and unifinder.js,
|
|
|
|
* some of it duplicated.)
|
|
|
|
*/
|
2004-10-26 22:25:41 +04:00
|
|
|
|
2005-06-01 17:33:25 +04:00
|
|
|
/** PUBLIC
|
2007-07-04 21:07:26 +04:00
|
|
|
*
|
|
|
|
* This changes the mouseover preview based on the start and end dates
|
|
|
|
* of an occurrence of a (one-time or recurring) calEvent or calToDo.
|
|
|
|
* Used by all grid views.
|
|
|
|
*/
|
2005-06-01 17:33:25 +04:00
|
|
|
|
2005-12-24 00:58:53 +03:00
|
|
|
function onMouseOverItem( occurrenceBoxMouseEvent )
|
2005-06-01 17:33:25 +04:00
|
|
|
{
|
|
|
|
if ("occurrence" in occurrenceBoxMouseEvent.currentTarget) {
|
|
|
|
// occurrence of repeating event or todo
|
|
|
|
var occurrence = occurrenceBoxMouseEvent.currentTarget.occurrence;
|
|
|
|
|
2005-12-24 00:58:53 +03:00
|
|
|
const toolTip = document.getElementById("itemTooltip");
|
2006-08-23 20:53:18 +04:00
|
|
|
|
|
|
|
var holderBox;
|
|
|
|
if (isEvent(occurrence)) {
|
|
|
|
holderBox = getPreviewForEvent(occurrence, occurrence.startDate, occurrence.endDate);
|
|
|
|
} else if (isToDo(occurrence)) {
|
|
|
|
holderBox = getPreviewForTask(occurrence);
|
2005-06-01 17:33:25 +04:00
|
|
|
}
|
|
|
|
if (holderBox) {
|
|
|
|
setToolTipContent(toolTip, holderBox);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2005-06-01 16:55:50 +04:00
|
|
|
/** For all instances of an event, as displayed by unifinder. **/
|
|
|
|
function onMouseOverEventTree( toolTip, mouseEvent )
|
|
|
|
{
|
|
|
|
var item = getCalendarEventFromEvent( mouseEvent );
|
|
|
|
if (isEvent(item)) {
|
|
|
|
var holderBox = getPreviewForEvent(item);
|
|
|
|
if (holderBox) {
|
|
|
|
setToolTipContent(toolTip, holderBox);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** For all instances of a task, as displayed by unifinderToDo. **/
|
|
|
|
function onMouseOverTaskTree( toolTip, mouseEvent )
|
|
|
|
{
|
|
|
|
var item = getToDoFromEvent( mouseEvent );
|
|
|
|
if (isToDo(item)) {
|
|
|
|
var holderBox = getPreviewForTask(item);
|
|
|
|
if (holderBox) {
|
|
|
|
setToolTipContent(toolTip, holderBox);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-07-04 21:07:26 +04:00
|
|
|
/**
|
|
|
|
* Removes old content from tooltip, adds new content box to tooltip,
|
|
|
|
* then resizes the tooltip to the size of the new content box.
|
|
|
|
*
|
|
|
|
* @param tooltip The tooltip to modify.
|
|
|
|
* @param holderBox The box element containing the new content.
|
|
|
|
*/
|
2005-06-01 16:55:50 +04:00
|
|
|
function setToolTipContent(toolTip, holderBox)
|
|
|
|
{
|
2007-07-04 20:55:10 +04:00
|
|
|
while (toolTip.hasChildNodes()) {
|
2005-06-01 16:55:50 +04:00
|
|
|
toolTip.removeChild( toolTip.firstChild );
|
2007-07-04 20:55:10 +04:00
|
|
|
}
|
2007-07-04 21:07:26 +04:00
|
|
|
|
2005-06-01 16:55:50 +04:00
|
|
|
toolTip.appendChild( holderBox );
|
2007-07-04 20:55:10 +04:00
|
|
|
var width = holderBox.boxObject.width;
|
|
|
|
var height = holderBox.boxObject.height;
|
|
|
|
|
|
|
|
// workaround bug 369225 (aspect: tooltip may not shrink height)
|
2007-07-04 21:07:26 +04:00
|
|
|
toolTip.sizeTo(0,0);
|
2007-07-04 20:55:10 +04:00
|
|
|
// workaround bug 369225 (aspect: tooltip height too short)
|
|
|
|
// Add top and bottom border and padding to workaround bug where bottom
|
|
|
|
// tooltip border disappears if wrapped description below header grid.
|
|
|
|
height += 1 + 2 + 2 + 1;
|
|
|
|
|
|
|
|
toolTip.sizeTo(width, height);
|
2005-06-01 16:55:50 +04:00
|
|
|
}
|
|
|
|
|
2004-10-26 22:25:41 +04:00
|
|
|
/**
|
2007-07-04 21:07:26 +04:00
|
|
|
* Called when a user hovers over a todo element and the text for the mouse over is changed.
|
|
|
|
*/
|
2004-10-26 22:25:41 +04:00
|
|
|
|
|
|
|
function getPreviewForTask( toDoItem )
|
|
|
|
{
|
|
|
|
if( toDoItem )
|
|
|
|
{
|
|
|
|
const vbox = document.createElement( "vbox" );
|
2007-07-04 20:55:10 +04:00
|
|
|
vbox.setAttribute("class", "tooltipBox");
|
|
|
|
// tooltip appears above or below pointer, so may have as little as
|
|
|
|
// one half the screen height available (avoid top going off screen).
|
|
|
|
vbox.maxHeight = Math.floor(screen.height / 2);
|
2004-10-26 22:25:41 +04:00
|
|
|
boxInitializeHeaderGrid(vbox);
|
|
|
|
|
|
|
|
var hasHeader = false;
|
|
|
|
|
|
|
|
if (toDoItem.title)
|
|
|
|
{
|
|
|
|
boxAppendLabeledText(vbox, "tooltipTitle", toDoItem.title);
|
|
|
|
hasHeader = true;
|
|
|
|
}
|
|
|
|
|
2005-05-24 23:07:19 +04:00
|
|
|
var location = toDoItem.getProperty("LOCATION");
|
|
|
|
if (location)
|
2004-10-26 22:25:41 +04:00
|
|
|
{
|
2005-05-24 23:07:19 +04:00
|
|
|
boxAppendLabeledText(vbox, "tooltipLocation", location);
|
2004-10-26 22:25:41 +04:00
|
|
|
hasHeader = true;
|
|
|
|
}
|
|
|
|
|
2005-06-16 13:23:41 +04:00
|
|
|
if (toDoItem.entryDate && toDoItem.entryDate.isValid)
|
2004-10-26 22:25:41 +04:00
|
|
|
{
|
2006-04-01 18:38:52 +04:00
|
|
|
boxAppendLabeledDateTime(vbox, "tooltipStart", toDoItem.entryDate);
|
2004-10-26 22:25:41 +04:00
|
|
|
hasHeader = true;
|
|
|
|
}
|
|
|
|
|
2006-04-01 18:38:52 +04:00
|
|
|
if (toDoItem.dueDate && toDoItem.dueDate.isValid)
|
2004-10-26 22:25:41 +04:00
|
|
|
{
|
2006-04-01 18:38:52 +04:00
|
|
|
boxAppendLabeledDateTime(vbox, "tooltipDue", toDoItem.dueDate);
|
2004-10-26 22:25:41 +04:00
|
|
|
hasHeader = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (toDoItem.priority && toDoItem.priority != 0)
|
|
|
|
{
|
2006-05-15 06:25:22 +04:00
|
|
|
var priorityInteger = parseInt(toDoItem.priority);
|
|
|
|
var priorityString;
|
|
|
|
|
|
|
|
// These cut-offs should match calendar-event-dialog.js
|
|
|
|
if (priorityInteger >= 1 && priorityInteger <= 4) {
|
2006-06-28 07:25:08 +04:00
|
|
|
priorityString = calGetString('calendar', 'highPriority'); // high priority
|
2006-05-15 06:25:22 +04:00
|
|
|
} else if (priorityInteger == 5) {
|
2006-06-28 07:25:08 +04:00
|
|
|
priorityString = calGetString('calendar', 'mediumPriority'); // medium priority
|
2006-05-15 06:25:22 +04:00
|
|
|
} else {
|
2006-06-28 07:25:08 +04:00
|
|
|
priorityString = calGetString('calendar', 'lowPriority'); // low priority
|
2006-05-15 06:25:22 +04:00
|
|
|
}
|
|
|
|
boxAppendLabeledText(vbox, "tooltipPriority", priorityString);
|
2004-10-26 22:25:41 +04:00
|
|
|
hasHeader = true;
|
|
|
|
}
|
|
|
|
|
2005-01-05 01:49:12 +03:00
|
|
|
if (toDoItem.status && toDoItem.status != "NONE")
|
2004-10-26 22:25:41 +04:00
|
|
|
{
|
|
|
|
var status = getToDoStatusString(toDoItem);
|
|
|
|
boxAppendLabeledText(vbox, "tooltipStatus", status);
|
|
|
|
hasHeader = true;
|
|
|
|
}
|
|
|
|
|
2005-01-05 01:49:12 +03:00
|
|
|
if (toDoItem.percentComplete != 0 && toDoItem.percentComplete != 100)
|
2004-10-26 22:25:41 +04:00
|
|
|
{
|
2005-01-05 01:49:12 +03:00
|
|
|
boxAppendLabeledText(vbox, "tooltipPercent", String(toDoItem.percentComplete)+"%");
|
2004-10-26 22:25:41 +04:00
|
|
|
hasHeader = true;
|
2005-01-05 01:49:12 +03:00
|
|
|
} else if (toDoItem.percentComplete == 100)
|
2004-10-26 22:25:41 +04:00
|
|
|
{
|
2005-08-15 22:05:11 +04:00
|
|
|
if (toDoItem.completedDate == null) {
|
|
|
|
boxAppendLabeledText(vbox, "tooltipPercent", "100%");
|
|
|
|
} else {
|
2006-04-01 18:38:52 +04:00
|
|
|
boxAppendLabeledDateTime(vbox, "tooltipCompleted", toDoItem.completedDate);
|
2005-08-15 22:05:11 +04:00
|
|
|
}
|
2004-10-26 22:25:41 +04:00
|
|
|
hasHeader = true;
|
|
|
|
}
|
|
|
|
|
2005-05-24 23:07:19 +04:00
|
|
|
var description = toDoItem.getProperty("DESCRIPTION");
|
2005-01-05 01:49:12 +03:00
|
|
|
if (description)
|
2004-10-26 22:25:41 +04:00
|
|
|
{
|
2007-07-04 20:55:10 +04:00
|
|
|
// display wrapped description lines like body of message below headers
|
|
|
|
if (hasHeader) {
|
|
|
|
boxAppendBodySeparator(vbox);
|
|
|
|
}
|
|
|
|
boxAppendBody(vbox, description);
|
2004-10-26 22:25:41 +04:00
|
|
|
}
|
2007-07-04 20:55:10 +04:00
|
|
|
|
2004-10-26 22:25:41 +04:00
|
|
|
return ( vbox );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2007-07-04 21:07:26 +04:00
|
|
|
* Called when mouse moves over a different, or
|
|
|
|
* when mouse moves over event in event list.
|
|
|
|
* The instStartDate is date of instance displayed at event box
|
|
|
|
* (recurring or multiday events may be displayed by more than one event box
|
|
|
|
* for different days), or null if should compute next instance from now.
|
|
|
|
*/
|
2004-10-26 22:25:41 +04:00
|
|
|
function getPreviewForEvent( event, instStartDate, instEndDate )
|
|
|
|
{
|
|
|
|
const vbox = document.createElement( "vbox" );
|
2007-07-04 20:55:10 +04:00
|
|
|
vbox.setAttribute("class", "tooltipBox");
|
|
|
|
// tooltip appears above or below pointer, so may have as little as
|
|
|
|
// one half the screen height available (avoid top going off screen).
|
|
|
|
vbox.maxHeight = Math.floor(screen.height / 2);
|
2004-10-26 22:25:41 +04:00
|
|
|
boxInitializeHeaderGrid(vbox);
|
2005-03-26 14:19:20 +03:00
|
|
|
|
2004-10-26 22:25:41 +04:00
|
|
|
if (event)
|
|
|
|
{
|
|
|
|
if (event.title)
|
|
|
|
{
|
|
|
|
boxAppendLabeledText(vbox, "tooltipTitle", event.title);
|
|
|
|
}
|
|
|
|
|
2005-03-27 18:34:46 +04:00
|
|
|
var location = event.getProperty("LOCATION");
|
|
|
|
if (location)
|
2004-10-26 22:25:41 +04:00
|
|
|
{
|
2005-03-26 14:19:20 +03:00
|
|
|
boxAppendLabeledText(vbox, "tooltipLocation", location);
|
2004-10-26 22:25:41 +04:00
|
|
|
}
|
|
|
|
|
2005-04-05 01:04:42 +04:00
|
|
|
if (event.startDate || instStartDate)
|
2004-10-26 22:25:41 +04:00
|
|
|
{
|
|
|
|
var startDate, endDate;
|
|
|
|
if (instStartDate && instEndDate) {
|
|
|
|
startDate = instStartDate;
|
|
|
|
endDate = instEndDate;
|
|
|
|
} else {
|
|
|
|
// Event may be recurrent event. If no displayed instance specified,
|
|
|
|
// use next instance, or previous instance if no next instance.
|
2006-08-23 20:53:18 +04:00
|
|
|
var occ = getCurrentNextOrPreviousRecurrence(event);
|
|
|
|
startDate = instStartDate || occ.startDate;
|
|
|
|
endDate = occ.endDate;
|
2004-10-26 22:25:41 +04:00
|
|
|
}
|
2006-04-01 18:38:52 +04:00
|
|
|
boxAppendLabeledDateTimeInterval(vbox, "tooltipDate", startDate, endDate);
|
2004-10-26 22:25:41 +04:00
|
|
|
}
|
|
|
|
|
2005-04-12 19:46:00 +04:00
|
|
|
if (event.status && event.status != "NONE")
|
2004-10-26 22:25:41 +04:00
|
|
|
{
|
|
|
|
var statusString = getEventStatusString(event);
|
|
|
|
boxAppendLabeledText(vbox, "tooltipStatus", statusString);
|
|
|
|
}
|
|
|
|
|
2005-03-27 18:34:46 +04:00
|
|
|
var description = event.getProperty("DESCRIPTION");
|
|
|
|
if (description)
|
2004-10-26 22:25:41 +04:00
|
|
|
{
|
2007-07-04 20:55:10 +04:00
|
|
|
boxAppendBodySeparator(vbox);
|
|
|
|
// display wrapped description lines, like body of message below headers
|
|
|
|
boxAppendBody(vbox, description);
|
2004-10-26 22:25:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return ( vbox );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** String for event status: (none), Tentative, Confirmed, or Cancelled **/
|
|
|
|
function getEventStatusString(calendarEvent)
|
|
|
|
{
|
|
|
|
switch( calendarEvent.status )
|
|
|
|
{
|
2005-04-12 19:46:00 +04:00
|
|
|
// Event status value keywords are specified in RFC2445sec4.8.1.11
|
|
|
|
case "TENTATIVE":
|
2006-06-28 07:25:08 +04:00
|
|
|
return calGetString('calendar', "statusTentative");
|
2005-04-12 19:46:00 +04:00
|
|
|
case "CONFIRMED":
|
2006-06-28 07:25:08 +04:00
|
|
|
return calGetString('calendar', "statusConfirmed");
|
2005-04-12 19:46:00 +04:00
|
|
|
case "CANCELLED":
|
2006-06-28 07:25:08 +04:00
|
|
|
return calGetString('calendar', "statusCancelled");
|
2004-10-26 22:25:41 +04:00
|
|
|
default:
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** String for todo status: (none), NeedsAction, InProcess, Cancelled, or Completed **/
|
|
|
|
function getToDoStatusString(iCalToDo)
|
|
|
|
{
|
|
|
|
switch( iCalToDo.status )
|
|
|
|
{
|
2005-04-12 19:46:00 +04:00
|
|
|
// Todo status keywords are specified in RFC2445sec4.8.1.11
|
|
|
|
case "NEEDS-ACTION":
|
2006-06-28 07:25:08 +04:00
|
|
|
return calGetString('calendar', "statusNeedsAction");
|
2005-04-12 19:46:00 +04:00
|
|
|
case "IN-PROCESS":
|
2006-06-28 07:25:08 +04:00
|
|
|
return calGetString('calendar', "statusInProcess");
|
2005-04-12 19:46:00 +04:00
|
|
|
case "CANCELLED":
|
2006-06-28 07:25:08 +04:00
|
|
|
return calGetString('calendar', "statusCancelled");
|
2005-04-12 19:46:00 +04:00
|
|
|
case "COMPLETED":
|
2006-06-28 07:25:08 +04:00
|
|
|
return calGetString('calendar', "statusCompleted");
|
2004-10-26 22:25:41 +04:00
|
|
|
default:
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-04 21:07:26 +04:00
|
|
|
/**
|
|
|
|
* PRIVATE: Append a separator, a thin space between header and body.
|
|
|
|
*
|
|
|
|
* @param vbox box to which to append separator.
|
|
|
|
*/
|
2007-07-04 20:55:10 +04:00
|
|
|
function boxAppendBodySeparator(vbox) {
|
|
|
|
const separator = document.createElement("separator");
|
|
|
|
separator.setAttribute("class", "tooltipBodySeparator");
|
|
|
|
vbox.appendChild(separator);
|
|
|
|
}
|
|
|
|
|
2007-07-04 21:07:26 +04:00
|
|
|
/**
|
|
|
|
* PRIVATE: Append description to box for body text. Text may contain
|
|
|
|
* paragraphs; line indent and line breaks will be preserved by CSS.
|
|
|
|
* @param box box to which to append body
|
|
|
|
* @param textString text of body
|
|
|
|
*/
|
2007-07-04 20:55:10 +04:00
|
|
|
function boxAppendBody(box, textString)
|
2004-10-26 22:25:41 +04:00
|
|
|
{
|
|
|
|
var textNode = document.createTextNode(textString);
|
|
|
|
var xulDescription = document.createElement("description");
|
|
|
|
xulDescription.setAttribute("class", "tooltipBody");
|
|
|
|
xulDescription.appendChild(textNode);
|
|
|
|
box.appendChild(xulDescription);
|
|
|
|
}
|
2007-07-04 21:07:26 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* PRIVATE: Use dateFormatter to format date and time,
|
|
|
|
* and to header grid append a row containing localized Label: date.
|
|
|
|
*/
|
2006-04-01 18:38:52 +04:00
|
|
|
function boxAppendLabeledDateTime(box, labelProperty, date)
|
2004-10-26 22:25:41 +04:00
|
|
|
{
|
2006-04-01 18:38:52 +04:00
|
|
|
var dateFormatter = Components.classes["@mozilla.org/calendar/datetime-formatter;1"]
|
|
|
|
.getService(Components.interfaces.calIDateTimeFormatter);
|
|
|
|
date = date.getInTimezone(calendarDefaultTimezone());
|
|
|
|
var formattedDateTime = dateFormatter.formatDateTime(date);
|
2004-10-26 22:25:41 +04:00
|
|
|
boxAppendLabeledText(box, labelProperty, formattedDateTime);
|
|
|
|
}
|
2007-07-04 21:07:26 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* PRIVATE: Use dateFormatter to format date and time interval,
|
|
|
|
* and to header grid append a row containing localized Label: interval.
|
|
|
|
* @param box contains header grid.
|
|
|
|
* @param labelProperty name of property for localized field label.
|
|
|
|
* @param start calDateTime of start of time interval.
|
|
|
|
* @param end calDateTime of end of time interval.
|
|
|
|
*/
|
2006-04-01 18:38:52 +04:00
|
|
|
function boxAppendLabeledDateTimeInterval(box, labelProperty, start, end)
|
2004-10-26 22:25:41 +04:00
|
|
|
{
|
2006-04-01 18:38:52 +04:00
|
|
|
var dateFormatter = Components.classes["@mozilla.org/calendar/datetime-formatter;1"]
|
|
|
|
.getService(Components.interfaces.calIDateTimeFormatter);
|
|
|
|
var startString = new Object();
|
|
|
|
var endString = new Object();
|
2006-08-23 20:53:18 +04:00
|
|
|
start = start.getInTimezone(calendarDefaultTimezone());
|
|
|
|
end = end.getInTimezone(calendarDefaultTimezone());
|
2006-04-01 18:38:52 +04:00
|
|
|
dateFormatter.formatInterval(start, end, startString, endString);
|
2006-08-23 20:53:18 +04:00
|
|
|
if (endString.value != "") {
|
|
|
|
boxAppendLabeledText(box, labelProperty, startString.value + ' - ' + endString.value);
|
|
|
|
} else {
|
|
|
|
boxAppendLabeledText(box, labelProperty, startString.value);
|
|
|
|
}
|
2004-10-26 22:25:41 +04:00
|
|
|
}
|
|
|
|
|
2007-07-04 21:07:26 +04:00
|
|
|
/**
|
|
|
|
* PRIVATE: create empty 2-column grid for header fields,
|
|
|
|
* and append it to box.
|
|
|
|
*/
|
2004-10-26 22:25:41 +04:00
|
|
|
function boxInitializeHeaderGrid(box)
|
|
|
|
{
|
|
|
|
var grid = document.createElement("grid");
|
2007-07-04 20:55:10 +04:00
|
|
|
grid.setAttribute("class", "tooltipHeaderGrid");
|
2004-10-26 22:25:41 +04:00
|
|
|
var rows;
|
|
|
|
{
|
|
|
|
var columns = document.createElement("columns");
|
|
|
|
{
|
2007-07-04 20:55:10 +04:00
|
|
|
var labelColumn = document.createElement("column");
|
|
|
|
labelColumn.setAttribute("class", "tooltipLabelColumn");
|
|
|
|
columns.appendChild(labelColumn);
|
|
|
|
var valueColumn = document.createElement("column");
|
|
|
|
valueColumn.setAttribute("class", "tooltipValueColumn");
|
|
|
|
columns.appendChild(valueColumn);
|
2004-10-26 22:25:41 +04:00
|
|
|
}
|
|
|
|
grid.appendChild(columns);
|
|
|
|
rows = document.createElement("rows");
|
|
|
|
grid.appendChild(rows);
|
|
|
|
}
|
|
|
|
box.appendChild(grid);
|
|
|
|
}
|
|
|
|
|
2007-07-04 21:07:26 +04:00
|
|
|
/**
|
|
|
|
* PRIVATE: To headers grid, append a row containing Label: value,
|
|
|
|
* where label is localized text for labelProperty.
|
|
|
|
* @param box box containing headers grid
|
|
|
|
* @param labelProperty name of property for localized name of header
|
|
|
|
* @param textString value of header field.
|
|
|
|
*/
|
2004-10-26 22:25:41 +04:00
|
|
|
function boxAppendLabeledText(box, labelProperty, textString)
|
|
|
|
{
|
2006-06-28 07:25:08 +04:00
|
|
|
var labelText = calGetString('calendar', labelProperty);
|
2004-10-26 22:25:41 +04:00
|
|
|
var rows = box.getElementsByTagName("rows")[0];
|
|
|
|
{
|
|
|
|
var row = document.createElement("row");
|
|
|
|
{
|
|
|
|
row.appendChild(createTooltipHeaderLabel(labelText));
|
|
|
|
row.appendChild(createTooltipHeaderDescription(textString));
|
|
|
|
}
|
|
|
|
rows.appendChild(row);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-04 20:55:10 +04:00
|
|
|
/** PRIVATE: create element for field label (for header grid). **/
|
2004-10-26 22:25:41 +04:00
|
|
|
function createTooltipHeaderLabel(text)
|
|
|
|
{
|
|
|
|
var label = document.createElement("label");
|
|
|
|
label.setAttribute("class", "tooltipHeaderLabel");
|
|
|
|
label.appendChild(document.createTextNode(text));
|
|
|
|
return label;
|
|
|
|
}
|
|
|
|
|
2007-07-04 20:55:10 +04:00
|
|
|
/** PRIVATE: create element for field value (for header grid). **/
|
2004-10-26 22:25:41 +04:00
|
|
|
function createTooltipHeaderDescription(text)
|
|
|
|
{
|
|
|
|
var label = document.createElement("description");
|
|
|
|
label.setAttribute("class", "tooltipHeaderDescription");
|
|
|
|
label.appendChild(document.createTextNode(text));
|
|
|
|
return label;
|
|
|
|
}
|
2007-02-13 05:46:12 +03:00
|
|
|
|
2007-07-04 21:07:26 +04:00
|
|
|
/**
|
2007-11-15 23:28:54 +03:00
|
|
|
* If now is during an occurrence, return the occurrence.
|
|
|
|
* Else if now is before an occurrence, return the next occurrence.
|
|
|
|
* Otherwise return the previous occurrence.
|
2007-07-04 21:07:26 +04:00
|
|
|
*/
|
2007-02-13 05:46:12 +03:00
|
|
|
function getCurrentNextOrPreviousRecurrence(calendarEvent)
|
|
|
|
{
|
|
|
|
if (!calendarEvent.recurrenceInfo) {
|
|
|
|
return calendarEvent;
|
|
|
|
}
|
|
|
|
|
|
|
|
var dur = calendarEvent.duration.clone();
|
|
|
|
dur.isNegative = true;
|
|
|
|
|
|
|
|
// To find current event when now is during event, look for occurrence
|
|
|
|
// starting duration ago.
|
|
|
|
var probeTime = now();
|
|
|
|
probeTime.addDuration(dur);
|
|
|
|
|
|
|
|
var occ = calendarEvent.recurrenceInfo.getNextOccurrence(probeTime);
|
|
|
|
|
|
|
|
if (!occ) {
|
|
|
|
var occs = calendarEvent.recurrenceInfo.getOccurrences(calendarEvent.startDate, probeTime, 0, {});
|
|
|
|
occ = occs[occs.length -1];
|
|
|
|
}
|
|
|
|
return occ;
|
|
|
|
}
|