Preparing fabric to run on node.js

This commit is contained in:
kangax 2011-08-05 19:00:26 -04:00
parent 7e5e9e3ea6
commit 35ad4bf6e3
21 changed files with 88 additions and 79 deletions

View file

@ -1,3 +1,7 @@
/*! Fabric.js Copyright 2008-2011, Bitsonnet (Juriy Zaytsev, Maxim Chernyak) */
var fabric = fabric || { version: "0.4.13" };
var fabric = fabric || { version: "0.4.13" };
if (typeof exports != 'undefined') {
exports.fabric = fabric;
}

79
dist/all.js vendored
View file

@ -2,18 +2,9 @@
var fabric = fabric || { version: "0.4.13" };
(function(){
var view = document.defaultView;
if (view && view.getComputedStyle) {
var style = view.getComputedStyle(document.documentElement, '');
if (style === null) {
view.getComputedStyle = function getComputedStyle(element, pseudoElement) {
return element.style;
}
}
}
})();
if (typeof exports != 'undefined') {
exports.fabric = fabric;
}
/*!
* Copyright (c) 2009 Simo Kinnunen.
@ -702,7 +693,7 @@ Cufon.registerEngine('canvas', (function() {
}
var wStyle = wrapper.style;
var cStyle = canvas.style;
var cStyle = canvas.style || { };
var height = size.convert(viewBox.height - expandTop + expandBottom);
var roundedHeight = Math.ceil(height);
@ -1114,6 +1105,10 @@ Cufon.registerEngine('vml', (function() {
};
})());
if (typeof exports != 'undefined') {
exports.Cufon = Cufon;
}
/*
http://www.JSON.org/json2.js
2010-03-20
@ -3255,7 +3250,7 @@ fabric.util.getElementOffset = getElementOffset;
getCSSRules: getCSSRules
});
})(this);
})(typeof exports != 'undefined' ? exports : this);
(function() {
function getColorStopFromStyle(el) {
@ -3624,7 +3619,7 @@ fabric.util.getElementOffset = getElementOffset;
}
};
})(this);
})(typeof exports != 'undefined' ? exports : this);
(function(global) {
@ -3774,7 +3769,7 @@ fabric.util.getElementOffset = getElementOffset;
return result;
};
})(this);
})(typeof exports != 'undefined' ? exports : this);
(function(global) {
"use strict";
@ -4054,7 +4049,8 @@ fabric.util.getElementOffset = getElementOffset;
oColor.setSource(source);
return oColor;
};
})(this);
})(typeof exports != 'undefined' ? exports : this);
(function (global) {
@ -4065,10 +4061,7 @@ fabric.util.getElementOffset = getElementOffset;
return;
}
var window = global.window,
document = window.document,
extend = fabric.util.object.extend,
var extend = fabric.util.object.extend,
capitalize = fabric.util.string.capitalize,
camelize = fabric.util.string.camelize,
getPointer = fabric.util.getPointer,
@ -4375,6 +4368,9 @@ fabric.util.getElementOffset = getElementOffset;
*/
_createCanvasElement: function() {
var element = document.createElement('canvas');
if (!element.style) {
element.style = { };
}
if (!element) {
throw CANVAS_INIT_ERROR;
}
@ -5960,7 +5956,7 @@ fabric.util.getElementOffset = getElementOffset;
*/
fabric.Element = fabric.Canvas;
})(this);
})(typeof exports != 'undefined' ? exports : this);
fabric.util.object.extend(fabric.Canvas.prototype, {
/**
@ -7595,7 +7591,8 @@ fabric.util.object.extend(fabric.Canvas.prototype, {
})(propName);
}
}
})(this);
})(typeof exports != 'undefined' ? exports : this);
(function(global) {
@ -7726,7 +7723,8 @@ fabric.util.object.extend(fabric.Canvas.prototype, {
var points = [object.x1, object.y1, object.x2, object.y2];
return new fabric.Line(points, object);
};
})(this);
})(typeof exports != 'undefined' ? exports : this);
(function(global) {
@ -7875,7 +7873,7 @@ fabric.util.object.extend(fabric.Canvas.prototype, {
return new fabric.Circle(object);
};
})(this);
})(typeof exports != 'undefined' ? exports : this);
(function(global) {
"use strict";
@ -7957,7 +7955,8 @@ fabric.util.object.extend(fabric.Canvas.prototype, {
fabric.Triangle.fromObject = function(object) {
return new fabric.Triangle(object);
};
})(this);
})(typeof exports != 'undefined' ? exports : this);
(function(global){
@ -8091,8 +8090,9 @@ fabric.util.object.extend(fabric.Canvas.prototype, {
*/
fabric.Ellipse.fromObject = function(object) {
return new fabric.Ellipse(object);
}
})(this);
};
})(typeof exports != 'undefined' ? exports : this);
(function(global) {
@ -8269,7 +8269,8 @@ fabric.util.object.extend(fabric.Canvas.prototype, {
fabric.Rect.fromObject = function(object) {
return new fabric.Rect(object);
};
})(this);
})(typeof exports != 'undefined' ? exports : this);
(function(global) {
@ -8399,7 +8400,7 @@ fabric.util.object.extend(fabric.Canvas.prototype, {
return new fabric.Polyline(points, object);
};
})(this);
})(typeof exports != 'undefined' ? exports : this);
(function(global) {
@ -8545,8 +8546,9 @@ fabric.util.object.extend(fabric.Canvas.prototype, {
*/
fabric.Polygon.fromObject = function(object) {
return new fabric.Polygon(object.points, object);
}
})(this);
};
})(typeof exports != 'undefined' ? exports : this);
(function(global) {
@ -9204,7 +9206,8 @@ fabric.util.object.extend(fabric.Canvas.prototype, {
var parsedAttributes = fabric.parseAttributes(element, fabric.Path.ATTRIBUTE_NAMES);
return new fabric.Path(parsedAttributes.d, extend(parsedAttributes, options));
};
})(this);
})(typeof exports != 'undefined' ? exports : this);
(function(global) {
@ -9434,7 +9437,8 @@ fabric.util.object.extend(fabric.Canvas.prototype, {
var paths = instantiatePaths(object.paths);
return new fabric.PathGroup(paths, object);
};
})(this);
})(typeof exports != 'undefined' ? exports : this);
(function(global){
@ -9891,7 +9895,7 @@ fabric.util.object.extend(fabric.Canvas.prototype, {
return new fabric.Group(object.objects, object);
};
})(this);
})(typeof exports != 'undefined' ? exports : this);
(function(global) {
@ -10227,7 +10231,8 @@ fabric.util.object.extend(fabric.Canvas.prototype, {
*/
fabric.Text.fromElement = function(element) {
};
})(this);
})(typeof exports != 'undefined' ? exports : this);
(function(global) {
@ -10656,4 +10661,4 @@ fabric.util.object.extend(fabric.Canvas.prototype, {
fabric.Image.fromElement.async = true;
})(this);
})(typeof exports != 'undefined' ? exports : this);

