Add asString parameter to exportSVG() methods.

This commit is contained in:
Jürg Lehni 2013-06-27 17:43:24 -07:00
parent f9925a71ea
commit 0bf19d02bd

View file

@ -466,7 +466,7 @@ new function() {
definitions.svgs[type + '-' + item._id] = node; definitions.svgs[type + '-' + item._id] = node;
} }
function exportDefinitions(node) { function exportDefinitions(node, asString) {
if (!definitions) if (!definitions)
return node; return node;
// We can only use svg nodes as defintion containers. Have the loop // We can only use svg nodes as defintion containers. Have the loop
@ -489,7 +489,7 @@ new function() {
} }
// Clear definitions at the end of export // Clear definitions at the end of export
definitions = null; definitions = null;
return svg; return asString ? new XMLSerializer().serializeToString(svg) : svg;
} }
function exportSVG(item) { function exportSVG(item) {
@ -509,8 +509,8 @@ new function() {
* *
* @return {SVGSVGElement} the item converted to an SVG node * @return {SVGSVGElement} the item converted to an SVG node
*/ */
exportSVG: function() { exportSVG: function(asString) {
return exportDefinitions(exportSVG(this)); return exportDefinitions(exportSVG(this), asString);
} }
}); });
@ -523,7 +523,7 @@ new function() {
* *
* @return {SVGSVGElement} the project converted to an SVG node * @return {SVGSVGElement} the project converted to an SVG node
*/ */
exportSVG: function() { exportSVG: function(asString) {
var layers = this.layers, var layers = this.layers,
size = this.view.getSize(), size = this.view.getSize(),
node = createElement('svg', { node = createElement('svg', {
@ -537,7 +537,7 @@ new function() {
}); });
for (var i = 0, l = layers.length; i < l; i++) for (var i = 0, l = layers.length; i < l; i++)
node.appendChild(exportSVG(layers[i])); node.appendChild(exportSVG(layers[i]));
return exportDefinitions(node); return exportDefinitions(node, asString);
} }
}); });
}; };