From fa4b5d547496e87f6fdb9da1706dfa2405f9fbe5 Mon Sep 17 00:00:00 2001 From: nightwing Date: Tue, 10 Jul 2012 09:59:17 +0400 Subject: [PATCH] fix loading of unpackaged workers --- lib/ace/config.js | 32 +++++++++++++++++++++----------- lib/ace/edit_session.js | 2 +- lib/ace/mode/coffee.js | 2 +- lib/ace/mode/css.js | 2 +- lib/ace/mode/javascript.js | 2 +- lib/ace/mode/xquery.js | 2 +- lib/ace/virtual_renderer.js | 2 +- lib/ace/worker/worker_client.js | 2 +- 8 files changed, 28 insertions(+), 18 deletions(-) diff --git a/lib/ace/config.js b/lib/ace/config.js index 0d2366a9f1d..9e9679c2d2e 100644 --- a/lib/ace/config.js +++ b/lib/ace/config.js @@ -50,20 +50,21 @@ var options = { workerPath: "", modePath: "", themePath: "", - suffix: ".js" + suffix: ".js", + $moduleUrls: {} }; exports.get = function(key) { if (!options.hasOwnProperty(key)) throw new Error("Unknown config key: " + key); - + return options[key]; }; exports.set = function(key, value) { if (!options.hasOwnProperty(key)) throw new Error("Unknown config key: " + key); - + options[key] = value; }; @@ -71,14 +72,23 @@ exports.all = function() { return lang.copyObject(options); }; -exports.moduleUrl = function(name) { +exports.moduleUrl = function(name, component) { + if (options.$moduleUrls[name]) + return options.$moduleUrls[name]; + var parts = name.split("/"); - var component = parts[1]; - var base = parts[2]; + component = component || parts[1]; + var base = parts[2].replace(component, "").replace(/(^[\-_])|([\-_]$)/, ""); + if (!base) + base = parts[1]; return this.get(component + "Path") + "/" + component + "-" + base + this.get("suffix"); }; +exports.setModuleUrl = function(name, subst) { + return options.$moduleUrls[name] = subst; +}; + exports.init = function() { options.packaged = require.packaged || module.packaged || (global.define && define.packaged); @@ -87,7 +97,7 @@ exports.init = function() { var scriptOptions = {}; var scriptUrl = ""; - + var scripts = document.getElementsByTagName("script"); for (var i=0; i