Browser-Cola fixed.

This commit is contained in:
Onoshko Dan 2014-05-24 00:00:21 +07:00
parent 5158fadfd3
commit 9a72bc48d0
3 changed files with 16 additions and 14 deletions

File diff suppressed because one or more lines are too long

View File

@ -45,7 +45,8 @@ Cola.AST_Toplevel.prototype.toJavaScript = function(options){
main_binding : true,
main_event : 'DOMContentLoaded',
parser : {},
std : true
std : true,
path_prefix : ""
});
var $_cola_ast = Cola.parse(Cola.$_cola, { is_js : true }),
@ -1779,7 +1780,7 @@ Cola.AST_Toplevel.prototype.toJavaScript = function(options){
options.parser.is_js = /\.js$/.test(file);
options.parser.filename = file;
var tl = Cola.parse(Cola.getSource(file), options.parser);
var tl = Cola.parse(Cola.getSource(options.path_prefix + file), options.parser);
if (options.parser.is_js) tl = tl.toJavaScript({
main_binding : options.main_binding,
main_event : options.main_event,
@ -1802,7 +1803,7 @@ Cola.AST_Toplevel.prototype.toJavaScript = function(options){
options.parser.is_js = /\.js$/.test(file);
options.parser.filename = file;
var tl = Cola.parse(Cola.getSource(file), options.parser);
var tl = Cola.parse(Cola.getSource(options.path_prefix + file), options.parser);
if (options.parser.is_js) tl = tl.toJavaScript({
main_binding : options.main_binding,
main_event : options.main_event,

View File

@ -77,9 +77,10 @@ Cola.bootstrap = function () {
var source = "";
Array.prototype.forEach.call(document.querySelectorAll('script[type="text/colascript"][src]'),
function(script){
source += Cola.getSource(script.src);
var path_prefix = script.src.split("/"); path_prefix.pop();
path_prefix = path_prefix.join("/") + "/";
Cola.eval(Cola.getSource(script.src), { main_event : "ColaScriptMain", path_prefix : path_prefix });
});
Cola.eval(source, { main_event : "ColaScriptMain" });
var event = document.createEvent("HTMLEvents");
event.initEvent("ColaScriptMain", true, true);