diff --git a/src/paper.js b/src/paper.js index e241cfc9..51c10259 100644 --- a/src/paper.js +++ b/src/paper.js @@ -111,10 +111,10 @@ var paper = function(window, undefined) { /*#*/ } /*#*/ if (__options.svg) { -/*#*/ include('svg/SVGNode.js'); -/*#*/ include('svg/SVGStyles.js'); -/*#*/ include('svg/SVGExport.js'); -/*#*/ include('svg/SVGImport.js'); +/*#*/ include('svg/SvgNode.js'); +/*#*/ include('svg/SvgStyles.js'); +/*#*/ include('svg/SvgExport.js'); +/*#*/ include('svg/SvgImport.js'); /*#*/ } /*#*/ if (__options.paperScript) { diff --git a/src/svg/SVGExport.js b/src/svg/SvgExport.js similarity index 92% rename from src/svg/SVGExport.js rename to src/svg/SvgExport.js index 57f28781..5d81af6f 100644 --- a/src/svg/SVGExport.js +++ b/src/svg/SvgExport.js @@ -61,16 +61,16 @@ new function() { function exportGroup(item, options) { var attrs = getTransform(item._matrix), children = item._children; - var node = SVGNode.create('g', attrs, formatter); + var node = SvgNode.create('g', attrs, formatter); for (var i = 0, l = children.length; i < l; i++) { var child = children[i]; var childNode = exportSVG(child, options); if (childNode) { if (child.isClipMask()) { - var clip = SVGNode.create('clipPath'); + var clip = SvgNode.create('clipPath'); clip.appendChild(childNode); setDefinition(child, clip, 'clip'); - SVGNode.set(node, { + SvgNode.set(node, { 'clip-path': 'url(#' + clip.id + ')' }); } else { @@ -92,7 +92,7 @@ new function() { attrs.height = size.height; attrs.href = options.embedImages === false && image && image.src || item.toDataURL(); - return SVGNode.create('image', attrs, formatter); + return SvgElement.create('image', attrs, formatter); } function exportPath(item, options) { @@ -129,7 +129,7 @@ new function() { type = 'path'; attrs.d = item.getPathData(null, options.precision); } - return SVGNode.create(type, attrs, formatter); + return SvgElement.create(type, attrs, formatter); } function exportShape(item) { @@ -156,7 +156,7 @@ new function() { attrs.ry = radius.height; } } - return SVGNode.create(type, attrs, formatter); + return SvgElement.create(type, attrs, formatter); } function exportCompoundPath(item, options) { @@ -164,7 +164,7 @@ new function() { var data = item.getPathData(null, options.precision); if (data) attrs.d = data; - return SVGNode.create('path', attrs, formatter); + return SvgElement.create('path', attrs, formatter); } function exportSymbolItem(item, options) { @@ -174,7 +174,7 @@ new function() { definitionItem = definition._item, bounds = definitionItem.getBounds(); if (!node) { - node = SVGNode.create('symbol', { + node = SvgElement.create('symbol', { viewBox: formatter.rectangle(bounds) }); node.appendChild(exportSVG(definitionItem, options)); @@ -186,7 +186,7 @@ new function() { attrs.width = bounds.width; attrs.height = bounds.height; attrs.overflow = 'visible'; - return SVGNode.create('use', attrs, formatter); + return SvgElement.create('use', attrs, formatter); } function exportGradient(color) { @@ -194,7 +194,7 @@ new function() { // we need to create a separate gradient object for each gradient, // even when they share the same gradient defintion. // http://www.svgopen.org/2011/papers/20-Separating_gradients_from_geometry/ - // TODO: Implement gradient merging in SVGImport + // TODO: Implement gradient merging in SvgImport var gradientNode = getDefinition(color, 'color'); if (!gradientNode) { var gradient = color.getGradient(), @@ -223,7 +223,7 @@ new function() { }; } attrs.gradientUnits = 'userSpaceOnUse'; - gradientNode = SVGNode.create((radial ? 'radial' : 'linear') + gradientNode = SvgElement.create((radial ? 'radial' : 'linear') + 'Gradient', attrs, formatter); var stops = gradient._stops; for (var i = 0, l = stops.length; i < l; i++) { @@ -239,7 +239,7 @@ new function() { if (alpha < 1) attrs['stop-opacity'] = alpha; gradientNode.appendChild( - SVGNode.create('stop', attrs, formatter)); + SvgElement.create('stop', attrs, formatter)); } setDefinition(color, gradientNode, 'color'); } @@ -247,7 +247,7 @@ new function() { } function exportText(item) { - var node = SVGNode.create('text', getTransform(item._matrix, true), + var node = SvgElement.create('text', getTransform(item._matrix, true), formatter); node.textContent = item._content; return node; @@ -272,7 +272,7 @@ new function() { if (item._name != null) attrs.id = item._name; - Base.each(SVGStyles, function(entry) { + Base.each(SvgStyles, function(entry) { // Get a given style only if it differs from the value on the parent // (A layer or group which can have style values in SVG). var get = entry.get, @@ -313,7 +313,7 @@ new function() { if (!item._visible) attrs.visibility = 'hidden'; - return SVGNode.set(node, attrs, formatter); + return SvgElement.set(node, attrs, formatter); } var definitions; @@ -349,10 +349,10 @@ new function() { // we actually have svgs. if (!defs) { if (!svg) { - svg = SVGNode.create('svg'); + svg = SvgElement.create('svg'); svg.appendChild(node); } - defs = svg.insertBefore( SVGNode.create('defs'), + defs = svg.insertBefore(SvgElement.create('defs'), svg.firstChild); } defs.appendChild(definitions.svgs[i]); @@ -401,21 +401,21 @@ new function() { var children = this._children, view = this.getView(), size = view.getViewSize(), - node = SVGNode.create('svg', { + node = SvgElement.create('svg', { x: 0, y: 0, width: size.width, height: size.height, version: '1.1', - xmlns: SVGNode.xmlns, - 'xmlns:xlink': SVGNode.xlink + xmlns: SvgElement.xmlns, + 'xmlns:xlink': SvgElement.xlink }, formatter), parent = node, matrix = view._matrix; // If the view has a transformation, wrap all layers in a group with // that transformation applied to. if (!matrix.isIdentity()) - parent = node.appendChild( SVGNode.create('g', + parent = node.appendChild(SvgElement.create('g', getTransform(matrix), formatter)); for (var i = 0, l = children.length; i < l; i++) parent.appendChild(exportSVG(children[i], options, true)); diff --git a/src/svg/SVGImport.js b/src/svg/SvgImport.js similarity index 99% rename from src/svg/SVGImport.js rename to src/svg/SvgImport.js index b43921c3..9a500d20 100644 --- a/src/svg/SVGImport.js +++ b/src/svg/SvgImport.js @@ -20,7 +20,7 @@ new function() { // index is option, and if passed, causes a lookup in a list. function getValue(node, name, isString, allowNull) { - var value = SVGNode.get(node, name); + var value = SvgElement.get(node, name); // Interpret value as number. Never return NaN, but 0 instead. // If the value is a sequence of numbers, parseFloat will // return the first occurring number, which is enough for now. @@ -186,7 +186,7 @@ new function() { // at the end. This parent node also helps fix a bug on IE. var body = document.body, // No need to inherit styles on Node.js - parent = !paper.agent.node && SVGNode.create('svg'); + parent = !paper.agent.node && SvgElement.create('svg'); if (parent) { body.appendChild(parent); // If no stroke-width is set, IE/Edge appears to have a @@ -381,9 +381,9 @@ new function() { // since transform needs to be applied after fill color, as transformations // can affect gradient fills. // Use Base.set() to control sequence of attributes and have all entries in - // SVGStyles (e.g. 'stroke') before the additional attributes below (e.g. + // SvgStyles (e.g. 'stroke') before the additional attributes below (e.g. // 'stroke-opacity'). See issue #694. - var attributes = Base.set(Base.each(SVGStyles, function(entry) { + var attributes = Base.set(Base.each(SvgStyles, function(entry) { this[entry.attribute] = function(item, value) { item[entry.set](convertValue(value, entry.type, entry.fromSVG)); // When applying gradient colors to shapes, we need to offset diff --git a/src/svg/SVGNode.js b/src/svg/SvgNode.js similarity index 95% rename from src/svg/SVGNode.js rename to src/svg/SvgNode.js index cef025bb..85ba7e43 100644 --- a/src/svg/SVGNode.js +++ b/src/svg/SvgNode.js @@ -11,11 +11,11 @@ */ /** - * @name SVGNode + * @name SvgElement * @namespace * @private */ -var SVGNode = new function() { +var SvgElement = new function() { // SVG related namespaces var svg = 'http://www.w3.org/2000/svg', xmlns = 'http://www.w3.org/2000/xmlns', @@ -53,7 +53,7 @@ var SVGNode = new function() { return node; } - return /** @lends SVGNode */{ + return /** @lends SvgElement */{ // Export namespaces svg: svg, xmlns: xmlns, diff --git a/src/svg/SVGStyles.js b/src/svg/SvgStyles.js similarity index 98% rename from src/svg/SVGStyles.js rename to src/svg/SvgStyles.js index 0fada395..af1827e2 100644 --- a/src/svg/SVGStyles.js +++ b/src/svg/SvgStyles.js @@ -10,7 +10,7 @@ * All rights reserved. */ -var SVGStyles = Base.each({ +var SvgStyles = Base.each({ // Fill fillColor: ['fill', 'color'], fillRule: ['fill-rule', 'string'], diff --git a/test/helpers.js b/test/helpers.js index c8007a9c..02a0d046 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -426,7 +426,7 @@ var getFunctionMessage = function(func) { var createSVG = function(str, attrs) { if (attrs) { - // Similar to SVGNode.create(): + // Similar to SvgElement.create(): var node = document.createElementNS('http://www.w3.org/2000/svg', str); for (var key in attrs) node.setAttribute(key, attrs[key]); diff --git a/test/tests/SVGExport.js b/test/tests/SvgExport.js similarity index 99% rename from test/tests/SVGExport.js rename to test/tests/SvgExport.js index 7de9a373..6a7acfbf 100644 --- a/test/tests/SVGExport.js +++ b/test/tests/SvgExport.js @@ -10,7 +10,7 @@ * All rights reserved. */ -QUnit.module('SVGExport'); +QUnit.module('SvgExport'); test('Export SVG line', function() { var attrs = { diff --git a/test/tests/SVGImport.js b/test/tests/SvgImport.js similarity index 99% rename from test/tests/SVGImport.js rename to test/tests/SvgImport.js index baf74773..5bb5b547 100644 --- a/test/tests/SVGImport.js +++ b/test/tests/SvgImport.js @@ -10,7 +10,7 @@ * All rights reserved. */ -QUnit.module('SVGImport'); +QUnit.module('SvgImport'); test('Import SVG line', function() { var attrs = { diff --git a/test/tests/load.js b/test/tests/load.js index 4c3f55c2..02964437 100644 --- a/test/tests/load.js +++ b/test/tests/load.js @@ -61,5 +61,5 @@ /*#*/ include('JSON.js'); -/*#*/ include('SVGImport.js'); -/*#*/ include('SVGExport.js'); +/*#*/ include('SvgImport.js'); +/*#*/ include('SvgExport.js');