File: addDescOnClick.svg

package info (click to toggle)
batik 1.7%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 29,196 kB
  • sloc: java: 194,874; xml: 16,741; sh: 163; makefile: 41
file content (196 lines) | stat: -rw-r--r-- 6,644 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">

<!--

   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

-->
<!-- ====================================================================== -->
<!-- Append/Remove desc/title test                                          -->
<!--                                                                        -->
<!-- @author deweese@apache.org                                             -->
<!-- @version $Id: addDescOnClick.svg 475477 2006-11-15 22:44:28Z cam $ -->
<!-- ====================================================================== -->

<?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?>  

<svg xmlns="http://www.w3.org/2000/svg" 
     xmlns:xlink="http://www.w3.org/1999/xlink"
     id="body" width="450" height="500" viewBox="0 0 450 500">

    <title>Add Desc element "onClick"</title>

    <text x="50%" y="45" class="title">Add Desc element "onClick"</text>

    <script type="text/ecmascript">

    var svgNamespaceURI = "http://www.w3.org/2000/svg";

    function addChild(evt, tag) {
        var r = evt.target;
        var document = r.ownerDocument;
        var e = document.createElementNS(svgNamespaceURI, tag);
        e.appendChild(document.createTextNode("Dynamic: " + tag));
        r.appendChild(e);
    }

    var desc  = document.getElementById("foo");
    var newD = document.createTextNode("Text 1");
    var oldD = desc.firstChild;

    function toggleDesc() {
       desc.replaceChild(newD, oldD);
       var tmp = newD; newD=oldD; oldD=tmp;
       setTimeout("toggleDesc()", 1000);
    }

    var title  = document.getElementById("bar");
    var newT = document.createTextNode("Title 2");
    var oldT = title.firstChild;

    function toggleTitle() {
       title.replaceChild(newT, oldT);
       var tmp = newT; newT=oldT; oldT=tmp;
       setTimeout("toggleTitle()", 1000);
    }

    toggleDesc();
    toggleTitle();


    var desc2  = document.getElementById("foo2");
    var newD2 = document.createTextNode("Text 1");
    var oldD2 = desc2.firstChild;

    function toggleDesc2() {
       desc2.removeChild(oldD2);
       desc2.appendChild(newD2);
       var tmp = newD2; newD2=oldD2; oldD2=tmp;
       setTimeout("toggleDesc2()", 1000);
    }

    var title2  = document.getElementById("bar2");
    var newT2 = document.createTextNode("Title 2");
    var oldT2 = title2.firstChild;

    function toggleTitle2() {
       title2.removeChild(oldT2);
       title2.appendChild(newT2);
       var tmp = newT2; newT2=oldT2; oldT2=tmp;
       setTimeout("toggleTitle2()", 1000);
    }

    toggleDesc2();
    toggleTitle2();

    var elT = document.getElementById("title");
    var tglTitle = elT.firstChild;
    var elD = document.getElementById("desc");
    var tglDesc = elD.firstChild;

    function toggleShowTitle() {
      if (elT.firstChild) 
         elT.removeChild(tglTitle);
      else
         elT.appendChild(tglTitle);
       setTimeout("toggleShowTitle()", 1000);
    }
    function toggleShowDesc() {
      if (elD.firstChild) 
         elD.removeChild(tglDesc);
      else
         elD.appendChild(tglDesc);
       setTimeout("toggleShowDesc()", 1000);
    }

    toggleShowDesc();
    toggleShowTitle();

    var elT2 = document.getElementById("title2");
    var tglTitle2 = elT2.firstChild;
    var elD2 = document.getElementById("desc2");
    var tglDesc2 = elD2.firstChild;

    function toggleShowTitle2() {
      if (tglTitle2.parentNode == elT2) 
         elT2.removeChild(tglTitle2);
      else
         elT2.appendChild(tglTitle2);
       setTimeout("toggleShowTitle2()", 1000);
    }
    function toggleShowDesc2() {
      if (tglDesc2.parentNode == elD2) 
         elD2.removeChild(tglDesc2);
      else
         elD2.appendChild(tglDesc2);
       setTimeout("toggleShowDesc2()", 1000);
    }

    toggleShowDesc2();
    toggleShowTitle2();
    </script>

    <g>
       <rect x="30"  y="75" width="75" height="75" style="fill:crimson"
             onclick="addChild(evt, 'desc')"/>

       <rect x="135" y="75" width="75" height="75" style="fill:gold"
             onclick="addChild(evt, 'title')"/>

       <rect x="240" y="75" width="75" height="75" style="fill:crimson"
             onclick="addChild(evt, 'desc')"
          ><title>Pre Existing Title</title></rect>

       <rect x="345" y="75" width="75" height="75" style="fill:gold"
             onclick="addChild(evt, 'title')"
          ><desc>Pre Existing Desc</desc></rect>


       <rect id="title" x="30" y="180" width="75" height="75" 
             style="fill:crimson"><title>Pre Existing Title</title></rect>

       <rect id="desc" x="135" y="180" width="75" height="75" 
             style="fill:gold"><desc>Pre-existing Desc</desc></rect>

       <rect id="title2" x="240" y="180" width="75" height="75" 
          style="fill:crimson"><title>Pre Existing Title</title>
                               <desc>A constant Desc</desc></rect>

       <rect id="desc2" x="345" y="180" width="75" height="75" 
             style="fill:gold"><desc>Pre-existing Desc</desc>
                               <title>A constant title</title></rect>


       <rect x="30" y="285" width="75" height="75" style="fill:crimson"
          ><title>Pre Existing Title</title
          ><desc id="foo">Text 2</desc></rect>

       <rect x="135" y="285" width="75" height="75" style="fill:gold"
          ><title id="bar">Title 1</title
          ><desc >Pre-existing Desc</desc></rect>

       <rect x="240" y="285" width="75" height="75" style="fill:crimson"
          ><title>Pre Existing Title</title
          ><desc id="foo2">Text 2</desc></rect>

       <rect x="345" y="285" width="75" height="75" style="fill:gold"
          ><title id="bar2">Title 1</title
          ><desc >Pre-existing Desc</desc></rect>

    </g>
</svg>