Bug 516387: nsPromptService dialogs should not have '&' shortcuts in labels, r=gavin

This commit is contained in:
Mark Finkle 2009-09-23 00:58:34 -04:00
parent 7f5cb0fa99
commit 1c876d9afc
4 changed files with 14 additions and 11 deletions

View File

@ -11,7 +11,7 @@
</scrollbox>
<hbox id="prompt-alert-checkbox-box" collapsed="true" align="center">
<checkbox class="toggle-dark" id="prompt-alert-checkbox"/>
<label id="prompt-alert-checkbox-msg"/>
<description id="prompt-alert-checkbox-msg"/>
</hbox>
<hbox pack="center">
<button class="button-dark" label="&ok.label;"

View File

@ -10,7 +10,7 @@
</scrollbox>
<hbox id="prompt-confirm-checkbox-box" collapsed="true" align="center">
<checkbox class="toggle-dark" id="prompt-confirm-checkbox"/>
<label id="prompt-confirm-checkbox-msg"/>
<description id="prompt-confirm-checkbox-msg"/>
</hbox>
<hbox pack="center" id="prompt-confirm-button-box">
<button class="button-dark" label="&ok.label;"

View File

@ -12,7 +12,7 @@
<textbox id="prompt-prompt-textbox"/>
<hbox id="prompt-prompt-checkbox-box" collapsed="true" align="center">
<checkbox class="toggle-dark" id="prompt-prompt-checkbox"/>
<label id="prompt-prompt-checkbox-msg"/>
<description id="prompt-prompt-checkbox-msg"/>
</hbox>
<hbox pack="center" id="prompt-prompt-button-box">
<button class="button-dark" label="&ok.label;"

View File

@ -101,7 +101,7 @@ promptService.prototype = {
this.sizeScrollableMsg("prompt-alert-message", 25);
doc.getElementById("prompt-alert-checkbox").checked = aCheckState.value;
doc.getElementById("prompt-alert-checkbox-msg").value = aCheckMsg;
this.setLabelForNode(doc.getElementById("prompt-alert-checkbox-msg"), aCheckMsg);
this.sizeElement("prompt-alert-checkbox-msg", 50);
doc.getElementById("prompt-alert-checkbox-box").removeAttribute("collapsed");
@ -134,7 +134,7 @@ promptService.prototype = {
this.sizeScrollableMsg("prompt-confirm-message", 25);
doc.getElementById("prompt-confirm-checkbox").checked = aCheckState.value;
doc.getElementById("prompt-confirm-checkbox-msg").value = aCheckMsg;
this.setLabelForNode(doc.getElementById("prompt-confirm-checkbox-msg"), aCheckMsg);
this.sizeElement("prompt-confirm-checkbox-msg", 50);
doc.getElementById("prompt-confirm-checkbox-box").removeAttribute("collapsed");
@ -149,7 +149,7 @@ promptService.prototype = {
//
// Copied from chrome://global/content/commonDialog.js
//
setLabelForNode: function(aNode, aLabel, aIsLabelFlag) {
setLabelForNode: function(aNode, aLabel) {
// This is for labels which may contain embedded access keys.
// If we end in (&X) where X represents the access key, optionally preceded
// by spaces and/or followed by the ':' character, store the access key and
@ -172,8 +172,11 @@ promptService.prototype = {
// && is the magic sequence to embed an & in your label.
aLabel = aLabel.replace(/\&\&/g, "&");
if (aIsLabelFlag) { // Set text for <label> element
if (aNode instanceof Ci.nsIDOMXULLabelElement) {
aNode.setAttribute("value", aLabel);
} else if (aNode instanceof Ci.nsIDOMXULDescriptionElement) {
text = aNode.ownerDocument.createTextNode(aLabel);
aNode.appendChild(text);
} else { // Set text for other xul elements
aNode.setAttribute("label", aLabel);
}
@ -200,7 +203,7 @@ promptService.prototype = {
this.sizeScrollableMsg("prompt-confirm-message", 25);
doc.getElementById("prompt-confirm-checkbox").checked = aCheckState.value;
doc.getElementById("prompt-confirm-checkbox-msg").value = aCheckMsg;
this.setLabelForNode(doc.getElementById("prompt-confirm-checkbox-msg"), aCheckMsg);
this.sizeElement("prompt-confirm-checkbox-msg", 50);
if (aCheckMsg) {
doc.getElementById("prompt-confirm-checkbox-box").removeAttribute("collapsed");
@ -242,7 +245,7 @@ promptService.prototype = {
if (bTitle) {
let button = doc.createElement("button");
this.setLabelForNode(button, bTitle, false);
this.setLabelForNode(button, bTitle);
button.setAttribute("class", "button-dark");
button.setAttribute("oncommand",
"document.getElementById('prompt-confirm-dialog').PromptHelper.closeConfirm(" + i + ")");
@ -269,7 +272,7 @@ promptService.prototype = {
this.sizeScrollableMsg("prompt-prompt-message", 25);
doc.getElementById("prompt-prompt-checkbox").checked = aCheckState.value;
doc.getElementById("prompt-prompt-checkbox-msg").value = aCheckMsg;
this.setLabelForNode(doc.getElementById("prompt-prompt-checkbox-msg"), aCheckMsg);
this.sizeElement("prompt-prompt-checkbox-msg", 50);
doc.getElementById("prompt-prompt-textbox").value = aValue.value;
if (aCheckMsg) {
@ -309,7 +312,7 @@ promptService.prototype = {
doc.getElementById("prompt-password-password").value = aPassword.value;
if (aCheckMsg) {
doc.getElementById("prompt-password-checkbox-box").removeAttribute("collapsed");
doc.getElementById("prompt-password-checkbox-msg").appendChild(doc.createTextNode(aCheckMsg));
this.setLabelForNode(doc.getElementById("prompt-password-checkbox-msg"), aCheckMsg);
this.sizeElement("prompt-password-checkbox-msg", 50);
this.sizeElement("prompt-password-checkbox-box", 50);
}