Difference between revisions of "Canyon Map/Test"
From B.E.R.T. Wiki
| (20 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
| + | Funky image testing first a reference to a SVG file, with included javascript. | ||
| + | |||
| + | |||
| + | [[Image:Svg_test.svg]] | ||
| + | |||
| + | |||
| + | then in-line HTML, which is behaving oddly. it stops displaying once we're in groups. but I think there is more going on than just that. | ||
<html> | <html> | ||
| − | + | <body> | |
| − | <script> | + | <p>be sure to look at the source for this page</p> |
| + | <object> | ||
| + | <svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg" onload="Init(evt)"> | ||
| + | <title>Hiding and Showing Elements</title> | ||
| + | |||
| + | <desc> | ||
| + | A demonstration of the differences in approach to hiding an element or group of elements in SVG, using the display, visibility, and opacity style properties. | ||
| + | Written by Doug Schepers [[email protected]], September 2003. | ||
| + | </desc> | ||
| + | |||
| + | <script type="text/ecmascript"><![CDATA[ | ||
| + | var SVGDocument = null; | ||
| + | var SVGRoot = null; | ||
| + | |||
| + | function Init(evt) | ||
| + | { | ||
| + | SVGDocument = evt.target.ownerDocument; | ||
| + | SVGRoot = SVGDocument.documentElement; | ||
| + | |||
| + | } | ||
| + | |||
| + | function ToggleDisplay(evt, targetId) | ||
| + | { | ||
| + | var newTarget = evt.target; | ||
| + | if (targetId) | ||
| + | { | ||
| + | newTarget = SVGDocument.getElementById(targetId); | ||
| + | } | ||
| + | var newValue = newTarget.getAttributeNS(null, 'display') | ||
| + | |||
| + | if ('none' != newValue) | ||
| + | { | ||
| + | newValue = 'none'; | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | newValue = 'inline'; | ||
| + | } | ||
| + | newTarget.setAttributeNS(null, 'display', newValue); | ||
| + | |||
| + | if (targetId) | ||
| + | { | ||
| + | SVGDocument.getElementById(targetId + 'Exception').setAttributeNS(null, 'display', 'inline'); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | function ToggleVisibilty(evt, targetId) | ||
| + | { | ||
| + | var newTarget = evt.target; | ||
| + | if (targetId) | ||
| + | { | ||
| + | newTarget = SVGDocument.getElementById(targetId); | ||
| + | } | ||
| + | var newValue = newTarget.getAttributeNS(null, 'visibility') | ||
| + | |||
| + | if ('hidden' != newValue) | ||
| + | { | ||
| + | newValue = 'hidden'; | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | newValue = 'visible'; | ||
| + | } | ||
| + | newTarget.setAttributeNS(null, 'visibility', newValue); | ||
| + | |||
| + | if (targetId) | ||
| + | { | ||
| + | SVGDocument.getElementById(targetId + 'Exception').setAttributeNS(null, 'visibility', 'visible'); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | function ToggleOpacity(evt, targetId) | ||
| + | { | ||
| + | var newTarget = evt.target; | ||
| + | if (targetId) | ||
| + | { | ||
| + | newTarget = SVGDocument.getElementById(targetId); | ||
| + | } | ||
| + | var newValue = newTarget.getAttributeNS(null, 'opacity') | ||
| + | |||
| + | if ('0' != newValue) | ||
| + | { | ||
| + | newValue = '0'; | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | newValue = '1'; | ||
| + | } | ||
| + | newTarget.setAttributeNS(null, 'opacity', newValue); | ||
| + | |||
| + | if (targetId) | ||
| + | { | ||
| + | SVGDocument.getElementById(targetId + 'Exception').setAttributeNS(null, 'opacity', '1'); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | ]]></script> | ||
| + | |||
| + | |||
| + | |||
| + | <circle cx="100" cy="25" r="20" fill="orange" onclick="ToggleDisplay(evt)" display="inline"/> | ||
| + | <text x="100" y="60" font-size="15px" text-anchor="middle">Display</text> | ||
| + | |||
| + | <circle cx="160" cy="25" r="20" fill="red" onclick="ToggleVisibilty(evt)" visibility="visible"/> | ||
| + | <text x="160" y="60" font-size="15px" text-anchor="middle">Visibilty</text> | ||
| + | |||
| + | <circle cx="220" cy="25" r="20" fill="blue" onclick="ToggleOpacity(evt)" opacity="1"/> | ||
| + | <text x="220" y="60" font-size="15px" text-anchor="middle">Opacity</text> | ||
| + | |||
| + | <!-- for some reason none of this displays --> | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | ||
| − | + | <p>more below here, but invisible - except for text blocks. weird. something about the groups?</p> | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | <g id="DisplayGroup" onclick='ToggleDisplay(evt, "DisplayGroup")' display="inline"> | |
| + | <circle cx="100" cy="335" r="20" fill="orange"/> | ||
| + | <circle id="DisplayGroupException" cx="100" cy="335" r="5" fill="lime" display="inline"/> | ||
| + | </g> | ||
| + | <text x="100" y="370" font-size="15px" text-anchor="middle">Display</text> | ||
| − | + | <g id="VisibiltyGroup" onclick='ToggleVisibilty(evt, "VisibiltyGroup")' visibility="visible"> | |
| − | + | <circle cx="160" cy="335" r="20" fill="red"/> | |
| − | + | <circle id="VisibiltyGroupException" cx="160" cy="335" r="5" fill="lime" visibilty="visible" /> | |
| − | </ | + | </g> |
| − | + | <text x="160" y="370" font-size="15px" text-anchor="middle">Visibilty</text> | |
| − | < | + | <g id="OpacityGroup" onclick='ToggleOpacity(evt, "OpacityGroup")' opacity="1"> |
| − | + | <circle cx="220" cy="335" r="20" fill="blue"/> | |
| − | + | <circle id="OpacityGroupException" cx="220" cy="335" r="5" fill="lime" opacity="1"/> | |
| − | </ | + | </g> |
| + | <text x="220" y="370" font-size="15px" text-anchor="middle">Opacity</text> | ||
| − | + | </svg> | |
| + | </object> | ||
| + | </body> | ||
</html> | </html> | ||