Alert, confirm and prompt windows 100% SVG
New version runing with Firefox 1.5, Opera 9 and Batik 1.6
Design and script are separated.
Script is load on begin
Design is load on request and removed after use.
You can create your design, save it in SVG or SVGZ files.
In main SVG, for using alert, prompt or confirm, you have to function messages_use_confirm(result,num_w) function messages_use_prompt(result,data,num_w) ( svgdoc must be name for SVGDocument and name
of group + "_use_confirm" or "_use_prompt" names of functions ) In SVG design, this function is called when you close window with
onclick="close_alert(true)".
1) load script with
<script xlink:href="js/alert.js"/>
manage windows
<script xlink:href="js/opera.js"/>
emulation for getURL() and parseXML()
<script xlink:href="js/tools.js"/>
moving windows
2) reserve at the end place for design with <g id="messages" transform="translate(100,50)"></g>
by example
3) put in <defs> gradients used by design
4) call it with
add_alert("svg/alert.svg","messages","Width of rectangle is\n"+large.toString());
in order: file for design, name of group where put fragment, string for text
or
add_confirm("svg/confirm.svg","messages","Change color\nof rectangle\nin
green",num);
in order: file for design, name of group where put fragment, string for text,
number for using
or
add_prompt("svg/prompt.svg","messages","Enter color\nof rectangle\nas red or #CCCC00",num);
in order: file for design, name of group where put fragment, string for text,
number for using
5) create functions to use result in main SVG as this
{
if (!result)
return
switch(num_w)
{
case 0:
obj=svgdoc.getElementById("rect");
obj.setAttribute("fill","green");
break;
case 1:
obj=svgdoc.getElementById("rect2");
obj.setAttribute("width","200");
break;
}
}
{
if (!result)
return
switch(num_w)
{
case 0:
obj=svgdoc.getElementById("rect3");
obj.setAttribute("fill",data);
break;
case 1:
obj=svgdoc.getElementById("rect4");
obj.setAttribute("fill",data);
break;
}
}
Functions alert_tape, confirm_tape and prompt_tape allow using Enter and Escape
keys to close window and enter text in prompt.
Three lines of text can be used with "invite0", "invite1",
"invite2" as id.
In prompt, string to enter with keyboard is with "prompt_result"
as id.