Bug 807956 - Event window: Early end date warning locks event edit window. (2nd patch) r=philipp

This commit is contained in:
Decathlon 2013-02-11 15:51:12 +01:00
Родитель 4d88fcb6f9
Коммит 1ffde03cd7
2 изменённых файлов: 49 добавлений и 25 удалений

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

@ -638,18 +638,20 @@ function dateTimeControls2State(aStartDatepicker) {
updateDateTime();
updateTimezone();
updateAccept();
if (warning) {
// Disable the "Save" and "Save and Close" commands as long as the
// warning dialog is showed.
enableAcceptCommand(false);
gWarning = true;
var callback = function func() {
enableAcceptCommand(false);
Services.prompt.alert(
null,
document.title,
calGetString("calendar", "warningEndBeforeStart"));
let callback = function func() {
Services.prompt.alert(null,
document.title,
cal.calGetString("calendar", "warningEndBeforeStart"));
gWarning = false;
enableAcceptCommand(true);
}
updateAccept();
};
setTimeout(callback, 1);
}
}
@ -1156,17 +1158,15 @@ function updateAccept() {
return enableAccept;
}
/* Enables/disables the cmd_accept command related to the save operation
/**
* Enables/disables the commands cmd_accept and cmd_save related to the
* save operation.
*
* @param aEnable true: enables the command
*/
function enableAcceptCommand(aEnable) {
let accept = document.getElementById("cmd_accept");
if (aEnable) {
accept.removeAttribute('disabled');
} else {
accept.setAttribute('disabled', 'true');
}
setElementValue("cmd_accept", !aEnable, "disabled");
setElementValue("cmd_save", !aEnable, "disabled");
}
// Global variables used to restore start and end date-time when changing the
@ -3237,7 +3237,7 @@ function updateAttendees() {
let callback = function func() {
attendeeList.setAttribute('value', attendeeNames.join(', '));
attendeeList.setAttribute('tooltiptext', attendeeEmails.join(', '));
}
};
setTimeout(callback, 1);
} else {
attendeeRow.setAttribute('collapsed', 'true');
@ -3498,6 +3498,8 @@ function checkUntilDate() {
return;
}
// The "time" part of the until date will be correctly assigned in the
// updateRepeat() function, but here we need to check only the date.
let untilDate = cal.jsDateToDateTime(repeatUntilDate, gStartTime.timezone);
let startDate = gStartTime.clone();
startDate.isDate = true;
@ -3509,7 +3511,8 @@ function checkUntilDate() {
: "forever");
gWarning = true;
let callback = function() {
// Disable the "Save" button until the warning dialog is showed
// Disable the "Save" and "Save and Close" commands as long as the
// warning dialog is showed.
enableAcceptCommand(false);
Services.prompt.alert(

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

@ -239,7 +239,7 @@
<xul:hbox flex="1" id="hbox" class="datepicker-box-class">
<xul:menulist editable="true" sizetopopup="false"
class="datepicker-text-class"
onchange="this.kDatePicker.parseTextBoxDate(true);"
onchange="this.kDatePicker.parseTextBoxDate(true, event);"
onkeypress="if (event.keyCode == 13) this.kDatePicker.parseTextBoxDate(true);"
xbl:inherits="disabled">
<xul:menupopup popupanchor="bottomright" popupalign="topright"
@ -340,8 +340,14 @@
<method name="parseTextBoxDate">
<parameter name="aRefresh"/>
<parameter name="aEvent"/>
<body>
<![CDATA[
// Stop the "change" event propagation. It will be properly
// fired inside the update method.
if (aEvent) {
aEvent.stopPropagation();
}
this.update(this.parseDateTime(this.kTextBox.value), aRefresh);
this.lastDateParseIncludedTime = false;
]]>
@ -394,7 +400,7 @@
<xul:hbox flex="1" id="hbox" class="datepicker-box-class">
<xul:menulist anonid="foreverMenulist" editable="true" sizetopopup="false"
class="datepicker-text-class"
onchange="this.kDatePicker.parseTextBoxDate(true);"
onchange="this.kDatePicker.parseTextBoxDate(true, event);"
onkeypress="if (event.keyCode == 13) this.kDatePicker.parseTextBoxDate(true);"
xbl:inherits="disabled">
<xul:menupopup popupanchor="bottomright" popupalign="topright"
@ -424,12 +430,18 @@
<method name="parseTextBoxDate">
<parameter name="aRefresh"/>
<parameter name="aEvent"/>
<body>
<![CDATA[
if (this.kTextBox.value.toLowerCase() == this.mForeverStr.toLowerCase()) {
this.mValue = "forever";
this.kTextBox.value = this.mForeverStr;
} else {
// Stop the "change" event propagation. It will be properly
// fired inside the update method.
if (aEvent) {
aEvent.stopPropagation();
}
let date = this.parseDateTime(this.kTextBox.value);
if (date) {
this.update(date, aRefresh);
@ -541,7 +553,7 @@
<xul:menulist editable="true" sizetopopup="false"
id="timepicker-text"
class="timepicker-text-class"
onchange="this.kTimePicker.parseTextBoxTime(true);"
onchange="this.kTimePicker.parseTextBoxTime(true, event);"
onkeypress="if (event.keyCode == 13) this.kTimePicker.parseTextBoxTime(true);"
xbl:inherits="disabled">
<xul:menupopup popupalign="topright" popupanchor="bottomright"
@ -574,14 +586,19 @@
<parameter name="aRefresh"/>
<body>
<![CDATA[
let timeChanged = false;
if (aValue != null) {
if (this.mValue) {
timeChanged = this.mValue.getHours() != aValue.getHours() ||
this.mValue.getMinutes() != aValue.getMinutes();
}
this.mValue = aValue;
}
// set textBox.value property, not attribute
this.kTextBox.value = this.formatTime(this.mValue);
if (aValue != null && aRefresh) {
var event = document.createEvent('Events');
if (aValue != null && aRefresh && timeChanged) {
let event = document.createEvent('Events');
event.initEvent("change", true, true);
this.dispatchEvent(event);;
}
@ -591,9 +608,15 @@
<method name="parseTextBoxTime">
<parameter name="aRefresh"/>
<parameter name="aEvent"/>
<body>
<![CDATA[
var time = this.parseTime(this.kTextBox.value);
// Stop the "change" event propagation. It will be properly
// fired inside the update method.
if (aEvent) {
aEvent.stopPropagation();
}
let time = this.parseTime(this.kTextBox.value);
this.update(time, aRefresh);
return time;
]]>
@ -1429,7 +1452,6 @@
tempTime.getSeconds());
this.mValue = dateTime;
this.kTimePicker.update(dateTime, false);
this.fireEvent("change");
]]>
</body>
</method>
@ -1445,7 +1467,6 @@
dateTime.setSeconds(newTime.getSeconds());
this.mValue = dateTime;
this.kDatePicker.update(dateTime, false);
this.fireEvent("change");
]]>
</body>
</method>