Checking in attachment 145873 and 145875 for bug 206382

This commit is contained in:
mostafah%oeone.com 2004-04-23 14:27:50 +00:00
Родитель a24dd64f8f
Коммит 10a3489e96
2 изменённых файлов: 60 добавлений и 229 удалений

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

@ -84,20 +84,17 @@ var debugenabled=false;
var gEvent; // event being edited
var gOnOkFunction; // function to be called when user clicks OK
var gTimeDifference = 3600000; //when editing an event, we change the end time if the start time is changing. This is the difference for the event time.
var gDateDifference = 3600000; //this is the difference for the dates, not the times.
var gDuration = -1; // used to preserve duration when changing event start.
const DEFAULT_ALARM_LENGTH = 15; //default number of time units, an alarm goes off before an event
var gMode = ''; //what mode are we in? new or edit...
const kRepeatDay_0 = 1; //Sunday
const kRepeatDay_1 = 2; //Monday
const kRepeatDay_2 = 4; //Tuesday
const kRepeatDay_3 = 8; //Wednesday
const kRepeatDay_4 = 16;//Thursday
const kRepeatDay_5 = 32;//Friday
const kRepeatDay_6 = 64;//Saturday
const kRepeatDay_0 = 1<<0;//Sunday
const kRepeatDay_1 = 1<<1;//Monday
const kRepeatDay_2 = 1<<2;//Tuesday
const kRepeatDay_3 = 1<<3;//Wednesday
const kRepeatDay_4 = 1<<4;//Thursday
const kRepeatDay_5 = 1<<5;//Friday
const kRepeatDay_6 = 1<<6;//Saturday
var gStartDate = new Date( );
@ -117,8 +114,6 @@ function loadCalendarEventDialog()
var args = window.arguments[0];
gMode = args.mode;
gOnOkFunction = args.onOk;
gEvent = args.calendarEvent;
@ -139,16 +134,12 @@ function loadCalendarEventDialog()
// fill in fields from the event
gStartDate.setTime( gEvent.start.getTime() );
document.getElementById( "start-date-picker" ).value = gStartDate;
document.getElementById( "start-datetime" ).value = gStartDate;
gEndDate.setTime(gEvent.end.getTime() );
document.getElementById( "end-date-picker" ).value = gEndDate;
gEndDate.setTime( gEvent.end.getTime() );
document.getElementById( "end-datetime" ).value = gEndDate;
setTimeFieldValue( "start-time-text", gStartDate );
setTimeFieldValue( "end-time-text", gEndDate );
gTimeDifference = gEndDate.getTime() - gStartDate.getTime(); //the time difference in ms
gDateDifference = gTimeDifference; //the time difference in ms
gDuration = gEndDate.getTime() - gStartDate.getTime(); //in ms
if ( gEvent.recurForever )
{
@ -506,9 +497,8 @@ function checkEndTime()
function checkEndDate()
{
// Bad to get into floats.
var startDate = document.getElementById( "start-date-picker" ).value;
var endDate = document.getElementById( "end-date-picker" ).value;
var startDate = document.getElementById( "start-datetime" ).value;
var endDate = document.getElementById( "end-datetime" ).value;
if( startDate.getFullYear() == endDate.getFullYear() &&
startDate.getMonth() == endDate.getMonth() &&
@ -559,7 +549,7 @@ function checkSetRecurTime()
{
var recurEndDate = document.getElementById( "repeat-end-date-picker" ).value;
var endDate = document.getElementById( "end-date-picker" ).value;
var endDate = document.getElementById( "end-datetime" ).value;
var recurForever = getFieldValue( "repeat-forever-radio", "selected" );
@ -596,8 +586,6 @@ function setOkButton(state)
document.getElementById( "calendar-new-eventwindow" ).getButton( "accept" ).setAttribute( "disabled", true );
else
document.getElementById( "calendar-new-eventwindow" ).getButton( "accept" ).removeAttribute( "disabled" );
}
function updateOKButton()
@ -613,142 +601,44 @@ function updateOKButton()
* Called when a datepicker is finished, and a date was picked.
*/
function onDatePick( datepicker )
function onDateTimePick( dateTimePicker )
{
var ThisDate = new Date( datepicker.value);
var pickedDateTime = new Date( dateTimePicker.value);
if( datepicker.id == "end-date-picker" )
if( dateTimePicker.id == "end-datetime" )
{
gEndDate.setMonth( ThisDate.getMonth() );
gEndDate.setDate( ThisDate.getDate() );
gEndDate.setFullYear( ThisDate.getFullYear() );
//get the new end time by adding on the time difference to the start time.
gDateDifference = gEndDate.getTime() - gStartDate.getTime();
updateOKButton();
return;
gEndDate = pickedDateTime;
// save the duration
gDuration = gEndDate.getTime() - gStartDate.getTime();
updateOKButton();
return;
}
if( datepicker.id == "start-date-picker" )
if( dateTimePicker.id == "start-datetime" )
{
gStartDate.setMonth( ThisDate.getMonth() );
gStartDate.setDate( ThisDate.getDate() );
gStartDate.setFullYear( ThisDate.getFullYear() );
//get the new end time by adding on the time difference to the start time.
gEndDate.setTime( gStartDate.getTime() + gDateDifference );
gStartDate = pickedDateTime;
// preserve the previous duration by changing end
gEndDate.setTime( gStartDate.getTime() + gDuration );
document.getElementById( "end-date-picker" ).value = gEndDate;
setTimeFieldValue( "end-time-text", gEndDate );
document.getElementById( "end-datetime" ).value = gEndDate;
}
var Now = new Date();
var now = new Date();
//change the end date of recurring events to today, if the new date is after today and repeat is not checked.
if ( datepicker.value.getTime() > Now.getTime() && !getFieldValue( "repeat-checkbox", "checked" ) )
// change the end date of recurring events to today,
// if the new date is after today and repeat is not checked.
if ( pickedDateTime.getTime() > now.getTime() &&
!getFieldValue( "repeat-checkbox", "checked" ) )
{
document.getElementById( "repeat-end-date-picker" ).value = datepicker.value;
document.getElementById( "repeat-end-date-picker" ).value = pickedDateTime;
}
updateAdvancedWeekRepeat();
updateAdvancedRepeatDayOfMonth();
updateAddExceptionButton();
updateOKButton();
}
/**
* Called when an item with a time picker is clicked, BEFORE the picker is shown.
*/
function prepareTimePicker( timeFieldName )
{
// get the popup and the field we are editing
var timePickerPopup = document.getElementById( "oe-time-picker-popup" );
var timeField = document.getElementById( timeFieldName );
timeField.focus();
// tell the time picker the time to edit.
setFieldValue( "oe-time-picker-popup", timeField.editDate, "value" );
// remember the time field that is to be updated by adding a
// property "timeField" to the popup.
timePickerPopup.timeField = timeField;
}
/**
* Called when a timepicker is finished, and a time was picked.
*/
function onTimePick( timepopup )
{
var ThisDate = timepopup.value;
if( timepopup.timeField.id == "end-time-text" )
{
gEndDate.setHours( ThisDate.getHours() );
gEndDate.setMinutes( ThisDate.getMinutes() );
//if we are changing the end time, change the global duration.
gTimeDifference = gEndDate.getTime() - gStartDate.getTime(); //the time difference in ms
if ( gTimeDifference < 0 )
{
gTimeDifference = 0;
}
}
if( timepopup.timeField.id == "start-time-text" )
{
gStartDate.setHours( ThisDate.getHours() );
gStartDate.setMinutes( ThisDate.getMinutes() );
//get the new end time by adding on the time difference to the start time.
gEndDate.setTime( gStartDate.getTime() + gTimeDifference );
document.getElementById( "end-date-picker" ).value = gEndDate;
setTimeFieldValue( "end-time-text", gEndDate );
}
// display the new time in the textbox
timepopup.timeField.value = formatTime( timepopup.value );
// remember the new date in a property, "editDate". we created on the time textbox
timepopup.timeField.editDate = timepopup.value;
updateOKButton();
}
/**
* Called when an item with a datepicker is clicked, BEFORE the picker is shown.
*/
function prepareDatePicker( dateFieldName )
{
// get the popup and the field we are editing
var datePickerPopup = document.getElementById( "oe-date-picker-popup" );
var dateField = document.getElementById( dateFieldName );
// tell the date picker the date to edit.
setFieldValue( "oe-date-picker-popup", dateField.editDate, "value" );
// remember the date field that is to be updated by adding a
// property "dateField" to the popup.
datePickerPopup.dateField = dateField;
}
/**
* Called when the repeat checkbox is clicked.
*/
@ -1077,41 +967,13 @@ function updateRepeatUnitExtensions( )
function updateStartEndItemEnabled()
{
var allDayCheckBox = document.getElementById( "all-day-event-checkbox" );
var editTimeDisabled = allDayCheckBox.checked;
var startTimePicker = document.getElementById( "start-time-button" );
var startTimeText = document.getElementById( "start-time-text" );
var endTimePicker = document.getElementById( "end-time-button" );
var endTimeText = document.getElementById( "end-time-text" );
if( allDayCheckBox.checked )
{
// disable popups by removing the popup attribute
startTimeText.setAttribute( "disabled", "true" );
startTimeText.removeAttribute( "popup" );
startTimePicker.setAttribute( "disabled", "true" );
startTimePicker.removeAttribute( "popup" );
endTimeText.setAttribute( "disabled", "true" );
endTimeText.removeAttribute( "popup" );
endTimePicker.setAttribute( "disabled", "true" );
endTimePicker.removeAttribute( "popup" );
}
else
{
// enable popups by setting the popup attribute
startTimeText.removeAttribute( "disabled" );
startTimeText.setAttribute( "popup", "oe-time-picker-popup" );
startTimePicker.removeAttribute( "disabled" );
startTimePicker.setAttribute( "popup", "oe-time-picker-popup" );
endTimeText.removeAttribute( "disabled" );
endTimeText.setAttribute( "popup", "oe-time-picker-popup" );
endTimePicker.removeAttribute( "disabled" );
endTimePicker.setAttribute( "popup", "oe-time-picker-popup" );
}
var startTimePicker = document.getElementById( "start-datetime" );
var endTimePicker = document.getElementById( "end-datetime" );
startTimePicker.timepickerdisabled = editTimeDisabled;
endTimePicker.timepickerdisabled = editTimeDisabled;
}
@ -1163,7 +1025,7 @@ function setAdvancedWeekRepeat()
}
//get the day number for today.
var dayNumber = document.getElementById( "start-date-picker" ).value.getDay();
var dayNumber = document.getElementById( "start-datetime" ).value.getDay();
setFieldValue( "advanced-repeat-week-"+dayNumber, "true", "checked" );
@ -1197,7 +1059,7 @@ function getAdvancedWeekRepeat()
function updateAdvancedWeekRepeat()
{
//get the day number for today.
var dayNumber = document.getElementById( "start-date-picker" ).value.getDay();
var dayNumber = document.getElementById( "start-datetime" ).value.getDay();
//uncheck them all if the repeat checkbox is checked
var repeatCheckBox = document.getElementById( "repeat-checkbox" );
@ -1234,7 +1096,7 @@ function updateAdvancedWeekRepeat()
function updateAdvancedRepeatDayOfMonth()
{
//get the day number for today.
var dayNumber = document.getElementById( "start-date-picker" ).value.getDate();
var dayNumber = document.getElementById( "start-datetime" ).value.getDate();
var dayExtension = getDayExtension( dayNumber );
@ -1308,7 +1170,7 @@ function addException( dateToAdd )
{
//get the date from the date and time box.
//returns a date object
var dateToAdd = document.getElementById( "exceptions-date-picker" ).value;
dateToAdd = document.getElementById( "exceptions-date-picker" ).value;
}
if( isAlreadyException( dateToAdd ) )
@ -1356,7 +1218,7 @@ function getDayExtension( dayNumber )
function getDayOfWeek( )
{
//get the day number for today.
var dayNumber = document.getElementById( "start-date-picker" ).value.getDay();
var dayNumber = document.getElementById( "start-datetime" ).value.getDay();
var dateStringBundle = srGetStrBundle("chrome://calendar/locale/dateFormat.properties");
@ -1370,7 +1232,7 @@ function getDayOfWeek( )
function getWeekNumberOfMonth()
{
//get the day number for today.
var startTime = document.getElementById( "start-date-picker" ).value;
var startTime = document.getElementById( "start-datetime" ).value;
var oldStartTime = startTime;
@ -1395,7 +1257,7 @@ function getWeekNumberOfMonth()
function isLastDayOfWeekOfMonth()
{
//get the day number for today.
var startTime = document.getElementById( "start-date-picker" ).value;
var startTime = document.getElementById( "start-datetime" ).value;
var oldStartTime = startTime;
@ -1632,8 +1494,6 @@ function setTimeFieldValue( elementId, newDate )
/**
* Take a Date object and return a displayable date string i.e.: May 5, 1959
* :TODO: This should be moved into DateFormater and made to use some kind of
* locale or user date format preference.
*/
function formatDate( date )
@ -1652,7 +1512,6 @@ function formatTime( time )
return timeString;
}
function debug( text )
{
if( debugenabled )

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

@ -43,14 +43,12 @@
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
<?xul-overlay href="chrome://calendar/content/timepicker/timepicker-overlay.xul"?>
<!-- CSS File with all styles specific to the dialog -->
<?xml-stylesheet href="chrome://calendar/skin/eventDialog.css" ?>
<?xml-stylesheet href="chrome://calendar/skin/dialogOverlay.css" type="text/css"?>
<?xml-stylesheet href="chrome://calendar/content/datepicker/datepicker.css" ?>
<?xml-stylesheet href="chrome://calendar/content/datepicker/calendar.css" ?>
<?xml-stylesheet
href="chrome://calendar/content/datetimepickers/datetimepicker.css" ?>
<!-- CSS for selecting contacts to invite to event -->
<?xml-stylesheet href="chrome://calendar/skin/selectAddresses.css" ?>
@ -119,9 +117,7 @@
</dataset>
<!-- Picker popups -->
<popup id="oe-time-picker-popup" position="after_start" oncommand="onTimePick( this )" value=""/>
<!-- Dialog content -->
<vbox id="standard-dialog-content" flex="1">
@ -162,20 +158,8 @@
<hbox class="field-label-box-class" pack="end">
<label value="&newevent.startdate.label;"/>
</hbox>
<hbox id="start-date-box" align="center">
<datepicker id="start-date-picker" value="" ondatepick="onDatePick( this );"/>
<textbox id="start-time-text"
readonly="true"
value=""
onmousedown="prepareTimePicker('start-time-text')"
popup="oe-time-picker-popup"
position="after_start"/>
<image id="start-time-button"
class="event-time-button-class"
onmousedown="prepareTimePicker('start-time-text')"
popup="oe-time-picker-popup"
position="after_start"/>
</hbox>
<datetimepicker id="start-datetime" value=""
onchange="onDateTimePick( this );"/>
</row>
<!-- End Date -->
@ -183,20 +167,8 @@
<hbox class="field-label-box-class" pack="end">
<label value="&newevent.enddate.label;"/>
</hbox>
<hbox id="end-date-box" align="center">
<datepicker id="end-date-picker" value="" ondatepick="onDatePick( this );"/>
<textbox id="end-time-text"
readonly="true"
value=""
onmousedown="prepareTimePicker('end-time-text')"
popup="oe-time-picker-popup"
position="after_start"/>
<image id="end-time-button"
class="event-time-button-class"
onmousedown="prepareTimePicker('end-time-text')"
popup="oe-time-picker-popup"
position="after_start"/>
</hbox>
<datetimepicker id="end-datetime" value=""
onchange="onDateTimePick( this );"/>
</row>
<!-- End Time Warning -->
@ -368,9 +340,9 @@
</rows>
</grid>
</tabpanel>
<tabpanel>
<!-- Repeat -->
<tabpanel>
<vbox>
<hbox id="repeat-box" align="center">
<checkbox id="repeat-checkbox"
@ -513,8 +485,9 @@
oncommand="commandUntil()"/>
<spacer id="until-spacer"/>
<datepicker id="repeat-end-date-picker"
disable-controller="repeat"
value=""
ondatepick="commandUntil()"/>
onchange="commandUntil()"/>
</hbox>
<label id="repeat-time-warning"
class="warning-text-class"
@ -538,7 +511,7 @@
<hbox align="center">
<datepicker id="exceptions-date-picker"
disable-controller="repeat"
ondatepick="updateAddExceptionButton();"
onchange="updateAddExceptionButton();"
value=""/>
</hbox>
<button id="exception-add-button"
@ -561,8 +534,7 @@
</groupbox>
</hbox>
</vbox>
<!-- /Repeat -->
</tabpanel>
</tabpanel><!-- /Repeat -->
<!-- Contacts panel -->
<tabpanel orient="vertical" collapsed="true">