29
30
var gLastRepeatSelection = 0;
30
31
var gIgnoreUpdate = false;
31
32
var gShowTimeAs = null;
33
35
var eventDialogQuitObserver = {
34
36
observe: function(aSubject, aTopic, aData) {
568
576
// jsDate is always in OS timezone, thus we create a calIDateTime
569
577
// object from the jsDate representation then we convert the timezone
570
578
// in order to keep gStartTime in default timezone.
571
gStartTime = jsDateToDateTime(getElementValue(startWidgetId),
572
(timezonesEnabled || allDay) ? gStartTimezone : kDefaultTimezone);
579
gStartTime = cal.jsDateToDateTime(getElementValue(startWidgetId),
580
(timezonesEnabled || allDay) ? gStartTimezone : kDefaultTimezone);
573
581
if (timezonesEnabled || allDay) {
574
582
gStartTime = gStartTime.getInTimezone(kDefaultTimezone);
589
597
timezone = gStartTimezone;
592
gEndTime = jsDateToDateTime(getElementValue(endWidgetId),
593
(timezonesEnabled || allDay) ? timezone : kDefaultTimezone);
600
gEndTime = cal.jsDateToDateTime(getElementValue(endWidgetId),
601
(timezonesEnabled || allDay) ? timezone : kDefaultTimezone);
594
602
if (timezonesEnabled || allDay) {
595
603
gEndTime = gEndTime.getInTimezone(kDefaultTimezone);
699
709
setElementValue(aDatePickerId, getElementValue(aDatePickerId));
701
711
// first of all disable the datetime picker if we don't have a date
702
var hasDate = getElementValue(aCheckboxId, "checked");
712
let hasDate = getElementValue(aCheckboxId, "checked");
703
713
setElementValue(aDatePickerId, !hasDate, "disabled");
705
715
// create a new datetime object if date is now checked for the first time
706
716
if (hasDate && !aDateTime.isValid()) {
707
var date = jsDateToDateTime(getElementValue(aDatePickerId), calendarDefaultTimezone());
708
aDateTime.setDateTime(date);
717
let dt = cal.jsDateToDateTime(getElementValue(aDatePickerId), cal.calendarDefaultTimezone());
718
aDateTime.setDateTime(dt);
709
719
} else if (!hasDate && aDateTime.isValid()) {
710
720
aDateTime.setDateTime(null);
713
723
// calculate the duration if possible
714
var hasEntryDate = getElementValue("todo-has-entrydate", "checked");
715
var hasDueDate = getElementValue("todo-has-duedate", "checked");
724
let hasEntryDate = getElementValue("todo-has-entrydate", "checked");
725
let hasDueDate = getElementValue("todo-has-duedate", "checked");
716
726
if (hasEntryDate && hasDueDate) {
717
var start = jsDateToDateTime(getElementValue("todo-entrydate"));
718
var end = jsDateToDateTime(getElementValue("todo-duedate"));
727
let start = cal.jsDateToDateTime(getElementValue("todo-entrydate"));
728
let end = cal.jsDateToDateTime(getElementValue("todo-duedate"));
719
729
gItemDuration = end.subtractDate(start);
721
731
gItemDuration = null;
1064
1074
if (isEvent(window.calendarItem)) {
1065
startDate = jsDateToDateTime(getElementValue("event-starttime"));
1066
endDate = jsDateToDateTime(getElementValue("event-endtime"));
1075
startDate = cal.jsDateToDateTime(getElementValue("event-starttime"));
1076
endDate = cal.jsDateToDateTime(getElementValue("event-endtime"));
1068
1078
var menuItem = document.getElementById('options-timezone-menuitem');
1069
1079
if (menuItem.getAttribute('checked') == 'true') {
1105
1115
startDate = getElementValue("todo-has-entrydate", "checked") ?
1106
jsDateToDateTime(getElementValue("todo-entrydate")) : null;
1116
cal.jsDateToDateTime(getElementValue("todo-entrydate")) : null;
1107
1117
endDate = getElementValue("todo-has-duedate", "checked") ?
1108
jsDateToDateTime(getElementValue("todo-duedate")) : null;
1118
cal.jsDateToDateTime(getElementValue("todo-duedate")) : null;
1111
1121
if (endDate && startDate && endDate.compare(startDate) == -1) {
2462
2472
// confirmed (i.e. not followed by a click, a tab or enter keys pressure).
2463
2473
document.documentElement.focus();
2475
// Don't save if a warning dialog about a wrong input date must be showed.
2465
2480
let originalItem = window.calendarItem;
2466
2481
let item = saveItem();
2467
2482
let calendar = getCurrentCalendar();
3139
3154
let startDate = getElementValue(event ? "event-starttime" : "todo-entrydate");
3140
3155
let endDate = getElementValue(event ? "event-endtime" : "todo-duedate");
3141
startDate = jsDateToDateTime(startDate, kDefaultTimezone);
3142
endDate = jsDateToDateTime(endDate, kDefaultTimezone);
3156
startDate = cal.jsDateToDateTime(startDate, kDefaultTimezone);
3157
endDate = cal.jsDateToDateTime(endDate, kDefaultTimezone);
3144
3159
let allDay = getElementValue("event-all-day", "checked");
3145
let detailsString = recurrenceRule2String(
3146
recurrenceInfo, startDate, endDate, allDay);
3160
let detailsString = recurrenceRule2String(recurrenceInfo, startDate,
3163
if (!detailsString) {
3164
detailsString = cal.calGetString("calendar-event-dialog", "ruleTooComplex");
3148
3167
// Now display the string...
3149
if (detailsString) {
3150
let lines = detailsString.split("\n");
3151
repeatDetails.removeAttribute("collapsed");
3152
while (repeatDetails.childNodes.length > lines.length) {
3153
repeatDetails.removeChild(repeatDetails.lastChild);
3155
let numChilds = repeatDetails.childNodes.length;
3156
for (let i = 0; i < lines.length; i++) {
3157
if (i >= numChilds) {
3158
var newNode = repeatDetails.childNodes[0]
3160
repeatDetails.appendChild(newNode);
3162
repeatDetails.childNodes[i].value = lines[i];
3163
repeatDetails.childNodes[i].setAttribute("tooltiptext",
3168
let lines = detailsString.split("\n");
3169
repeatDetails.removeAttribute("collapsed");
3170
while (repeatDetails.childNodes.length > lines.length) {
3171
repeatDetails.removeChild(repeatDetails.lastChild);
3173
let numChilds = repeatDetails.childNodes.length;
3174
for (let i = 0; i < lines.length; i++) {
3175
if (i >= numChilds) {
3176
var newNode = repeatDetails.childNodes[0]
3178
repeatDetails.appendChild(newNode);
3180
repeatDetails.childNodes[i].value = lines[i];
3181
repeatDetails.childNodes[i].setAttribute("tooltiptext",
3168
3185
let repeatDetails = document.getElementById("repeat-details");