mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-07 13:22:07 -05:00
Export PaperScript.install, so it can be loaded after onload.
This commit is contained in:
parent
3685a614a5
commit
b4356078a7
1 changed files with 28 additions and 21 deletions
|
@ -163,34 +163,41 @@ var PaperScript = new function() {
|
||||||
};
|
};
|
||||||
return xhr.send(null);
|
return xhr.send(null);
|
||||||
}
|
}
|
||||||
|
function install() {
|
||||||
Events.add(window, {
|
var scripts = document.getElementsByTagName('script');
|
||||||
load: function() {
|
for (var i = 0, l = scripts.length; i < l; i++) {
|
||||||
var scripts = document.getElementsByTagName('script');
|
var script = scripts[i];
|
||||||
for (var i = 0, l = scripts.length; i < l; i++) {
|
if (script.type === 'text/paperscript') {
|
||||||
var script = scripts[i];
|
// If a canvas id is provided, create a document for it now,
|
||||||
if (script.type === 'text/paperscript') {
|
// so the active document is defined.
|
||||||
// If a canvas id is provided, create a document for it now,
|
var canvas = script.getAttribute('canvas');
|
||||||
// so the active document is defined.
|
if (canvas && (canvas = document.getElementById(canvas))) {
|
||||||
var canvas = script.getAttribute('canvas');
|
new Document(canvas);
|
||||||
if (canvas && (canvas = document.getElementById(canvas))) {
|
}
|
||||||
new Document(canvas);
|
if (script.src) {
|
||||||
}
|
load(script.src);
|
||||||
if (script.src) {
|
} else {
|
||||||
load(script.src);
|
run(script.innerHTML);
|
||||||
} 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 {
|
return {
|
||||||
compile: compile,
|
compile: compile,
|
||||||
run: run
|
run: run
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//#endif // !BROWSER
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue