pjs/xpfe/components/sample/resources/nsSampleAppShellComponent.xul

134 строки
4.6 KiB
XML

<?xml version="1.0"?>
<?xml-stylesheet href="xul.css" type="text/css"?>
<!DOCTYPE window>
<window xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="Mozilla Sample App Shell Component"
width="425"
height="180"
onload="onLoad()">
<data>
<!--
Place your broadcaster's within this element. There is
no significance to the <data> element itself, except as a
container for the broadcasters.
By convention, each broadcaster has the id "data.foo".
This permits "foo" to be used for a corresponding UI
element, which will have id "dialog.foo" (see below).
-->
<broadcaster id="data.input" value=""/>
<broadcaster id="data.output" value=""/>
</data>
<html:script>
/*
The variables "data" and "dialog", by convention, are generic
JS Objects with properties corresponding to corresponding
document elements. For example, in this sample .xul file,
the "input" property of the variable data refers to the
document element with id "data.input".
The properties of these objects are set in the functions
initData() and initDialog(), respectively.
*/
var data;
var dialog;
/*
initData is called by the onload handler. It creates the
data Object and sets each property of interest.
*/
function initData() {
data = new Object;
data.input = document.getElementById( "data.input" );
data.output = document.getElementById( "data.output" );
}
/*
initDialog does likewise for the dialog object and properties.
*/
function initDialog() {
dialog = new Object;
dialog.input = document.getElementById( "dialog.input" );
dialog.output = document.getElementById( "dialog.output" );
dialog.close = document.getElementById("dialog.close");
}
/*
loadDialog is called by the onload handler. It should load
the dialog (UI) controls from appropriate data fields and
otherwise set up for display of the dialog.
*/
function loadDialog() {
}
/*
onLoad is the onload handler. It initializes the data, then
the dialog, then loads the initial dialog contents.
*/
function onLoad() {
window.arguments[0].Observe( window, "sample", "onLoad called" );
// Init data.
initData();
// Init dialog.
initDialog();
// Fill dialog.
loadDialog();
}
/*
onClose is the onclick handler for the dialog's close button.
It issues the "close" command to the underlying C++ code
(which will presumably close the window).
*/
function onClose() {
// Close the window.
data.execute.setAttribute( "command", "close" );
}
</html:script>
<html:table style="width:100%;">
<html:tr>
<html:td colspan="5">
<html:center><html:h1>XUL Dialog Tests</html:h1></html:center>
<html:br/>
This dialog demonstrates use of XUL dialogs. You can cause the
dialog to be opened from C++ or JavaScript. The dialog can be
displayed modally or not.
<html:br/>
Input: <html:input id="dialog.inpout"/>
<html:br/>
Output: <html:input id="dialog.output"/>
</html:td>
</html:tr>
<html:tr>
<html:td style="width:20%">
<html:button id="dialog.more" onclick="onCPPNonModal()" disabled="">Non-modal C++...</html:button>
</html:td>
<html:td style="width:20%">
<html:button id="dialog.pick" onclick="onJSNonModal()" disabled="">Non-modal JS...</html:button>
</html:td>
<html:td style="width:20%">
<html:button id="dialog.save" onclick="onCPPModal()">Modal C++...</html:button>
</html:td>
<html:td style="width:20%">
<html:button id="dialog.save" onclick="onJSModal">Modal JS...</html:button>
</html:td>
<html:td style="width:20%">
<html:button id="dialog.close" onclick="onClose()">Close</html:button>
</html:td>
</html:tr>
</html:table>
</window>