Extract packaged module loading

This commit is contained in:
Joshua Peek 2012-07-02 14:28:33 -05:00
commit b8a7b8ec90
4 changed files with 21 additions and 9 deletions

View file

@ -835,7 +835,7 @@ var EditSession = function(text, mode) {
if (!this.$mode)
this.$setModePlaceholder();
fetch(function() {
fetch(mode, function() {
require([mode], done);
});
@ -852,13 +852,11 @@ var EditSession = function(text, mode) {
callback(_self.$modes[mode]);
}
function fetch(callback) {
function fetch(name, callback) {
if (!config.get("packaged"))
return callback();
var base = mode.split("/").pop();
var filename = config.get("modePath") + "/mode-" + base + ".js";
net.loadScript(filename, callback);
net.loadScript(config.moduleUrl(name), callback);
}
};