Allow jax files to be loaded in parallel rather than sequentially (need to synchronize output jax with modifications of element jax)

This commit is contained in:
Davide P. Cervone 2010-11-14 19:36:09 -05:00
parent d23f38412d
commit db3b0ef731
5 changed files with 46 additions and 11 deletions

View File

@ -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.7";
MathJax.version = "1.0.8";
/**********************************************************/
@ -1684,12 +1684,33 @@ 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;
var queue = CALLBACK.Queue();
// Load any needed the element jax
var jax = this.elementJax; if (!(jax instanceof Array)) {jax = [jax]}
for (var i = 0, m = jax.length; i < m; i++) {
var file = BASE.ElementJax.directory+"/"+jax[i]+"/jax.js";
if (!this.require) {this.require = []}
else if (!(this.require instanceof Array)) {this.require = [this.require]};
this.require.push(file); // so Startup will wait for it to be loaded
queue.Push(AJAX.Require(file));
}
// Load the input jax
queue.Push(AJAX.Require(this.directory+"/jax.js"));
// Load the associated output jax
jax = HUB.config.outputJax["jax/"+jax[0]];
if (jax) {queue.Push(AJAX.Require(jax[0].directory+"/jax.js"))}
return queue.Push({});
},
Register: function (mimetype) {
if (!BASE.Hub.config.inputJax) {HUB.config.inputJax = {}}
HUB.config.inputJax[mimetype] = this;
}
},{
version: "1.0",
version: "1.0.1",
directory: JAX.directory+"/input",
extensionDir: JAX.extensionDir
});
@ -1704,10 +1725,14 @@ MathJax.Hub.Startup = {
if (!HUB.config.menuSettings.renderer) {HUB.config.menuSettings.renderer = this.id}
}
HUB.config.outputJax[mimetype].push(this);
// Make sure the element jax is loaded before Startup is called
if (!this.require) {this.require = []}
else if (!(this.require instanceof Array)) {this.require = [this.require]};
this.require.push(BASE.ElementJax.directory+"/"+(mimetype.split(/\//)[1])+"/jax.js");
},
Remove: function (jax) {}
},{
version: "1.0",
version: "1.0.1",
directory: JAX.directory+"/output",
extensionDir: JAX.extensionDir,
fontDir: ROOT+(BASE.isPacked?"":"/..")+"/fonts"

View File

@ -28,7 +28,6 @@ MathJax.InputJax.MathML = MathJax.InputJax({
directory: MathJax.InputJax.directory + "/MathML",
extensionDir: MathJax.InputJax.extensionDir + "/MathML",
entityDir: MathJax.InputJax.directory + "/MathML/entities",
require: [MathJax.ElementJax.directory + "/mml/jax.js"],
config: {
useMathMLspacing: false // false means use TeX spacing, true means MML spacing

View File

@ -27,7 +27,6 @@ MathJax.InputJax.TeX = MathJax.InputJax({
version: "1.0.3",
directory: MathJax.InputJax.directory + "/TeX",
extensionDir: MathJax.InputJax.extensionDir + "/TeX",
require: [MathJax.ElementJax.directory + "/mml/jax.js"],
config: {
TagSide: "right",

View File

@ -23,7 +23,9 @@
* limitations under the License.
*/
(function (MML,AJAX,HUB,HTMLCSS) {
(function (AJAX,HUB,HTMLCSS) {
var MML;
var FONTTEST = MathJax.Object.Subclass({
timeout: 5*1000, // timeout for loading web fonts
@ -179,7 +181,6 @@
});
HTMLCSS.Augment({
config: {
useOldImageData: true, // for now
@ -1138,6 +1139,10 @@
rfuzz: 0 // adjustment to rule placements in roots
});
MathJax.Hub.Register.StartupHook("mml Jax Ready",function () {
MML = MathJax.ElementJax.mml;
MML.mbase.Augment({
toHTML: function (span) {
var split = this.HTMLlineBreaks();
@ -2082,6 +2087,7 @@
return span;
}
});
});
//
// Handle browser-specific setup
@ -2210,4 +2216,4 @@
HTMLCSS.loadComplete("jax.js");
})(MathJax.ElementJax.mml, MathJax.Ajax, MathJax.Hub, MathJax.OutputJax["HTML-CSS"]);
})(MathJax.Ajax, MathJax.Hub, MathJax.OutputJax["HTML-CSS"]);

View File

@ -22,8 +22,8 @@
* limitations under the License.
*/
(function (MML,nMML,HUB,AJAX) {
var isMSIE = HUB.Browser.isMSIE;
(function (nMML,HUB,AJAX) {
var MML, isMSIE = HUB.Browser.isMSIE;
nMML.Augment({
LEFTBUTTON: (isMSIE ? 1 : 0), // the event.button value for left button
@ -208,6 +208,10 @@
}
});
MathJax.Hub.Register.StartupHook("mml Jax Ready",function () {
MML = MathJax.ElementJax.mml;
MML.mbase.Augment({
//
// Add a MathML tag of the correct type, and set its attributes
@ -435,9 +439,11 @@
});
});
});
if (HUB.config.menuSettings.zoom !== "None")
{AJAX.Require("[MathJax]/extensions/MathZoom.js")}
nMML.loadComplete("jax.js");
})(MathJax.ElementJax.mml, MathJax.OutputJax.NativeMML, MathJax.Hub, MathJax.Ajax);
})(MathJax.OutputJax.NativeMML, MathJax.Hub, MathJax.Ajax);