bug 283103 disable accept button in security dialogs when not focused

(suite version of bug 260560) r=caillon, sr=neil.parkwaycc, a=caillon
This commit is contained in:
dveditz%cruzio.com 2005-03-10 22:26:47 +00:00
Родитель 1c6f7571d2
Коммит 40ba69c24c
4 изменённых файлов: 77 добавлений и 4 удалений

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

@ -302,6 +302,12 @@ nsHelperAppDialog.prototype = {
// Set initial focus
this.dialogElement( "mode" ).focus();
this.mDialog.document.documentElement.getButton("accept").disabled = true;
const nsITimer = Components.interfaces.nsITimer;
this._timer = Components.classes["@mozilla.org/timer;1"]
.createInstance(nsITimer);
this._timer.initWithCallback(this, 250, nsITimer.TYPE_ONE_SHOT);
},
// initIntro:
@ -362,6 +368,34 @@ nsHelperAppDialog.prototype = {
location.setAttribute( "tooltiptext", this.mSourcePath );
},
_timer: null,
notify: function (aTimer) {
if (!this._blurred)
this.mDialog.document.documentElement.getButton('accept').disabled = false;
_timer = null;
},
_blurred: false,
onBlur: function(aEvent) {
if (aEvent.target != this.mDialog.document)
return;
this._blurred = true;
this.mDialog.document.documentElement.getButton("accept").disabled = true;
},
onFocus: function(aEvent) {
if (aEvent.target != this.mDialog.document)
return;
this._blurred = false;
if (!_timer) {
// Don't enable the button if the initial timer is running
var script = "document.documentElement.getButton('accept').disabled = false";
this.mDialog.setTimeout(script, 250);
}
},
// Returns true iff opening the default application makes sense.
openWithDefaultOK: function() {
var result;

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

@ -51,6 +51,8 @@
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&caption.label;"
onload="dialog.initDialog()"
onblur="dialog.onBlur(event);"
onfocus="dialog.onFocus(event);"
onunload="if (dialog) dialog.onCancel()"
style="width: 40em;"
ondialogaccept="return dialog.onOK()"

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

@ -417,7 +417,7 @@ pref("dom.disable_window_open_feature.menubar", false);
pref("dom.disable_window_open_feature.scrollbars", false);
pref("dom.disable_window_open_feature.resizable", false);
pref("dom.disable_window_open_feature.minimizable", false);
pref("dom.disable_window_open_feature.status", false);
pref("dom.disable_window_open_feature.status", true);
pref("dom.allow_scripts_to_close_windows", false);

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

@ -201,16 +201,53 @@ function commonDialogOnLoad()
document.documentElement.getButton("extra2").disabled = true;
setTimeout(commonDialogReenableButtons, delayInterval);
addEventListener("blur", commonDialogBlur, false);
addEventListener("focus", commonDialogFocus, false);
}
getAttention();
}
var gDelayExpired = false;
var gBlurred = false;
function commonDialogBlur(aEvent)
{
if (aEvent.target != document)
return;
gBlurred = true;
document.documentElement.getButton("accept").disabled = true;
document.documentElement.getButton("extra1").disabled = true;
document.documentElement.getButton("extra2").disabled = true;
}
function commonDialogFocus(aEvent)
{
if (aEvent.target != document)
return;
gBlurred = false;
// When refocusing the window, don't enable the buttons unless the countdown
// delay has expired.
if (gDelayExpired) {
var script = "document.documentElement.getButton('accept').disabled = false; ";
script += "document.documentElement.getButton('extra1').disabled = false; ";
script += "document.documentElement.getButton('extra2').disabled = false;";
setTimeout(script, 250);
}
}
function commonDialogReenableButtons()
{
document.documentElement.getButton("accept").disabled = false;
document.documentElement.getButton("extra1").disabled = false;
document.documentElement.getButton("extra2").disabled = false;
// Don't automatically enable the buttons if we're not in the foreground
if (!gBlurred) {
document.documentElement.getButton("accept").disabled = false;
document.documentElement.getButton("extra1").disabled = false;
document.documentElement.getButton("extra2").disabled = false;
}
gDelayExpired = true;
}
function initTextbox(aName, aLabelIndex, aValueIndex, aAlwaysLabel)