diff --git a/calendar/resources/content/calendar.js b/calendar/resources/content/calendar.js
index f8ebed6cd597..c825fe9382cf 100644
--- a/calendar/resources/content/calendar.js
+++ b/calendar/resources/content/calendar.js
@@ -437,11 +437,16 @@ function newEvent( startDate )
args.calendarEvent = createEvent();
args.calendarEvent.start.setTime( startDate );
- args.calendarEvent.end.setTime( startDate );
- args.calendarEvent.end.hour++;
+
+ var MinutesToAddOn = gCalendarWindow.calendarPreferences.getPref( "defaulteventlength" );
+
+ var endDate = new Date();
+
+ var endDateTime = startDate.getTime() + ( 1000 * 60 * MinutesToAddOn );
+ args.calendarEvent.end.setTime( endDateTime );
+
// open the dialog non modally
-
openDialog( "chrome://calendar/content/calendarEventDialog.xul", "caNewEvent", "chrome", args );
}
diff --git a/calendar/resources/content/calendarEventDialog.js b/calendar/resources/content/calendarEventDialog.js
index 2260f626c026..655c217b64e3 100644
--- a/calendar/resources/content/calendarEventDialog.js
+++ b/calendar/resources/content/calendarEventDialog.js
@@ -141,7 +141,7 @@ function loadCalendarEventDialog()
if ( gEvent.recurForever )
{
var today = new Date();
- gEvent.recurEnd.setTime( startDate );
+ gEvent.recurEnd.setTime( endDate );
}
var recurEndDate = new Date( gEvent.recurEnd.getTime() );
@@ -295,12 +295,6 @@ function onOKCommand()
if( gEvent.recur == true )
{
//check that the repeat end time is later than the end time
- if( recurEndDate.getTime() < gEvent.end.getTime() && gEvent.recurForever == false )
- {
- alert( neRecurErrorAlertMessage );
- return( false );
- }
-
if( gEvent.recurUnits == "weeks" )
{
/*
@@ -326,21 +320,67 @@ function onOKCommand()
// :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 ( gEvent.end.getTime() < gEvent.start.getTime() && !gEvent.allDay )
+ // call caller's on OK function
+ gOnOkFunction( gEvent );
+
+ // tell standard dialog stuff to close the dialog
+ return true;
+}
+
+function checkEndTime()
+{
+ var endDate = getDateTimeFieldValue( "end-time-text" );
+
+ var startDate = getDateTimeFieldValue( "start-time-text" );
+
+ var AllDayEvent = getFieldValue( "all-day-event-checkbox", "checked" );
+
+ if( endDate.getTime() < startDate.getTime() && !AllDayEvent )
{
- alert( neStartTimeErrorAlertMessage );
+ document.getElementById( "end-time-warning" ).setAttribute( "collapsed", "false" );
+
return( false );
}
else
{
- // call caller's on OK function
- gOnOkFunction( gEvent );
+ document.getElementById( "end-time-warning" ).setAttribute( "collapsed", "true" );
+
+ return( true );
+ }
- // tell standard dialog stuff to close the dialog
- return true;
+}
+
+
+function checkRecurTime()
+{
+ var recurEndDate = getDateTimeFieldValue( "repeat-end-date-text" );
+
+ var endDate = getDateTimeFieldValue( "end-time-text" );
+
+ var recurForever = getFieldValue( "repeat-forever-radio", "selected" );
+
+ if( recurEndDate.getTime() < endDate.getTime() && recurForever == false )
+ {
+ document.getElementById( "repeat-time-warning" ).setAttribute( "collapsed", "false" );
+
+ return( false );
+ }
+ else
+ {
+ document.getElementById( "repeat-time-warning" ).setAttribute( "collapsed", "true" );
+
+ return( true );
}
}
+function updateOKButton()
+{
+ var CheckEndTime = checkEndTime();
+
+ var CheckRecurTime = checkRecurTime();
+
+ document.getElementById( "ok" ).setAttribute( "disabled", !( CheckEndTime && CheckRecurTime ) );
+}
/**
* Called when an item with a datepicker is clicked, BEFORE the picker is shown.
@@ -392,6 +432,8 @@ function onDatePick( datepopup )
updateAdvancedWeekRepeat();
updateAdvancedRepeatDayOfMonth();
+
+ updateOKButton();
}
@@ -438,7 +480,7 @@ function onTimePick( timepopup )
55,
0);
}
- formattedEndTime = formatTime( newEndDate );
+
if( timepopup.timeField.id != "end-time-text" )
{
setTimeFieldValue( "end-time-text", newEndDate );
@@ -468,6 +510,8 @@ function onTimePick( timepopup )
// remember the new date in a property, "editDate". we created on the time textbox
timepopup.timeField.editDate = timepopup.value;
+
+ updateOKButton();
}
@@ -489,6 +533,8 @@ function commandRepeat()
function commandUntil()
{
updateUntilItemEnabled();
+
+ updateOKButton();
}
/**
diff --git a/calendar/resources/content/calendarEventDialog.xul b/calendar/resources/content/calendarEventDialog.xul
index d54ac9f6d1e4..3210ab36c87c 100644
--- a/calendar/resources/content/calendarEventDialog.xul
+++ b/calendar/resources/content/calendarEventDialog.xul
@@ -141,7 +141,7 @@
-
+
@@ -178,6 +178,7 @@
+
@@ -285,10 +286,16 @@
-
-
-
-
+
+
+
+
+
+
+
+
+
+
diff --git a/calendar/resources/content/eventDialog.js b/calendar/resources/content/eventDialog.js
index 2260f626c026..655c217b64e3 100644
--- a/calendar/resources/content/eventDialog.js
+++ b/calendar/resources/content/eventDialog.js
@@ -141,7 +141,7 @@ function loadCalendarEventDialog()
if ( gEvent.recurForever )
{
var today = new Date();
- gEvent.recurEnd.setTime( startDate );
+ gEvent.recurEnd.setTime( endDate );
}
var recurEndDate = new Date( gEvent.recurEnd.getTime() );
@@ -295,12 +295,6 @@ function onOKCommand()
if( gEvent.recur == true )
{
//check that the repeat end time is later than the end time
- if( recurEndDate.getTime() < gEvent.end.getTime() && gEvent.recurForever == false )
- {
- alert( neRecurErrorAlertMessage );
- return( false );
- }
-
if( gEvent.recurUnits == "weeks" )
{
/*
@@ -326,21 +320,67 @@ function onOKCommand()
// :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 ( gEvent.end.getTime() < gEvent.start.getTime() && !gEvent.allDay )
+ // call caller's on OK function
+ gOnOkFunction( gEvent );
+
+ // tell standard dialog stuff to close the dialog
+ return true;
+}
+
+function checkEndTime()
+{
+ var endDate = getDateTimeFieldValue( "end-time-text" );
+
+ var startDate = getDateTimeFieldValue( "start-time-text" );
+
+ var AllDayEvent = getFieldValue( "all-day-event-checkbox", "checked" );
+
+ if( endDate.getTime() < startDate.getTime() && !AllDayEvent )
{
- alert( neStartTimeErrorAlertMessage );
+ document.getElementById( "end-time-warning" ).setAttribute( "collapsed", "false" );
+
return( false );
}
else
{
- // call caller's on OK function
- gOnOkFunction( gEvent );
+ document.getElementById( "end-time-warning" ).setAttribute( "collapsed", "true" );
+
+ return( true );
+ }
- // tell standard dialog stuff to close the dialog
- return true;
+}
+
+
+function checkRecurTime()
+{
+ var recurEndDate = getDateTimeFieldValue( "repeat-end-date-text" );
+
+ var endDate = getDateTimeFieldValue( "end-time-text" );
+
+ var recurForever = getFieldValue( "repeat-forever-radio", "selected" );
+
+ if( recurEndDate.getTime() < endDate.getTime() && recurForever == false )
+ {
+ document.getElementById( "repeat-time-warning" ).setAttribute( "collapsed", "false" );
+
+ return( false );
+ }
+ else
+ {
+ document.getElementById( "repeat-time-warning" ).setAttribute( "collapsed", "true" );
+
+ return( true );
}
}
+function updateOKButton()
+{
+ var CheckEndTime = checkEndTime();
+
+ var CheckRecurTime = checkRecurTime();
+
+ document.getElementById( "ok" ).setAttribute( "disabled", !( CheckEndTime && CheckRecurTime ) );
+}
/**
* Called when an item with a datepicker is clicked, BEFORE the picker is shown.
@@ -392,6 +432,8 @@ function onDatePick( datepopup )
updateAdvancedWeekRepeat();
updateAdvancedRepeatDayOfMonth();
+
+ updateOKButton();
}
@@ -438,7 +480,7 @@ function onTimePick( timepopup )
55,
0);
}
- formattedEndTime = formatTime( newEndDate );
+
if( timepopup.timeField.id != "end-time-text" )
{
setTimeFieldValue( "end-time-text", newEndDate );
@@ -468,6 +510,8 @@ function onTimePick( timepopup )
// remember the new date in a property, "editDate". we created on the time textbox
timepopup.timeField.editDate = timepopup.value;
+
+ updateOKButton();
}
@@ -489,6 +533,8 @@ function commandRepeat()
function commandUntil()
{
updateUntilItemEnabled();
+
+ updateOKButton();
}
/**
diff --git a/calendar/resources/content/eventDialog.xul b/calendar/resources/content/eventDialog.xul
index d54ac9f6d1e4..3210ab36c87c 100644
--- a/calendar/resources/content/eventDialog.xul
+++ b/calendar/resources/content/eventDialog.xul
@@ -141,7 +141,7 @@
-
+
@@ -178,6 +178,7 @@
+
@@ -285,10 +286,16 @@
-
-
-
-
+
+
+
+
+
+
+
+
+
+
diff --git a/calendar/resources/content/pref/calendarPref.xul b/calendar/resources/content/pref/calendarPref.xul
index 751d7d6cd156..f6c12100504f 100644
--- a/calendar/resources/content/pref/calendarPref.xul
+++ b/calendar/resources/content/pref/calendarPref.xul
@@ -53,7 +53,7 @@
@@ -91,5 +91,10 @@
+
+ Default Event Length:
+
+
+
diff --git a/calendar/resources/content/pref/rootCalendarPref.js b/calendar/resources/content/pref/rootCalendarPref.js
index a47c0456e77d..dd4c131870b7 100644
--- a/calendar/resources/content/pref/rootCalendarPref.js
+++ b/calendar/resources/content/pref/rootCalendarPref.js
@@ -69,6 +69,7 @@ function calendarPreferences( CalendarWindow )
this.calendarPref.setBoolPref( "alarms.playsound", false );
this.calendarPref.setIntPref( "date.format", 0 );
this.calendarPref.setIntPref( "week.start", 0 );
+ this.calendarPref.setIntPref( "event.defaultlength", 60 );
this.loadPreferences();
}
@@ -84,6 +85,8 @@ calendarPreferences.prototype.loadPreferences = function()
this.arrayOfPrefs.dateformat = this.calendarPref.getIntPref( "date.format" );
this.arrayOfPrefs.weekstart = this.calendarPref.getIntPref( "week.start" );
+
+ this.arrayOfPrefs.defaulteventlength = this.calendarPref.getIntPref( "event.defaultlength" );
}
calendarPreferences.prototype.getPref = function( Preference )
diff --git a/calendar/resources/locale/en-US/calendar.dtd b/calendar/resources/locale/en-US/calendar.dtd
index 3cf790908221..34be47f893bd 100644
--- a/calendar/resources/locale/en-US/calendar.dtd
+++ b/calendar/resources/locale/en-US/calendar.dtd
@@ -75,6 +75,9 @@
+
+
+