diff --git a/HEADER.js b/HEADER.js index 7cbeca78..58f2a593 100644 --- a/HEADER.js +++ b/HEADER.js @@ -1,3 +1,7 @@ /*! Fabric.js Copyright 2008-2011, Bitsonnet (Juriy Zaytsev, Maxim Chernyak) */ -var fabric = fabric || { version: "0.4.13" }; \ No newline at end of file +var fabric = fabric || { version: "0.4.13" }; + +if (typeof exports != 'undefined') { + exports.fabric = fabric; +} \ No newline at end of file diff --git a/dist/all.js b/dist/all.js index 41b02006..485c22d2 100644 --- a/dist/all.js +++ b/dist/all.js @@ -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); diff --git a/lib/cufon.js b/lib/cufon.js index 7dccb390..fe80b03d 100644 --- a/lib/cufon.js +++ b/lib/cufon.js @@ -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() { }; -})()); \ No newline at end of file +})()); + +if (typeof exports != 'undefined') { + exports.Cufon = Cufon; +} \ No newline at end of file diff --git a/src/canvas.class.js b/src/canvas.class.js index 56fa7348..884aaba0 100644 --- a/src/canvas.class.js +++ b/src/canvas.class.js @@ -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); \ No newline at end of file +})(typeof exports != 'undefined' ? exports : this); \ No newline at end of file diff --git a/src/circle.class.js b/src/circle.class.js index c5c22b13..72f5ad6e 100644 --- a/src/circle.class.js +++ b/src/circle.class.js @@ -148,4 +148,4 @@ return new fabric.Circle(object); }; -})(this); \ No newline at end of file +})(typeof exports != 'undefined' ? exports : this); \ No newline at end of file diff --git a/src/color.class.js b/src/color.class.js index cb2cff65..0b390492 100644 --- a/src/color.class.js +++ b/src/color.class.js @@ -277,4 +277,5 @@ oColor.setSource(source); return oColor; }; -})(this); \ No newline at end of file + +})(typeof exports != 'undefined' ? exports : this); \ No newline at end of file diff --git a/src/ellipse.class.js b/src/ellipse.class.js index f942c7be..935d5a29 100644 --- a/src/ellipse.class.js +++ b/src/ellipse.class.js @@ -133,5 +133,6 @@ */ fabric.Ellipse.fromObject = function(object) { return new fabric.Ellipse(object); - } -})(this); \ No newline at end of file + }; + +})(typeof exports != 'undefined' ? exports : this); \ No newline at end of file diff --git a/src/group.class.js b/src/group.class.js index f66827cd..a269e80d 100644 --- a/src/group.class.js +++ b/src/group.class.js @@ -458,4 +458,4 @@ return new fabric.Group(object.objects, object); }; -})(this); \ No newline at end of file +})(typeof exports != 'undefined' ? exports : this); \ No newline at end of file diff --git a/src/image.class.js b/src/image.class.js index c33777cc..f3511108 100644 --- a/src/image.class.js +++ b/src/image.class.js @@ -430,4 +430,4 @@ fabric.Image.fromElement.async = true; -})(this); \ No newline at end of file +})(typeof exports != 'undefined' ? exports : this); \ No newline at end of file diff --git a/src/intersection.class.js b/src/intersection.class.js index affedb71..cdf17d5a 100644 --- a/src/intersection.class.js +++ b/src/intersection.class.js @@ -148,4 +148,4 @@ return result; }; -})(this); \ No newline at end of file +})(typeof exports != 'undefined' ? exports : this); \ No newline at end of file diff --git a/src/line.class.js b/src/line.class.js index 5c0fe03c..1e1bbe0a 100644 --- a/src/line.class.js +++ b/src/line.class.js @@ -133,4 +133,5 @@ var points = [object.x1, object.y1, object.x2, object.y2]; return new fabric.Line(points, object); }; -})(this); \ No newline at end of file + +})(typeof exports != 'undefined' ? exports : this); \ No newline at end of file diff --git a/src/object.class.js b/src/object.class.js index 9ea144d3..d78db931 100644 --- a/src/object.class.js +++ b/src/object.class.js @@ -1316,4 +1316,5 @@ })(propName); } } -})(this); \ No newline at end of file + +})(typeof exports != 'undefined' ? exports : this); \ No newline at end of file diff --git a/src/parser.js b/src/parser.js index 2742e349..6eba2dab 100644 --- a/src/parser.js +++ b/src/parser.js @@ -521,4 +521,4 @@ getCSSRules: getCSSRules }); -})(this); \ No newline at end of file +})(typeof exports != 'undefined' ? exports : this); \ No newline at end of file diff --git a/src/path.class.js b/src/path.class.js index 6b35740b..4d3f8b37 100644 --- a/src/path.class.js +++ b/src/path.class.js @@ -670,4 +670,5 @@ var parsedAttributes = fabric.parseAttributes(element, fabric.Path.ATTRIBUTE_NAMES); return new fabric.Path(parsedAttributes.d, extend(parsedAttributes, options)); }; -})(this); \ No newline at end of file + +})(typeof exports != 'undefined' ? exports : this); \ No newline at end of file diff --git a/src/path_group.class.js b/src/path_group.class.js index 8bf6cd2c..aeee30c2 100644 --- a/src/path_group.class.js +++ b/src/path_group.class.js @@ -243,4 +243,5 @@ var paths = instantiatePaths(object.paths); return new fabric.PathGroup(paths, object); }; -})(this); \ No newline at end of file + +})(typeof exports != 'undefined' ? exports : this); \ No newline at end of file diff --git a/src/point.class.js b/src/point.class.js index 15a10e2f..59375edb 100644 --- a/src/point.class.js +++ b/src/point.class.js @@ -193,4 +193,4 @@ } }; -})(this); \ No newline at end of file +})(typeof exports != 'undefined' ? exports : this); \ No newline at end of file diff --git a/src/polygon.class.js b/src/polygon.class.js index ef6177bf..bc2de987 100644 --- a/src/polygon.class.js +++ b/src/polygon.class.js @@ -145,5 +145,6 @@ */ fabric.Polygon.fromObject = function(object) { return new fabric.Polygon(object.points, object); - } -})(this); \ No newline at end of file + }; + +})(typeof exports != 'undefined' ? exports : this); \ No newline at end of file diff --git a/src/polyline.class.js b/src/polyline.class.js index c0ab5d6a..c796d6d1 100644 --- a/src/polyline.class.js +++ b/src/polyline.class.js @@ -129,4 +129,4 @@ return new fabric.Polyline(points, object); }; -})(this); \ No newline at end of file +})(typeof exports != 'undefined' ? exports : this); \ No newline at end of file diff --git a/src/rect.class.js b/src/rect.class.js index 22b54ab9..0ac317d4 100644 --- a/src/rect.class.js +++ b/src/rect.class.js @@ -177,4 +177,5 @@ fabric.Rect.fromObject = function(object) { return new fabric.Rect(object); }; -})(this); \ No newline at end of file + +})(typeof exports != 'undefined' ? exports : this); \ No newline at end of file diff --git a/src/text.class.js b/src/text.class.js index 663236d6..a3b42665 100644 --- a/src/text.class.js +++ b/src/text.class.js @@ -351,4 +351,5 @@ fabric.Text.fromElement = function(element) { // TODO (kangax): implement this }; -})(this); \ No newline at end of file + +})(typeof exports != 'undefined' ? exports : this); \ No newline at end of file diff --git a/src/triangle.class.js b/src/triangle.class.js index 96a132bb..def6355b 100644 --- a/src/triangle.class.js +++ b/src/triangle.class.js @@ -79,4 +79,5 @@ fabric.Triangle.fromObject = function(object) { return new fabric.Triangle(object); }; -})(this); \ No newline at end of file + +})(typeof exports != 'undefined' ? exports : this); \ No newline at end of file