updating eventDialog to use the new calendar APIs

revamp of the event dialog by mattwillis@gmail.com
bug 272732 r=shaver
This commit is contained in:
pavlov%pavlov.net 2004-12-02 17:41:13 +00:00
parent edf0052253
commit 84dee1b4db
7 changed files with 1188 additions and 1010 deletions

View File

@ -165,6 +165,7 @@ interface calIItemBase : nsISupports
readonly attribute nsISimpleEnumerator propertyEnumerator; readonly attribute nsISimpleEnumerator propertyEnumerator;
nsIVariant getProperty(in AString name); nsIVariant getProperty(in AString name);
void setProperty(in AString name, in nsIVariant value); void setProperty(in AString name, in nsIVariant value);
// will not throw an error if you delete a property that doesn't exist
void deleteProperty(in AString name); void deleteProperty(in AString name);
// The array returned here is not live; it will not reflect calls to // The array returned here is not live; it will not reflect calls to

View File

@ -148,7 +148,11 @@ calItemBase.prototype = {
get propertyEnumerator() { return this.mProperties.enumerator; }, get propertyEnumerator() { return this.mProperties.enumerator; },
getProperty: function (aName) { getProperty: function (aName) {
return this.mProperties.getProperty(aName); try {
return this.mProperties.getProperty(aName);
} catch (e) {
return null;
}
}, },
setProperty: function (aName, aValue) { setProperty: function (aName, aValue) {
if (this.mImmutable) if (this.mImmutable)
@ -158,7 +162,10 @@ calItemBase.prototype = {
deleteProperty: function (aName) { deleteProperty: function (aName) {
if (this.mImmutable) if (this.mImmutable)
throw Components.results.NS_ERROR_FAILURE; throw Components.results.NS_ERROR_FAILURE;
this.mProperties.deleteProperty(aName); try {
this.mProperties.deleteProperty(aName);
} catch (e) {
}
}, },
getAttendees: function (countObj) { getAttendees: function (countObj) {

View File

@ -1,104 +1,166 @@
/* ***** BEGIN LICENSE BLOCK ***** /* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
* *
* The contents of this file are subject to the Mozilla Public License Version * 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 * 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 * the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/ * http://www.mozilla.org/MPL/
* *
* Software distributed under the License is distributed on an "AS IS" basis, * Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the * for the specific language governing rights and limitations under the
* License. * License.
* *
* Alternatively, the contents of this file may be used under the terms of * 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 * 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"), * 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 * 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 * 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 * 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 * 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 * 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 * 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 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. * the terms of any one of the MPL, the GPL or the LGPL.
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
const nsIWindowMediator = Components.interfaces.nsIWindowMediator; const nsIWindowMediator = Components.interfaces.nsIWindowMediator;
function toOpenWindowByType( inType, uri ) function toOpenWindowByType( inType, uri )
{ {
var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(); var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService();
var windowManagerInterface = windowManager.QueryInterface(nsIWindowMediator); var windowManagerInterface = windowManager.QueryInterface(nsIWindowMediator);
var topWindow = windowManagerInterface.getMostRecentWindow( inType ); var topWindow = windowManagerInterface.getMostRecentWindow( inType );
if ( topWindow ) if ( topWindow )
topWindow.focus(); topWindow.focus();
else else
window.open(uri, "_blank", "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar"); window.open(uri, "_blank", "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar");
} }
function toBrowser() function toBrowser()
{ {
toOpenWindowByType("navigator:browser", ""); toOpenWindowByType("navigator:browser", "");
} }
function toJavaScriptConsole() function toJavaScriptConsole()
{ {
toOpenWindowByType("global:console", "chrome://global/content/console.xul"); toOpenWindowByType("global:console", "chrome://global/content/console.xul");
} }
function toMessengerWindow() function toMessengerWindow()
{ {
toOpenWindowByType("mail:3pane", "chrome://messenger/content/messenger.xul"); toOpenWindowByType("mail:3pane", "chrome://messenger/content/messenger.xul");
} }
function toAddressBook() function toAddressBook()
{ {
toOpenWindowByType("mail:addressbook", "chrome://messenger/content/addressbook/addressbook.xul"); toOpenWindowByType("mail:addressbook", "chrome://messenger/content/addressbook/addressbook.xul");
} }
function launchBrowser( UrlToGoTo ) function launchBrowser( UrlToGoTo )
{ {
if( navigator.vendor != "Thunderbird") { if( navigator.vendor != "Thunderbird") {
var navWindow; var navWindow;
// if not, get the most recently used browser window // if not, get the most recently used browser window
try { try {
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator); .getService(Components.interfaces.nsIWindowMediator);
navWindow = wm.getMostRecentWindow("navigator:browser"); navWindow = wm.getMostRecentWindow("navigator:browser");
} }
catch (ex) { } catch (ex) { }
if (navWindow) { if (navWindow) {
if ("delayedOpenTab" in navWindow) if ("delayedOpenTab" in navWindow)
navWindow.delayedOpenTab(UrlToGoTo); navWindow.delayedOpenTab(UrlToGoTo);
else if ("loadURI" in navWindow) else if ("loadURI" in navWindow)
navWindow.loadURI(UrlToGoTo); navWindow.loadURI(UrlToGoTo);
else else
navWindow.content.location.href = UrlToGoTo; navWindow.content.location.href = UrlToGoTo;
} }
// if all else fails, open a new window // if all else fails, open a new window
else { else {
var ass = Components.classes["@mozilla.org/appshell/appShellService;1"].getService(Components.interfaces.nsIAppShellService); var ass = Components.classes["@mozilla.org/appshell/appShellService;1"].getService(Components.interfaces.nsIAppShellService);
w = ass.hiddenDOMWindow; w = ass.hiddenDOMWindow;
w.openDialog( getBrowserURL(), "_blank", "chrome,all,dialog=no", UrlToGoTo ); w.openDialog( getBrowserURL(), "_blank", "chrome,all,dialog=no", UrlToGoTo );
} }
} }
else else
{ {
try { try {
var messenger = Components.classes["@mozilla.org/messenger;1"].createInstance(); var messenger = Components.classes["@mozilla.org/messenger;1"].createInstance();
messenger = messenger.QueryInterface(Components.interfaces.nsIMessenger); messenger = messenger.QueryInterface(Components.interfaces.nsIMessenger);
messenger.launchExternalURL(UrlToGoTo); messenger.launchExternalURL(UrlToGoTo);
} catch (ex) {} } catch (ex) {}
} }
//window.open(UrlToGoTo, "_blank", "chrome,menubar,toolbar,resizable,dialog=no"); //window.open(UrlToGoTo, "_blank", "chrome,menubar,toolbar,resizable,dialog=no");
//window.open( UrlToGoTo, "calendar-opened-window" ); //window.open( UrlToGoTo, "calendar-opened-window" );
} }
function goToggleToolbar( id, elementID )
{
var toolbar = document.getElementById(id);
var element = document.getElementById(elementID);
if (toolbar) {
var isHidden = toolbar.hidden;
toolbar.hidden = !isHidden;
document.persist(id, 'hidden');
if (element) {
element.setAttribute("checked", isHidden ? "true" : "false");
document.persist(elementID, 'checked');
}
}
}
function openExtensions(aOpenMode)
{
const EMTYPE = "Extension:Manager";
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var needToOpen = true;
var windowType = EMTYPE + "-" + aOpenMode;
var windows = wm.getEnumerator(windowType);
while (windows.hasMoreElements()) {
var theEM = windows.getNext().QueryInterface(Components.interfaces.nsIDOMWindowInternal);
if (theEM.document.documentElement.getAttribute("windowtype") == windowType) {
theEM.focus();
needToOpen = false;
break;
}
}
if (needToOpen) {
const EMURL = "chrome://mozapps/content/extensions/extensions.xul?type=" + aOpenMode;
const EMFEATURES = "chrome,dialog=no,resizable";
window.openDialog(EMURL, "", EMFEATURES);
}
}
function showElement( elementId )
{
try {
dump("showElement: showing "+elementId+"\n");
document.getElementById( elementId ).removeAttribute( "hidden" );
}
catch (e) {
dump("showElement: Couldn't remove hidden attribute from "+elementId+"\n");
}
}
function hideElement( elementId )
{
try {
dump("hideElement: hiding "+elementId+"\n");
document.getElementById( elementId ).setAttribute( "hidden", "true" );
}
catch (e) {
dump("hideElement: Couldn't set hidden attribute on "+elementId+"\n");
}
}

View File

@ -1,4 +1,5 @@
/* ***** BEGIN LICENSE BLOCK ***** /* -*- Mode: javascript; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
* *
* The contents of this file are subject to the Mozilla Public License Version * The contents of this file are subject to the Mozilla Public License Version
@ -69,6 +70,8 @@
* G L O B A L V A R I A B L E S * G L O B A L V A R I A B L E S
*/ */
var gCalendar = null;
//the next line needs XX-DATE-XY but last X instead of Y //the next line needs XX-DATE-XY but last X instead of Y
var gDateMade = "2002052213-cal" var gDateMade = "2002052213-cal"
@ -168,15 +171,11 @@ var categoryPrefObserver =
function calendarInit() function calendarInit()
{ {
// get the calendar event data source // XXX remove this eventually
gEventSource = new CalendarEventDataSource(); gICalLib = new Object();
// get the Ical Library gCalendar = createCalendar();
gICalLib = gEventSource.getICalLib();
// this suspends feedbacks to observers until all is settled
gICalLib.batchMode = true;
// set up the CalendarWindow instance // set up the CalendarWindow instance
gCalendarWindow = new CalendarWindow(); gCalendarWindow = new CalendarWindow();
@ -196,8 +195,13 @@ function calendarInit()
update_date(); update_date();
checkForMailNews(); checkForMailNews();
//updateColors();
}
function updateColors()
{
// Change made by CofC for Calendar Coloring // Change made by CofC for Calendar Coloring
// initialize calendar color style rules in the calendar's styleSheet // initialize calendar color style rules in the calendar's styleSheet
@ -657,6 +661,13 @@ function multiweekToDoBoxDoubleClickEvent( todoBox, event )
} }
function jsDateToDateTime(date)
{
newDate = createDateTime();
newDate.nativeTime = date;
return newDate;
}
/** /**
* Called when the new event button is clicked * Called when the new event button is clicked
*/ */
@ -664,6 +675,7 @@ var gNewDateVariable = null;
function newEventCommand( event ) function newEventCommand( event )
{ {
/*
var startDate; var startDate;
if( gNewDateVariable != null ) if( gNewDateVariable != null )
@ -675,13 +687,11 @@ function newEventCommand( event )
var Minutes = Math.ceil( startDate.getMinutes() / 5 ) * 5 ; var Minutes = Math.ceil( startDate.getMinutes() / 5 ) * 5 ;
startDate = new Date( startDate.getFullYear(), date = jsDateToDateTime(startDate);
startDate.getMonth(), date.minute = Minutes;
startDate.getDate(), */
startDate.getHours(), date = null;
Minutes, newEvent( date );
0);
newEvent( startDate );
} }
@ -697,29 +707,34 @@ function newToDoCommand()
function createEvent () function createEvent ()
{ {
var iCalEventComponent = Components.classes["@mozilla.org/icalevent;1"].createInstance(); return Components.classes["@mozilla.org/calendar/event;1"].createInstance(Components.interfaces.calIEvent);
var iCalEvent = iCalEventComponent.QueryInterface(Components.interfaces.oeIICalEvent);
return iCalEvent;
} }
function createToDo () function createToDo ()
{ {
var iCalToDoComponent = Components.classes["@mozilla.org/icaltodo;1"].createInstance(); return Components.classes["@mozilla.org/calendar/todo;1"].createInstance(Components.interfaces.calITodo);
var iCalToDo = iCalToDoComponent.QueryInterface(Components.interfaces.oeIICalTodo);
return iCalToDo;
} }
function createDateTime()
{
return Components.classes["@mozilla.org/calendar/datetime;1"].createInstance(Components.interfaces.calIDateTime);
}
function createCalendar()
{
return Components.classes["@mozilla.org/calendar/calendar;1?type=memory"].getService(Components.interfaces.calICalendar);
}
function isEvent ( aObject ) function isEvent ( aObject )
{ {
return (aObject instanceof Components.interfaces.oeIICalEvent) && !(aObject instanceof Components.interfaces.oeIICalTodo); return aObject instanceof Components.interfaces.calIEvent;
} }
function isToDo ( aObject ) function isToDo ( aObject )
{ {
return aObject instanceof Components.interfaces.oeIICalTodo; return aObject instanceof Components.interfaces.calITodo;
} }
@ -769,27 +784,29 @@ function newEvent( startDate, endDate, allDay )
{ {
// create a new event to be edited and added // create a new event to be edited and added
var calendarEvent = createEvent(); var calendarEvent = createEvent();
if( !startDate )
startDate = gCalendarWindow.currentView.getNewEventDate();
calendarEvent.start.setTime( startDate ); /*
if (!startDate) {
if( !endDate ) startDate = gCalendarWindow.currentView.getNewEventDate();
{
var MinutesToAddOn = getIntPref(gCalendarWindow.calendarPreferences.calendarPref, "event.defaultlength", gCalendarBundle.getString("defaultEventLength" ) );
var endDateTime = startDate.getTime() + ( 1000 * 60 * MinutesToAddOn );
calendarEvent.end.setTime( endDateTime );
} }
else
calendarEvent.startDate.jsDate = startDate;
if (!endDate)
{ {
calendarEvent.end.setTime( endDate.getTime() ); var MinutesToAddOn = getIntPref(gCalendarWindow.calendarPreferences.calendarPref, "event.defaultlength", gCalendarBundle.getString("defaultEventLength" ) );
var endDateTime = startDate.clone();
endDateTime.minute += MinutesToAddOn; // XXX this could overflow
endDateTime.normalize();
} }
calendarEvent.endDate.jsDate = endDate
*/
if( allDay ) if (allDay)
calendarEvent.allDay = true; calendarEvent.isAllDay = true;
var server = getSelectedCalendarPathOrNull(); var server = getSelectedCalendarPathOrNull();
@ -806,18 +823,14 @@ function newToDo ( startDate, dueDate )
var calendarToDo = createToDo(); var calendarToDo = createToDo();
// created todo has no start or due date unless user wants one // created todo has no start or due date unless user wants one
if (! startDate ) if (startDate)
calendarToDo.start.clear(); calendarToDo.start.jsDate = startDate;
else
calendarToDo.start.setTime( startDate );
if (! dueDate ) if (dueDate)
calendarToDo.due.clear(); calendarToDo.dueDate.jsDate = dueDate;
else
calendarToDo.due.setTime( dueDate );
var server = getSelectedCalendarPathOrNull(); var server = getSelectedCalendarPathOrNull();
editNewToDo(calendarToDo, server); editNewToDo(calendarToDo, server);
} }
@ -879,7 +892,7 @@ function addEventDialogResponse( calendarEvent, Server )
function addToDoDialogResponse( calendarToDo, Server ) function addToDoDialogResponse( calendarToDo, Server )
{ {
saveItem( calendarToDo, Server, "addTodo" ); addEventDialogResponse(calendarToDo, Server);
} }
@ -931,7 +944,7 @@ function modifyEventDialogResponse( calendarEvent, Server, originalEvent )
function modifyToDoDialogResponse( calendarToDo, Server, originalToDo ) function modifyToDoDialogResponse( calendarToDo, Server, originalToDo )
{ {
saveItem( calendarToDo, Server, "modifyTodo", originalToDo ); modifyEventDialogResponse(calendarToDo, Server, originalToDo);
} }
@ -999,6 +1012,18 @@ function editEventCommand()
//used to check if there were external changes for shared calendar //used to check if there were external changes for shared calendar
function saveItem( calendarEvent, Server, functionToRun, originalEvent ) function saveItem( calendarEvent, Server, functionToRun, originalEvent )
{ {
if (functionToRun == 'addEvent')
gCalendar.addItem(calendarEvent, null);
else if (functionToRun == 'modifyEvent')
gCalendar.modifyItem(calendarEvent, null);
/*
var calendarServer = gCalendarWindow.calendarManager.getCalendarByName( Server ); var calendarServer = gCalendarWindow.calendarManager.getCalendarByName( Server );
var path = calendarServer.getAttribute("http://home.netscape.com/NC-rdf#path"); var path = calendarServer.getAttribute("http://home.netscape.com/NC-rdf#path");
var shared = (calendarServer.getAttribute("http://home.netscape.com/NC-rdf#shared" ) == "true"); var shared = (calendarServer.getAttribute("http://home.netscape.com/NC-rdf#shared" ) == "true");
@ -1059,6 +1084,8 @@ function saveItem( calendarEvent, Server, functionToRun, originalEvent )
eval( "gICalLib."+functionToRun+"( calendarEvent, Server )" ); eval( "gICalLib."+functionToRun+"( calendarEvent, Server )" );
gCalendarWindow.clearSelectedEvent( calendarEvent ); gCalendarWindow.clearSelectedEvent( calendarEvent );
} }
*/
} }
@ -1278,7 +1305,7 @@ function launchWizard()
function reloadApplication() function reloadApplication()
{ {
gEventSource.calendarManager.refreshAllRemoteCalendars(); gEventSource.calendarManager.refreshAllRemoteCalendars();
} }

View File

@ -47,7 +47,6 @@
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?> <?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
<?xml-stylesheet href="chrome://calendar/skin/calendar.css" type="text/css"?> <?xml-stylesheet href="chrome://calendar/skin/calendar.css" type="text/css"?>
<?xml-stylesheet href="chrome://calendar/content/datetimepickers/minimonth.css" type="text/css"?> <?xml-stylesheet href="chrome://calendar/content/datetimepickers/minimonth.css" type="text/css"?>
<?xml-stylesheet href="chrome://communicator/skin/communicator.css" type="text/css"?>
<!-- Overlays --> <!-- Overlays -->
<?xul-overlay href="chrome://global/content/globalOverlay.xul"?> <?xul-overlay href="chrome://global/content/globalOverlay.xul"?>
@ -199,7 +198,6 @@
<!-- Javascript includes --> <!-- Javascript includes -->
<script type="application/x-javascript" src="chrome://calendar/content/jslib/jslib.js"/> <script type="application/x-javascript" src="chrome://calendar/content/jslib/jslib.js"/>
<script type="application/x-javascript" src="chrome://communicator/content/utilityOverlay.js"/>
<!-- NEEDED FOR DRAG AND DROP SUPPORT --> <!-- NEEDED FOR DRAG AND DROP SUPPORT -->
<script type="application/x-javascript" src="chrome://calendar/content/dragDrop.js"/> <script type="application/x-javascript" src="chrome://calendar/content/dragDrop.js"/>

View File

@ -1,4 +1,5 @@
/* ***** BEGIN LICENSE BLOCK ***** /* -*- Mode: javascript; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
* *
* The contents of this file are subject to the Mozilla Public License Version * The contents of this file are subject to the Mozilla Public License Version
@ -47,7 +48,7 @@
* Garth Smedley * Garth Smedley
* REQUIRED INCLUDES * REQUIRED INCLUDES
* <script type="application/x-javascript" src="chrome://calendar/content/dateUtils.js"/> * <script type="application/x-javascript" src="chrome://calendar/content/dateUtils.js"/>
* * <script type="application/x-javascript" src="chrome://calendar/content/applicationUtil.js"/>
* NOTES * NOTES
* Code for the calendar's new/edit event dialog. * Code for the calendar's new/edit event dialog.
* *
@ -79,11 +80,10 @@
* W I N D O W V A R I A B L E S * W I N D O W V A R I A B L E S
*/ */
var debugenabled=false; var debugenabled=true;
var gEvent; // event being edited var gEvent; // event being edited
var gOnOkFunction; // function to be called when user clicks OK var gOnOkFunction; // function to be called when user clicks OK
var gOriginalEvent; //Event before edits
var gDuration = -1; // used to preserve duration when changing event start. var gDuration = -1; // used to preserve duration when changing event start.
@ -113,223 +113,228 @@ var gEndDate = new Date( );
function loadCalendarEventDialog() function loadCalendarEventDialog()
{ {
// Get arguments, see description at top of file // Get arguments, see description at top of file
var args = window.arguments[0];
gOnOkFunction = args.onOk;
// XXX I want to get rid of the use of gEvent
gEvent = args.calendarEvent;
event = args.calendarEvent;
// mode is "new or "edit" - show proper header
var titleDataItem = null;
if ("new" == args.mode)
title = document.getElementById("data-event-title-new").getAttribute("value");
else {
title = document.getElementById("data-event-title-edit").getAttribute("value");
}
document.getElementById("calendar-new-component-window").setAttribute("title", title);
// fill in fields from the event
gStartDate = event.startDate.jsDate;
document.getElementById("start-datetime").value = gStartDate;
gEndDate = event.endDate.jsDate;
var displayEndDate = new Date(gEndDate);
if (event.isAllDay) {
//displayEndDate == icalEndDate - 1, in the case of allday events
displayEndDate.setDate(displayEndDate.getDate() - 1);
}
document.getElementById("end-datetime").value = displayEndDate;
gDuration = gEndDate.getTime() - gStartDate.getTime(); //in ms
/*
if (event.recurForever) {
event.recurEnd.setTime(gEndDate);
}
//do the stuff for exceptions
var ArrayOfExceptions = event.getExceptions();
while( ArrayOfExceptions.hasMoreElements() ) {
var ExceptionTime = ArrayOfExceptions.getNext().QueryInterface(Components.interfaces.nsISupportsPRTime).data;
var ExceptionDate = new Date( ExceptionTime );
addException( ExceptionDate );
}
//file attachments;
for( var i = 0; i < event.attachmentsArray.Count(); i++ ) {
var thisAttachment = event.attachmentsArray.QueryElementAt( i, Components.interfaces.nsIMsgAttachment );
addAttachment( thisAttachment );
}
*/
document.getElementById("exceptions-date-picker").value = gStartDate;
dump("event: "+event+"\n");
setFieldValue("title-field", event.title );
setFieldValue("description-field", event.getProperty("description"));
setFieldValue("location-field", event.getProperty("location"));
setFieldValue("uri-field", event.getProperty("url"));
switch(event.status) {
case event.CAL_ITEM_STATUS_TENTATIVE:
setFieldValue("event-status-field", "ICAL_STATUS_TENTATIVE");
break;
case event.CAL_ITEM_STATUS_CONFIRMED:
setFieldValue("event-status-field", "ICAL_STATUS_CONFIRMED");
break;
case event.CAL_ITEM_STATUS_CANCELLED:
setFieldValue("event-status-field", "ICAL_STATUS_CANCELLED");
break;
}
setFieldValue("all-day-event-checkbox", event.isAllDay, "checked");
setFieldValue("private-checkbox", event.isPrivate, "checked");
if (!event.hasAlarm) {
// If the event has no alarm
setFieldValue("alarm-type", "none");
}
else {
setFieldValue("alarm-length-field", event.getProperty("alarmLength"));
setFieldValue("alarm-length-units", event.getProperty("alarmUnits"));
setFieldValue("alarm-trigger-relation", event.getProperty("ICAL_RELATED_PARAMETER"));
// If the event has an alarm email address, assume email alarm type
var alarmEmailAddress = event.getProperty("alarmEmailAddress");
if (alarmEmailAddress && alarmEmailAddress != "") {
setFieldValue("alarm-type", "email");
setFieldValue("alarm-email-field", alarmEmailAddress);
}
else {
setFieldValue("alarm-type", "popup");
/* XXX lilmatt: finish this by selection between popup and
popupAndSound by checking pref "calendar.alarms.playsound" */
}
}
var inviteEmailAddress = event.getProperty("inviteEmailAddress");
if (inviteEmailAddress != undefined && inviteEmailAddress != "") {
setFieldValue("invite-checkbox", true, "checked");
setFieldValue("invite-email-field", inviteEmailAddress);
}
else {
setFieldValue("invite-checkbox", false, "checked");
}
/* XXX
setFieldValue("repeat-checkbox", gEvent.recur, "checked");
if( gEvent.recurInterval < 1 )
gEvent.recurInterval = 1;
setFieldValue( "repeat-length-field", gEvent.recurInterval );
if( gEvent.recurUnits )
setFieldValue( "repeat-length-units", gEvent.recurUnits ); //don't put the extra "value" element here, or it won't work.
else
setFieldValue( "repeat-length-units", "weeks" );
if ( gEvent.recurEnd && gEvent.recurEnd.isSet )
setFieldValue( "repeat-end-date-picker", new Date( gEvent.recurEnd.getTime() ) );
else
setFieldValue( "repeat-end-date-picker", new Date() ); // now
setFieldValue( "repeat-forever-radio", (gEvent.recurForever != undefined && gEvent.recurForever != false), "selected" );
setFieldValue( "repeat-until-radio", ( (gEvent.recurForever == undefined || gEvent.recurForever == false ) && gEvent.recurCount == 0), "selected" );
setFieldValue( "repeat-numberoftimes-radio", (gEvent.recurCount != 0), "selected" );
setFieldValue( "repeat-numberoftimes-textbox", Math.max(gEvent.recurCount, 1));
*/
/* Categories stuff */
// Load categories
/*
var categoriesString = opener.GetUnicharPref(opener.gCalendarWindow.calendarPreferences.calendarPref, "categories.names", getDefaultCategories());
var categoriesList = categoriesString.split( "," );
// insert the category already in the task so it doesn't get lost
var categories = event.getProperty("categories");
if (categories) {
if (categoriesString.indexOf(categories) == -1)
categoriesList[categoriesList.length] = categories;
}
categoriesList.sort();
var oldMenulist = document.getElementById( "categories-menulist-menupopup" );
while( oldMenulist.hasChildNodes() )
oldMenulist.removeChild( oldMenulist.lastChild );
for (i = 0; i < categoriesList.length ; i++)
{
document.getElementById( "categories-field" ).appendItem(categoriesList[i], categoriesList[i]);
}
document.getElementById( "categories-field" ).selectedIndex = -1;
setFieldValue( "categories-field", gEvent.categories );
var args = window.arguments[0];
// Server stuff
document.getElementById( "server-menulist-menupopup" ).database.AddDataSource( opener.gCalendarWindow.calendarManager.rdf.getDatasource() );
document.getElementById( "server-menulist-menupopup" ).builder.rebuild();
gOnOkFunction = args.onOk; if (args.mode == "new") {
gEvent = args.calendarEvent; if ("server" in args) {
setFieldValue( "server-field", args.server );
// mode is "new or "edit" - show proper header }
var titleDataItem = null; else {
document.getElementById( "server-field" ).selectedIndex = 1;
}
} else {
if (gEvent.parent)
setFieldValue( "server-field", gEvent.parent.server );
else
document.getElementById( "server-field" ).selectedIndex = 1;
//for now you can't edit which file the event is in.
setFieldValue( "server-field", "true", "disabled" );
setFieldValue( "server-field-label", "true", "disabled" );
}
*/
if( "new" == args.mode )
{
titleDataItem = document.getElementById( "data-event-title-new" );
}
else
{
titleDataItem = document.getElementById( "data-event-title-edit" );
gOriginalEvent = gEvent.clone();
}
var titleString = titleDataItem.getAttribute( "value" );
document.getElementById("calendar-new-eventwindow").setAttribute("title", titleString);
// fill in fields from the event // update enabling and disabling
gStartDate.setTime( gEvent.start.getTime() ); updateRepeatItemEnabled();
document.getElementById( "start-datetime" ).value = gStartDate; updateStartEndItemEnabled();
updateInviteItemEnabled();
gEndDate.setTime( gEvent.end.getTime() );
var displayEndDate = new Date(gEndDate);
if( gEvent.allDay ) {
//displayEndDate == icalEndDate - 1, in the case of allday events
displayEndDate.setDate( displayEndDate.getDate() - 1 );
}
document.getElementById( "end-datetime" ).value = displayEndDate;
gDuration = gEndDate.getTime() - gStartDate.getTime(); //in ms
if ( gEvent.recurForever )
{
gEvent.recurEnd.setTime( gEndDate );
}
//do the stuff for exceptions updateAddExceptionButton();
var ArrayOfExceptions = gEvent.getExceptions();
while( ArrayOfExceptions.hasMoreElements() ) //set the advanced weekly repeating stuff
{ setAdvancedWeekRepeat();
var ExceptionTime = ArrayOfExceptions.getNext().QueryInterface(Components.interfaces.nsISupportsPRTime).data;
var ExceptionDate = new Date( ExceptionTime );
addException( ExceptionDate ); /*
} setFieldValue("advanced-repeat-dayofmonth", (gEvent.recurWeekNumber == 0 || gEvent.recurWeekNumber == undefined), "selected");
setFieldValue("advanced-repeat-dayofweek", (gEvent.recurWeekNumber > 0 && gEvent.recurWeekNumber != 5), "selected");
setFieldValue("advanced-repeat-dayofweek-last", (gEvent.recurWeekNumber == 5), "selected");
*/
//file attachments; // hide/show fields and widgets for item type
for( var i = 0; i < gEvent.attachmentsArray.Count(); i++ ) processComponentType();
{
var thisAttachment = gEvent.attachmentsArray.QueryElementAt( i, Components.interfaces.nsIMsgAttachment );
addAttachment( thisAttachment );
}
document.getElementById( "exceptions-date-picker" ).value = gStartDate; // hide/show fields and widgets for alarm type
processAlarmType();
setFieldValue( "title-field", gEvent.title );
setFieldValue( "description-field", gEvent.description );
setFieldValue( "location-field", gEvent.location );
setFieldValue( "uri-field", gEvent.url );
switch( gEvent.status ) // start focus on title
{ var firstFocus = document.getElementById("title-field");
case gEvent.ICAL_STATUS_TENTATIVE: firstFocus.focus();
setFieldValue( "status-field", "ICAL_STATUS_TENTATIVE" );
break;
case gEvent.ICAL_STATUS_CONFIRMED:
setFieldValue( "status-field", "ICAL_STATUS_CONFIRMED" );
break;
case gEvent.ICAL_STATUS_CANCELLED:
setFieldValue( "status-field", "ICAL_STATUS_CANCELLED" );
break;
}
setFieldValue( "all-day-event-checkbox", gEvent.allDay, "checked" );
setFieldValue( "private-checkbox", gEvent.privateEvent, "checked" ); // revert cursor from "wait" set in calendar.js editEvent, editNewEvent
opener.setCursor( "auto" );
setFieldValue( "alarm-checkbox", gEvent.alarm, "checked" );
setFieldValue( "alarm-length-field", gEvent.alarmLength );
setFieldValue( "alarm-length-units", gEvent.alarmUnits );
setFieldValue( "alarm-trigger-relation", gEvent.getParameter( "ICAL_RELATED_PARAMETER" ) );
if ( gEvent.alarmEmailAddress && gEvent.alarmEmailAddress != "" ) self.focus();
{
setFieldValue( "alarm-email-checkbox", true, "checked" );
setFieldValue( "alarm-email-field", gEvent.alarmEmailAddress );
}
else
{
setFieldValue( "alarm-email-checkbox", false, "checked" );
setFieldValue( "alarm-email-field", true, "disabled" );
}
if ( gEvent.inviteEmailAddress != undefined && gEvent.inviteEmailAddress != "" )
{
setFieldValue( "invite-checkbox", true, "checked" );
setFieldValue( "invite-email-field", gEvent.inviteEmailAddress );
}
else
{
setFieldValue( "invite-checkbox", false, "checked" );
}
setFieldValue( "repeat-checkbox", gEvent.recur, "checked");
if( gEvent.recurInterval < 1 )
gEvent.recurInterval = 1;
setFieldValue( "repeat-length-field", gEvent.recurInterval );
if( gEvent.recurUnits )
setFieldValue( "repeat-length-units", gEvent.recurUnits ); //don't put the extra "value" element here, or it won't work.
else
setFieldValue( "repeat-length-units", "weeks" );
if ( gEvent.recurEnd && gEvent.recurEnd.isSet )
setFieldValue( "repeat-end-date-picker", new Date( gEvent.recurEnd.getTime() ) );
else
setFieldValue( "repeat-end-date-picker", new Date() ); // now
setFieldValue( "repeat-forever-radio", (gEvent.recurForever != undefined && gEvent.recurForever != false), "selected" );
setFieldValue( "repeat-until-radio", ( (gEvent.recurForever == undefined || gEvent.recurForever == false ) && gEvent.recurCount == 0), "selected" );
setFieldValue( "repeat-numberoftimes-radio", (gEvent.recurCount != 0), "selected" );
setFieldValue( "repeat-numberoftimes-textbox", Math.max(gEvent.recurCount, 1));
/* Categories stuff */
// Load categories
var categoriesString = opener.GetUnicharPref(opener.gCalendarWindow.calendarPreferences.calendarPref, "categories.names", getDefaultCategories() );
var categoriesList = categoriesString.split( "," );
// insert the category already in the task so it doesn't get lost
if( gEvent.categories )
{
if( categoriesString.indexOf( gEvent.categories ) == -1 )
categoriesList[categoriesList.length] = gEvent.categories;
}
categoriesList.sort();
var oldMenulist = document.getElementById( "categories-menulist-menupopup" );
while( oldMenulist.hasChildNodes() )
oldMenulist.removeChild( oldMenulist.lastChild );
for (i = 0; i < categoriesList.length ; i++)
{
document.getElementById( "categories-field" ).appendItem(categoriesList[i], categoriesList[i]);
}
document.getElementById( "categories-field" ).selectedIndex = -1;
setFieldValue( "categories-field", gEvent.categories );
/* Server stuff */
document.getElementById( "server-menulist-menupopup" ).database.AddDataSource( opener.gCalendarWindow.calendarManager.rdf.getDatasource() );
document.getElementById( "server-menulist-menupopup" ).builder.rebuild();
if( args.mode == "new" )
{
if( "server" in args )
{
setFieldValue( "server-field", args.server );
}
else
{
document.getElementById( "server-field" ).selectedIndex = 1;
}
}
else
{
if( gEvent.parent )
setFieldValue( "server-field", gEvent.parent.server );
else
{
document.getElementById( "server-field" ).selectedIndex = 1;
}
//for now you can't edit which file the event is in.
setFieldValue( "server-field", "true", "disabled" );
setFieldValue( "server-field-label", "true", "disabled" );
}
// update enabling and disabling
updateRepeatItemEnabled();
updateStartEndItemEnabled();
updateAlarmItemEnabled();
updateInviteItemEnabled();
updateAddExceptionButton();
//updateAlarmEmailItemEnabled();
/*
** set the advanced weekly repeating stuff
*/
setAdvancedWeekRepeat();
setFieldValue( "advanced-repeat-dayofmonth", ( gEvent.recurWeekNumber == 0 || gEvent.recurWeekNumber == undefined ), "selected" );
setFieldValue( "advanced-repeat-dayofweek", ( gEvent.recurWeekNumber > 0 && gEvent.recurWeekNumber != 5 ), "selected" );
setFieldValue( "advanced-repeat-dayofweek-last", ( gEvent.recurWeekNumber == 5 ), "selected" );
// start focus on title
var firstFocus = document.getElementById( "title-field" );
firstFocus.focus();
// revert cursor from "wait" set in calendar.js editEvent, editNewEvent
opener.setCursor( "auto" );
self.focus();
} }
@ -340,100 +345,76 @@ function loadCalendarEventDialog()
function onOKCommand() function onOKCommand()
{ {
// get values from the form and put them into the event event = gEvent;
gEvent.title = getFieldValue( "title-field" );
gEvent.description = getFieldValue( "description-field" );
gEvent.location = getFieldValue( "location-field" );
gEvent.start.setTime( gStartDate.getTime() );
gEvent.end.setTime( gEndDate.getTime() );
if( getFieldValue( "status-field" ) != "" ) // if this event isn't mutable, we need to clone it like a sheep
gEvent.status = eval( "gEvent."+getFieldValue( "status-field" ) ); var originalEvent = event;
if (!event.isMutable)
gEvent.allDay = getFieldValue( "all-day-event-checkbox", "checked" ); event = originalEvent.clone();
gEvent.url = getFieldValue( "uri-field" );
gEvent.privateEvent = getFieldValue( "private-checkbox", "checked" ); // get values from the form and put them into the event
// calIEvent properties
if( getFieldValue( "invite-checkbox", "checked" ) ) //event.startDate.jsDate = gStartDate;
{ //event.endDate.jsDate = gEndDate;
gEvent.inviteEmailAddress = getFieldValue( "invite-email-field", "value" ); event.isAllDay = getFieldValue( "all-day-event-checkbox", "checked" );
}
else
{
gEvent.inviteEmailAddress = "";
}
gEvent.alarm = getFieldValue( "alarm-checkbox", "checked" );
gEvent.alarmLength = getFieldValue( "alarm-length-field" );
gEvent.alarmUnits = getFieldValue( "alarm-length-units", "value" );
gEvent.setParameter( "ICAL_RELATED_PARAMETER", getFieldValue( "alarm-trigger-relation", "value" ) );
if ( getFieldValue( "alarm-email-checkbox", "checked" ) )
{
gEvent.alarmEmailAddress = getFieldValue( "alarm-email-field", "value" );
}
else
{
gEvent.alarmEmailAddress = "";
}
gEvent.categories = getFieldValue( "categories-field", "value" ); // calIItemBase properties
event.title = getFieldValue( "title-field" );
event.isPrivate = getFieldValue( "private-checkbox", "checked" );
if (getFieldValue( "alarm-type" ) != "" && getFieldValue( "alarm-type" ) != "none")
event.hasAlarm == 1
if (event.hasAlarm) {
alarmLength = getFieldValue( "alarm-length-field" );
alarmUnits = getFieldValue( "alarm-length-units", "value" );
//event.alarmTime = ...
}
gEvent.recur = getFieldValue( "repeat-checkbox", "checked" ); event.recurrenceInfo = null;
gEvent.recurUnits = getFieldValue( "repeat-length-units", "value" );
gEvent.recurForever = getFieldValue( "repeat-forever-radio", "selected" ); if (getFieldValue("repeat-checkbox", "checked")) {
gEvent.recurInterval = getFieldValue( "repeat-length-field" ); recurrenceInfo = createRecurrenceInfo();
gEvent.recurCount = (getFieldValue("repeat-numberoftimes-radio", "selected") recurUnits = getFieldValue("repeat-length-units", "value");
? Math.max(1, getFieldValue( "repeat-numberoftimes-textbox")) recurForever = getFieldValue("repeat-forever-radio", "selected");
: 0); // 0 means not selected. recurInterval = getFieldValue("repeat-length-field");
recurCount = (getFieldValue("repeat-numberoftimes-radio", "selected")
if( gEvent.recurInterval == 0 ) ? Math.max(1, getFieldValue("repeat-numberoftimes-textbox"))
gEvent.recur = false; : 0); // 0 means not selected.
if ( gEvent.recur && getFieldValue( "repeat-until-radio", "selected" )) //recurrenceInfo.recurType = ...
{ //recurrenceInfo.recurEnd = ...
var recurEndDate = document.getElementById( "repeat-end-date-picker" ).value; }
gEvent.recurEnd.setTime( recurEndDate );
gEvent.recurEnd.hour = gEvent.start.hour;
gEvent.recurEnd.minute = gEvent.start.minute; // other properties
} event.setProperty('categories', getFieldValue("categories-field", "value"));
else event.setProperty('description', getFieldValue("description-field"));
{ event.setProperty('location', getFieldValue("location-field"));
gEvent.recurEnd.clear(); event.setProperty('url', getFieldValue("uri-field"));
}
event.setProperty("ICAL_RELATED_PARAMETER", getFieldValue("alarm-trigger-relation", "value"));
if (getFieldValue("alarm-type") == "email" )
event.setProperty('alarmEmailAddress', getFieldValue("alarm-email-field", "value"));
else
event.deleteProperty('alarmEmailAddress');
/*
if( getFieldValue( "status-field" ) != "" )
gEvent.status = eval( "gEvent."+getFieldValue( "status-field" ) );
*/
if (getFieldValue("invite-checkbox", "checked"))
event.setProperty('inviteEmailAddress', getFieldValue("invite-email-field", "value"));
else
event.deleteProperty('inviteEmailAddress');
if( gEvent.recur == true )
{
if( gEvent.recurUnits == "weeks" )
{
/*
** advanced weekly repeating, choosing the days to repeat
*/
gEvent.recurWeekdays = getAdvancedWeekRepeat();
}
else if( gEvent.recurUnits == "months" )
{
/*
** advanced month repeating, either every day or every date
*/
if( getFieldValue( "advanced-repeat-dayofweek", "selected" ) == true )
{
gEvent.recurWeekNumber = getWeekNumberOfMonth();
}
else if( getFieldValue( "advanced-repeat-dayofweek-last", "selected" ) == true )
{
gEvent.recurWeekNumber = 5;
}
else
gEvent.recurWeekNumber = 0;
}
}
/* EXCEPTIONS */ /* EXCEPTIONS */
/*
gEvent.removeAllExceptions(); gEvent.removeAllExceptions();
var listbox = document.getElementById( "exception-dates-listbox" ); var listbox = document.getElementById( "exception-dates-listbox" );
@ -447,51 +428,47 @@ function onOKCommand()
gEvent.addException( dateObj ); gEvent.addException( dateObj );
} }
*/
/* File attachments */ /* File attachments */
//loop over the items in the listbox //loop over the items in the listbox
gEvent.removeAttachments(); //event.attachments.clear();
var attachmentListbox = document.getElementById( "attachmentBucket" ); var attachmentListbox = document.getElementById( "attachmentBucket" );
for( i = 0; i < attachmentListbox.childNodes.length; i++ ) for (i = 0; i < attachmentListbox.childNodes.length; i++) {
{ attachment = Components.classes["@mozilla.org/messengercompose/attachment;1"].createInstance(Components.interfaces.nsIMsgAttachment);
Attachment = Components.classes["@mozilla.org/messengercompose/attachment;1"].createInstance( Components.interfaces.nsIMsgAttachment ); attachment.url = attachmentListbox.childNodes[i].getAttribute("label");
// XXX
Attachment.url = attachmentListbox.childNodes[i].getAttribute( "label" ); //event.attachments.appendElement(attachment);
}
gEvent.addAttachment( Attachment );
}
// Attach any specified contacts to the event // Attach any specified contacts to the event
if( gEventCardArray ) if (gEventCardArray) {
{ try {
try{
// Remove any existing contacts // Remove any existing contacts
gEvent.removeContacts(); //event.contacts.clear();
// Add specified contacts
for( var cardId in gEventCardArray )
{
if( gEventCardArray[ cardId ] )
{
gEvent.addContact( gEventCardArray[ cardId ] );
}
}
}
catch( e )
{
// Add specified contacts
for (var cardId in gEventCardArray)
if (gEventCardArray[cardId]) {
// XXX
//event.contacts.appendElement(gEventCardArray[cardId]);
}
}
catch (e)
{
} }
} }
var Server = getFieldValue( "server-field" ); var Server = getFieldValue( "server-field" );
// :TODO: REALLY only do this if the alarm or start settings change.? // :TODO: REALLY only do this if the alarm or start settings change.?
//if the end time is later than the start time... alert the user using text from the dtd. //if the end time is later than the start time... alert the user using text from the dtd.
// call caller's on OK function // call caller's on OK function
gOnOkFunction( gEvent, Server, gOriginalEvent );
gOnOkFunction(event, Server, originalEvent);
// tell standard dialog stuff to close the dialog // tell standard dialog stuff to close the dialog
return true; return true;
} }
@ -577,25 +554,25 @@ function checkSetRecur()
function setRecurError(state) function setRecurError(state)
{ {
document.getElementById("repeat-time-warning" ).setAttribute( "collapsed", !state); document.getElementById("repeat-time-warning" ).setAttribute( "hidden", !state);
} }
function setDateError(state) function setDateError(state)
{ {
document.getElementById( "end-date-warning" ).setAttribute( "collapsed", !state ); document.getElementById( "end-date-warning" ).setAttribute( "hidden", !state );
} }
function setTimeError(state) function setTimeError(state)
{ {
document.getElementById( "end-time-warning" ).setAttribute( "collapsed", !state ); document.getElementById( "end-time-warning" ).setAttribute( "hidden", !state );
} }
function setOkButton(state) function setOkButton(state)
{ {
if (state == false) if (state == false)
document.getElementById( "calendar-new-eventwindow" ).getButton( "accept" ).setAttribute( "disabled", true ); document.getElementById( "calendar-new-component-window" ).getButton( "accept" ).setAttribute( "disabled", true );
else else
document.getElementById( "calendar-new-eventwindow" ).getButton( "accept" ).removeAttribute( "disabled" ); document.getElementById( "calendar-new-component-window" ).getButton( "accept" ).removeAttribute( "disabled" );
} }
function updateOKButton() function updateOKButton()
@ -698,89 +675,9 @@ function commandAllDay()
updateOKButton(); updateOKButton();
} }
/**
* Called when the alarm checkbox is clicked.
*/
function commandAlarm()
{
updateAlarmItemEnabled();
}
/** /**
* Enable/Disable Alarm items * Called when the invite checkbox is clicked.
*/
function updateAlarmItemEnabled()
{
var alarmCheckBox = "alarm-checkbox";
var alarmField = "alarm-length-field";
var alarmMenu = "alarm-length-units";
var alarmTrigger = "alarm-trigger-relation";
var alarmEmailCheckbox = "alarm-email-checkbox";
var alarmEmailField = "alarm-email-field";
// if( getFieldValue(alarmCheckBox, "checked" ) || getFieldValue( alarmEmailCheckbox, "checked" ) )
if( getFieldValue(alarmCheckBox, "checked" ) )
{
// call remove attribute beacuse some widget code checks for the presense of a
// disabled attribute, not the value.
setFieldValue( alarmField, false, "disabled" );
setFieldValue( alarmMenu, false, "disabled" );
setFieldValue( alarmTrigger, false, "disabled" );
setFieldValue( alarmEmailField, false, "disabled" );
setFieldValue( alarmEmailCheckbox, false, "disabled" );
}
else
{
setFieldValue( alarmField, true, "disabled" );
setFieldValue( alarmMenu, true, "disabled" );
setFieldValue( alarmTrigger, true, "disabled" );
setFieldValue( alarmEmailField, true, "disabled" );
setFieldValue( alarmEmailCheckbox, true, "disabled" );
}
}
/**
* Called when the alarm checkbox is clicked.
*/
function commandAlarmEmail()
{
updateAlarmEmailItemEnabled();
}
/**
* Enable/Disable Alarm items
*/
function updateAlarmEmailItemEnabled()
{
var alarmCheckBox = "alarm-email-checkbox";
var alarmEmailField = "alarm-email-field";
if( getFieldValue( alarmCheckBox, "checked" ) )
{
// call remove attribute beacuse some widget code checks for the presense of a
// disabled attribute, not the value.
setFieldValue( alarmEmailField, false, "disabled" );
}
else
{
setFieldValue( alarmEmailField, true, "disabled" );
}
}
/**
* Called when the alarm checkbox is clicked.
*/ */
function commandInvite() function commandInvite()
@ -883,7 +780,8 @@ function updateMenuPlural( lengthFieldId, menuId )
var newLabelNumber; var newLabelNumber;
if( Number( length ) > 1 ) // XXX This assumes that "0 days, minutes, etc." is plural in other languages.
if( ( Number( length ) == 0 ) || ( Number( length ) > 1 ) )
{ {
newLabelNumber = "labelplural" newLabelNumber = "labelplural"
} }
@ -997,7 +895,6 @@ function updateRepeatUnitExtensions( )
} }
/** /**
* Enable/Disable Start/End items * Enable/Disable Start/End items
*/ */
@ -1015,8 +912,6 @@ function updateStartEndItemEnabled()
} }
/** /**
* Handle key down in repeat field * Handle key down in repeat field
*/ */
@ -1414,22 +1309,29 @@ function setFieldValue( elementId, newValue, propertyName )
{ {
var undefined; var undefined;
if( newValue !== undefined ) if( newValue !== undefined ) {
{
var field = document.getElementById( elementId ); var field = document.getElementById( elementId );
if( newValue === false ) if( newValue === false ) {
{ try {
field.removeAttribute( propertyName ); field.removeAttribute( propertyName );
}
else
{
if( propertyName )
{
field.setAttribute( propertyName, newValue );
} }
else catch (e) {
{ dump("setFieldValue: field.removeAttribute couldn't remove "+propertyName+
" from "+elementId+" e: "+e+"\n");
}
}
else {
if( propertyName ) {
try {
field.setAttribute( propertyName, newValue );
}
catch (e) {
dump("setFieldValue: field.setAttribute couldn't set "+propertyName+
" from "+elementId+" to "+newValue+" e: "+e+"\n");
}
}
else {
field.value = newValue; field.value = newValue;
} }
} }
@ -1518,7 +1420,6 @@ function setDateFieldValue( elementId, newDate )
function setTimeFieldValue( elementId, newDate ) function setTimeFieldValue( elementId, newDate )
{ {
// set the value to a formatted time string // set the value to a formatted time string
var field = document.getElementById( elementId ); var field = document.getElementById( elementId );
field.value = formatTime( newDate ); field.value = formatTime( newDate );
@ -1557,3 +1458,85 @@ function debug( text )
if( debugenabled ) if( debugenabled )
dump( "\n"+ text + "\n"); dump( "\n"+ text + "\n");
} }
// XXX lilmatt's new crap for the new XUL
function processAlarmType()
{
var alarmMenu = document.getElementById("alarm-type");
if( alarmMenu.selectedItem ) {
dump("processAlarmType: "+alarmMenu.selectedItem.value+"\n");
switch( alarmMenu.selectedItem.value )
{
case "none":
hideElement("alarm-length-field");
hideElement("alarm-length-units");
hideElement("alarm-box-email");
break;
case "popup":
showElement("alarm-length-field");
showElement("alarm-length-units");
hideElement("alarm-box-email");
break;
case "popupAndSound":
showElement("alarm-length-field");
showElement("alarm-length-units");
hideElement("alarm-box-email");
break;
case "email":
showElement("alarm-length-field");
showElement("alarm-length-units");
showElement("alarm-box-email");
break;
}
// Make the window big enough for all the fields and widgets
window.sizeToContent();
}
else
dump("processAlarmType: no alarmMenu.selectedItem!\n");
}
function processComponentType()
{
var componentMenu = document.getElementById("component-type");
if( componentMenu.selectedItem) {
dump("processComponentType: "+componentMenu.selectedItem.value+"\n");
var args = window.arguments[0];
switch( componentMenu.selectedItem.value )
{
case "ICAL_COMPONENT_EVENT":
// Hide and show the appropriate fields and widgets
hideElement("task-status-label");
hideElement("cancelled-checkbox");
showElement("event-status-label");
showElement("event-status-field");
showElement("all-day-event-checkbox");
// Set menubar title correctly - New vs. Edit
if( "new" == args.mode )
titleDataItem = document.getElementById( "data-event-title-new" );
else
titleDataItem = document.getElementById( "data-event-title-edit" );
document.getElementById("calendar-new-component-window").setAttribute("title", titleDataItem.getAttribute( "value" ));
break;
case "ICAL_COMPONENT_TODO":
// Hide and show the appropriate fields and widgets
hideElement("event-status-label");
hideElement("event-status-field");
hideElement("all-day-event-checkbox");
showElement("task-status-label");
showElement("cancelled-checkbox");
// Set menubar title correctly - New vs. Edit
if( "new" == args.mode )
titleDataItem = document.getElementById( "data-event-title-new" );
else
titleDataItem = document.getElementById( "data-event-title-edit" );
document.getElementById("calendar-new-component-window").setAttribute("title", titleDataItem.getAttribute( "value" ));
break;
//case "ICAL_COMPONENT_JOURNAL":
}
// Make the window big enough for all the fields and widgets
window.sizeToContent();
}
else
dump("processComponentType: no componentMenu.selectedItem!\n");
}

File diff suppressed because it is too large Load Diff