Fixed enter key handling in Publish Progress dialog. b=140962, r=brade, sr=hewitt

This commit is contained in:
cmanske%netscape.com 2002-05-05 23:07:27 +00:00
parent c917916adf
commit 037ea85da6
2 changed files with 26 additions and 2 deletions

View File

@ -30,6 +30,7 @@ var gFinishedCount = 0;
var gFinished = false;
var gFinalMessage="";
var gTimerID;
var gAllowEnterKey = false;
function Startup()
{
@ -161,7 +162,7 @@ function SetProgressFinished(filename, networkStatus)
{
// XXX Interpret networkStatus and call SetStatusMessage() with
// appropriate error description.
if (filename == gPublishData.filename)
if (!gPublishData.publishOtherFiles || filename == gPublishData.filename)
gFinalMessage = GetString("PublishFailed");
else
gFinalMessage = GetString("PublishSomeFileFailed");
@ -171,6 +172,9 @@ function SetProgressFinished(filename, networkStatus)
gFinished = true;
gDialog.Close.setAttribute("label", GetString("Close"));
gFinalMessage = GetString("PublishCompleted");
// Now allow "Enter/Return" key to close the dialog
AllowDefaultButton();
}
if (gFinalMessage)
SetStatusMessage(gFinalMessage);
@ -212,6 +216,20 @@ function onClose()
return true;
}
function AllowDefaultButton()
{
gDialog.Close.setAttribute("default","true");
gAllowEnterKey = true;
}
function onEnterKey()
{
if (gAllowEnterKey)
return CloseDialog();
return false;
}
function RequestCloseDialog()
{
if (gFinished && !gDialog.KeepOpen.checked)
@ -219,6 +237,10 @@ function RequestCloseDialog()
// Leave window open a minimum amount of time
gTimerID = setTimeout("CloseDialog();", 3000);
}
// Now allow "Enter/Return" key to close the dialog
AllowDefaultButton();
// If window remains open, be sure final message is set
SetStatusMessage(gFinalMessage);
}
@ -230,4 +252,5 @@ function CloseDialog()
try {
window.close();
} catch (e) {}
}
}

View File

@ -34,6 +34,7 @@
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
buttons="cancel"
onload="Startup()"
ondialogaccept="return onEnterKey();"
ondialogcancel="return onClose();">
<!-- Methods common to all editor dialogs -->