| 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 a rect's x attribute in an 'onclick' event handler. --> |
| 25 |
<!-- --> |
| 26 |
<!-- @author [email protected] --> |
| 27 |
<!-- @version $Id$ --> |
| 28 |
<!-- ========================================================================= --> |
| 29 |
<?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?> |
| 30 |
<svg id="body" width="450" height="500" viewBox="0 0 450 500"> |
| 31 |
<title><rect> x modification in 'onclick'</title> |
| 32 |
|
| 33 |
<text x="50%" y="45" class="title"><rect> x modification in 'onclick'</text> |
| 34 |
|
| 35 |
<script type="text/ecmascript"> |
| 36 |
|
| 37 |
function moveToX(evt, target, val){ |
| 38 |
var r = evt.target; |
| 39 |
var doc = r.ownerDocument; |
| 40 |
var t = doc.getElementById(target); |
| 41 |
t.setAttribute('x', val); |
| 42 |
} |
| 43 |
|
| 44 |
</script> |
| 45 |
|
| 46 |
<g id="test-content" transform="translate(0,125)"> |
| 47 |
<g transform="translate(75,0)"> |
| 48 |
<text class="legend" x="75" y="70">Position A</text> |
| 49 |
|
| 50 |
<rect id="originalPlaceShadowBorder" x="32" y="77" width="86" height="46" style="fill:none; stroke:black" /> |
| 51 |
|
| 52 |
<g onclick="moveToX(evt, 'targetRect', '110')"> |
| 53 |
<circle cx="75" cy="100" r="10" style="fill:crimson;stroke:black;"/> |
| 54 |
<line x1="75" x2="75" y1="90" y2="110" style="stroke:black;fill:none" /> |
| 55 |
<line x1="65" x2="85" y1="100" y2="100" style="stroke:black;fill:none" /> |
| 56 |
</g> |
| 57 |
</g> |
| 58 |
|
| 59 |
<g transform="translate(225,0)"> |
| 60 |
<text class="legend" x="75" y="70">Position B</text> |
| 61 |
|
| 62 |
<rect id="targetPlaceShadowBorder" x="32" y="77" width="86" height="46" style="fill:none; stroke:black" /> |
| 63 |
|
| 64 |
<g onclick="moveToX(evt, 'targetRect', '260')"> |
| 65 |
<circle cx="75" cy="100" r="10" style="fill:crimson;stroke:black;"/> |
| 66 |
<line x1="75" x2="75" y1="90" y2="110" style="stroke:black;fill:none" /> |
| 67 |
<line x1="65" x2="85" y1="100" y2="100" style="stroke:black;fill:none" /> |
| 68 |
</g> |
| 69 |
</g> |
| 70 |
|
| 71 |
<rect id="targetRect" x="110" y="80" width="80" height="40" style="fill:crimson;" /> |
| 72 |
|
| 73 |
<text class="legend" x="225" y="145">Click on the Position A or Position B</text> |
| 74 |
<text class="legend" x="225" y="160">target (crimson circle) to move the rectangle</text> |
| 75 |
<text class="legend" x="225" y="175">to a new position</text> |
| 76 |
</g> |
| 77 |
</svg> |