2001-11-07 20:29:04 +00:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2001-11-07 19:18:46 +00:00
|
|
|
* 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.
|
|
|
|
*
|
2001-11-07 20:29:04 +00:00
|
|
|
* The Original Code is OEone Calendar Code, released October 31st, 2001.
|
2001-11-07 19:18:46 +00:00
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* OEone Corporation.
|
2001-11-07 20:29:04 +00:00
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2001
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
2001-11-07 19:18:46 +00:00
|
|
|
*
|
2001-11-07 20:29:04 +00:00
|
|
|
* Contributor(s): Garth Smedley <garths@oeone.com>
|
|
|
|
* Mike Potter <mikep@oeone.com>
|
|
|
|
* Colin Phillips <colinp@oeone.com>
|
2002-03-28 15:03:39 +00:00
|
|
|
* Karl Guertin <grayrest@grayrest.com>
|
2002-04-05 18:52:57 +00:00
|
|
|
* Mike Norton <xor@ivwnet.com>
|
2001-11-07 19:18:46 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
2001-11-07 20:29:04 +00:00
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2001-11-07 19:18:46 +00:00
|
|
|
|
|
|
|
/***** calendar
|
|
|
|
* AUTHOR
|
|
|
|
* Garth Smedley
|
|
|
|
*
|
|
|
|
* REQUIRED INCLUDES
|
|
|
|
* <script type="application/x-javascript" src="chrome://global/content/strres.js"/>
|
|
|
|
* <script type="application/x-javascript" src="chrome://calendar/content/calendarEvent.js"/>
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Code for the oe-calendar.
|
|
|
|
*
|
|
|
|
* What is in this file:
|
|
|
|
* - Global variables and functions - Called directly from the XUL
|
|
|
|
* - Several classes:
|
|
|
|
* CalendarWindow - Owns the 3 subviews, keeps track of the selection etc.
|
|
|
|
* CalendarView - Super class for three views
|
|
|
|
* MonthView
|
|
|
|
* WeekView
|
|
|
|
* DayView
|
|
|
|
* - Unifinder functions - fill in content of the unifinder.
|
|
|
|
*
|
|
|
|
* IMPLEMENTATION NOTES
|
|
|
|
*
|
|
|
|
* WARNING - We currently use CalendarEvent objects in what will be an unsafe way
|
|
|
|
* when the datasource changes. We assume that there is exactly one instance of CalendarEvent for
|
|
|
|
* each unique event. We will probably have to switch to using the calendar event id
|
|
|
|
* property instead of the object. G.S. April 2001.
|
|
|
|
**********
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------
|
|
|
|
* G L O B A L V A R I A B L E S
|
|
|
|
*/
|
|
|
|
|
2002-05-06 19:11:19 +00:00
|
|
|
//the next line needs XX-DATE-XY but last X instead of Y
|
2002-05-23 14:08:00 +00:00
|
|
|
var gDateMade = "2002052213-cal"
|
2002-04-02 19:50:52 +00:00
|
|
|
|
2001-11-07 19:18:46 +00:00
|
|
|
// turn on debuging
|
|
|
|
var gDebugCalendar = false;
|
|
|
|
|
2001-12-20 15:53:03 +00:00
|
|
|
// ICal Library
|
|
|
|
var gICalLib = null;
|
|
|
|
|
|
|
|
// calendar event data source see penCalendarEvent.js
|
2001-11-07 19:18:46 +00:00
|
|
|
var gEventSource = null;
|
|
|
|
|
|
|
|
// single global instance of CalendarWindow
|
|
|
|
var gCalendarWindow;
|
|
|
|
|
|
|
|
//an array of indexes to boxes for the week view
|
|
|
|
var gHeaderDateItemArray = null;
|
|
|
|
|
2002-05-06 19:11:19 +00:00
|
|
|
var gClockId;
|
|
|
|
|
2001-11-07 19:18:46 +00:00
|
|
|
// Show event details on mouseover
|
|
|
|
var showEventDetails = true;
|
|
|
|
|
|
|
|
// DAY VIEW VARIABLES
|
|
|
|
var kDayViewHourHeight = 50;
|
|
|
|
var kDayViewHourWidth = 105;
|
|
|
|
var kDayViewHourLeftStart = 105;
|
|
|
|
|
|
|
|
var kWeekViewHourHeight = 50;
|
|
|
|
var kWeekViewHourWidth = 78;
|
|
|
|
var kWeekViewItemWidth = 20;
|
|
|
|
var kWeekViewHourLeftStart = 97;
|
|
|
|
var kWeekViewHourHeightDifference = 2;
|
2002-04-19 13:44:05 +00:00
|
|
|
var kDaysInWeek = 7;
|
2001-11-07 19:18:46 +00:00
|
|
|
|
|
|
|
const kMAX_NUMBER_OF_DOTS_IN_MONTH_VIEW = "8"; //the maximum number of dots that fit in the month view
|
|
|
|
|
2002-04-03 22:14:18 +00:00
|
|
|
|
|
|
|
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
|
|
|
|
.getService(Components.interfaces.nsIPrefService);
|
|
|
|
var rootPrefNode = prefService.getBranch(null); // preferences root node
|
|
|
|
|
2001-11-07 19:18:46 +00:00
|
|
|
/*-----------------------------------------------------------------
|
|
|
|
* G L O B A L C A L E N D A R F U N C T I O N S
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called from calendar.xul window onload.
|
|
|
|
*/
|
|
|
|
|
|
|
|
function calendarInit()
|
|
|
|
{
|
2001-12-20 15:53:03 +00:00
|
|
|
// get the calendar event data source
|
2002-07-19 15:56:53 +00:00
|
|
|
gEventSource = new CalendarEventDataSource();
|
2001-11-07 19:18:46 +00:00
|
|
|
|
2001-12-20 15:53:03 +00:00
|
|
|
// get the Ical Library
|
|
|
|
gICalLib = gEventSource.getICalLib();
|
2001-11-07 19:18:46 +00:00
|
|
|
|
|
|
|
// set up the CalendarWindow instance
|
|
|
|
|
|
|
|
gCalendarWindow = new CalendarWindow( gEventSource );
|
|
|
|
|
2002-06-04 19:01:03 +00:00
|
|
|
gCalendarWindow.currentView.switchTo( gCalendarWindow.currentView );
|
|
|
|
|
|
|
|
gCalendarWindow.currentView.refresh( gCalendarWindow.currentView );
|
|
|
|
|
2002-03-05 14:18:27 +00:00
|
|
|
// set up the unifinder
|
|
|
|
|
2002-07-19 15:56:53 +00:00
|
|
|
prepareCalendarUnifinder();
|
2002-03-05 14:18:27 +00:00
|
|
|
|
2002-07-19 15:56:53 +00:00
|
|
|
prepareCalendarToDoUnifinder();
|
2002-06-27 17:59:51 +00:00
|
|
|
|
2002-07-19 15:56:53 +00:00
|
|
|
update_date();
|
2002-04-02 19:50:52 +00:00
|
|
|
|
2002-04-12 20:24:10 +00:00
|
|
|
checkForMailNews();
|
2001-11-07 19:18:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set the date and time on the clock and set up a timeout to refresh the clock when the
|
|
|
|
// next minute ticks over
|
|
|
|
|
2002-07-19 15:56:53 +00:00
|
|
|
function update_date()
|
2001-11-07 19:18:46 +00:00
|
|
|
{
|
|
|
|
// get the current time
|
|
|
|
var now = new Date();
|
|
|
|
|
|
|
|
var tomorrow = new Date( now.getFullYear(), now.getMonth(), ( now.getDate() + 1 ) );
|
|
|
|
|
|
|
|
var milliSecsTillTomorrow = tomorrow.getTime() - now.getTime();
|
|
|
|
|
|
|
|
gCalendarWindow.currentView.hiliteTodaysDate();
|
|
|
|
|
2002-07-19 15:56:53 +00:00
|
|
|
gClockId = setTimeout( "update_date()", milliSecsTillTomorrow );
|
2001-11-07 19:18:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called from calendar.xul window onunload.
|
|
|
|
*/
|
|
|
|
|
|
|
|
function calendarFinish()
|
|
|
|
{
|
2002-07-19 15:56:53 +00:00
|
|
|
finishCalendarUnifinder();
|
2002-05-06 19:11:19 +00:00
|
|
|
|
2002-07-19 15:56:53 +00:00
|
|
|
finishCalendarToDoUnifinder();
|
2002-07-02 17:07:38 +00:00
|
|
|
|
2002-07-19 15:56:53 +00:00
|
|
|
gCalendarWindow.close();
|
2001-11-07 19:18:46 +00:00
|
|
|
}
|
|
|
|
|
2002-04-03 22:14:18 +00:00
|
|
|
function launchPreferences()
|
|
|
|
{
|
2002-07-19 15:56:53 +00:00
|
|
|
goPreferences( "advancedItem", "chrome://calendar/content/pref/calendarPref.xul", "calendar" );
|
2002-04-03 22:14:18 +00:00
|
|
|
}
|
|
|
|
|
2001-11-07 19:18:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called to set up the date picker from the go to day button
|
|
|
|
*/
|
|
|
|
|
|
|
|
function prepareChooseDate()
|
|
|
|
{
|
|
|
|
// the value attribute of the datePickerPopup is the initial date shown
|
|
|
|
|
|
|
|
var datePickerPopup = document.getElementById( "oe-date-picker-popup" );
|
|
|
|
|
|
|
|
datePickerPopup.setAttribute( "value", gCalendarWindow.getSelectedDate() );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called on single click in the day view, select an event
|
|
|
|
*
|
|
|
|
* PARAMETERS
|
|
|
|
* hourNumber - 0-23 hard-coded in the XUL
|
|
|
|
* event - the click event, Not used yet
|
|
|
|
*/
|
|
|
|
|
|
|
|
function dayEventItemClick( eventBox, event )
|
|
|
|
{
|
2002-04-01 19:52:51 +00:00
|
|
|
gCalendarWindow.EventSelection.replaceSelection( eventBox.calendarEventDisplay.event );
|
2002-05-06 19:11:19 +00:00
|
|
|
|
2001-11-07 19:18:46 +00:00
|
|
|
if ( event )
|
|
|
|
{
|
|
|
|
event.stopPropagation();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called on double click in the day view, edit an existing event
|
|
|
|
* or create a new one.
|
|
|
|
*
|
|
|
|
* PARAMETERS
|
|
|
|
* hourNumber - 0-23 hard-coded in the XUL
|
|
|
|
* event - the click event, Not used yet
|
|
|
|
*/
|
|
|
|
|
|
|
|
function dayEventItemDoubleClick( eventBox, event )
|
|
|
|
{
|
2001-12-20 15:53:03 +00:00
|
|
|
editEvent( eventBox.calendarEventDisplay.event );
|
2001-11-07 19:18:46 +00:00
|
|
|
|
|
|
|
if ( event )
|
|
|
|
{
|
|
|
|
event.stopPropagation();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called on single click in the hour area in the day view
|
|
|
|
*
|
|
|
|
* PARAMETERS
|
|
|
|
* hourNumber - 0-23 hard-coded in the XUL
|
|
|
|
* event - the click event, Not used yet
|
|
|
|
*/
|
|
|
|
|
2002-04-11 19:18:30 +00:00
|
|
|
function dayViewHourClick( event )
|
2001-11-07 19:18:46 +00:00
|
|
|
{
|
2002-04-11 19:18:30 +00:00
|
|
|
gCalendarWindow.setSelectedHour( event.target.getAttribute( "hour" ) );
|
2001-11-07 19:18:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called on double click of an hour box.
|
|
|
|
*/
|
|
|
|
|
2002-04-11 19:18:30 +00:00
|
|
|
function dayViewHourDoubleClick( event )
|
2001-11-07 19:18:46 +00:00
|
|
|
{
|
|
|
|
// change the date selection to the clicked hour
|
|
|
|
|
2002-04-11 19:18:30 +00:00
|
|
|
gCalendarWindow.setSelectedHour( event.target.getAttribute( "hour" ) );
|
2001-11-07 19:18:46 +00:00
|
|
|
|
|
|
|
var startDate = gCalendarWindow.dayView.getNewEventDate();
|
2001-12-20 15:53:03 +00:00
|
|
|
newEvent( startDate );
|
2001-11-07 19:18:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called on single click in the day view, select an event
|
|
|
|
*
|
|
|
|
* PARAMETERS
|
|
|
|
* hourNumber - 0-23 hard-coded in the XUL
|
|
|
|
* event - the click event, Not used yet
|
|
|
|
*/
|
|
|
|
|
|
|
|
function weekEventItemClick( eventBox, event )
|
|
|
|
{
|
2002-04-01 19:52:51 +00:00
|
|
|
gCalendarWindow.EventSelection.replaceSelection( eventBox.calendarEventDisplay.event );
|
2002-05-06 19:11:19 +00:00
|
|
|
|
2001-11-07 19:18:46 +00:00
|
|
|
if ( event )
|
|
|
|
{
|
|
|
|
event.stopPropagation();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called on double click in the day view, edit an existing event
|
|
|
|
* or create a new one.
|
|
|
|
*
|
|
|
|
* PARAMETERS
|
|
|
|
* hourNumber - 0-23 hard-coded in the XUL
|
|
|
|
* event - the click event, Not used yet
|
|
|
|
*/
|
|
|
|
|
|
|
|
function weekEventItemDoubleClick( eventBox, event )
|
|
|
|
{
|
2001-12-20 15:53:03 +00:00
|
|
|
editEvent( eventBox.calendarEventDisplay.event );
|
2001-11-07 19:18:46 +00:00
|
|
|
|
|
|
|
if ( event )
|
|
|
|
{
|
|
|
|
event.stopPropagation();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** ( event )
|
|
|
|
* Called on single click in the hour area in the day view
|
|
|
|
*
|
|
|
|
* PARAMETERS
|
|
|
|
* hourNumber - 0-23 hard-coded in the XUL
|
|
|
|
* event - the click event, Not used yet
|
|
|
|
*/
|
|
|
|
|
2002-04-11 19:56:30 +00:00
|
|
|
function weekViewHourClick( event )
|
2001-11-07 19:18:46 +00:00
|
|
|
{
|
2002-04-11 19:56:30 +00:00
|
|
|
var dayIndex = event.target.getAttribute( "day" );
|
|
|
|
|
2001-11-07 19:18:46 +00:00
|
|
|
newDate = gHeaderDateItemArray[dayIndex].getAttribute( "date" );
|
|
|
|
|
|
|
|
gCalendarWindow.setSelectedDate( newDate );
|
|
|
|
|
2002-04-11 19:56:30 +00:00
|
|
|
gCalendarWindow.setSelectedHour( event.target.getAttribute( "hour" ) );
|
2001-11-07 19:18:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called on double click of an hour box.
|
|
|
|
*/
|
|
|
|
|
2002-04-11 19:56:30 +00:00
|
|
|
function weekViewHourDoubleClick( event )
|
2001-11-07 19:18:46 +00:00
|
|
|
{
|
2002-04-11 19:56:30 +00:00
|
|
|
var dayIndex = event.target.getAttribute( "day" );
|
|
|
|
|
2001-11-07 19:18:46 +00:00
|
|
|
newDate = gHeaderDateItemArray[dayIndex].getAttribute( "date" );
|
|
|
|
|
|
|
|
gCalendarWindow.setSelectedDate( newDate );
|
|
|
|
|
|
|
|
// change the date selection to the clicked hour
|
|
|
|
|
2002-04-11 19:56:30 +00:00
|
|
|
gCalendarWindow.setSelectedHour( event.target.getAttribute( "hour" ) );
|
2001-11-07 19:18:46 +00:00
|
|
|
|
|
|
|
var startDate = gCalendarWindow.weekView.getNewEventDate();
|
2001-12-20 15:53:03 +00:00
|
|
|
newEvent( startDate );
|
2001-11-07 19:18:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called on single click on an event box in the month view
|
|
|
|
*
|
|
|
|
* PARAMETERS
|
|
|
|
* eventBox - The XUL box clicked on
|
|
|
|
* event - the click event
|
|
|
|
*/
|
|
|
|
|
|
|
|
function monthEventBoxClickEvent( eventBox, event )
|
|
|
|
{
|
2002-04-01 19:52:51 +00:00
|
|
|
gCalendarWindow.MonthView.clickEventBox( eventBox, event );
|
|
|
|
|
|
|
|
if ( event )
|
|
|
|
{
|
|
|
|
event.stopPropagation();
|
|
|
|
}
|
2001-11-07 19:18:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called on double click on an event box in the month view,
|
|
|
|
* launches the edit dialog on the event
|
|
|
|
*
|
|
|
|
* PARAMETERS
|
|
|
|
* eventBox - The XUL box clicked on
|
|
|
|
*/
|
|
|
|
|
|
|
|
function monthEventBoxDoubleClickEvent( eventBox, event )
|
|
|
|
{
|
2002-07-19 15:56:53 +00:00
|
|
|
gCalendarWindow.monthView.clearSelectedDate();
|
2001-11-07 19:18:46 +00:00
|
|
|
|
2001-12-20 15:53:03 +00:00
|
|
|
editEvent( eventBox.calendarEventDisplay.event );
|
2001-11-07 19:18:46 +00:00
|
|
|
|
|
|
|
if ( event )
|
|
|
|
{
|
|
|
|
event.stopPropagation();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when the new event button is clicked
|
|
|
|
*/
|
|
|
|
|
|
|
|
function newEventCommand()
|
|
|
|
{
|
|
|
|
var startDate = gCalendarWindow.currentView.getNewEventDate();
|
|
|
|
|
|
|
|
|
2002-01-30 15:45:39 +00:00
|
|
|
var Minutes = Math.ceil( startDate.getMinutes() / 5 ) * 5 ;
|
2001-12-20 15:53:03 +00:00
|
|
|
|
2001-11-07 19:18:46 +00:00
|
|
|
startDate = new Date( startDate.getFullYear(),
|
|
|
|
startDate.getMonth(),
|
|
|
|
startDate.getDate(),
|
|
|
|
startDate.getHours(),
|
|
|
|
Minutes,
|
|
|
|
0);
|
2001-12-20 15:53:03 +00:00
|
|
|
newEvent( startDate );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-06-19 15:00:38 +00:00
|
|
|
/**
|
|
|
|
* Called when the new event button is clicked
|
|
|
|
*/
|
|
|
|
|
|
|
|
function newToDoCommand()
|
|
|
|
{
|
2002-06-27 17:59:51 +00:00
|
|
|
var calendarToDo = createToDo();
|
2002-06-19 15:00:38 +00:00
|
|
|
|
|
|
|
var dueDate = gCalendarWindow.currentView.getNewEventDate();
|
|
|
|
|
|
|
|
|
|
|
|
var Minutes = Math.ceil( dueDate.getMinutes() / 5 ) * 5 ;
|
|
|
|
|
|
|
|
dueDate = new Date( dueDate.getFullYear(),
|
|
|
|
dueDate.getMonth(),
|
|
|
|
dueDate.getDate(),
|
|
|
|
dueDate.getHours(),
|
|
|
|
Minutes,
|
|
|
|
0);
|
|
|
|
|
|
|
|
|
2002-06-27 17:59:51 +00:00
|
|
|
calendarToDo.due.setTime( dueDate );
|
2002-07-05 18:41:18 +00:00
|
|
|
|
|
|
|
calendarToDo.start.setTime( dueDate );
|
2002-06-19 15:00:38 +00:00
|
|
|
|
|
|
|
var args = new Object();
|
|
|
|
args.mode = "new";
|
|
|
|
args.onOk = self.addToDoDialogResponse;
|
2002-06-27 17:59:51 +00:00
|
|
|
args.calendarToDo = calendarToDo;
|
2002-06-19 15:00:38 +00:00
|
|
|
|
|
|
|
// open the dialog modally
|
|
|
|
openDialog("chrome://calendar/content/calendarToDoDialog.xul", "caEditEvent", "chrome,modal", args );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-20 15:53:03 +00:00
|
|
|
function createEvent ()
|
|
|
|
{
|
2002-07-02 17:07:38 +00:00
|
|
|
var iCalEventComponent = Components.classes["@mozilla.org/icalevent;1"].createInstance();
|
|
|
|
var iCalEvent = iCalEventComponent.QueryInterface(Components.interfaces.oeIICalEvent);
|
|
|
|
return iCalEvent;
|
2002-06-19 15:00:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function createToDo ()
|
|
|
|
{
|
2002-07-02 17:07:38 +00:00
|
|
|
var iCalToDoComponent = Components.classes["@mozilla.org/icaltodo;1"].createInstance();
|
|
|
|
var iCalToDo = iCalToDoComponent.QueryInterface(Components.interfaces.oeIICalTodo);
|
|
|
|
return iCalToDo;
|
2001-11-07 19:18:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-20 15:53:03 +00:00
|
|
|
|
2001-11-07 19:18:46 +00:00
|
|
|
/**
|
|
|
|
* Helper function to launch the event composer to create a new event.
|
|
|
|
* When the user clicks OK "addEventDialogResponse" is called
|
|
|
|
*/
|
|
|
|
|
2002-04-11 19:18:30 +00:00
|
|
|
function newEvent( startDate, endDate )
|
2001-11-07 19:18:46 +00:00
|
|
|
{
|
2002-05-06 19:27:50 +00:00
|
|
|
// create a new event to be edited and added
|
|
|
|
var calendarEvent = createEvent();
|
2001-11-07 19:18:46 +00:00
|
|
|
|
2002-05-06 19:27:50 +00:00
|
|
|
calendarEvent.start.setTime( startDate );
|
2002-04-10 18:23:40 +00:00
|
|
|
|
2002-04-11 19:18:30 +00:00
|
|
|
if( !endDate )
|
|
|
|
{
|
|
|
|
var MinutesToAddOn = gCalendarWindow.calendarPreferences.getPref( "defaulteventlength" );
|
2002-04-10 18:23:40 +00:00
|
|
|
|
2002-04-11 19:18:30 +00:00
|
|
|
var endDateTime = startDate.getTime() + ( 1000 * 60 * MinutesToAddOn );
|
2002-04-10 18:23:40 +00:00
|
|
|
|
2002-05-06 19:27:50 +00:00
|
|
|
calendarEvent.end.setTime( endDateTime );
|
2002-04-11 19:18:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-05-06 19:27:50 +00:00
|
|
|
calendarEvent.end.setTime( endDate.getTime() );
|
2002-04-11 19:18:30 +00:00
|
|
|
}
|
2002-05-06 19:27:50 +00:00
|
|
|
editNewEvent( calendarEvent );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper function to launch the event composer to edit a new event.
|
|
|
|
* When the user clicks OK "addEventDialogResponse" is called
|
|
|
|
*/
|
|
|
|
|
|
|
|
function editNewEvent( calendarEvent )
|
|
|
|
{
|
|
|
|
// set up a bunch of args to pass to the dialog
|
|
|
|
|
|
|
|
var args = new Object();
|
|
|
|
args.mode = "new";
|
|
|
|
args.onOk = self.addEventDialogResponse;
|
|
|
|
args.calendarEvent = calendarEvent;
|
|
|
|
|
|
|
|
// open the dialog modally
|
2002-05-07 13:15:25 +00:00
|
|
|
openDialog("chrome://calendar/content/calendarEventDialog.xul", "caEditEvent", "chrome,modal", args );
|
2001-11-07 19:18:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when the user clicks OK in the new event dialog
|
|
|
|
*
|
|
|
|
* Update the data source, the unifinder views and the calendar views will be
|
|
|
|
* notified of the change through their respective observers
|
|
|
|
*/
|
|
|
|
|
2002-07-22 18:54:15 +00:00
|
|
|
function addEventDialogResponse( calendarEvent )
|
2001-11-07 19:18:46 +00:00
|
|
|
{
|
2001-12-20 15:53:03 +00:00
|
|
|
gICalLib.addEvent( calendarEvent );
|
2001-11-07 19:18:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-06-19 15:00:38 +00:00
|
|
|
/**
|
|
|
|
* Called when the user clicks OK in the new to do item dialog
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
function addToDoDialogResponse( calendarToDo )
|
|
|
|
{
|
2002-06-27 17:59:51 +00:00
|
|
|
gICalLib.addTodo( calendarToDo );
|
2002-06-19 15:00:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-11-07 19:18:46 +00:00
|
|
|
/**
|
|
|
|
* Helper function to launch the event composer to edit an event.
|
|
|
|
* When the user clicks OK "modifyEventDialogResponse" is called
|
|
|
|
*/
|
|
|
|
|
|
|
|
function editEvent( calendarEvent )
|
|
|
|
{
|
|
|
|
// set up a bunch of args to pass to the dialog
|
|
|
|
|
|
|
|
var args = new Object();
|
|
|
|
args.mode = "edit";
|
|
|
|
args.onOk = self.modifyEventDialogResponse;
|
|
|
|
args.calendarEvent = calendarEvent;
|
|
|
|
|
|
|
|
// open the dialog modally
|
|
|
|
|
2002-05-06 19:11:19 +00:00
|
|
|
openDialog("chrome://calendar/content/calendarEventDialog.xul", "caEditEvent", "chrome,modal", args );
|
2001-11-07 19:18:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-06-19 15:00:38 +00:00
|
|
|
/**
|
|
|
|
* Helper function to launch the event composer to edit an event.
|
|
|
|
* When the user clicks OK "modifyEventDialogResponse" is called
|
|
|
|
*/
|
|
|
|
|
|
|
|
function editToDo( calendarToDo )
|
|
|
|
{
|
|
|
|
// set up a bunch of args to pass to the dialog
|
|
|
|
|
|
|
|
var args = new Object();
|
|
|
|
args.mode = "edit";
|
|
|
|
args.onOk = self.modifyToDoDialogResponse;
|
|
|
|
args.calendarToDo = calendarToDo;
|
2002-06-27 17:59:51 +00:00
|
|
|
|
2002-06-19 15:00:38 +00:00
|
|
|
// open the dialog modally
|
|
|
|
|
|
|
|
openDialog("chrome://calendar/content/calendarToDoDialog.xul", "caEditToDo", "chrome,modal", args );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-11-07 19:18:46 +00:00
|
|
|
/**
|
|
|
|
* Called when the user clicks OK in the edit event dialog
|
|
|
|
*
|
|
|
|
* Update the data source, the unifinder views and the calendar views will be
|
|
|
|
* notified of the change through their respective observers
|
|
|
|
*/
|
|
|
|
|
2002-07-22 18:54:15 +00:00
|
|
|
function modifyEventDialogResponse( calendarEvent )
|
2001-11-07 19:18:46 +00:00
|
|
|
{
|
2002-05-13 19:25:20 +00:00
|
|
|
gICalLib.modifyEvent( calendarEvent );
|
2001-11-07 19:18:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-06-19 15:00:38 +00:00
|
|
|
/**
|
|
|
|
* Called when the user clicks OK in the edit event dialog
|
|
|
|
*
|
|
|
|
* Update the data source, the unifinder views and the calendar views will be
|
|
|
|
* notified of the change through their respective observers
|
|
|
|
*/
|
|
|
|
|
|
|
|
function modifyToDoDialogResponse( calendarToDo )
|
|
|
|
{
|
2002-06-27 17:59:51 +00:00
|
|
|
gICalLib.modifyTodo( calendarToDo );
|
2002-06-19 15:00:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-04-10 14:38:06 +00:00
|
|
|
function alertCalendarVersion()
|
|
|
|
{
|
2002-06-05 19:58:47 +00:00
|
|
|
window.openDialog( getBrowserURL(), "_blank", "chrome,all,dialog=no", 'chrome://calendar/content/about.html' );
|
2002-04-10 14:38:06 +00:00
|
|
|
}
|
2001-11-07 19:18:46 +00:00
|
|
|
|
2002-04-10 14:38:06 +00:00
|
|
|
function playSound( ThisURL )
|
|
|
|
{
|
|
|
|
ThisURL = "chrome://calendar/content/sound.wav";
|
2001-12-20 15:53:03 +00:00
|
|
|
|
2002-04-10 14:38:06 +00:00
|
|
|
var url = Components.classes["@mozilla.org/network/standard-url;1"].createInstance();
|
|
|
|
url = url.QueryInterface(Components.interfaces.nsIURL);
|
|
|
|
url.spec = ThisURL;
|
2001-11-07 19:18:46 +00:00
|
|
|
|
2002-04-10 14:38:06 +00:00
|
|
|
var sample = Components.classes["@mozilla.org/sound;1"].createInstance();
|
|
|
|
|
|
|
|
sample = sample.QueryInterface(Components.interfaces.nsISound);
|
2001-11-07 19:18:46 +00:00
|
|
|
|
2002-04-10 14:38:06 +00:00
|
|
|
sample.play( url );
|
|
|
|
}
|
2001-11-07 19:18:46 +00:00
|
|
|
|
2002-05-17 13:16:14 +00:00
|
|
|
function selectAllEvents()
|
|
|
|
{
|
|
|
|
gCalendarWindow.EventSelection.setArrayToSelection( gCalendarWindow.eventSource.getCurrentEvents() );
|
|
|
|
}
|
2002-07-03 17:10:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
function deleteToDoCommand( event )
|
|
|
|
{
|
|
|
|
alert( event.originalTarget.getAttribute( "id" ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function closeCalendar()
|
|
|
|
{
|
|
|
|
self.close();
|
|
|
|
}
|
2002-07-05 18:41:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
function changeToolTipTextForToDo( event )
|
|
|
|
{
|
|
|
|
var toDoItem = event.currentTarget.toDo;
|
|
|
|
|
|
|
|
var Html = document.getElementById( "savetip" );
|
|
|
|
|
|
|
|
while( Html.hasChildNodes() )
|
|
|
|
{
|
|
|
|
Html.removeChild( Html.firstChild );
|
|
|
|
}
|
|
|
|
|
|
|
|
var HolderBox = document.createElement( "vbox" );
|
|
|
|
|
|
|
|
if (toDoItem.title)
|
|
|
|
{
|
|
|
|
var TitleHtml = document.createElement( "description" );
|
|
|
|
var TitleText = document.createTextNode( "Title: "+toDoItem.title );
|
|
|
|
TitleHtml.appendChild( TitleText );
|
|
|
|
HolderBox.appendChild( TitleHtml );
|
|
|
|
}
|
|
|
|
|
|
|
|
var DateHtml = document.createElement( "description" );
|
|
|
|
var startDate = new Date( toDoItem.start.getTime() );
|
|
|
|
var DateText = document.createTextNode( "Start Date: "+gCalendarWindow.dateFormater.getFormatedDate( startDate ) );
|
|
|
|
DateHtml.appendChild( DateText );
|
|
|
|
HolderBox.appendChild( DateHtml );
|
|
|
|
|
|
|
|
var DateHtml = document.createElement( "description" );
|
|
|
|
var dueDate = new Date( toDoItem.due.getTime() );
|
|
|
|
var DateText = document.createTextNode( "Due Date: "+gCalendarWindow.dateFormater.getFormatedDate( dueDate ) );
|
|
|
|
DateHtml.appendChild( DateText );
|
|
|
|
HolderBox.appendChild( DateHtml );
|
|
|
|
|
|
|
|
if (toDoItem.description)
|
|
|
|
{
|
|
|
|
var DescriptionHtml = document.createElement( "description" );
|
|
|
|
var DescriptionText = document.createTextNode( "Description: "+toDoItem.description );
|
|
|
|
DescriptionHtml.appendChild( DescriptionText );
|
|
|
|
HolderBox.appendChild( DescriptionHtml );
|
|
|
|
}
|
|
|
|
|
|
|
|
Html.appendChild( HolderBox );
|
|
|
|
}
|
|
|
|
|
|
|
|
function changeToolTipTextForEvent( event )
|
|
|
|
{
|
|
|
|
var thisEvent = event.currentTarget.event;
|
|
|
|
|
|
|
|
var Html = document.getElementById( "savetip" );
|
|
|
|
|
|
|
|
while( Html.hasChildNodes() )
|
|
|
|
{
|
|
|
|
Html.removeChild( Html.firstChild );
|
|
|
|
}
|
|
|
|
|
|
|
|
var HolderBox = getPreviewText( event.currentTarget.event );
|
|
|
|
|
|
|
|
Html.appendChild( HolderBox );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when a user hovers over an element and the text for the mouse over is changed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
function getPreviewText( calendarEvent )
|
|
|
|
{
|
|
|
|
var HolderBox = document.createElement( "vbox" );
|
|
|
|
|
|
|
|
if (calendarEvent.title)
|
|
|
|
{
|
|
|
|
var TitleHtml = document.createElement( "description" );
|
|
|
|
var TitleText = document.createTextNode( "Title: "+calendarEvent.title );
|
|
|
|
TitleHtml.appendChild( TitleText );
|
|
|
|
HolderBox.appendChild( TitleHtml );
|
|
|
|
}
|
|
|
|
|
|
|
|
var DateHtml = document.createElement( "description" );
|
|
|
|
var startDate = new Date( calendarEvent.start.getTime() );
|
|
|
|
var DateText = document.createTextNode( "Start: "+gCalendarWindow.dateFormater.getFormatedDate( startDate )+" "+gCalendarWindow.dateFormater.getFormatedTime( startDate ) );
|
|
|
|
DateHtml.appendChild( DateText );
|
|
|
|
HolderBox.appendChild( DateHtml );
|
|
|
|
|
|
|
|
var DateHtml = document.createElement( "description" );
|
|
|
|
var endDate = new Date( calendarEvent.end.getTime() );
|
|
|
|
var DateText = document.createTextNode( "End: "+gCalendarWindow.dateFormater.getFormatedDate( endDate )+" "+gCalendarWindow.dateFormater.getFormatedTime( endDate ) );
|
|
|
|
DateHtml.appendChild( DateText );
|
|
|
|
HolderBox.appendChild( DateHtml );
|
|
|
|
|
|
|
|
if (calendarEvent.description)
|
|
|
|
{
|
|
|
|
var DescriptionHtml = document.createElement( "description" );
|
|
|
|
var DescriptionText = document.createTextNode( "Description: "+calendarEvent.description );
|
|
|
|
DescriptionHtml.appendChild( DescriptionText );
|
|
|
|
HolderBox.appendChild( DescriptionHtml );
|
|
|
|
}
|
|
|
|
|
|
|
|
return ( HolderBox );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when a user hovers over an element and the text for the mouse over is changed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
function getPreviewTextForRepeatingEvent( calendarEventDisplay )
|
|
|
|
{
|
|
|
|
var HolderBox = document.createElement( "vbox" );
|
|
|
|
|
|
|
|
if (calendarEventDisplay.event.title)
|
|
|
|
{
|
|
|
|
var TitleHtml = document.createElement( "description" );
|
|
|
|
var TitleText = document.createTextNode( "Title: "+calendarEventDisplay.event.title );
|
|
|
|
TitleHtml.appendChild( TitleText );
|
|
|
|
HolderBox.appendChild( TitleHtml );
|
|
|
|
}
|
|
|
|
|
|
|
|
var DateHtml = document.createElement( "description" );
|
|
|
|
var startDate = new Date( calendarEventDisplay.displayDate.getTime() );
|
|
|
|
var DateText = document.createTextNode( "Start: "+gCalendarWindow.dateFormater.getFormatedDate( startDate )+" "+gCalendarWindow.dateFormater.getFormatedTime( startDate ) );
|
|
|
|
DateHtml.appendChild( DateText );
|
|
|
|
HolderBox.appendChild( DateHtml );
|
|
|
|
|
|
|
|
if (calendarEventDisplay.event.description)
|
|
|
|
{
|
|
|
|
var DescriptionHtml = document.createElement( "description" );
|
|
|
|
var DescriptionText = document.createTextNode( "Description: "+calendarEventDisplay.event.description );
|
|
|
|
DescriptionHtml.appendChild( DescriptionText );
|
|
|
|
HolderBox.appendChild( DescriptionHtml );
|
|
|
|
}
|
|
|
|
|
|
|
|
return ( HolderBox );
|
|
|
|
}
|
2002-07-19 15:56:53 +00:00
|
|
|
|
|
|
|
function reloadApplication()
|
|
|
|
{
|
|
|
|
gCalendarWindow.currentView.refreshEvents();
|
|
|
|
}
|