From 629e16144a63cb9c920bbe1decd615d77e4c3c22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Mon, 11 Feb 2013 18:23:41 -0800 Subject: [PATCH] Define #_type property for both Symbol and Gradient and use it in SvgExport. --- src/color/Gradient.js | 2 ++ src/project/Symbol.js | 2 ++ src/svg/SvgExport.js | 9 +++++---- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/color/Gradient.js b/src/color/Gradient.js index 6c9b5117..3782b4d0 100644 --- a/src/color/Gradient.js +++ b/src/color/Gradient.js @@ -16,6 +16,8 @@ * @class The Gradient object. */ var Gradient = this.Gradient = Base.extend(/** @lends Gradient# */{ + _type: 'gradient', + // TODO: Should type here be called 'radial' and have it receive a // boolean value? /** diff --git a/src/project/Symbol.js b/src/project/Symbol.js index eb7cb1ff..139907c7 100644 --- a/src/project/Symbol.js +++ b/src/project/Symbol.js @@ -20,6 +20,8 @@ * to be updated with every transformation. */ var Symbol = this.Symbol = Base.extend(/** @lends Symbol# */{ + _type: 'symbol', + /** * Creates a Symbol item. * diff --git a/src/svg/SvgExport.js b/src/svg/SvgExport.js index b3a1568e..749bc3f2 100644 --- a/src/svg/SvgExport.js +++ b/src/svg/SvgExport.js @@ -364,7 +364,7 @@ new function() { viewBox: formatRectangle(bounds) }); symbolNode.appendChild(exportSvg(definition)); - setDefinition(symbol, symbolNode, 'symbol'); + setDefinition(symbol, symbolNode); } attrs.href = '#' + symbolNode.id; attrs.x += bounds.x; @@ -421,7 +421,7 @@ new function() { attrs['stop-opacity'] = color._alpha; gradientNode.appendChild(createElement('stop', attrs)); } - setDefinition(gradient, gradientNode, 'gradient'); + setDefinition(gradient, gradientNode); } return 'url(#' + gradientNode.id + ')'; } @@ -485,8 +485,9 @@ new function() { return definitions.svgs[item._id]; } - function setDefinition(item, node, type) { - var id = definitions.ids[type] = (definitions.ids[type] || 0) + 1; + function setDefinition(item, node) { + var type = item._type, + id = definitions.ids[type] = (definitions.ids[type] || 0) + 1; node.id = type + '-' + id; definitions.svgs[item._id] = node; }