From b53209437f164f476a3788c991149e6d7eab0694 Mon Sep 17 00:00:00 2001 From: kangax Date: Thu, 30 May 2013 21:53:49 +0200 Subject: [PATCH] Move shape classes (circle, line, rect, path, etc.) to /shapes dir --- src/{ => shapes}/circle.class.js | 2 ++ src/{ => shapes}/ellipse.class.js | 2 ++ src/{ => shapes}/group.class.js | 0 src/{ => shapes}/image.class.js | 2 ++ src/{ => shapes}/line.class.js | 2 ++ src/{ => shapes}/object.class.js | 2 ++ src/{ => shapes}/path.class.js | 2 ++ src/{ => shapes}/path_group.class.js | 0 src/{ => shapes}/polygon.class.js | 2 ++ src/{ => shapes}/polyline.class.js | 2 ++ src/{ => shapes}/rect.class.js | 2 ++ src/{ => shapes}/text.class.js | 22 ++++++++++++---------- src/{ => shapes}/triangle.class.js | 0 13 files changed, 30 insertions(+), 10 deletions(-) rename src/{ => shapes}/circle.class.js (99%) rename src/{ => shapes}/ellipse.class.js (99%) rename src/{ => shapes}/group.class.js (100%) rename src/{ => shapes}/image.class.js (99%) rename src/{ => shapes}/line.class.js (99%) rename src/{ => shapes}/object.class.js (99%) rename src/{ => shapes}/path.class.js (99%) rename src/{ => shapes}/path_group.class.js (100%) rename src/{ => shapes}/polygon.class.js (99%) rename src/{ => shapes}/polyline.class.js (99%) rename src/{ => shapes}/rect.class.js (99%) rename src/{ => shapes}/text.class.js (99%) rename src/{ => shapes}/triangle.class.js (100%) diff --git a/src/circle.class.js b/src/shapes/circle.class.js similarity index 99% rename from src/circle.class.js rename to src/shapes/circle.class.js index dea34385..99a4a40c 100644 --- a/src/circle.class.js +++ b/src/shapes/circle.class.js @@ -128,6 +128,7 @@ } }); + /* _FROM_SVG_START_ */ /** * List of attribute names to account for when parsing SVG element (used by {@link fabric.Circle.fromElement}) * @static @@ -169,6 +170,7 @@ function isValidRadius(attributes) { return (('radius' in attributes) && (attributes.radius > 0)); } + /* _FROM_SVG_END_ */ /** * Returns {@link fabric.Circle} instance from an object representation diff --git a/src/ellipse.class.js b/src/shapes/ellipse.class.js similarity index 99% rename from src/ellipse.class.js rename to src/shapes/ellipse.class.js index 7f4cfa07..0054cb17 100644 --- a/src/ellipse.class.js +++ b/src/shapes/ellipse.class.js @@ -136,6 +136,7 @@ } }); + /* _FROM_SVG_START_ */ /** * List of attribute names to account for when parsing SVG element (used by {@link fabric.Ellipse.fromElement}) * @static @@ -171,6 +172,7 @@ return ellipse; }; + /* _FROM_SVG_END_ */ /** * Returns {@link fabric.Ellipse} instance from an object representation diff --git a/src/group.class.js b/src/shapes/group.class.js similarity index 100% rename from src/group.class.js rename to src/shapes/group.class.js diff --git a/src/image.class.js b/src/shapes/image.class.js similarity index 99% rename from src/image.class.js rename to src/shapes/image.class.js index 17dc16d0..48ce6ef4 100644 --- a/src/image.class.js +++ b/src/shapes/image.class.js @@ -446,6 +446,7 @@ }); }; + /* _FROM_SVG_START_ */ /** * List of attribute names to account for when parsing SVG element (used by {@link fabric.Image.fromElement}) * @static @@ -467,6 +468,7 @@ fabric.Image.fromURL(parsedAttributes['xlink:href'], callback, extend((options ? fabric.util.object.clone(options) : { }), parsedAttributes)); }; + /* _FROM_SVG_END_ */ /** * Indicates that instances of this type are async diff --git a/src/line.class.js b/src/shapes/line.class.js similarity index 99% rename from src/line.class.js rename to src/shapes/line.class.js index 6a6ede29..e6ccf340 100644 --- a/src/line.class.js +++ b/src/shapes/line.class.js @@ -178,6 +178,7 @@ } }); + /* _FROM_SVG_START_ */ /** * List of attribute names to account for when parsing SVG element (used by {@link fabric.Line.fromElement}) * @static @@ -202,6 +203,7 @@ ]; return new fabric.Line(points, extend(parsedAttributes, options)); }; + /* _FROM_SVG_END_ */ /** * Returns fabric.Line instance from an object representation diff --git a/src/object.class.js b/src/shapes/object.class.js similarity index 99% rename from src/object.class.js rename to src/shapes/object.class.js index 1e77c2b4..205ee905 100644 --- a/src/object.class.js +++ b/src/shapes/object.class.js @@ -486,6 +486,7 @@ return this.toObject(propertiesToInclude); }, + /* _TO_SVG_START_ */ /** * Returns styles-string for svg-export * @return {String} @@ -537,6 +538,7 @@ return [ translatePart, anglePart, scalePart, flipXPart, flipYPart ].join(''); }, + /* _TO_SVG_END_ */ /** * @private diff --git a/src/path.class.js b/src/shapes/path.class.js similarity index 99% rename from src/path.class.js rename to src/shapes/path.class.js index 312582e9..e3a30537 100644 --- a/src/path.class.js +++ b/src/shapes/path.class.js @@ -793,6 +793,7 @@ return new fabric.Path(object.path, object); }; + /* _FROM_SVG_START_ */ /** * List of attribute names to account for when parsing SVG element (used by `fabric.Path.fromElement`) * @static @@ -811,5 +812,6 @@ var parsedAttributes = fabric.parseAttributes(element, fabric.Path.ATTRIBUTE_NAMES); return new fabric.Path(parsedAttributes.d, extend(parsedAttributes, options)); }; + /* _FROM_SVG_END_ */ })(typeof exports !== 'undefined' ? exports : this); diff --git a/src/path_group.class.js b/src/shapes/path_group.class.js similarity index 100% rename from src/path_group.class.js rename to src/shapes/path_group.class.js diff --git a/src/polygon.class.js b/src/shapes/polygon.class.js similarity index 99% rename from src/polygon.class.js rename to src/shapes/polygon.class.js index 85ac8f18..501528cf 100644 --- a/src/polygon.class.js +++ b/src/shapes/polygon.class.js @@ -158,6 +158,7 @@ } }); + /* _FROM_SVG_START_ */ /** * List of attribute names to account for when parsing SVG element (used by `fabric.Polygon.fromElement`) * @static @@ -194,6 +195,7 @@ return new fabric.Polygon(points, extend(parsedAttributes, options), true); }; + /* _FROM_SVG_END_ */ /** * Returns fabric.Polygon instance from an object representation diff --git a/src/polyline.class.js b/src/shapes/polyline.class.js similarity index 99% rename from src/polyline.class.js rename to src/shapes/polyline.class.js index c85e29f7..6a42547b 100644 --- a/src/polyline.class.js +++ b/src/shapes/polyline.class.js @@ -129,6 +129,7 @@ } }); + /* _FROM_SVG_START_ */ /** * List of attribute names to account for when parsing SVG element (used by {@link fabric.Polyline.fromElement}) * @static @@ -165,6 +166,7 @@ return new fabric.Polyline(points, fabric.util.object.extend(parsedAttributes, options), true); }; + /* _FROM_SVG_END_ */ /** * Returns fabric.Polyline instance from an object representation diff --git a/src/rect.class.js b/src/shapes/rect.class.js similarity index 99% rename from src/rect.class.js rename to src/shapes/rect.class.js index ee52ff3f..2290402f 100644 --- a/src/rect.class.js +++ b/src/shapes/rect.class.js @@ -209,6 +209,7 @@ } }); + /* _FROM_SVG_START_ */ /** * List of attribute names to account for when parsing SVG element (used by `fabric.Rect.fromElement`) * @static @@ -244,6 +245,7 @@ return rect; }; + /* _FROM_SVG_END_ */ /** * Returns {@link fabric.Rect} instance from an object representation diff --git a/src/text.class.js b/src/shapes/text.class.js similarity index 99% rename from src/text.class.js rename to src/shapes/text.class.js index 066510b5..9677e4fa 100644 --- a/src/text.class.js +++ b/src/shapes/text.class.js @@ -938,6 +938,7 @@ } }); + /* _FROM_SVG_START_ */ /** * List of attribute names to account for when parsing SVG element (used by {@link fabric.Text.fromElement}) * @static @@ -945,16 +946,6 @@ fabric.Text.ATTRIBUTE_NAMES = fabric.SHARED_ATTRIBUTES.concat( 'x y font-family font-style font-weight font-size text-decoration'.split(' ')); - /** - * Returns fabric.Text instance from an object representation - * @static - * @param object {Object} object Object to create an instance from - * @return {fabric.Text} Instance of fabric.Text - */ - fabric.Text.fromObject = function(object) { - return new fabric.Text(object.text, clone(object)); - }; - /** * Returns fabric.Text instance from an SVG element (not yet implemented) * @static @@ -986,6 +977,17 @@ return text; }; + /* _FROM_SVG_END_ */ + + /** + * Returns fabric.Text instance from an object representation + * @static + * @param object {Object} object Object to create an instance from + * @return {fabric.Text} Instance of fabric.Text + */ + fabric.Text.fromObject = function(object) { + return new fabric.Text(object.text, clone(object)); + }; fabric.util.createAccessors(fabric.Text); diff --git a/src/triangle.class.js b/src/shapes/triangle.class.js similarity index 100% rename from src/triangle.class.js rename to src/shapes/triangle.class.js