Allow config parameter and script to both be used together

This commit is contained in:
Davide P. Cervone 2011-01-01 17:19:56 -05:00
parent 0c43db656c
commit e0da83e172
2 changed files with 22 additions and 5 deletions

File diff suppressed because one or more lines are too long

View File

@ -1473,6 +1473,9 @@ MathJax.Hub.Startup = {
//
Config: function () {
this.queue.Push(["Post",this.signal,"Begin Config"]);
//
// Check for user cookie configuration
//
var user = MathJax.HTML.Cookie.Get("user");
if (user.URL || user.Config) {
if (confirm(
@ -1484,24 +1487,38 @@ MathJax.Hub.Startup = {
if (user.Config) {MathJax.userConfig = new Function(user.Config)}
} else {MathJax.HTML.Cookie.Set("user",{})}
}
//
// Run the configuration script, if any
// Then load the config files specified in the parameters
// If neither of the above, load the default configuration file
//
var loadDefault = true;
if (this.script.match(/\S/)) {
this.queue.Push(this.script+";\n1;");
} else if (this.params && this.params.config) {
loadDefault = false;
}
if (this.params && this.params.config) {
var files = this.params.config.split(/,/);
for (var i = 0, m = files.length; i < m; i++) {
if (!files[i].match(/\.js$/)) {files[i] += ".js"}
this.queue.Push(["Require",MathJax.Ajax,this.URL("config",files[i])]);
}
} else {
loadDefault = false;
}
if (loadDefault) {
this.queue.Push(["Require",MathJax.Ajax,this.URL("config","MathJax.js")]);
}
return this.queue.Push(
//
// Delay the startup, if requested,
// then load the files in the configuration's config array
//
this.queue.Push(
[function (config,onload) {
if (config.delayStartupUntil.isCallback) {return config.delayStartupUntil}
if (config.delayStartupUntil === "onload") {return onload}
return function () {};
}, MathJax.Hub.config, this.onload],
// use a function here since MathJax.Hub.config.config might change in MathJax.js above
// use a function here since MathJax.Hub.config.config might change in files loaded above
[function (THIS) {return THIS.loadArray(MathJax.Hub.config.config,"config",null,true)},this],
["Post",this.signal,"End Config"]
);