From 15d7a9803703931b8684d634bcd1da8a11ddc5ad Mon Sep 17 00:00:00 2001 From: "danm%netscape.com" Date: Fri, 2 Apr 1999 20:06:37 +0000 Subject: [PATCH] XUL samples --- xpfe/browser/samples/dexanimdialog.xul | 112 ++++++++++++++++++ xpfe/browser/samples/dexanimmaster.xul | 81 +++++++++++++ xpfe/browser/samples/dexsimpledialog.xul | 77 ++++++++++++ xpfe/browser/samples/dexsimplemaster.xul | 48 ++++++++ xpfe/browser/samples/makefile.win | 34 ++++++ xpfe/browser/samples/sampleimages/bongo.gif | Bin 0 -> 139 bytes xpfe/browser/samples/sampleimages/down.gif | Bin 0 -> 186 bytes xpfe/browser/samples/sampleimages/left.gif | 0 .../browser/samples/sampleimages/makefile.win | 35 ++++++ xpfe/browser/samples/sampleimages/right.gif | Bin 0 -> 151 bytes xpfe/browser/samples/sampleimages/up.gif | Bin 0 -> 316 bytes 11 files changed, 387 insertions(+) create mode 100644 xpfe/browser/samples/dexanimdialog.xul create mode 100644 xpfe/browser/samples/dexanimmaster.xul create mode 100644 xpfe/browser/samples/dexsimpledialog.xul create mode 100644 xpfe/browser/samples/dexsimplemaster.xul create mode 100644 xpfe/browser/samples/makefile.win create mode 100644 xpfe/browser/samples/sampleimages/bongo.gif create mode 100644 xpfe/browser/samples/sampleimages/down.gif create mode 100644 xpfe/browser/samples/sampleimages/left.gif create mode 100644 xpfe/browser/samples/sampleimages/makefile.win create mode 100644 xpfe/browser/samples/sampleimages/right.gif create mode 100644 xpfe/browser/samples/sampleimages/up.gif diff --git a/xpfe/browser/samples/dexanimdialog.xul b/xpfe/browser/samples/dexanimdialog.xul new file mode 100644 index 00000000000..bafd31498b4 --- /dev/null +++ b/xpfe/browser/samples/dexanimdialog.xul @@ -0,0 +1,112 @@ + + + + + + + + // 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; + } + + + + + + + + + + + + + + + + + + + + + +
Give me your money
+ + Remind me +
+ +
diff --git a/xpfe/browser/samples/dexanimmaster.xul b/xpfe/browser/samples/dexanimmaster.xul new file mode 100644 index 00000000000..2d59c04d988 --- /dev/null +++ b/xpfe/browser/samples/dexanimmaster.xul @@ -0,0 +1,81 @@ + + + + + + + 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; + } + + + + + + + + + + + + + diff --git a/xpfe/browser/samples/dexsimpledialog.xul b/xpfe/browser/samples/dexsimpledialog.xul new file mode 100644 index 00000000000..5cc7a86ec19 --- /dev/null +++ b/xpfe/browser/samples/dexsimpledialog.xul @@ -0,0 +1,77 @@ + + + + + + + + // 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; + } + + + + + + + + + + + + +
Give me your money
+ + Remind me +
+ +
+ +
diff --git a/xpfe/browser/samples/dexsimplemaster.xul b/xpfe/browser/samples/dexsimplemaster.xul new file mode 100644 index 00000000000..cb830d4d0a3 --- /dev/null +++ b/xpfe/browser/samples/dexsimplemaster.xul @@ -0,0 +1,48 @@ + + + + + + + + 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; + } + + + + + + + + + + diff --git a/xpfe/browser/samples/makefile.win b/xpfe/browser/samples/makefile.win new file mode 100644 index 00000000000..e18463574a9 --- /dev/null +++ b/xpfe/browser/samples/makefile.win @@ -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 diff --git a/xpfe/browser/samples/sampleimages/bongo.gif b/xpfe/browser/samples/sampleimages/bongo.gif new file mode 100644 index 0000000000000000000000000000000000000000..619e2e612ced5cf3f1cdf2c54223ffc15266f820 GIT binary patch literal 139 zcmZ?wbhEHbtY8RYXl7tgmX&n1&<*mij|vW|OpB;5&hKw+S~js|^}l&^!fAW zFJHcV{rdIWw{PFSfB*60$IqWXfBpLP`}glZfByXa`}g0!fB*mgKLZY+0}=<><-q!1 zL7^`tbKdfTwX3(vv>2><^HhT~Xv!B=)5u(F;%qgsE UgNA`})|3^tA}xm#4{mY*0CG=EqW}N^ literal 0 HcmV?d00001 diff --git a/xpfe/browser/samples/sampleimages/left.gif b/xpfe/browser/samples/sampleimages/left.gif new file mode 100644 index 00000000000..e69de29bb2d diff --git a/xpfe/browser/samples/sampleimages/makefile.win b/xpfe/browser/samples/sampleimages/makefile.win new file mode 100644 index 00000000000..3f59a5e2fb1 --- /dev/null +++ b/xpfe/browser/samples/sampleimages/makefile.win @@ -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 diff --git a/xpfe/browser/samples/sampleimages/right.gif b/xpfe/browser/samples/sampleimages/right.gif new file mode 100644 index 0000000000000000000000000000000000000000..fb4b73b24f8db501d48cdf82489c120ec42e4da1 GIT binary patch literal 151 zcmZ?wbhEHbRA5kG_{_k-#l@AJoLo~=)85`bapJ^9ixzF%xN-mf{ijc#zIX55r%#{$ z|NqZ`1av@bkX{Ft{{kmGSMQBjyEjzQDS-9ZLXBhTxlGUcypkrm`U)(J$cz@+H<>xT u!b?J!cZ#pOd literal 0 HcmV?d00001 diff --git a/xpfe/browser/samples/sampleimages/up.gif b/xpfe/browser/samples/sampleimages/up.gif new file mode 100644 index 0000000000000000000000000000000000000000..99e4f049df609624e3bd56659a58d5c16589a34a GIT binary patch literal 316 zcmZ?wbhEHbRA5kGc+9}S$;s*M?VX>W-_+DJapJ^9ixzF#wCTWs16QtGdHC?*$B!TX z|NqZ`1QdU=FfuUkFzA59KxR0w{1-Ukxq9!9HEY{AA`&FpCyBHy)%D`im>n4KdJ>Pr z0lB=;KN|fG4x1%8<}+|Od*+C7TykWn))F{!Ve*DKGP~|~DK6A_Fzf1a$A}uWloR~H zLJ~LFIgW~&zB#9_RF%nLTVLX@BUi`BUTMu1sU_o4r)ba4$-0tG$4?}QM8A>H)YCvQ?)KHAI4c_&a3CJvwH4nJ8|;F@l)c=p&Wf3+-#>9GiS<` zTymQ)o+(?jNu@HCb?TDNM~X&lT<-T6{3BlYuqL