View file

@ -1,17 +1,3 @@
(function(){
var view = document.defaultView;
if (view && view.getComputedStyle) {
var style = view.getComputedStyle(document.documentElement, '');
// Jaxer does not implement `getComputedStyle` and always returns `null`
if (style === null) {
view.getComputedStyle = function getComputedStyle(element, pseudoElement) {
return element.style;
}
}
}
})();
/*!
* Copyright (c) 2009 Simo Kinnunen.
* Licensed under the MIT license.
@ -725,7 +711,7 @@ Cufon.registerEngine('canvas', (function() {
}
var wStyle = wrapper.style;
var cStyle = canvas.style;
var cStyle = canvas.style || { };
var height = size.convert(viewBox.height - expandTop + expandBottom);
var roundedHeight = Math.ceil(height);
@ -1154,4 +1140,8 @@ Cufon.registerEngine('vml', (function() {
};
})());
})());
if (typeof exports != 'undefined') {
exports.Cufon = Cufon;
}

View file

@ -7,11 +7,8 @@
return;
}
var window = global.window,
document = window.document,
// aliases for faster resolution
extend = fabric.util.object.extend,
// aliases for faster resolution
var extend = fabric.util.object.extend,
capitalize = fabric.util.string.capitalize,
camelize = fabric.util.string.camelize,
getPointer = fabric.util.getPointer,
@ -318,6 +315,9 @@
*/
_createCanvasElement: function() {
var element = document.createElement('canvas');
if (!element.style) {
element.style = { };
}
if (!element) {
throw CANVAS_INIT_ERROR;
}
@ -1964,4 +1964,4 @@
*/
fabric.Element = fabric.Canvas;
})(this);
})(typeof exports != 'undefined' ? exports : this);

