Add callback to loadDomain to make it easier to use
This commit is contained in:
parent
c9578c7a0b
commit
c4d47bb10d
|
@ -1209,7 +1209,8 @@ MathJax.Localization = {
|
||||||
// Load a langauge data file from the proper
|
// Load a langauge data file from the proper
|
||||||
// directory and file.
|
// directory and file.
|
||||||
//
|
//
|
||||||
loadFile: function (file,data) {
|
loadFile: function (file,data,callback) {
|
||||||
|
callback = MathJax.Callback(callback||{});
|
||||||
file = (data.file || file); // the data's file name or the default name
|
file = (data.file || file); // the data's file name or the default name
|
||||||
if (!file.match(/\.js$/)) {file += ".js"} // add .js if needed
|
if (!file.match(/\.js$/)) {file += ".js"} // add .js if needed
|
||||||
//
|
//
|
||||||
|
@ -1227,7 +1228,7 @@ MathJax.Localization = {
|
||||||
// failed to load, so we don't continue to try to load it
|
// failed to load, so we don't continue to try to load it
|
||||||
// over and over).
|
// over and over).
|
||||||
//
|
//
|
||||||
var load = MathJax.Ajax.Require(file,function () {data.isLoaded = true});
|
var load = MathJax.Ajax.Require(file,function () {data.isLoaded = true; return callback()});
|
||||||
//
|
//
|
||||||
// Return the callback if needed, otherwise null.
|
// Return the callback if needed, otherwise null.
|
||||||
//
|
//
|
||||||
|
@ -1240,24 +1241,27 @@ MathJax.Localization = {
|
||||||
// and return a callback for the loading operation.
|
// and return a callback for the loading operation.
|
||||||
// Otherwise return null (data are loaded).
|
// Otherwise return null (data are loaded).
|
||||||
//
|
//
|
||||||
loadDomain: function (domain) {
|
loadDomain: function (domain,callback) {
|
||||||
var load;
|
var load, localeData = this.strings[this.locale];
|
||||||
var localeData = this.strings[this.locale];
|
|
||||||
if (localeData) {
|
if (localeData) {
|
||||||
if (!localeData.isLoaded) {
|
if (!localeData.isLoaded) {
|
||||||
load = this.loadFile(this.locale,localeData);
|
load = this.loadFile(this.locale,localeData);
|
||||||
// if the main file must be loaded, call us again to load domain
|
if (load) {
|
||||||
if (load) {return MathJax.Callback.After(["loadDomain",this,domain],load)}
|
return MathJax.Callback.Queue(
|
||||||
|
load,["loadDomain",this,domain] // call again to load domain
|
||||||
|
).Push(callback);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (localeData.domains && domain in localeData.domains) {
|
if (localeData.domains && domain in localeData.domains) {
|
||||||
var domainData = localeData.domains[domain];
|
var domainData = localeData.domains[domain];
|
||||||
if (!domainData.isLoaded) {
|
if (!domainData.isLoaded) {
|
||||||
load = this.loadFile(domain,domainData);
|
load = this.loadFile(domain,domainData);
|
||||||
if (load) {return load}
|
if (load) {return MathJax.Callback.Queue(load).Push(callback)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null; // localization data are loaded
|
// localization data are loaded, so just do the callback
|
||||||
|
return MathJax.Callback(callback)();
|
||||||
},
|
},
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -306,12 +306,8 @@
|
||||||
if (message.match(/- Web-Font/)) {if (localFonts) {MSG = "webFont"}}
|
if (message.match(/- Web-Font/)) {if (localFonts) {MSG = "webFont"}}
|
||||||
else if (message.match(/- using image fonts/)) {MSG = "imageFonts"}
|
else if (message.match(/- using image fonts/)) {MSG = "imageFonts"}
|
||||||
else if (message.match(/- no valid font/)) {MSG = "noFonts"}
|
else if (message.match(/- no valid font/)) {MSG = "noFonts"}
|
||||||
if (MSG && CONFIG.Message[MSG]) {
|
if (MSG && CONFIG.Message[MSG])
|
||||||
MathJax.Callback.Queue(
|
{MathJax.Localization.loadDomain("FontWarnings",[CREATEMESSAGE,CONFIG.Message[MSG]])}
|
||||||
["loadDomain",MathJax.Localization,"FontWarnings"], // make sure these are available
|
|
||||||
[CREATEMESSAGE,CONFIG.Message[MSG]]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
|
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
|
||||||
/* vim: set ts=2 et sw=2 tw=80: */
|
/* vim: set ts=2 et sw=2 tw=80: */
|
||||||
|
|
||||||
/*************************************************************
|
/*************************************************************
|
||||||
*
|
*
|
||||||
* MathJax/extensions/v1.0-warning.js
|
* MathJax/extensions/v1.0-warning.js
|
||||||
|
|
Loading…
Reference in New Issue
Block a user