Add fully qualified function calls, shuffle a couple tiny functions into svgutils.js, add an empty coords.js module for later

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@2390 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
Jeff Schiller
2013-02-14 15:19:46 +00:00
parent e150132453
commit a779a74aa9
7 changed files with 262 additions and 193 deletions

View File

@@ -308,20 +308,23 @@ svgedit.utilities.setHref = function(elem, val) {
}
// Function: findDefs
// Parameters:
// svgElement - The <svg> element.
//
// Returns:
// The document's <defs> element, create it first if necessary
svgedit.utilities.findDefs = function(svgElement) {
svgedit.utilities.findDefs = function() {
var svgElement = editorContext_.getSVGContent().documentElement;
var defs = svgElement.getElementsByTagNameNS(SVGNS, "defs");
if (defs.length > 0) {
defs = defs[0];
}
else {
// first child is a comment, so call nextSibling
defs = svgElement.insertBefore( svgElement.ownerDocument.createElementNS(SVGNS, "defs" ), svgElement.firstChild.nextSibling);
defs = svgElement.ownerDocument.createElementNS(SVGNS, "defs");
if (svgElement.firstChild) {
// first child is a comment, so call nextSibling
svgElement.insertBefore(defs, svgElement.firstChild.nextSibling);
} else {
svgElement.appendChild(defs);
}
}
return defs;
};
@@ -558,6 +561,15 @@ svgedit.utilities.getRotationAngle = function(elem, to_rad) {
return 0.0;
};
// Function getRefElem
// Get the reference element associated with the given attribute value
//
// Parameters:
// attrVal - The attribute value as a string
svgedit.utilities.getRefElem = this.getRefElem = function(attrVal) {
return svgedit.utilities.getElem(svgedit.utilities.getUrlFromAttr(attrVal).substr(1));
};
// Function: getElem
// Get a DOM element by ID within the SVG root element.
//