Make AssistiveMML menu item not hidden, and make it add and remove the MathML when toggled. Refactor AssistiveMML extension so that the Add and Remove functions can be called by the menu change.
This commit is contained in:
parent
db1ce61854
commit
d0d59b6876
|
@ -56,18 +56,18 @@
|
|||
if (!this.config.disabled && SETTINGS.assistiveMML == null)
|
||||
HUB.Config({menuSettings:{assistiveMML:true}});
|
||||
AJAX.Styles(this.config.styles);
|
||||
HUB.Register.MessageHook("End Math",function (msg) {AssistiveMML.EndMathHook(msg[1])});
|
||||
HUB.Register.MessageHook("End Math",function (msg) {
|
||||
if (SETTINGS.assistiveMML) return AssistiveMML.AddAssistiveMathML(msg[1])
|
||||
});
|
||||
},
|
||||
|
||||
//
|
||||
// The hook for the End Math signal.
|
||||
// This sets up a state object that lists the jax and index into the jax,
|
||||
// and a dummy callback that is used to synchronizing with MathJax.
|
||||
// It will be called when the jax are all processed, and that will
|
||||
// let the MathJax queue continue (it will block until then).
|
||||
//
|
||||
EndMathHook: function (node) {
|
||||
if (!SETTINGS.assistiveMML) return;
|
||||
AddAssistiveMathML: function (node) {
|
||||
var state = {
|
||||
jax: HUB.getAllJax(node), i: 0,
|
||||
callback: MathJax.Callback({})
|
||||
|
@ -76,6 +76,22 @@
|
|||
return state.callback;
|
||||
},
|
||||
|
||||
//
|
||||
// This removes the data-mathml attribute and the assistive MathML from
|
||||
// all the jax.
|
||||
//
|
||||
RemoveAssistiveMathML: function (node) {
|
||||
var jax = HUB.getAllJax(node), frame;
|
||||
for (var i = 0, m = jax.length; i < m; i++) {
|
||||
frame = document.getElementById(jax[i].inputID+"-Frame");
|
||||
if (frame && frame.getAttribute("data-mathml")) {
|
||||
frame.removeAttribute("data-mathml");
|
||||
if (frame.lastChild && frame.lastChild.className.match(/MJX_Assistive_MathML/))
|
||||
frame.removeChild(frame.lastChild);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
//
|
||||
// For each jax in the state, look up the frame.
|
||||
// If the jax doesn't use NativeMML and hasn't already been handled:
|
||||
|
@ -105,9 +121,9 @@
|
|||
});
|
||||
span.innerHTML = mml;
|
||||
frame.style.position = "relative";
|
||||
frame.setAttribute("role", "presentation");
|
||||
frame.setAttribute("role","presentation");
|
||||
frame.firstChild.setAttribute("aria-hidden","true");
|
||||
span.setAttribute("role", "presentation");
|
||||
span.setAttribute("role","presentation");
|
||||
}
|
||||
state.i++;
|
||||
}
|
||||
|
|
|
@ -1327,6 +1327,17 @@
|
|||
"not display properly."]
|
||||
}
|
||||
};
|
||||
|
||||
MENU.AssistiveMML = function (item,restart) {
|
||||
var AMML = MathJax.Extension.AssistiveMML;
|
||||
if (!AMML) {
|
||||
// Try to load the extension, but only try once.
|
||||
if (!restart)
|
||||
AJAX.Require("[MathJax]/extensions/AssistiveMML.js",["AssistiveMML",MENU,item,true]);
|
||||
return;
|
||||
}
|
||||
MathJax.Hub.Queue([(CONFIG.settings.assistiveMML ? "Add" : "Remove")+"AssistiveMathML",AMML]);
|
||||
};
|
||||
|
||||
/*
|
||||
* Handle setting the HTMLCSS fonts
|
||||
|
@ -1523,7 +1534,7 @@
|
|||
ITEM.RADIO("PlainSource","renderer", {action: MENU.Renderer, value:"PlainSource"}),
|
||||
ITEM.RULE(),
|
||||
ITEM.CHECKBOX("Fast Preview", "FastPreview"),
|
||||
ITEM.CHECKBOX("Assistive MathML", "assistiveMML", {hidden:!CONFIG.showAssistiveMML})
|
||||
ITEM.CHECKBOX("Assistive MathML", "assistiveMML", {action:MENU.AssistiveMML})
|
||||
),
|
||||
ITEM.SUBMENU("MathPlayer", {hidden:!HUB.Browser.isMSIE || !CONFIG.showMathPlayer,
|
||||
disabled:!HUB.Browser.hasMathPlayer},
|
||||
|
@ -1610,10 +1621,6 @@
|
|||
MENU.cookie.showLocale = CONFIG.showLocale = show; MENU.saveCookie();
|
||||
MENU.menu.Find("Language").hidden = !show;
|
||||
};
|
||||
MENU.showAssistiveMML = function (show) {
|
||||
MENU.cookie.showAssistiveMML = CONFIG.showAssistiveMML = show; MENU.saveCookie();
|
||||
MENU.menu.Find("Math Settings","Math Renderer","Assistive MathML").hidden = !show;
|
||||
};
|
||||
|
||||
MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
|
||||
if (!MathJax.OutputJax["HTML-CSS"].config.imageFont)
|
||||
|
|
Loading…
Reference in New Issue
Block a user