View file

@ -148,4 +148,4 @@
return new fabric.Circle(object);
};
})(this);
})(typeof exports != 'undefined' ? exports : this);

View file

@ -277,4 +277,5 @@
oColor.setSource(source);
return oColor;
};
})(this);
})(typeof exports != 'undefined' ? exports : this);

View file

@ -133,5 +133,6 @@
*/
fabric.Ellipse.fromObject = function(object) {
return new fabric.Ellipse(object);
}
})(this);
};
})(typeof exports != 'undefined' ? exports : this);

View file

@ -458,4 +458,4 @@
return new fabric.Group(object.objects, object);
};
})(this);
})(typeof exports != 'undefined' ? exports : this);

View file

@ -430,4 +430,4 @@
fabric.Image.fromElement.async = true;
})(this);
})(typeof exports != 'undefined' ? exports : this);

View file

@ -148,4 +148,4 @@
return result;
};
})(this);
})(typeof exports != 'undefined' ? exports : this);

View file

@ -133,4 +133,5 @@
var points = [object.x1, object.y1, object.x2, object.y2];
return new fabric.Line(points, object);
};
})(this);
})(typeof exports != 'undefined' ? exports : this);

View file

@ -1316,4 +1316,5 @@
})(propName);
}
}
})(this);
})(typeof exports != 'undefined' ? exports : this);

View file

@ -521,4 +521,4 @@
getCSSRules: getCSSRules
});
})(this);
})(typeof exports != 'undefined' ? exports : this);

View file

@ -670,4 +670,5 @@
var parsedAttributes = fabric.parseAttributes(element, fabric.Path.ATTRIBUTE_NAMES);
return new fabric.Path(parsedAttributes.d, extend(parsedAttributes, options));
};
})(this);
})(typeof exports != 'undefined' ? exports : this);

View file

@ -243,4 +243,5 @@
var paths = instantiatePaths(object.paths);
return new fabric.PathGroup(paths, object);
};
})(this);
})(typeof exports != 'undefined' ? exports : this);

View file

@ -193,4 +193,4 @@
}
};
})(this);
})(typeof exports != 'undefined' ? exports : this);

View file

@ -145,5 +145,6 @@
*/
fabric.Polygon.fromObject = function(object) {
return new fabric.Polygon(object.points, object);
}
})(this);
};
})(typeof exports != 'undefined' ? exports : this);

View file

@ -129,4 +129,4 @@
return new fabric.Polyline(points, object);
};
})(this);
})(typeof exports != 'undefined' ? exports : this);

View file

@ -177,4 +177,5 @@
fabric.Rect.fromObject = function(object) {
return new fabric.Rect(object);
};
})(this);
})(typeof exports != 'undefined' ? exports : this);

View file

@ -351,4 +351,5 @@
fabric.Text.fromElement = function(element) {
// TODO (kangax): implement this
};
})(this);
})(typeof exports != 'undefined' ? exports : this);

View file

@ -79,4 +79,5 @@
fabric.Triangle.fromObject = function(object) {
return new fabric.Triangle(object);
};
})(this);
})(typeof exports != 'undefined' ? exports : this);