mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-14 02:31:59 +00:00
109169 - dialog should support custom dialog buttons, r=ben, sr=hyatt
This commit is contained in:
parent
a609bd6e28
commit
33afd372bd
@ -26,6 +26,7 @@
|
|||||||
</content>
|
</content>
|
||||||
|
|
||||||
<implementation>
|
<implementation>
|
||||||
|
<field name="_mStrBundle">null</field>
|
||||||
<field name="_closeHandler">(function(event) {
|
<field name="_closeHandler">(function(event) {
|
||||||
if (!document.documentElement.cancelDialog())
|
if (!document.documentElement.cancelDialog())
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@ -63,6 +64,8 @@
|
|||||||
|
|
||||||
<constructor>
|
<constructor>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
|
this._useAnonButton = {};
|
||||||
|
|
||||||
this._initDialogButton("accept");
|
this._initDialogButton("accept");
|
||||||
this._initDialogButton("cancel");
|
this._initDialogButton("cancel");
|
||||||
this._initDialogButton("help");
|
this._initDialogButton("help");
|
||||||
@ -109,8 +112,17 @@
|
|||||||
<method name="_initDialogButton">
|
<method name="_initDialogButton">
|
||||||
<parameter name="aDlgType"/>
|
<parameter name="aDlgType"/>
|
||||||
<body><![CDATA[
|
<body><![CDATA[
|
||||||
|
// determine if button is going to be anonymous or explicit
|
||||||
|
var btn;
|
||||||
var btns = this.getElementsByAttribute("dlgtype", aDlgType);
|
var btns = this.getElementsByAttribute("dlgtype", aDlgType);
|
||||||
var btn = btns.length > 0 ? btns[0] : document.getAnonymousElementByAttribute(this, "dlgtype", aDlgType);
|
if (btns.length > 0) {
|
||||||
|
btn = btns[0];
|
||||||
|
this._useAnonButton[aDlgType] = false;
|
||||||
|
} else {
|
||||||
|
btn = document.getAnonymousElementByAttribute(this, "dlgtype", aDlgType);
|
||||||
|
this._useAnonButton[aDlgType] = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (btn) {
|
if (btn) {
|
||||||
btn.addEventListener("command", this._handleButtonCommand, true);
|
btn.addEventListener("command", this._handleButtonCommand, true);
|
||||||
// don't set pre-defined labels on explicit buttons
|
// don't set pre-defined labels on explicit buttons
|
||||||
@ -139,14 +151,15 @@
|
|||||||
for (var i = 0; i < list.length; ++i)
|
for (var i = 0; i < list.length; ++i)
|
||||||
shown[list[i].replace(/ /g, "")] = true;
|
shown[list[i].replace(/ /g, "")] = true;
|
||||||
|
|
||||||
// hide or show the buttons
|
// hide anonymous buttons that aren't mentioned in the buttons attribute, and are not
|
||||||
|
// supplied via explicit content
|
||||||
for (var dlgtype in shown) {
|
for (var dlgtype in shown) {
|
||||||
var button = document.getAnonymousElementByAttribute(this, "dlgtype", dlgtype);
|
var anonBtn = document.getAnonymousElementByAttribute(this, "dlgtype", dlgtype);
|
||||||
if (button) {
|
if (anonBtn) {
|
||||||
if (shown[dlgtype])
|
if (this._useAnonButton[dlgtype] && shown[dlgtype])
|
||||||
button.removeAttribute("hidden");
|
anonBtn.removeAttribute("hidden");
|
||||||
else
|
else
|
||||||
button.setAttribute("hidden", "true");
|
anonBtn.setAttribute("hidden", "true");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]]>
|
]]>
|
||||||
|
Loading…
Reference in New Issue
Block a user