moved warning messages to statusbar

This commit is contained in:
michael.buettner%sun.com 2006-07-31 16:24:38 +00:00
Родитель 203f000d26
Коммит 434e29c510
4 изменённых файлов: 47 добавлений и 40 удалений

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

@ -55,12 +55,12 @@
<xul:vbox id="dialog-box" flex="1"> <xul:vbox id="dialog-box" flex="1">
<xul:label id="read-only-item" value="&newevent.readonly.item.warning;" class="warning-text-class" hidden="true"/> <xul:label id="read-only-item" value="&newevent.readonly.item.warning;" hidden="true"/>
<xul:label id="read-only-cal" value="&newevent.readonly.cal.warning;" class="warning-text-class" hidden="true"/> <xul:label id="read-only-cal" value="&newevent.readonly.cal.warning;" hidden="true"/>
<xul:label id="end-time-warning" value="&newevent.endtime.warning;" class="warning-text-class" hidden="true"/> <xul:label id="end-time-warning" value="&newevent.endtime.warning;" hidden="true"/>
<xul:label id="task-repeat-warning" value="&newtodo.repeatstart.warning;" class="warning-text-class" hidden="true"/> <xul:label id="task-repeat-warning" value="&newtodo.repeatstart.warning;" hidden="true"/>
<xul:label id="alarm-start-warning" value="&alarm.start.warning;" class="warning-text-class" hidden="true"/> <xul:label id="alarm-start-warning" value="&alarm.start.warning;" hidden="true"/>
<xul:label id="alarm-end-warning" value="&alarm.due.warning;" class="warning-text-class" hidden="true"/> <xul:label id="alarm-end-warning" value="&alarm.due.warning;" hidden="true"/>
<xul:grid flex="1"> <xul:grid flex="1">
<xul:columns> <xul:columns>
@ -493,8 +493,6 @@
// update alarm checkbox/label/settings button // update alarm checkbox/label/settings button
this.updateAlarm(); this.updateAlarm();
this.updateTaskAlarmWarnings();
this.updateURL(item.getProperty("URL")); this.updateURL(item.getProperty("URL"));
// hide rows based on if this is an event or todo // hide rows based on if this is an event or todo
@ -507,9 +505,6 @@
// update datetime pickers // update datetime pickers
this.updateAllDay(); this.updateAllDay();
// update the accept button
this.updateAccept();
// set 'mIsReadOnly' if the calendar is read-only // set 'mIsReadOnly' if the calendar is read-only
if (calendar && calendar.readOnly) if (calendar && calendar.readOnly)
this.mIsReadOnly = true; this.mIsReadOnly = true;
@ -540,6 +535,9 @@
if (!this.mIsReadOnly) if (!this.mIsReadOnly)
this.mIsReadOnly = !this.mIsOrganizer; this.mIsReadOnly = !this.mIsOrganizer;
// update the accept button
this.updateAccept();
if(this.mIsReadOnly) { if(this.mIsReadOnly) {
var list = document.getAnonymousNodes(this)[0]; var list = document.getAnonymousNodes(this)[0];
var disableElements = list.getElementsByAttribute("disable-on-readonly", "true"); var disableElements = list.getElementsByAttribute("disable-on-readonly", "true");
@ -775,9 +773,6 @@
<method name="updateTaskAlarmWarnings"> <method name="updateTaskAlarmWarnings">
<body> <body>
<![CDATA[ <![CDATA[
document.getElementById("alarm-start-warning").setAttribute("hidden", true);
document.getElementById("alarm-end-warning").setAttribute("hidden", true);
var alarmType = getElementValue("item-alarm"); var alarmType = getElementValue("item-alarm");
if (!isToDo(window.calendarItem) || alarmType == "none") { if (!isToDo(window.calendarItem) || alarmType == "none") {
return true; return true;
@ -789,13 +784,13 @@
var alarmRelated = document.getElementById("alarm-trigger-relation").selectedItem.value; var alarmRelated = document.getElementById("alarm-trigger-relation").selectedItem.value;
if ((alarmType != "custom" || alarmRelated == "START") && !hasEntryDate) { if ((alarmType != "custom" || alarmRelated == "START") && !hasEntryDate) {
document.getElementById("alarm-start-warning").removeAttribute("hidden"); this.showWarning("alarm-start-warning");
return false; return false;
} }
if (alarmRelated == "END" && !hasDueDate) { if (alarmRelated == "END" && !hasDueDate) {
document.getElementById("alarm-end-warning").removeAttribute("hidden"); this.showWarning("alarm-end-warning");
return false; return false;
} }
return true; return true;
@ -1036,34 +1031,29 @@
endDate = getElementValue("todo-has-duedate", "checked") ? endDate = getElementValue("todo-has-duedate", "checked") ?
jsDateToDateTime(getElementValue("todo-duedate")) : null; jsDateToDateTime(getElementValue("todo-duedate")) : null;
var taskRepeatWarning = document.getElementById("task-repeat-warning");
//@@@ TODO: this needs to be addressed //@@@ TODO: this needs to be addressed
/*if (!startDate && getElementValue("item-recurrence", "checked")) { //var taskRepeatWarning = document.getElementById();
enableAccept = false; //this.showWarning("task-repeat-warning");
taskRepeatWarning.removeAttribute("hidden"); //if (!startDate && getElementValue("item-recurrence", "checked")) {
} else { //enableAccept = false;
taskRepeatWarning.setAttribute("hidden", "true"); //taskRepeatWarning.removeAttribute("hidden");
}*/ //}
} }
var timeWarning = document.getElementById("end-time-warning");
if (endDate && startDate && endDate.compare(startDate) == -1) { if (endDate && startDate && endDate.compare(startDate) == -1) {
enableAccept = false; enableAccept = false;
timeWarning.removeAttribute("hidden"); this.showWarning("end-time-warning");
} else {
timeWarning.setAttribute("hidden", "true");
} }
// can't add/edit items in readOnly calendars // can't add/edit items in readOnly calendars
document.getElementById("read-only-item").setAttribute("hidden", !this.mIsReadOnly); if (this.mIsReadOnly)
this.showWarning("read-only-item");
var cal = document.getElementById("item-calendar").selectedItem.calendar; var cal = document.getElementById("item-calendar").selectedItem.calendar;
document.getElementById("read-only-cal").setAttribute("hidden", if (cal.readOnly)
!cal.readOnly); this.showWarning("read-only-cal");
if (this.mIsReadOnly || cal.readOnly) { if (this.mIsReadOnly || cal.readOnly) {
enableAccept = false; enableAccept = false;
} }
if (!this.updateTaskAlarmWarnings()) { if (!this.updateTaskAlarmWarnings()) {
enableAccept = false; enableAccept = false;
} }
@ -1076,6 +1066,18 @@
</body> </body>
</method> </method>
<method name="showWarning">
<parameter name="identifier"/>
<body>
<![CDATA[
var event = document.createEvent('Events');
event.initEvent('warning', true, false);
event.details = document.getElementById(identifier).value;
this.dispatchEvent(event);
]]>
</body>
</method>
<method name="setItemProperty"> <method name="setItemProperty">
<parameter name="item"/> <parameter name="item"/>
<parameter name="propertyName"/> <parameter name="propertyName"/>

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

@ -43,10 +43,6 @@ label.label {
text-align: right; text-align: right;
} }
.warning-text-class {
color : red;
}
main-page main-page
{ {
-moz-binding: url("chrome://calendar/content/sun-calendar-event-dialog-main.xml#main-page"); -moz-binding: url("chrome://calendar/content/sun-calendar-event-dialog-main.xml#main-page");

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

@ -50,6 +50,7 @@ function onLoad()
document.getElementById("sun-calendar-event-dialog").getButton("accept").setAttribute("collapsed","true"); document.getElementById("sun-calendar-event-dialog").getButton("accept").setAttribute("collapsed","true");
document.getElementById("sun-calendar-event-dialog").getButton("cancel").setAttribute("collapsed","true"); document.getElementById("sun-calendar-event-dialog").getButton("cancel").setAttribute("collapsed","true");
document.getElementById("sun-calendar-event-dialog").getButton("cancel").parentNode.setAttribute("collapsed","true");
var accept = function acceptHandler(event) { var accept = function acceptHandler(event) {
var enableAccept = event.details; var enableAccept = event.details;
@ -58,10 +59,18 @@ function onLoad()
acceptButton.setAttribute("disabled", "true"); acceptButton.setAttribute("disabled", "true");
} else if (acceptButton.getAttribute("disabled")) { } else if (acceptButton.getAttribute("disabled")) {
acceptButton.removeAttribute("disabled"); acceptButton.removeAttribute("disabled");
var statusbarPanel = document.getElementById("statusbarpanel");
statusbarPanel.removeAttribute("label");
} }
}; };
window.addEventListener('accept', accept, true); window.addEventListener('accept', accept, true);
var warning = function warningHandler(event) {
var statusbarPanel = document.getElementById("statusbarpanel");
statusbarPanel.setAttribute("label",event.details);
};
window.addEventListener('warning', warning, true);
// figure out what the title of the dialog should be and set it // figure out what the title of the dialog should be and set it
updateTitle(); updateTitle();

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

@ -100,7 +100,7 @@
</tabbox> </tabbox>
<statusbar> <statusbar>
<statusbarpanel label="### TODO ###" flex="1"/> <statusbarpanel id="statusbarpanel" flex="1"/>
</statusbar> </statusbar>
</dialog> </dialog>