Merge branch 'issue323' into develop. Issue #323.

This commit is contained in:
Davide P. Cervone 2014-08-24 09:56:38 -04:00
commit 384964dfe1
2 changed files with 54 additions and 27 deletions

View File

@ -2359,7 +2359,7 @@ MathJax.Hub = {
if (callback == null && (element instanceof Array || typeof element === 'function')) if (callback == null && (element instanceof Array || typeof element === 'function'))
{try {MathJax.Callback(element); callback = element; element = null} catch(e) {}} {try {MathJax.Callback(element); callback = element; element = null} catch(e) {}}
if (element == null) {element = this.config.elements || []} if (element == null) {element = this.config.elements || []}
if (element instanceof HTMLCollection) {element = [].slice.apply(element)} if (this.isHTMLCollection(element)) {element = this.HTMLCollection2Array(element)}
if (!(element instanceof Array)) {element = [element]} if (!(element instanceof Array)) {element = [element]}
element = [].concat(element); // make a copy so the original isn't changed element = [].concat(element); // make a copy so the original isn't changed
for (var i = 0, m = element.length; i < m; i++) for (var i = 0, m = element.length; i < m; i++)
@ -2375,8 +2375,8 @@ MathJax.Hub = {
}, },
elementScripts: function (element) { elementScripts: function (element) {
if (element instanceof Array || element instanceof HTMLCollection) {
var scripts = []; var scripts = [];
if (element instanceof Array || this.isHTMLCollection(element)) {
for (var i = 0, m = element.length; i < m; i++) for (var i = 0, m = element.length; i < m; i++)
{scripts.push.apply(scripts,this.elementScripts(element[i]))} {scripts.push.apply(scripts,this.elementScripts(element[i]))}
return scripts; return scripts;
@ -2385,7 +2385,25 @@ MathJax.Hub = {
if (!document.body) {document.body = document.getElementsByTagName("body")[0]} if (!document.body) {document.body = document.getElementsByTagName("body")[0]}
if (element == null) {element = document.body} if (element == null) {element = document.body}
if (element.tagName != null && element.tagName.toLowerCase() === "script") {return [element]} if (element.tagName != null && element.tagName.toLowerCase() === "script") {return [element]}
return element.getElementsByTagName("script"); scripts = element.getElementsByTagName("script");
if (this.msieHTMLCollectionBug) {scripts = this.HTMLCollection2Array(scripts)}
return scripts;
},
//
// IE8 fails to check "obj instanceof HTMLCollection" for some values of obj.
//
isHTMLCollection: function (obj) {
return (typeof(obj) === "object" && obj instanceof HTMLCollection);
},
//
// IE8 doesn't deal with HTMLCollection as an array, so convert to array
//
HTMLCollection2Array: function (nodes) {
if (!this.msieHTMLCollectionBug) {return [].slice.call(nodes)}
var NODES = [];
for (var i = 0, m = nodes.length; i < m; i++) {NODES[i] = nodes[i]}
return NODES;
}, },
Insert: function (dst,src) { Insert: function (dst,src) {
@ -3118,11 +3136,18 @@ MathJax.Hub.Startup = {
MSIE: function (browser) { MSIE: function (browser) {
browser.isIE9 = !!(document.documentMode && (window.performance || window.msPerformance)); browser.isIE9 = !!(document.documentMode && (window.performance || window.msPerformance));
MathJax.HTML.setScriptBug = !browser.isIE9 || document.documentMode < 9; MathJax.HTML.setScriptBug = !browser.isIE9 || document.documentMode < 9;
var MathPlayer = false; MathJax.Hub.msieHTMLCollectionBug = (document.documentMode < 9);
try {new ActiveXObject("MathPlayer.Factory.1"); browser.hasMathPlayer = MathPlayer = true} //
catch (err) {} // MathPlayer doesn't function properly in IE10, and not at all in IE11,
// so don't even try to load it.
//
if (document.documentMode < 10 && !STARTUP.params.NoMathPlayer) {
try { try {
if (MathPlayer && !STARTUP.params.NoMathPlayer) { new ActiveXObject("MathPlayer.Factory.1");
browser.hasMathPlayer = true;
} catch (err) {}
try {
if (browser.hasMathPlayer) {
var mathplayer = document.createElement("object"); var mathplayer = document.createElement("object");
mathplayer.id = "mathplayer"; mathplayer.classid = "clsid:32F66A20-7614-11D4-BD11-00104BD3F987"; mathplayer.id = "mathplayer"; mathplayer.classid = "clsid:32F66A20-7614-11D4-BD11-00104BD3F987";
document.getElementsByTagName("head")[0].appendChild(mathplayer); document.getElementsByTagName("head")[0].appendChild(mathplayer);
@ -3141,6 +3166,7 @@ MathJax.Hub.Startup = {
} }
} catch (err) {} } catch (err) {}
} }
}
}); });
HUB.Browser.Select(MathJax.Message.browsers); HUB.Browser.Select(MathJax.Message.browsers);

View File

@ -156,7 +156,7 @@
this.Mouseout = HOVER.Mouseout; this.Mouseout = HOVER.Mouseout;
this.Mousemove = HOVER.Mousemove; this.Mousemove = HOVER.Mousemove;
if (!isMSIE) { if (!HUB.Browser.hasMathPlayer) {
// Used in preTranslate to get scaling factors // Used in preTranslate to get scaling factors
this.EmExSpan = HTML.Element("span", this.EmExSpan = HTML.Element("span",
{style:{position:"absolute","font-size-adjust":"none"}}, {style:{position:"absolute","font-size-adjust":"none"}},
@ -173,10 +173,11 @@
}, },
// //
// Set up MathPlayer for IE on the first time through. // Set up MathPlayer for IE on the first time through.
// Get the ex and em sizes.
// //
InitializeMML: function () { InitializeMML: function () {
this.initialized = true; this.initialized = true;
if (isMSIE) { if (HUB.Browser.hasMathPlayer) {
try { try {
// //
// Insert data needed to use MathPlayer for MathML output // Insert data needed to use MathPlayer for MathML output