From 5508e6eab62e312d05f36776df158835477e912e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Thu, 3 Mar 2011 16:57:29 +0000 Subject: [PATCH] Change scoped compilation of paper so that only a populated paper object is returned to the global scope, but nothing is installed yet. --- src/build.js | 7 +++---- src/paper.js | 8 ++++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/build.js b/src/build.js index 2f67ee0d..b3683b10 100644 --- a/src/build.js +++ b/src/build.js @@ -1,4 +1,4 @@ -(function(scope) { +var paper = new function() { #include "paper.js" @@ -39,7 +39,6 @@ #include "util/CanvasProvider.js" #include "util/MathUtils.js" -paper.populate(); -paper.install(scope); +return paper.populate(); -})(this); +}; diff --git a/src/paper.js b/src/paper.js index 788c1160..23548839 100644 --- a/src/paper.js +++ b/src/paper.js @@ -4,15 +4,15 @@ var paper = { populate: function() { // Inject all prototypes from the paper scope into the paper object. - Base.each(['Point', 'Size', 'Rectangle', 'Matrix', 'DocumentView', + // return this so build.js can use 'return paper.populate()'. + return Base.each(['Point', 'Size', 'Rectangle', 'Matrix', 'DocumentView', 'Doc', 'Symbol', 'Item', 'Group', 'Layer', 'Raster', 'PlacedSymbol', 'PathStyle', 'Segment', 'Curve', 'PathItem', 'Path', 'CompoundPath', 'Color', 'RGBColor', 'GrayColor', 'GradientColor', 'Gradient', 'GradientStop', 'ToolEvent', 'ToolHandler', 'Tool'], function(name) { - paper[name] = eval(name); - } - ); + this[name] = eval(name); + }, this); }, install: function(scope) {