| 1 |
<?xml version="1.0" standalone="no"?> |
| 2 |
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" |
| 3 |
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> |
| 4 |
|
| 5 |
<!-- |
| 6 |
|
| 7 |
Licensed to the Apache Software Foundation (ASF) under one or more |
| 8 |
contributor license agreements. See the NOTICE file distributed with |
| 9 |
this work for additional information regarding copyright ownership. |
| 10 |
The ASF licenses this file to You under the Apache License, Version 2.0 |
| 11 |
(the "License"); you may not use this file except in compliance with |
| 12 |
the License. You may obtain a copy of the License at |
| 13 |
|
| 14 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 15 |
|
| 16 |
Unless required by applicable law or agreed to in writing, software |
| 17 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 18 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 19 |
See the License for the specific language governing permissions and |
| 20 |
limitations under the License. |
| 21 |
|
| 22 |
--> |
| 23 |
<!-- ====================================================================== --> |
| 24 |
<!-- Append/Remove desc/title test --> |
| 25 |
<!-- --> |
| 26 |
<!-- @author [email protected] --> |
| 27 |
<!-- @version $Id$ --> |
| 28 |
<!-- ====================================================================== --> |
| 29 |
|
| 30 |
<?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?> |
| 31 |
|
| 32 |
<svg xmlns="http://www.w3.org/2000/svg" |
| 33 |
xmlns:xlink="http://www.w3.org/1999/xlink" |
| 34 |
id="body" width="450" height="500" viewBox="0 0 450 500"> |
| 35 |
|
| 36 |
<title>Add Desc element "onClick"</title> |
| 37 |
|
| 38 |
<text x="50%" y="45" class="title">Add Desc element "onClick"</text> |
| 39 |
|
| 40 |
<script type="text/ecmascript"> |
| 41 |
|
| 42 |
var svgNamespaceURI = "http://www.w3.org/2000/svg"; |
| 43 |
|
| 44 |
function addChild(evt, tag) { |
| 45 |
var r = evt.target; |
| 46 |
var document = r.ownerDocument; |
| 47 |
var e = document.createElementNS(svgNamespaceURI, tag); |
| 48 |
e.appendChild(document.createTextNode("Dynamic: " + tag)); |
| 49 |
r.appendChild(e); |
| 50 |
} |
| 51 |
|
| 52 |
var desc = document.getElementById("foo"); |
| 53 |
var newD = document.createTextNode("Text 1"); |
| 54 |
var oldD = desc.firstChild; |
| 55 |
|
| 56 |
function toggleDesc() { |
| 57 |
desc.replaceChild(newD, oldD); |
| 58 |
var tmp = newD; newD=oldD; oldD=tmp; |
| 59 |
setTimeout("toggleDesc()", 1000); |
| 60 |
} |
| 61 |
|
| 62 |
var title = document.getElementById("bar"); |
| 63 |
var newT = document.createTextNode("Title 2"); |
| 64 |
var oldT = title.firstChild; |
| 65 |
|
| 66 |
function toggleTitle() { |
| 67 |
title.replaceChild(newT, oldT); |
| 68 |
var tmp = newT; newT=oldT; oldT=tmp; |
| 69 |
setTimeout("toggleTitle()", 1000); |
| 70 |
} |
| 71 |
|
| 72 |
toggleDesc(); |
| 73 |
toggleTitle(); |
| 74 |
|
| 75 |
|
| 76 |
var desc2 = document.getElementById("foo2"); |
| 77 |
var newD2 = document.createTextNode("Text 1"); |
| 78 |
var oldD2 = desc2.firstChild; |
| 79 |
|
| 80 |
function toggleDesc2() { |
| 81 |
desc2.removeChild(oldD2); |
| 82 |
desc2.appendChild(newD2); |
| 83 |
var tmp = newD2; newD2=oldD2; oldD2=tmp; |
| 84 |
setTimeout("toggleDesc2()", 1000); |
| 85 |
} |
| 86 |
|
| 87 |
var title2 = document.getElementById("bar2"); |
| 88 |
var newT2 = document.createTextNode("Title 2"); |
| 89 |
var oldT2 = title2.firstChild; |
| 90 |
|
| 91 |
function toggleTitle2() { |
| 92 |
title2.removeChild(oldT2); |
| 93 |
title2.appendChild(newT2); |
| 94 |
var tmp = newT2; newT2=oldT2; oldT2=tmp; |
| 95 |
setTimeout("toggleTitle2()", 1000); |
| 96 |
} |
| 97 |
|
| 98 |
toggleDesc2(); |
| 99 |
toggleTitle2(); |
| 100 |
|
| 101 |
var elT = document.getElementById("title"); |
| 102 |
var tglTitle = elT.firstChild; |
| 103 |
var elD = document.getElementById("desc"); |
| 104 |
var tglDesc = elD.firstChild; |
| 105 |
|
| 106 |
function toggleShowTitle() { |
| 107 |
if (elT.firstChild) |
| 108 |
elT.removeChild(tglTitle); |
| 109 |
else |
| 110 |
elT.appendChild(tglTitle); |
| 111 |
setTimeout("toggleShowTitle()", 1000); |
| 112 |
} |
| 113 |
function toggleShowDesc() { |
| 114 |
if (elD.firstChild) |
| 115 |
elD.removeChild(tglDesc); |
| 116 |
else |
| 117 |
elD.appendChild(tglDesc); |
| 118 |
setTimeout("toggleShowDesc()", 1000); |
| 119 |
} |
| 120 |
|
| 121 |
toggleShowDesc(); |
| 122 |
toggleShowTitle(); |
| 123 |
|
| 124 |
var elT2 = document.getElementById("title2"); |
| 125 |
var tglTitle2 = elT2.firstChild; |
| 126 |
var elD2 = document.getElementById("desc2"); |
| 127 |
var tglDesc2 = elD2.firstChild; |
| 128 |
|
| 129 |
function toggleShowTitle2() { |
| 130 |
if (tglTitle2.parentNode == elT2) |
| 131 |
elT2.removeChild(tglTitle2); |
| 132 |
else |
| 133 |
elT2.appendChild(tglTitle2); |
| 134 |
setTimeout("toggleShowTitle2()", 1000); |
| 135 |
} |
| 136 |
function toggleShowDesc2() { |
| 137 |
if (tglDesc2.parentNode == elD2) |
| 138 |
elD2.removeChild(tglDesc2); |
| 139 |
else |
| 140 |
elD2.appendChild(tglDesc2); |
| 141 |
setTimeout("toggleShowDesc2()", 1000); |
| 142 |
} |
| 143 |
|
| 144 |
toggleShowDesc2(); |
| 145 |
toggleShowTitle2(); |
| 146 |
</script> |
| 147 |
|
| 148 |
<g> |
| 149 |
<rect x="30" y="75" width="75" height="75" style="fill:crimson" |
| 150 |
onclick="addChild(evt, 'desc')"/> |
| 151 |
|
| 152 |
<rect x="135" y="75" width="75" height="75" style="fill:gold" |
| 153 |
onclick="addChild(evt, 'title')"/> |
| 154 |
|
| 155 |
<rect x="240" y="75" width="75" height="75" style="fill:crimson" |
| 156 |
onclick="addChild(evt, 'desc')" |
| 157 |
><title>Pre Existing Title</title></rect> |
| 158 |
|
| 159 |
<rect x="345" y="75" width="75" height="75" style="fill:gold" |
| 160 |
onclick="addChild(evt, 'title')" |
| 161 |
><desc>Pre Existing Desc</desc></rect> |
| 162 |
|
| 163 |
|
| 164 |
<rect id="title" x="30" y="180" width="75" height="75" |
| 165 |
style="fill:crimson"><title>Pre Existing Title</title></rect> |
| 166 |
|
| 167 |
<rect id="desc" x="135" y="180" width="75" height="75" |
| 168 |
style="fill:gold"><desc>Pre-existing Desc</desc></rect> |
| 169 |
|
| 170 |
<rect id="title2" x="240" y="180" width="75" height="75" |
| 171 |
style="fill:crimson"><title>Pre Existing Title</title> |
| 172 |
<desc>A constant Desc</desc></rect> |
| 173 |
|
| 174 |
<rect id="desc2" x="345" y="180" width="75" height="75" |
| 175 |
style="fill:gold"><desc>Pre-existing Desc</desc> |
| 176 |
<title>A constant title</title></rect> |
| 177 |
|
| 178 |
|
| 179 |
<rect x="30" y="285" width="75" height="75" style="fill:crimson" |
| 180 |
><title>Pre Existing Title</title |
| 181 |
><desc id="foo">Text 2</desc></rect> |
| 182 |
|
| 183 |
<rect x="135" y="285" width="75" height="75" style="fill:gold" |
| 184 |
><title id="bar">Title 1</title |
| 185 |
><desc >Pre-existing Desc</desc></rect> |
| 186 |
|
| 187 |
<rect x="240" y="285" width="75" height="75" style="fill:crimson" |
| 188 |
><title>Pre Existing Title</title |
| 189 |
><desc id="foo2">Text 2</desc></rect> |
| 190 |
|
| 191 |
<rect x="345" y="285" width="75" height="75" style="fill:gold" |
| 192 |
><title id="bar2">Title 1</title |
| 193 |
><desc >Pre-existing Desc</desc></rect> |
| 194 |
|
| 195 |
</g> |
| 196 |
</svg> |