gecko/mobile/chrome/content/bindings/dialog.xml

79 lines
2.7 KiB
XML
Raw Normal View History

<?xml version="1.0"?>
<bindings
xmlns="http://www.mozilla.org/xbl"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="dialog">
<content>
<xul:stack>
<xul:box xbl:inherits="orient" class="dialog-dark" align="center">
<children/>
</xul:box>
<xul:image collapsed="true" top="-10" left="0" anonid="close" class="close-button"
onclick="document.getBindingParent(this).close()"/>
</xul:stack>
</content>
<implementation implements="nsIDOMEventListener">
<field name="arguments"/>
<field name="parent"/>
<constructor><![CDATA[
if (!this.hasAttribute("orient"))
this.setAttribute("orient", "vertical");
if (this.hasAttribute("closebutton") && (this.getAttribute("closebutton") == "true"))
document.getAnonymousElementByAttribute(this, "anonid", "close").removeAttribute("collapsed");
this._closed = false;
if (this.hasAttribute("script")) {
try {
let loader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Components.interfaces.mozIJSSubScriptLoader);
loader.loadSubScript(this.getAttribute("script"), this);
} catch(e) {
throw("Dialog : Unable to load script : " + this.getAttribute("script") + "\n");
}
}
window.addEventListener("unload", this, true);
]]>
</constructor>
<method name="handleEvent">
<parameter name="aEvent"/>
<body>
if (aEvent.type == "unload")
this._closed = true;
</body>
</method>
<method name="close">
<body>
if (this.hasAttribute("onclose")) {
var f = new Function(this.getAttribute("onclose"));
f.call(this);
}
this.parentNode.parentNode.removeChild(this.parentNode);
this._closed = true;
// emit DOMModalDialogClosed event
let event = document.createEvent("Events");
event.initEvent("DOMModalDialogClosed", true, false);
let dispatcher = this.parent || getBrowser();
dispatcher.dispatchEvent(event);
</body>
</method>
<method name="waitForClose">
<body>
let thread = Components.classes["@mozilla.org/thread-manager;1"]
.getService(Components.interfaces.nsIThreadManager)
.currentThread;
while (!this._closed)
thread.processNextEvent(true);
</body>
</method>
</implementation>
</binding>
</bindings>