From b4356078a75aaa84deb0a6d98b429761015b66f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Mon, 7 Mar 2011 18:35:48 +0000 Subject: [PATCH] Export PaperScript.install, so it can be loaded after onload. --- src/util/PaperScript.js | 49 +++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/src/util/PaperScript.js b/src/util/PaperScript.js index ccfc5974..1471655d 100644 --- a/src/util/PaperScript.js +++ b/src/util/PaperScript.js @@ -163,34 +163,41 @@ var PaperScript = new function() { }; return xhr.send(null); } - - Events.add(window, { - load: function() { - var scripts = document.getElementsByTagName('script'); - for (var i = 0, l = scripts.length; i < l; i++) { - var script = scripts[i]; - if (script.type === 'text/paperscript') { - // If a canvas id is provided, create a document for it now, - // so the active document is defined. - var canvas = script.getAttribute('canvas'); - if (canvas && (canvas = document.getElementById(canvas))) { - new Document(canvas); - } - if (script.src) { - load(script.src); - } else { - run(script.innerHTML); - } + function install() { + var scripts = document.getElementsByTagName('script'); + for (var i = 0, l = scripts.length; i < l; i++) { + var script = scripts[i]; + if (script.type === 'text/paperscript') { + // If a canvas id is provided, create a document for it now, + // so the active document is defined. + var canvas = script.getAttribute('canvas'); + if (canvas && (canvas = document.getElementById(canvas))) { + new Document(canvas); + } + if (script.src) { + load(script.src); + } else { + run(script.innerHTML); } } - return null; } - }); + return null; + } -//#endif // BROWSER + Events.add(window, { load: install }); + + return { + compile: compile, + run: run, + install: install + }; + +//#else // !BROWSER return { compile: compile, run: run }; + +//#endif // !BROWSER };