commit f5c0ac5bcd34f89f4275e4f12ce8a13d160773bb
parent 244069816a8fee98668c70b65b84d327cb0b07e1
Author: Davide P. Cervone <dpvc@union.edu>
Date: Sat, 1 Jan 2011 16:44:48 -0500
Changes to allow output jax to be included in a combined configuration file (more careful synchronization is needed in order to make sure the jax is loaded before typesetting begins)
Diffstat:
1 file changed, 25 insertions(+), 14 deletions(-)
diff --git a/unpacked/MathJax.js b/unpacked/MathJax.js
@@ -29,7 +29,7 @@ if (document.getElementById && document.childNodes && document.createElement) {
if (!window.MathJax) {window.MathJax= {}}
if (!MathJax.Hub) { // skip if already loaded
-MathJax.version = "1.0.8";
+MathJax.version = "1.0.9";
/**********************************************************/
@@ -662,6 +662,16 @@ MathJax.version = "1.0.8";
},
//
+ // Used when files are combined in a preloading configuration file
+ //
+ Preloading: function () {
+ for (var i = 0, m = arguments.length; i < m; i++) {
+ var file = this.fileURL(arguments[i]);
+ if (!this.loading[file]) {this.loading[file] = {preloaded: true}}
+ }
+ },
+
+ //
// Code used to load the various types of files
// (JS for JavaScript, CSS for style sheets)
//
@@ -799,7 +809,7 @@ MathJax.version = "1.0.8";
loadComplete: function (file) {
file = this.fileURL(file);
var loading = this.loading[file];
- if (loading) {
+ if (loading && !loading.preloaded) {
BASE.Message.Clear(loading.message);
clearTimeout(loading.timeout);
if (loading.script) {
@@ -1361,9 +1371,9 @@ MathJax.Hub = {
if (!script.MathJax || script.MathJax.state === STATE.PROCESSED) continue;
if (!script.MathJax.elementJax || script.MathJax.state === STATE.UPDATE) {
this.checkScriptSiblings(script);
- result = inputJax[type].Translate(script);
+ result = inputJax[type].Process(script);
if (typeof result === 'function') {
- if (result.called) continue; // go back and call Translate() again
+ if (result.called) continue; // go back and call Process() again
this.RestartAfter(result);
}
result.Attach(script,inputJax[type]);
@@ -1374,10 +1384,10 @@ MathJax.Hub = {
throw Error("No output jax registered for "+jax.mimeType);
}
jax.outputJax = outputJax[jax.mimeType][0];
- result = jax.outputJax.Translate(script);
+ result = jax.outputJax.Process(script);
if (typeof result === 'function') {
script.MathJax.state = STATE.UPDATE;
- if (result.called) continue; // go back and call Translate() again
+ if (result.called) continue; // go back and call Process() again
this.RestartAfter(result);
}
script.MathJax.state = STATE.PROCESSED;
@@ -1652,11 +1662,12 @@ MathJax.Hub.Startup = {
cObject.Augment(null,cdef);
return this;
},
- Translate: function (element) {
- this.constructor.prototype.Translate = this.noTranslate;
- return AJAX.Require(this.directory+"/"+this.JAXFILE);
+ Process: function (element) {
+ var load = AJAX.Require(this.directory+"/"+this.JAXFILE);
+ if (!load.called) {this.constructor.prototype.Process = function (element) {return load}}
+ return load;
},
- noTranslate: function (element) {
+ Translate: function (element) {
throw Error(this.directory+"/"+this.JAXFILE+" failed to redefine the Translate() method");
},
Register: function (mimetype) {},
@@ -1681,6 +1692,7 @@ MathJax.Hub.Startup = {
queue.Push(["Post",HUB.Startup.signal,this.id+" Jax Startup"]);
queue.Push(["Startup",this]);
queue.Push(["Post",HUB.Startup.signal,this.id+" Jax Ready"]);
+ queue.Push([function (THIS) {THIS.Process = THIS.Translate},this.constructor.prototype]);
return queue.Push(["loadComplete",AJAX,this.directory+"/"+file]);
}
}
@@ -1695,9 +1707,7 @@ MathJax.Hub.Startup = {
BASE.InputJax = JAX.Subclass({
elementJax: "mml", // the element jax to load for this input jax
- Translate: function (element) {
- // Make Translate produce an error message until the true one is loaded
- this.constructor.prototype.Translate = this.noTranslate;
+ Process: function (element) {
var queue = CALLBACK.Queue();
// Load any needed element jax
var jax = this.elementJax; if (!(jax instanceof Array)) {jax = [jax]}
@@ -1709,7 +1719,8 @@ MathJax.Hub.Startup = {
queue.Push(AJAX.Require(file));
}
// Load the input jax
- queue.Push(AJAX.Require(this.directory+"/"+this.JAXFILE));
+ var load = queue.Push(AJAX.Require(this.directory+"/"+this.JAXFILE));
+ if (!load.called) {this.constructor.prototype.Process = function () {return load}}
// Load the associated output jax
jax = HUB.config.outputJax["jax/"+jax[0]];
if (jax) {queue.Push(AJAX.Require(jax[0].directory+"/"+this.JAXFILE))}