Debian Codegraph @

samples/tests/spec/scripting/text_children3.svg

raw
1 <?xml version="1.0" standalone="no"?>
2 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000802//EN"
3 "http://www.w3.org/TR/2000/CR-SVG-20000802/DTD/svg-20000802.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 <!-- Modification of text children -->
25 <!-- -->
26 <!-- @author [email protected] -->
27 <!-- @version $Id$ -->
28 <!-- ====================================================================== -->
29
30 <?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?>
31
32 <svg id="body" width="450" height="500" viewBox="0 0 450 500"
33 xmlns:xlink="http://www.w3.org/1999/xlink" >
34
35 <defs>
36 <text id="browndef"> brown</text>
37 <path id="pathdef" d="M250,180 C300,250 500,250 500,180" />
38 <path id="pathdef1" d="M250,380 C300,250 500,250 500,380" />
39 </defs>
40
41 <title>&lt;text&gt; children 'onload'</title>
42
43 <text x="50%" y="45" class="title">&lt;text&gt; children in 'onload'</text>
44
45 <script type="text/ecmascript"><![CDATA[
46 function remove(evt,target){
47 var elt = evt.target;
48 var doc = elt.getOwnerDocument();
49
50 var remove = doc.getElementById(target);
51 elt = remove.getParentNode();
52 elt.removeChild(remove);
53 }
54 function addtspan(evt,pos,t,s){
55 var elt = evt.target;
56 var doc = elt.getOwnerDocument();
57
58 var textnode = elt.getFirstChild();
59
60 textnode = textnode.splitText(pos);
61
62 var tspan = doc.createElementNS(elt.getNamespaceURI(),'tspan');
63 tspan.setAttribute('style',s);
64
65 var newtextnode = doc.createTextNode(t);
66
67 tspan.appendChild(newtextnode);
68
69 elt.insertBefore(tspan,textnode);
70 }
71 function addtref(evt,pos,ref,s){
72 var elt = evt.target;
73 var doc = elt.getOwnerDocument();
74
75 var textnode = elt.getFirstChild();
76
77 textnode = textnode.splitText(pos);
78
79 var tref = doc.createElementNS(elt.getNamespaceURI(),'tref');
80 tref.setAttribute('style',s);
81 var attr = doc.createAttributeNS("http://www.w3.org/1999/xlink","href");
82 attr.setValue(ref);
83 tref.setAttributeNodeNS(attr);
84
85 elt.insertBefore(tref,textnode);
86
87
88 }
89 function addtextpath(evt,pos,ref,t,s){
90 var elt = evt.target;
91 var doc = elt.getOwnerDocument();
92
93 var textnode = elt.getFirstChild();
94
95 textnode = textnode.splitText(pos);
96
97 var textPath = doc.createElementNS(elt.getNamespaceURI(),'textPath');
98 textPath.setAttribute('style',s);
99
100 var attr = doc.createAttributeNS("http://www.w3.org/1999/xlink","href");
101 attr.setValue(ref);
102 textPath.setAttributeNodeNS(attr);
103
104 var newtextnode = doc.createTextNode(t);
105
106 textPath.appendChild(newtextnode);
107
108 elt.insertBefore(textPath,textnode);
109 }
110
111 ]]>
112 </script>
113
114 <g id="test-content">
115 <g style="font-size:40" >
116
117 <text x="70" y="115" style="fill:orange"
118 onload="addtspan(evt,9,' brown','fill:brown')" >the quick fox</text>
119
120 <text x="70" y="155" style="fill:orange"
121 onload="addtref(evt,9,'#browndef','fill:brown')" >the quick fox</text>
122
123 <text x="70" y="195" style="fill:orange"
124 onload="addtextpath(evt,9,'#pathdef','brown','fill:brown')" >the quick fox</text>
125
126 <text x="70" y="315" style="fill:orange"
127 onload="remove(evt,'tspan')" >
128 the quick
129 <tspan id="tspan" style="fill:brown">brown</tspan>
130 fox
131 </text>
132
133 <text x="70" y="355" style="fill:orange"
134 onload="remove(evt,'tref')" >
135 the quick
136 <tref id="tref" style="fill:brown" xlink:href="#browndef"/>
137 fox
138 </text>
139
140 <text x="70" y="395" style="fill:orange"
141 onload="remove(evt,'textpath')" >
142 the quick
143 <textPath id="textpath" xlink:href="#pathdef1" style="fill:brown">brown</textPath>fox</text>
144
145 </g>
146
147 <g style="stroke:black;fill:none;stroke-width:1;font-size:40">
148 <text x="70" y="115">
149 the quick <tspan>brown</tspan> fox
150 </text>
151 <text x="70" y="155">
152 the quick <tref xlink:href="#browndef" /> fox
153 </text>
154 <text x="70" y="195">
155 the quick <textPath xlink:href="#pathdef" >brown</textPath> fox
156 </text>
157 <text x="70" y="315">
158 the quick fox
159 </text>
160 <text x="70" y="355">
161 the quick fox
162 </text>
163 <text x="70" y="395">
164 the quick fox
165 </text>
166 </g>
167
168 <g style="fill:black; stroke:none; text-anchor:middle">
169 <text x="225" y="230" >insert nodes
170 <tspan style="font-size:8">( &lt;tspan&gt;,&lt;tref&gt;,&lt;textPath&gt; )</tspan>
171 </text>
172 <text x="225" y="430" >remove nodes
173 <tspan style="font-size:8">( &lt;tspan&gt;,&lt;tref&gt;,&lt;textPath&gt; )</tspan>
174 </text>
175 </g>
176 </g>
177 </svg>