Debian Codegraph @

samples/tests/spec/scripting/tspan_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 tspan 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;tspan&gt; children 'onload'</title>
42
43 <text x="50%" y="45" class="title">&lt;tspan&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
90 ]]>
91 </script>
92
93 <g id="test-content">
94 <g style="font-size:40" >
95
96 <text x="70" y="115" style="fill:orange" >
97 <tspan onload="addtspan(evt,9,' brown','fill:brown')" >the quick fox</tspan></text>
98
99 <text x="70" y="155" style="fill:orange" >
100 <tspan onload="addtref(evt,9,'#browndef','fill:brown')" >the quick fox</tspan></text>
101
102 <text x="70" y="315" style="fill:orange" >
103 <tspan onload="remove(evt,'tspan')" >
104 the quick
105 <tspan id="tspan" style="fill:brown">brown</tspan>
106 fox
107 </tspan></text>
108
109 <text x="70" y="355" style="fill:orange" >
110 <tspan onload="remove(evt,'tref')" >
111 the quick
112 <tref id="tref" style="fill:brown" xlink:href="#browndef"/>
113 fox
114 </tspan></text>
115
116 </g>
117
118 <g style="stroke:black;fill:none;stroke-width:1;font-size:40">
119 <text x="70" y="115">
120 the quick <tspan>brown</tspan> fox
121 </text>
122 <text x="70" y="155">
123 the quick <tref xlink:href="#browndef" /> fox
124 </text>
125 <text x="70" y="315">
126 the quick fox
127 </text>
128 <text x="70" y="355">
129 the quick fox
130 </text>
131 </g>
132
133 <g style="fill:black; stroke:none; text-anchor:middle">
134 <text x="225" y="230" >insert nodes
135 <tspan style="font-size:8">( &lt;tspan&gt;,&lt;tref&gt; )</tspan>
136 </text>
137 <text x="225" y="430" >remove nodes
138 <tspan style="font-size:8">( &lt;tspan&gt;,&lt;tref&gt; )</tspan>
139 </text>
140 </g>
141 </g>
142 </svg>