Fix several loading issues with localization files (don't add menu div until files are loaded, and properly handle empty callbacks in loadDomain).

This commit is contained in:
Davide P. Cervone 2014-04-22 12:31:03 -04:00
parent 833b69cd2c
commit c6d73f4689
2 changed files with 5 additions and 3 deletions

View File

@ -1396,7 +1396,7 @@ MathJax.Localization = {
// directory and file. // directory and file.
// //
loadFile: function (file,data,callback) { loadFile: function (file,data,callback) {
callback = MathJax.Callback(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
// //
@ -1435,7 +1435,7 @@ MathJax.Localization = {
if (load) { if (load) {
return MathJax.Callback.Queue( return MathJax.Callback.Queue(
load,["loadDomain",this,domain] // call again to load domain load,["loadDomain",this,domain] // call again to load domain
).Push(callback); ).Push(callback||{});
} }
} }
if (localeData.domains && domain in localeData.domains) { if (localeData.domains && domain in localeData.domains) {

View File

@ -200,7 +200,7 @@
SIGNAL.Post(["post",MENU.jax]); SIGNAL.Post(["post",MENU.jax]);
MENU.isRTL = (MathJax.Localization.fontDirection() === "rtl"); MENU.isRTL = (MathJax.Localization.fontDirection() === "rtl");
} }
var menu = HTML.addElement(div,"div",{ var menu = HTML.Element("div",{
onmouseup: MENU.Mouseup, ondblclick: FALSE, onmouseup: MENU.Mouseup, ondblclick: FALSE,
ondragstart: FALSE, onselectstart: FALSE, oncontextmenu: FALSE, ondragstart: FALSE, onselectstart: FALSE, oncontextmenu: FALSE,
menuItem: this, className: "MathJax_Menu" menuItem: this, className: "MathJax_Menu"
@ -214,6 +214,8 @@
ontouchstart: MENU.Close, ontouchend: FALSE, onmousedown: MENU.Close, onmouseup: FALSE ontouchstart: MENU.Close, ontouchend: FALSE, onmousedown: MENU.Close, onmouseup: FALSE
},[["img",{src: CONFIG.closeImg, style:{width:"100%",height:"100%"}}]]); },[["img",{src: CONFIG.closeImg, style:{width:"100%",height:"100%"}}]]);
} }
div.appendChild(menu);
this.posted = true; this.posted = true;
menu.style.width = (menu.offsetWidth+2) + "px"; menu.style.width = (menu.offsetWidth+2) + "px";