You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Gautam Ganguly <gg...@transunion.com> on 2004/02/11 17:48:43 UTC
[FIXED] RE: Embedded JavaScript file inside dynamic SVG isn't
working
hi Robby and Steve,
when i changed the href value from
<svg:script xlink:href="scripts/MoveCircle.js" />
to
<svg:script xlink:href="../scripts/MoveCircle.js" />
and that made it find the script file.
hope that helps you all and thanks once again.
regards
Gautam
>>> ggangul@transunion.com 02/11/04 09:14AM >>>
hi Robby ,
Thanks for that that worked.I ahd tried that logic earlier for
including the
script code inside the svg file itself but that didnot seem to
work.Now
when i looked your example here..i changed the script type from
"text/ecmascript" to "text/javascript",it started working.Thanks a lot
for that.Even though the svg gets a lot bigger given the fact that i
would put all the logic inside it,but i i will check into the fact as
to
why the sitemap can't find the javascript file from inside the
generated
svg.I will keep you all informed on that.
..and thanks to you too Steve,for your time and your help.
As always thanks to all those who always seem to somehow make a dumb
person like me, look a little bit intelligent in his own world!!!
regards,
Gautam
>>> robby.pelssers@vodafone.com 02/11/04 02:32AM >>>
Hi Steve and Gautam,
you can try the following to see if your code works at all.... I did
embed
the scripting and CSS in the stylesheet, because I wanted a quick
solution
and hadn't any knowledge of how to use the sitemap.
<xsl:stylesheet xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<svg xmlns:svg="http://www.w3.org/2000/svg" width="1000"
heigth="120">
<script language="JavaScript" type="text/javascript">
<![CDATA[
//////////////////////////////
// Declare Global Variables //
//////////////////////////////
var SVGDoc = null
// Make sure we're using the correct SVG object on the page
// - there can be more than 1 sourced element
//
function getObj(mouseEvent) {
SVGDoc = mouseEvent.getTarget().getOwnerDocument()
}
////////////////////////////////
// SVG Manipulation Functions //
////////////////////////////////
// change the fill color of an element
function elemColor(mouseEvent, elemName, value) {
// get the proper SVG object
getObj(mouseEvent)
// check for AI converted spaces
elemName = spaceTrans(elemName)
// get the element we want to change
var thisElem =
SVGDoc.getElementById(elemName).getStyle()
// perform the fill color change
thisElem.setProperty('fill', value)
}
// change the stroke width of an element
function elemStrokeWidth(mouseEvent, elemName, value) {
// get the proper SVG object
getObj(mouseEvent)
// check for AI converted spaces
elemName = spaceTrans(elemName)
// get the element we want to change
var thisElem =
SVGDoc.getElementById(elemName).getStyle()
// perform the stroke width change
thisElem.setProperty('stroke-width', value)
}
// change the stroke color of an element
function elemStrokeColor(mouseEvent, elemName, value) {
// get the proper SVG object
getObj(mouseEvent)
// check for AI converted spaces
elemName = spaceTrans(elemName)
// get the element we want to change
var thisElem =
SVGDoc.getElementById(elemName).getStyle()
// perform the stroke color change
thisElem.setProperty('stroke', value)
}
// show an element - note: these work with the display
property,
not visibility
function elemShow(mouseEvent, elemName) {
// get the proper SVG object
getObj(mouseEvent)
// check for AI converted spaces
elemName = spaceTrans(elemName)
// get the element we want to change
var thisElem =
SVGDoc.getElementById(elemName).getStyle()
// make the element visible
thisElem.setProperty('display', 'inline')
}
// hide an element - note: these work with the display
property,
not visibility
function elemHide(mouseEvent, elemName) {
// get the proper SVG object
getObj(mouseEvent)
// check for AI converted spaces
elemName = spaceTrans(elemName)
// get the element we want to change
var thisElem =
SVGDoc.getElementById(elemName).getStyle()
// hide the element
thisElem.setProperty('display', 'none')
}
// translate spaces into equivalent AI exported space string
function spaceTrans(stringIn) {
var result = ""
for (var i = 0; i < stringIn.length; i++) {
if (stringIn.charAt(i) == " ") {
result += "_x0020_"
} else {
result += stringIn.charAt(i)
}
}
return result
}
]]></script>
<defs>
<style type="text/css"><![CDATA[
path {
fill: none;
stroke: grey;
stroke-opacity:0.8;
stroke-width: 1;
}
line {
fill:none;
stroke:grey;
stroke-opacity:0.8;
stroke-width:1;
}
rect {
fill:none;
stroke:grey;
stroke-opacity:0.8;
stroke-width:1;
}
text {
font-size:10;
font-family:Verdana;
text-anchor:right;
fill:black;
display:none;
}
]]></style>
</defs>
<xsl:variable name="scalingfactor"><xsl:value-of
select="//scaling"/></xsl:variable>
<g transform="scale({$scalingfactor} {$scalingfactor})">
<g transform="translate(0,20)">
<xsl:apply-templates/>
</g>
</g>
</svg>
</xsl:template>
</xsl:stylesheet>
Kind regards,
Robby Pelssers
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org