From 3253c2149d2c4e01e885c7a200e45436e6ced47c 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 | Bin 0 -> 566 bytes .../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 000000000000..bafd31498b43 --- /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 000000000000..2d59c04d988b --- /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 000000000000..5cc7a86ec19c --- /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 000000000000..cb830d4d0a39 --- /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 000000000000..e18463574a95 --- /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 0000000000000000000000000000000000000000..401e2aa4d772aaced0ebbbe97607c6d02f879940 GIT binary patch literal 566 zcmZ?wbhEHbRA5kG_`<-z!NFl^Y3b$V6%`ego}QkcpI=^HUSD6|-rnBd-#>l&^!fAW zFJHcV{rdIWw{PFSfB*60$IqWXfBpLP`}glZefsqM`}g0!fB*mgKLZY+0}=<><-q!1 zL7^`tb6$GETCpIWr<=}&Emq+OS|#4{Z>ck@kb$8Duh-f{1y-%eZifs6A{rMRd6RTA zPg8*Xq4-RfWk)YE{7TT^V?C5$ry#-8&YWqm*g{BEG%i}mjGZmhft8c1my@%gh$+IJ zkz2S~n5%ONuL*BE<03{TL1Q649_}hN8xgKTLt{~XZZ6Bp@-@n0Vj`2LXfX40sWioK zt1fG978BrZP+<`i+RMjlrR?9#&tAkl$GVq`=XeWONZ5gcZ{AK_{BAA(851F%hxYSy z68MFLW22RpoN9C8=4N3#HerHcauahj=e3D5$`>**S#HV**&y&RY#x*978lQmMF+Y# zw<=UfY8;sKRJJofN#TKrg6I;9&?}KMgB9Ahi7GsvXyNdXu~U*asyFIX$do20l`pX` zR`kTppTgz-Cz_FQws0|{q>ti+(uK|J($XdzT1mHAxkMzE>~2yzAjo!A!=>WDbbYT9 zOI5913lAK$=XO4J?%?shE9M0~tzLYL42u8kgHlsUlT%X^Of6Iu929_Yte2jdR-Rdv tSd^ldoS&=UUYc55Vx{2c@2BhR@9XOt + +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