Do setup for MathPlayer and DOM Parser when first needed rather than at startup (since these can be disabled by IE causing errors). Put up alerts indicating security settings to change if IE fails to set these up properly.
This commit is contained in:
parent
37f61a88ef
commit
46320e5b9e
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -12,5 +12,5 @@
|
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
|
||||
MathJax.InputJax.MathML=MathJax.InputJax({id:"MathML",version:"1.1.3",directory:MathJax.InputJax.directory+"/MathML",extensionDir:MathJax.InputJax.extensionDir+"/MathML",entityDir:MathJax.InputJax.directory+"/MathML/entities",config:{useMathMLspacing:false}});MathJax.InputJax.MathML.Register("math/mml");MathJax.InputJax.MathML.loadComplete("config.js");
|
||||
MathJax.InputJax.MathML=MathJax.InputJax({id:"MathML",version:"1.1.4",directory:MathJax.InputJax.directory+"/MathML",extensionDir:MathJax.InputJax.extensionDir+"/MathML",entityDir:MathJax.InputJax.directory+"/MathML/entities",config:{useMathMLspacing:false}});MathJax.InputJax.MathML.Register("math/mml");MathJax.InputJax.MathML.loadComplete("config.js");
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -12,5 +12,5 @@
|
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
|
||||
MathJax.OutputJax.NativeMML=MathJax.OutputJax({id:"NativeMML",version:"1.1.3",directory:MathJax.OutputJax.directory+"/NativeMML",extensionDir:MathJax.OutputJax.extensionDir+"/NativeMML",config:{scale:100,showMathMenu:true,showMathMenuMSIE:true,styles:{"DIV.MathJax_MathML":{"text-align":"center",margin:".75em 0px"}}}});if(!MathJax.Hub.config.delayJaxRegistration){MathJax.OutputJax.NativeMML.Register("jax/mml")}(function(a){if(a.isMSIE){MathJax.Hub.Register.StartupHook("onLoad",function(){var b=document.createElement("object");b.id="mathplayer";b.classid="clsid:32F66A20-7614-11D4-BD11-00104BD3F987";document.getElementsByTagName("head")[0].appendChild(b);document.namespaces.add("mjx","http://www.w3.org/1998/Math/MathML");document.namespaces.mjx.doImport("#mathplayer")})}})(MathJax.Hub.Browser);MathJax.OutputJax.NativeMML.loadComplete("config.js");
|
||||
MathJax.OutputJax.NativeMML=MathJax.OutputJax({id:"NativeMML",version:"1.1.4",directory:MathJax.OutputJax.directory+"/NativeMML",extensionDir:MathJax.OutputJax.extensionDir+"/NativeMML",config:{scale:100,showMathMenu:true,showMathMenuMSIE:true,styles:{"DIV.MathJax_MathML":{"text-align":"center",margin:".75em 0px"}}}});if(!MathJax.Hub.config.delayJaxRegistration){MathJax.OutputJax.NativeMML.Register("jax/mml")}MathJax.OutputJax.NativeMML.loadComplete("config.js");
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -24,7 +24,7 @@
|
|||
|
||||
MathJax.InputJax.MathML = MathJax.InputJax({
|
||||
id: "MathML",
|
||||
version: "1.1.3",
|
||||
version: "1.1.4",
|
||||
directory: MathJax.InputJax.directory + "/MathML",
|
||||
extensionDir: MathJax.InputJax.extensionDir + "/MathML",
|
||||
entityDir: MathJax.InputJax.directory + "/MathML/entities",
|
||||
|
|
|
@ -129,6 +129,7 @@
|
|||
|
||||
MATHML.Augment({
|
||||
Translate: function (script) {
|
||||
if (!this.ParseXML) {this.ParseXML = this.createParser()}
|
||||
var mml, math;
|
||||
if (script.firstChild &&
|
||||
script.firstChild.nodeName.toLowerCase().replace(/^[a-z]+:/,"") === "math") {
|
||||
|
@ -165,6 +166,39 @@
|
|||
this.div.innerHTML = string.replace(/<([a-z]+)([^>]*)\/>/g,"<$1$2></$1>");
|
||||
return this.div;
|
||||
},
|
||||
parseError: function (string) {return null},
|
||||
//
|
||||
// Create the parser using a DOMParser, or other fallback method
|
||||
//
|
||||
createParser: function () {
|
||||
if (window.DOMParser) {
|
||||
this.parser = new DOMParser();
|
||||
return(this.parseDOM);
|
||||
} else if (window.ActiveXObject) {
|
||||
var xml = ["MSXML2.DOMDocument.6.0","MSXML2.DOMDocument.5.0","MSXML2.DOMDocument.4.0",
|
||||
"MSXML2.DOMDocument.3.0","MSXML2.DOMDocument.2.0","Microsoft.XMLDOM"];
|
||||
for (var i = 0, m = xml.length; i < m && !this.parser; i++)
|
||||
{try {this.parser = new ActiveXObject(xml[i])} catch (err) {}}
|
||||
if (!this.parser) {
|
||||
alert("MathJax can't create an XML parser for MathML. Check that\n"+
|
||||
"the 'Script ActiveX controls marked safe for scripting' security\n"+
|
||||
"setting is enabled (use the Internet Options item in the Tools\n"+
|
||||
"menu, and select the Security panel, then press the Custom Level\n"+
|
||||
"button to check this).\n\n"+
|
||||
"MathML equations will not be able to be processed by MathJax.");
|
||||
return(this.parseError);
|
||||
}
|
||||
this.parser.async = false;
|
||||
return(this.parseMS);
|
||||
}
|
||||
this.div = MathJax.Hub.Insert(document.createElement("div"),{
|
||||
style:{visibility:"hidden", overflow:"hidden", height:"1px",
|
||||
position:"absolute", top:0}
|
||||
});
|
||||
if (!document.body.firstChild) {document.body.appendChild(this.div)}
|
||||
else {document.body.insertBefore(this.div,document.body.firstChild)}
|
||||
return(this.parseDIV);
|
||||
},
|
||||
//
|
||||
// Initialize the parser object (whichever type is used)
|
||||
//
|
||||
|
@ -173,26 +207,6 @@
|
|||
MML.mspace.Augment({mmlSelfClosing: true});
|
||||
MML.none.Augment({mmlSelfClosing: true});
|
||||
MML.mprescripts.Augment({mmlSelfClossing:true});
|
||||
if (window.DOMParser) {
|
||||
this.parser = new DOMParser();
|
||||
this.ParseXML = this.parseDOM;
|
||||
} else if (window.ActiveXObject) {
|
||||
var xml = ["MSXML2.DOMDocument.6.0","MSXML2.DOMDocument.5.0","MSXML2.DOMDocument.4.0",
|
||||
"MSXML2.DOMDocument.3.0","MSXML2.DOMDocument.2.0","Microsoft.XMLDOM"];
|
||||
for (var i = 0, m = xml.length; i < m && !this.parser; i++)
|
||||
{try {this.parser = new ActiveXObject(xml[i])} catch (err) {}}
|
||||
if (!this.parser) MATHML.Error("Can't create XML parser for MathML");
|
||||
this.parser.async = false;
|
||||
this.ParseXML = this.parseMS;
|
||||
} else {
|
||||
this.div = MathJax.Hub.Insert(document.createElement("div"),{
|
||||
style:{visibility:"hidden", overflow:"hidden", height:"1px",
|
||||
position:"absolute", top:0}
|
||||
});
|
||||
if (!document.body.firstChild) {document.body.appendChild(this.div)}
|
||||
else {document.body.insertBefore(this.div,document.body.firstChild)}
|
||||
this.ParseXML = this.parseDIV;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
MathJax.OutputJax.NativeMML = MathJax.OutputJax({
|
||||
id: "NativeMML",
|
||||
version: "1.1.3",
|
||||
version: "1.1.4",
|
||||
directory: MathJax.OutputJax.directory + "/NativeMML",
|
||||
extensionDir: MathJax.OutputJax.extensionDir + "/NativeMML",
|
||||
|
||||
|
@ -45,20 +45,4 @@ MathJax.OutputJax.NativeMML = MathJax.OutputJax({
|
|||
if (!MathJax.Hub.config.delayJaxRegistration)
|
||||
MathJax.OutputJax.NativeMML.Register("jax/mml");
|
||||
|
||||
(function (browser) {
|
||||
if (browser.isMSIE) {
|
||||
//
|
||||
// Insert data needed to use MathPlayer for MathML output
|
||||
// (but wait for onload, since adding the namespace can fail if done too early)
|
||||
//
|
||||
MathJax.Hub.Register.StartupHook("onLoad",function () {
|
||||
var mathplayer = document.createElement("object");
|
||||
mathplayer.id = "mathplayer"; mathplayer.classid = "clsid:32F66A20-7614-11D4-BD11-00104BD3F987";
|
||||
document.getElementsByTagName("head")[0].appendChild(mathplayer);
|
||||
document.namespaces.add("mjx","http://www.w3.org/1998/Math/MathML");
|
||||
document.namespaces.mjx.doImport("#mathplayer");
|
||||
});
|
||||
}
|
||||
})(MathJax.Hub.Browser);
|
||||
|
||||
MathJax.OutputJax.NativeMML.loadComplete("config.js");
|
||||
|
|
|
@ -53,12 +53,40 @@
|
|||
});
|
||||
}
|
||||
},
|
||||
//
|
||||
// Set up MathPlayer for IE on the first time through.
|
||||
//
|
||||
InitializeMML: function () {
|
||||
this.initialized = true;
|
||||
if (MathJax.Hub.Browser.isMSIE) {
|
||||
try {
|
||||
//
|
||||
// Insert data needed to use MathPlayer for MathML output
|
||||
//
|
||||
var mathplayer = document.createElement("object");
|
||||
mathplayer.id = "mathplayer"; mathplayer.classid = "clsid:32F66A20-7614-11D4-BD11-00104BD3F987";
|
||||
document.getElementsByTagName("head")[0].appendChild(mathplayer);
|
||||
document.namespaces.add("mjx","http://www.w3.org/1998/Math/MathML");
|
||||
document.namespaces.mjx.doImport("#mathplayer");
|
||||
} catch (err) {
|
||||
//
|
||||
// If that fails, give an alert about security settings
|
||||
//
|
||||
alert("MathJax was not able to setup MathPlayer. It may be that your\n"+
|
||||
"security settings are preventing ActiveX controls from running.\n"+
|
||||
"Use the Internet Options item under the Tools menu, and select the\n"+
|
||||
"Security tab. Then press the Custom Level button and check that the\n"+
|
||||
"setting for 'Run ActiveX Controls' is enabled.");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
//
|
||||
// Add a SPAN to use as a container, and render the math into it
|
||||
//
|
||||
Translate: function (script) {
|
||||
if (!script.parentNode) return;
|
||||
if (!this.initialized) {this.InitializeMML()}
|
||||
var prev = script.previousSibling;
|
||||
if (prev && String(prev.className).match(/^MathJax(_MathML|_Display)?$/))
|
||||
{prev.parentNode.removeChild(prev)}
|
||||
|
|
Loading…
Reference in New Issue
Block a user