mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-07 13:24:12 +00:00
XUL samples
This commit is contained in:
parent
d5e687f7f6
commit
3253c2149d
112
xpfe/browser/samples/dexanimdialog.xul
Normal file
112
xpfe/browser/samples/dexanimdialog.xul
Normal file
@ -0,0 +1,112 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="xul.css" type="text/css"?>
|
||||
<!DOCTYPE window>
|
||||
<!-- dialog containing a control requiring initial setup -->
|
||||
<xul:window
|
||||
xmlns:html="http://www.w3.org/TR/REC-html40"
|
||||
xmlns:xul ="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload = "Startup()"
|
||||
title = "Things to do today"
|
||||
width = "400" height = "300">
|
||||
|
||||
<html:script>
|
||||
// dialog initialization code
|
||||
|
||||
// preload an array of offscreen images
|
||||
var images = new Array(4);
|
||||
var imageNames = new Array("up.gif", "right.gif", "down.gif", "left.gif");
|
||||
var animationFrame = 0;
|
||||
var animationFunction = null;
|
||||
for(var i = 0; i < 4; i++) {
|
||||
images[i] = new Image();
|
||||
images[i].src = "sampleimages/" + imageNames[i];
|
||||
}
|
||||
function Startup() {
|
||||
var checkbox = ElementByID("remind");
|
||||
if (checkbox)
|
||||
checkbox.checked = true;
|
||||
}
|
||||
|
||||
// OK button handler
|
||||
function DoOK() {
|
||||
// get checkbox
|
||||
// (using a document method available on HTML and XUL
|
||||
// documents, but not on XML documents)
|
||||
var checkbox = document.getElementById("remind");
|
||||
if (checkbox) {
|
||||
// load some hypothetical appcore interested in
|
||||
// the outcome of this dialog
|
||||
var donationsCore = XPAppCoresManager.Find("DonationsCore");
|
||||
if (!donationsCore) {
|
||||
donationsCore = new DonationsCore();
|
||||
if (donationsCore)
|
||||
donationsCore.Init("DonationsCore");
|
||||
}
|
||||
// tell the appcore about the new setting
|
||||
if (donationsCore)
|
||||
donationsCore.SetRemindFlag(checkbox.checked);
|
||||
}
|
||||
}
|
||||
|
||||
// find and return the DOM element with the given ID
|
||||
// the equivalent of document.getElementById(), but also
|
||||
// works for XML documents (unused in the example)
|
||||
function ElementByID(id) {
|
||||
var element;
|
||||
var ctr;
|
||||
var taglist = document.getElementsByTagName("*");
|
||||
|
||||
element = null;
|
||||
for (ctr = 0; ctr < taglist.length; ctr++)
|
||||
if (taglist[ctr].getAttribute("id") == id) {
|
||||
element = taglist[ctr];
|
||||
break;
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
function animateButtonImage() {
|
||||
var button = document.getElementById("animation");
|
||||
if (button) {
|
||||
button.src = images[animationFrame].src;
|
||||
animationFrame = (animationFrame + 1) % 4;
|
||||
animationFunction = setTimeout("animateButtonImage()", 250);
|
||||
}
|
||||
}
|
||||
function startAnimation() {
|
||||
if (animationFunction == null)
|
||||
animateButtonImage();
|
||||
}
|
||||
function stopAnimation() {
|
||||
if (animationFunction)
|
||||
clearTimeout(animationFunction);
|
||||
animationFunction = null;
|
||||
}
|
||||
</html:script>
|
||||
|
||||
<table xmlns="http://www.w3.org/TR/REC-html40">
|
||||
<tr>
|
||||
<td>Give me your money</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<!-- note the html namespace on the id attribute, which
|
||||
seems at this time to be required by getAttribute() -->
|
||||
<input type="checkbox" html:id="remind"/>Remind me
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="sampleimages/bongo.gif"/></td>
|
||||
<td><img id="animation" src="sampleimages/right.gif"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><button onclick="startAnimation()">Start Animation</button></td>
|
||||
<td><button onclick="stopAnimation()">Stop Animation</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><button onclick="DoOK()">OK</button></td>
|
||||
<td><button>Cancel</button></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</xul:window>
|
81
xpfe/browser/samples/dexanimmaster.xul
Normal file
81
xpfe/browser/samples/dexanimmaster.xul
Normal file
@ -0,0 +1,81 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="xul.css" type="text/css"?>
|
||||
<!DOCTYPE window>
|
||||
<!-- sample interface for bringing up a nonmodal dialog, including some
|
||||
JavaScript-testing animations -->
|
||||
<window
|
||||
xmlns:html="http://www.w3.org/TR/REC-html40"
|
||||
xmlns ="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title = "Dialog maker JS animation stress test">
|
||||
<html:script>
|
||||
function MakeDialog() {
|
||||
var toolkitCore = GetToolkitCore();
|
||||
if (toolkitCore)
|
||||
toolkitCore.ShowWindow("resource:/res/samples/dexanimdialog.xul",
|
||||
window);
|
||||
}
|
||||
function ModalDialog() {
|
||||
var toolkitCore = GetToolkitCore();
|
||||
if (toolkitCore)
|
||||
toolkitCore.ShowModalDialog("resource:/res/samples/dexanimdialog.xul",
|
||||
window);
|
||||
}
|
||||
function GetToolkitCore() {
|
||||
var toolkitCore = XPAppCoresManager.Find("ToolkitCore");
|
||||
if (!toolkitCore) {
|
||||
toolkitCore = new ToolkitCore();
|
||||
if (toolkitCore)
|
||||
toolkitCore.Init("ToolkitCore");
|
||||
}
|
||||
return toolkitCore;
|
||||
}
|
||||
|
||||
// preload an array of offscreen images
|
||||
var images = new Array(4);
|
||||
var imageNames = new Array("up.gif", "right.gif", "down.gif", "left.gif");
|
||||
var animationFrame = 0;
|
||||
var animationFunction = null;
|
||||
for(var i = 0; i < 4; i++) {
|
||||
images[i] = new Image();
|
||||
images[i].src = "sampleimages/" + imageNames[i];
|
||||
}
|
||||
|
||||
function animateButtonImage() {
|
||||
var button = document.getElementById("animation");
|
||||
if (button) {
|
||||
button.src = images[animationFrame].src;
|
||||
animationFrame = (animationFrame + 1) % 4;
|
||||
animationFunction = setTimeout("animateButtonImage()", 250);
|
||||
}
|
||||
}
|
||||
function startAnimation() {
|
||||
if (animationFunction == null)
|
||||
animateButtonImage();
|
||||
}
|
||||
function stopAnimation() {
|
||||
if (animationFunction)
|
||||
clearTimeout(animationFunction);
|
||||
animationFunction = null;
|
||||
}
|
||||
</html:script>
|
||||
|
||||
<toolbox>
|
||||
<toolbar>
|
||||
<titledbutton
|
||||
src="resource:/res/toolbar/TB_Back.gif" align="bottom"
|
||||
value="Make Dialog" onclick="MakeDialog()"
|
||||
style="background-color:rgb(192,192,192);"/>
|
||||
<titledbutton
|
||||
src="resource:/res/toolbar/TB_Back.gif" align="bottom"
|
||||
value="Start Animation" onclick="startAnimation()"
|
||||
style="background-color:rgb(192,192,192);"/>
|
||||
<titledbutton
|
||||
src="resource:/res/toolbar/TB_Back.gif" align="bottom"
|
||||
value="Stop Animation" onclick = "stopAnimation()"
|
||||
style="background-color:rgb(192,192,192);"/>
|
||||
</toolbar>
|
||||
</toolbox>
|
||||
|
||||
<html:img src="sampleimages/bongo.gif"/>
|
||||
<html:img id="animation" src="sampleimages/right.gif"/>
|
||||
</window>
|
77
xpfe/browser/samples/dexsimpledialog.xul
Normal file
77
xpfe/browser/samples/dexsimpledialog.xul
Normal file
@ -0,0 +1,77 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="xul.css" type="text/css"?>
|
||||
<!DOCTYPE window>
|
||||
<!-- dialog containing a control requiring initial setup -->
|
||||
<xul:window
|
||||
xmlns:html="http://www.w3.org/TR/REC-html40"
|
||||
xmlns:xul ="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload = "Startup()"
|
||||
title = "Things to do"
|
||||
height = "200" width = "300">
|
||||
|
||||
<html:script>
|
||||
// dialog initialization code
|
||||
function Startup() {
|
||||
var checkbox = ElementByID("remind");
|
||||
if (checkbox)
|
||||
checkbox.checked = true;
|
||||
}
|
||||
|
||||
// OK button handler
|
||||
function DoOK() {
|
||||
// get checkbox
|
||||
// (using a document method available on HTML and XUL
|
||||
// documents, but not on XML documents)
|
||||
var checkbox = document.getElementById("remind");
|
||||
if (checkbox) {
|
||||
// load some hypothetical appcore interested in
|
||||
// the outcome of this dialog
|
||||
var donationsCore = XPAppCoresManager.Find("DonationsCore");
|
||||
if (!donationsCore) {
|
||||
donationsCore = new DonationsCore();
|
||||
if (donationsCore)
|
||||
donationsCore.Init("DonationsCore");
|
||||
}
|
||||
// tell the appcore about the new setting
|
||||
if (donationsCore)
|
||||
donationsCore.SetRemindFlag(checkbox.checked);
|
||||
}
|
||||
}
|
||||
|
||||
// find and return the DOM element with the given ID
|
||||
// the equivalent of document.getElementById(), but also
|
||||
// works for XML documents (unused in the example)
|
||||
function ElementByID(id) {
|
||||
var element;
|
||||
var ctr;
|
||||
var taglist = document.getElementsByTagName("*");
|
||||
|
||||
element = null;
|
||||
for (ctr = 0; ctr < taglist.length; ctr++)
|
||||
if (taglist[ctr].getAttribute("id") == id) {
|
||||
element = taglist[ctr];
|
||||
break;
|
||||
}
|
||||
return element;
|
||||
}
|
||||
</html:script>
|
||||
|
||||
<table xmlns="http://www.w3.org/TR/REC-html40">
|
||||
<tr>
|
||||
<td>Give me your money</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<!-- note the html namespace on the id attribute, which
|
||||
seems at this time to be required by getAttribute() -->
|
||||
<input type="checkbox" html:id="remind"/>Remind me
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<button onclick="DoOK()">OK</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</xul:window>
|
48
xpfe/browser/samples/dexsimplemaster.xul
Normal file
48
xpfe/browser/samples/dexsimplemaster.xul
Normal file
@ -0,0 +1,48 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="xul.css" type="text/css"?>
|
||||
<!DOCTYPE window>
|
||||
<!-- Simple sample interface for bringing up a nonmodal dialog -->
|
||||
<xul:window
|
||||
xmlns:html="http://www.w3.org/TR/REC-html40"
|
||||
xmlns:xul ="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title = "Dialog creation sample">
|
||||
|
||||
<html:script>
|
||||
function MakeDialog() {
|
||||
var toolkitCore = GetToolkitCore();
|
||||
if (toolkitCore)
|
||||
toolkitCore.ShowWindow("resource:/res/samples/dexsimpledialog.xul",
|
||||
window);
|
||||
}
|
||||
function ModalDialog() {
|
||||
var toolkitCore = GetToolkitCore();
|
||||
if (toolkitCore)
|
||||
toolkitCore.ShowModalDialog("resource:/res/samples/dexsimpledialog.xul",
|
||||
window);
|
||||
}
|
||||
function GetToolkitCore() {
|
||||
var toolkitCore = XPAppCoresManager.Find("ToolkitCore");
|
||||
if (!toolkitCore) {
|
||||
toolkitCore = new ToolkitCore();
|
||||
if (toolkitCore)
|
||||
toolkitCore.Init("ToolkitCore");
|
||||
}
|
||||
return toolkitCore;
|
||||
}
|
||||
</html:script>
|
||||
|
||||
<xul:toolbox>
|
||||
<xul:toolbar>
|
||||
<!-- buttons temporarily have (inappropriate) images because of
|
||||
a bug in titledbutton -->
|
||||
<xul:titledbutton
|
||||
src="resource:/res/toolbar/TB_Back.gif" align="bottom"
|
||||
value="Make Dialog" onclick="MakeDialog()"
|
||||
style="background-color:rgb(192,192,192);"/>
|
||||
<xul:titledbutton
|
||||
src="resource:/res/toolbar/TB_Back.gif" align="bottom"
|
||||
value="Modal Dialog" onclick="ModalDialog()"
|
||||
style="background-color:rgb(192,192,192);"/>
|
||||
</xul:toolbar>
|
||||
</xul:toolbox>
|
||||
</xul:window>
|
34
xpfe/browser/samples/makefile.win
Normal file
34
xpfe/browser/samples/makefile.win
Normal file
@ -0,0 +1,34 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..\..
|
||||
IGNORE_MANIFEST=1
|
||||
DIRS=sampleimages
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) dexsimplemaster.xul $(DIST)\bin\res\samples
|
||||
$(MAKE_INSTALL) dexsimpledialog.xul $(DIST)\bin\res\samples
|
||||
$(MAKE_INSTALL) dexanimmaster.xul $(DIST)\bin\res\samples
|
||||
$(MAKE_INSTALL) dexanimdialog.xul $(DIST)\bin\res\samples
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\res\samples\dexsimplemaster.xul
|
||||
rm -f $(DIST)\res\samples\dexsimpledialog.xul
|
||||
rm -f $(DIST)\res\samples\dexanimmaster.xul
|
||||
rm -f $(DIST)\res\samples\dexanimdialog.xul
|
BIN
xpfe/browser/samples/sampleimages/bongo.gif
Normal file
BIN
xpfe/browser/samples/sampleimages/bongo.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 139 B |
BIN
xpfe/browser/samples/sampleimages/down.gif
Normal file
BIN
xpfe/browser/samples/sampleimages/down.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 186 B |
BIN
xpfe/browser/samples/sampleimages/left.gif
Normal file
BIN
xpfe/browser/samples/sampleimages/left.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 566 B |
35
xpfe/browser/samples/sampleimages/makefile.win
Normal file
35
xpfe/browser/samples/sampleimages/makefile.win
Normal file
@ -0,0 +1,35 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
IGNORE_MANIFEST=1
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) right.gif $(DIST)\bin\res\samples\sampleimages
|
||||
$(MAKE_INSTALL) down.gif $(DIST)\bin\res\samples\sampleimages
|
||||
$(MAKE_INSTALL) left.gif $(DIST)\bin\res\samples\sampleimages
|
||||
$(MAKE_INSTALL) up.gif $(DIST)\bin\res\samples\sampleimages
|
||||
$(MAKE_INSTALL) bongo.gif $(DIST)\bin\res\samples\sampleimages
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\res\samples\sampleimages\right.gif
|
||||
rm -f $(DIST)\res\samples\sampleimages\down.gif
|
||||
rm -f $(DIST)\res\samples\sampleimages\left.gif
|
||||
rm -f $(DIST)\res\samples\sampleimages\up.gif
|
||||
rm -f $(DIST)\res\samples\sampleimages\bongo.gif
|
BIN
xpfe/browser/samples/sampleimages/right.gif
Normal file
BIN
xpfe/browser/samples/sampleimages/right.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 151 B |
BIN
xpfe/browser/samples/sampleimages/up.gif
Normal file
BIN
xpfe/browser/samples/sampleimages/up.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 316 B |
Loading…
Reference in New Issue
Block a user