| 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 |
<?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?> |
| 24 |
|
| 25 |
<svg xmlns="http://www.w3.org/2000/svg" |
| 26 |
xmlns:xlink="http://www.w3.org/1999/xlink" |
| 27 |
xmlns:cb="http://www.example.org/gui/checkbox" |
| 28 |
id="body" width="450" height="500" viewBox="0 0 450 500"> |
| 29 |
|
| 30 |
<title>Dynamic test of CSS selectors</title> |
| 31 |
<text x="50%" y="45" class="title">Dynamic test of CSS selectors</text> |
| 32 |
|
| 33 |
<style type="text/css"><![CDATA[ |
| 34 |
text.button { |
| 35 |
fill: #00F; |
| 36 |
} |
| 37 |
|
| 38 |
text + text.button { |
| 39 |
fill: #888; |
| 40 |
} |
| 41 |
|
| 42 |
text + g > text { |
| 43 |
fill: #F00; |
| 44 |
} |
| 45 |
|
| 46 |
g > text { |
| 47 |
fill: #0F0; |
| 48 |
} |
| 49 |
|
| 50 |
g.xxx > text { fill: #F0F; } |
| 51 |
|
| 52 |
[id=test4] > text { fill: #80F; } |
| 53 |
|
| 54 |
g + [id=foo] > text { fill: #808; } |
| 55 |
|
| 56 |
.checkbox > path { fill: none; stroke: black; stroke-width: 2; } |
| 57 |
.checkbox > rect { fill: white; stroke: black; stroke-width: 1; } |
| 58 |
.checkbox[selected=true] > path { visibility: visible;} |
| 59 |
.checkbox[selected=false] > path { visibility: hidden; } |
| 60 |
|
| 61 |
.a { fill: red; } |
| 62 |
.b { fill: orange; } |
| 63 |
rect.a + .b { fill: blue; } |
| 64 |
|
| 65 |
]]></style> |
| 66 |
|
| 67 |
<script type="text/ecmascript"><![CDATA[ |
| 68 |
var svgns = "http://www.w3.org/2000/svg"; |
| 69 |
|
| 70 |
function insertTextEvt(evt, x, y) { |
| 71 |
insertText(evt.currentTarget, x, y); |
| 72 |
} |
| 73 |
|
| 74 |
function removeTargetEvt(evt) { |
| 75 |
removeTarget(evt.currentTarget); |
| 76 |
} |
| 77 |
|
| 78 |
function setAttributeEvt(evt, attr, val) { |
| 79 |
evt.currentTarget.setAttribute(attr, val); |
| 80 |
} |
| 81 |
|
| 82 |
function removeTarget(e) { |
| 83 |
e.parentNode.removeChild(e); |
| 84 |
} |
| 85 |
|
| 86 |
function insertText(e, x, y) { |
| 87 |
var t = document.createElementNS(svgns, "text"); |
| 88 |
t.setAttribute("x", x); |
| 89 |
t.setAttribute("y", y); |
| 90 |
t.appendChild(document.createTextNode("Inserted")); |
| 91 |
e.parentNode.insertBefore(t, e); |
| 92 |
} |
| 93 |
|
| 94 |
function toggleSelectedEvt(evt) { |
| 95 |
toggleSelected(evt.currentTarget); |
| 96 |
} |
| 97 |
function toggleSelected(e) { |
| 98 |
var sel = e.getAttribute("selected"); |
| 99 |
if (sel == "true") { |
| 100 |
e.setAttribute("selected", "false"); |
| 101 |
} else { |
| 102 |
e.setAttribute("selected", "true"); |
| 103 |
} |
| 104 |
} |
| 105 |
|
| 106 |
|
| 107 |
function regardStart() { |
| 108 |
var e; |
| 109 |
removeTarget(document.getElementById("rm1")) |
| 110 |
insertText(document.getElementById("in1"), '10', '75'); |
| 111 |
|
| 112 |
removeTarget(document.getElementById("rm2")) |
| 113 |
insertText(document.getElementById("in2"), '10', '125'); |
| 114 |
|
| 115 |
document.getElementById("test3").setAttribute("class", "xxx"); |
| 116 |
document.getElementById("test4").setAttribute("class", ""); |
| 117 |
document.getElementById("test5").setAttribute("id", "foo"); |
| 118 |
toggleSelected(document.getElementById("cb")); |
| 119 |
|
| 120 |
document.getElementById("a").setAttribute("class", ""); |
| 121 |
|
| 122 |
regardTestInstance.scriptDone(); |
| 123 |
} |
| 124 |
]]></script> |
| 125 |
|
| 126 |
<g/> |
| 127 |
<text id="rm1" x="10" y="100" onclick="removeTargetEvt(evt)">Click me</text> |
| 128 |
<text x="100" y="100" class="button">Do I change?</text> |
| 129 |
|
| 130 |
<g/> |
| 131 |
<text id="in1" x="100" y="125" class="button" |
| 132 |
onclick="insertTextEvt(evt, '10', '125')">Click Me!</text> |
| 133 |
|
| 134 |
<g/> |
| 135 |
<text id="rm2" x="10" y="150" onclick="removeTargetEvt(evt)">Click me</text> |
| 136 |
<g id="test1"> |
| 137 |
<text id="ct" x="100" y="150">Child Text</text> |
| 138 |
</g> |
| 139 |
|
| 140 |
<g/> |
| 141 |
<g id="in2" onclick="insertTextEvt(evt, '10', '175')"> |
| 142 |
<text id="ct2" x="100" y="175">Click me</text> |
| 143 |
</g> |
| 144 |
|
| 145 |
<g id="test3" onclick="setAttributeEvt(evt, 'class', 'xxx')"> |
| 146 |
<text id="ct3" x="10" y="200">Click me</text> |
| 147 |
</g> |
| 148 |
|
| 149 |
<g id="test4" class="xxx" onclick="setAttributeEvt(evt, 'class', '')"> |
| 150 |
<text id="ct4" x="100" y="200">Click me</text> |
| 151 |
</g> |
| 152 |
|
| 153 |
<g id="test5" class="xxx" onclick="setAttributeEvt(evt, 'id', 'foo')"> |
| 154 |
<text id="ct5" x="200" y="200">Click me</text> |
| 155 |
</g> |
| 156 |
|
| 157 |
<g id="cb" class="checkbox" selected="true" transform="translate(10, 225)" |
| 158 |
onclick="toggleSelectedEvt(evt)"> |
| 159 |
<rect width="15" height="15" fill="white" stroke="black"/> |
| 160 |
<path d="M3,3 L12,12 M12,3 L3,12"/> |
| 161 |
</g> |
| 162 |
|
| 163 |
<g fill="white" stroke="black"> |
| 164 |
<rect id="a" class="a" x="10" y="275" width="100" height="50" |
| 165 |
onclick="setAttributeEvt(evt, 'class', '')"/> |
| 166 |
<rect id="b" class="b" x="150" y="275" width="100" height="50"/> |
| 167 |
<g/> |
| 168 |
<text x="25" y="300" pointer-events="none" |
| 169 |
style="fill: black; stroke: none">Click Me</text> |
| 170 |
</g> |
| 171 |
</svg> |