From cd49e7d90e65af5fb956fe2ba8a4e8bb2d4402c8 Mon Sep 17 00:00:00 2001 From: Kienz Date: Fri, 31 May 2013 20:52:04 +0200 Subject: [PATCH] Update README Move getKlass into seperate function (fabric.util.getKlass) --- README.md | 4 ++-- src/util/misc.js | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index d88ffef9..6daa739a 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,8 @@ Using Fabric.js, you can create and populate objects on canvas; objects like sim ### Goals -- Unit tested (1570+ tests at the moment) -- Modular (~40 small "classes", modules, mixins) +- Unit tested (1660+ tests at the moment) +- Modular (~60 small "classes", modules, mixins) - Cross-browser - [Fast](https://github.com/kangax/fabric.js/wiki/Focus-on-speed) - Encapsulated in one object diff --git a/src/util/misc.js b/src/util/misc.js index 3d1faaa9..26288332 100644 --- a/src/util/misc.js +++ b/src/util/misc.js @@ -162,6 +162,16 @@ return _requestAnimFrame.apply(fabric.window, arguments); }; + /** + * Returns klass "Class" object of given fabric.Object type + * @memberOf fabric.util + * @param {String} type Type of object (eg. 'circle') + * @return {Object} klass "Class" + */ + function getKlass(type) { + return fabric[fabric.util.string.camelize(fabric.util.string.capitalize(type))]; + } + /** * Loads image element from given url and passes it to a callback * @memberOf fabric.util @@ -193,10 +203,6 @@ */ function enlivenObjects(objects, callback) { - function getKlass(type) { - return fabric[fabric.util.string.camelize(fabric.util.string.capitalize(type))]; - } - function onLoaded() { if (++numLoadedObjects === numTotalObjects) { if (callback) { @@ -213,7 +219,7 @@ if (!o.type) { return; } - var klass = getKlass(o.type); + var klass = fabric.util.getKlass(o.type); if (klass.async) { klass.fromObject(o, function (o, error) { if (!error) { @@ -449,6 +455,7 @@ fabric.util.falseFunction = falseFunction; fabric.util.animate = animate; fabric.util.requestAnimFrame = requestAnimFrame; + fabric.util.getKlass = getKlass; fabric.util.loadImage = loadImage; fabric.util.enlivenObjects = enlivenObjects; fabric.util.groupSVGElements = groupSVGElements;