| 1 |
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */ |
| 2 |
/* vim: set ts=2 et sw=2 tw=80: */ |
| 3 |
|
| 4 |
/************************************************************* |
| 5 |
* |
| 6 |
* MathJax/jax/output/NativeMML/jax.js |
| 7 |
* |
| 8 |
* Implements the NativeMML OutputJax that displays mathematics |
| 9 |
* using a browser's native MathML capabilities (if any). |
| 10 |
* |
| 11 |
* --------------------------------------------------------------------- |
| 12 |
* |
| 13 |
* Copyright (c) 2010-2020 The MathJax Consortium |
| 14 |
* |
| 15 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 16 |
* you may not use this file except in compliance with the License. |
| 17 |
* You may obtain a copy of the License at |
| 18 |
* |
| 19 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 20 |
* |
| 21 |
* Unless required by applicable law or agreed to in writing, software |
| 22 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 23 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 24 |
* See the License for the specific language governing permissions and |
| 25 |
* limitations under the License. |
| 26 |
*/ |
| 27 |
|
| 28 |
(function (nMML,HUB,AJAX,HTML) { |
| 29 |
var MML, isMSIE = HUB.Browser.isMSIE; |
| 30 |
|
| 31 |
var EVENT, TOUCH, HOVER, ZOOM; // filled in later |
| 32 |
|
| 33 |
HUB.Register.StartupHook("MathZoom Ready",function () {ZOOM = MathJax.Extension.MathZoom}); |
| 34 |
|
| 35 |
var NOPADDING = function (side,obj) { |
| 36 |
var span = HTML.Element("span"); side = "padding"+side; |
| 37 |
if (obj) { |
| 38 |
span.style.cssText = (obj.getAttribute("style")||""); |
| 39 |
if (span.style.padding === "" && (span.style[side]||"") === "") { |
| 40 |
span.style[side] = "0px"; obj.setAttribute("style",span.style.cssText) |
| 41 |
} |
| 42 |
} |
| 43 |
}; |
| 44 |
|
| 45 |
var CELLSPACING = function (obj,rowSpacing,columnSpacing) { |
| 46 |
// |
| 47 |
// Webkit default padding on mtd cells is simply |
| 48 |
// |
| 49 |
// mtd {padding: 0.5ex;} |
| 50 |
// |
| 51 |
// Gecko default padding on mtd cells is |
| 52 |
// |
| 53 |
// mtd {padding-right: 0.4em; |
| 54 |
// padding-left: 0.4em; |
| 55 |
// padding-bottom: 0.5ex; |
| 56 |
// padding-top: 0.5ex;} |
| 57 |
// mtr:first-child > mtd {padding-top: 0ex;} |
| 58 |
// mtr:last-child > mtd {padding-bottom: 0ex;} |
| 59 |
// mtd:first-child {padding-left: 0em;} |
| 60 |
// mtd:last-child {padding-right: 0em;} |
| 61 |
// |
| 62 |
// that is the columnspacing/rowspacing is split into two adjacent cells, |
| 63 |
// and the periphery of boundary cells is set to zero. |
| 64 |
// |
| 65 |
// Here, we will set the left/top padding of each cell to |
| 66 |
// rowSpacing/columnSpacing (or 0px for the leftmost/topmost cells) and |
| 67 |
// reset the right/bottom padding to zero. |
| 68 |
// |
| 69 |
if (obj) { |
| 70 |
var span = HTML.Element("span"); |
| 71 |
span.style.cssText = (obj.getAttribute("style")||""); |
| 72 |
if (span.style.padding === "") { |
| 73 |
var padding = { paddingLeft: columnSpacing, paddingTop: rowSpacing, |
| 74 |
paddingRight: "0px", paddingBottom: "0px" }; |
| 75 |
for (var side in padding) {if (padding.hasOwnProperty(side)) { |
| 76 |
if ((span.style[side]||"") === "") {span.style[side] = padding[side];} |
| 77 |
}} |
| 78 |
} |
| 79 |
obj.setAttribute("style",span.style.cssText); |
| 80 |
} |
| 81 |
}; |
| 82 |
|
| 83 |
nMML.Augment({ |
| 84 |
// |
| 85 |
// User can configure styles |
| 86 |
// |
| 87 |
config: { |
| 88 |
styles: { |
| 89 |
".MathJax_MathML": { |
| 90 |
"font-style": "normal", |
| 91 |
"font-weight": "normal", |
| 92 |
"line-height": "normal", |
| 93 |
"font-size": "100%", |
| 94 |
"font-size-adjust":"none", |
| 95 |
"text-indent": 0, |
| 96 |
"text-align": "left", |
| 97 |
"text-transform": "none", |
| 98 |
"letter-spacing": "normal", |
| 99 |
"word-spacing": "normal", |
| 100 |
"word-wrap": "normal", |
| 101 |
"white-space": "nowrap", |
| 102 |
"float": "none", |
| 103 |
"direction": "ltr", |
| 104 |
"max-width": "none", "max-height": "none", |
| 105 |
"min-width": 0, "min-height": 0, |
| 106 |
border: 0, padding: 0, margin: 0 |
| 107 |
}, |
| 108 |
|
| 109 |
"span.MathJax_MathML": { |
| 110 |
display: "inline!important" |
| 111 |
}, |
| 112 |
|
| 113 |
"div.MathJax_MathML": { |
| 114 |
display: "block!important" |
| 115 |
}, |
| 116 |
|
| 117 |
".MathJax_mmlExBox": { |
| 118 |
display:"block!important", overflow:"hidden", |
| 119 |
height:"1px", width:"60ex", |
| 120 |
"min-height": 0, "max-height":"none", |
| 121 |
padding:0, border: 0, margin: 0 |
| 122 |
} |
| 123 |
} |
| 124 |
}, |
| 125 |
handlesVariants: false, // true if native support for mathvariants |
| 126 |
settings: HUB.config.menuSettings, |
| 127 |
ex: 1, scale: 1, // filled in later |
| 128 |
adjustWidths: [], // array of elements to have their widths adjusted |
| 129 |
|
| 130 |
Config: function () { |
| 131 |
this.SUPER(arguments).Config.call(this); |
| 132 |
if (this.settings.scale) {this.config.scale = this.settings.scale} |
| 133 |
// |
| 134 |
// Insert styling to take account of displayAlign and displayIndent |
| 135 |
// |
| 136 |
if (HUB.config.displayAlign !== "center") { |
| 137 |
var align = HUB.config.displayAlign, indent = HUB.config.displayIndent; |
| 138 |
var def = {"text-align": align+"!important"}; def["margin-"+align] = indent+"!important"; |
| 139 |
HUB.Insert(this.config.styles,{ |
| 140 |
"div.MathJax_MathML": def, |
| 141 |
"div.MathJax_MathML math": {"text-align": align}, |
| 142 |
"div.MathJax_MathContainer > span": {"text-align": align+"!important"} |
| 143 |
}); |
| 144 |
} |
| 145 |
if (!this.require) {this.require = []} |
| 146 |
this.require.push(MathJax.OutputJax.extensionDir+"/MathEvents.js"); |
| 147 |
}, |
| 148 |
Startup: function () { |
| 149 |
// Set up event handling |
| 150 |
EVENT = MathJax.Extension.MathEvents.Event; |
| 151 |
TOUCH = MathJax.Extension.MathEvents.Touch; |
| 152 |
HOVER = MathJax.Extension.MathEvents.Hover; |
| 153 |
this.ContextMenu = EVENT.ContextMenu; |
| 154 |
this.Mousedown = EVENT.AltContextMenu; |
| 155 |
this.Mouseover = HOVER.Mouseover; |
| 156 |
this.Mouseout = HOVER.Mouseout; |
| 157 |
this.Mousemove = HOVER.Mousemove; |
| 158 |
|
| 159 |
if (!HUB.Browser.hasMathPlayer) { |
| 160 |
// Used in preTranslate to get scaling factors |
| 161 |
this.EmExSpan = HTML.Element("span", |
| 162 |
{style:{position:"absolute","font-size-adjust":"none"}}, |
| 163 |
[ |
| 164 |
["div",{className:"MathJax_mmlExBox"}], |
| 165 |
["span",{className:"MathJax_MathML"}] |
| 166 |
] |
| 167 |
); |
| 168 |
MML.math(MML.mspace().With({width:"60ex"})).toNativeMML(this.EmExSpan.lastChild); |
| 169 |
} |
| 170 |
|
| 171 |
// Set up styles |
| 172 |
return AJAX.Styles(this.config.styles); |
| 173 |
}, |
| 174 |
// |
| 175 |
// Set up MathPlayer for IE on the first time through. |
| 176 |
// Get the ex and em sizes. |
| 177 |
// |
| 178 |
InitializeMML: function () { |
| 179 |
this.initialized = true; |
| 180 |
if (HUB.Browser.hasMathPlayer) { |
| 181 |
try { |
| 182 |
// |
| 183 |
// Insert data needed to use MathPlayer for MathML output |
| 184 |
// |
| 185 |
if (!HUB.Browser.mpNamespace) { |
| 186 |
var mathplayer = document.createElement("object"); |
| 187 |
mathplayer.id = "mathplayer"; mathplayer.classid = "clsid:32F66A20-7614-11D4-BD11-00104BD3F987"; |
| 188 |
document.getElementsByTagName("head")[0].appendChild(mathplayer); |
| 189 |
document.namespaces.add("m","http://www.w3.org/1998/Math/MathML"); |
| 190 |
HUB.Browser.mpNamespace = true; |
| 191 |
} |
| 192 |
if (!HUB.Browser.mpImported) { |
| 193 |
document.namespaces.m.doImport("#mathplayer"); |
| 194 |
HUB.Browser.mpImported = true; |
| 195 |
} |
| 196 |
} catch (err) { |
| 197 |
// |
| 198 |
// If that fails, give an alert about security settings |
| 199 |
// |
| 200 |
if (!this.config.noMathPlayerWarning) { |
| 201 |
alert(MathJax.Localization._(["MathML", "MathPlayer"], |
| 202 |
"MathJax was not able to set up MathPlayer.\n\n"+ |
| 203 |
"If MathPlayer is not installed, you need to install it first.\n"+ |
| 204 |
"Otherwise, your security settings may be preventing ActiveX \n"+ |
| 205 |
"controls from running. Use the Internet Options item under\n"+ |
| 206 |
"the Tools menu and select the Security tab, then press the\n"+ |
| 207 |
"Custom Level button. Check that the settings for\n"+ |
| 208 |
"'Run ActiveX Controls', and 'Binary and script behaviors'\n"+ |
| 209 |
"are enabled.\n\n"+ |
| 210 |
"Currently you will see error messages rather than\n"+ |
| 211 |
"typeset mathematics.")); |
| 212 |
} |
| 213 |
} |
| 214 |
} else { |
| 215 |
// |
| 216 |
// Get the default sizes (need styles in place to do this) |
| 217 |
// |
| 218 |
document.body.appendChild(this.EmExSpan); |
| 219 |
this.defaultEx = this.EmExSpan.firstChild.offsetWidth/60; |
| 220 |
this.defaultMEx = this.EmExSpan.lastChild.offsetWidth/60; |
| 221 |
document.body.removeChild(this.EmExSpan); |
| 222 |
} |
| 223 |
}, |
| 224 |
|
| 225 |
preTranslate: function (state) { |
| 226 |
var scripts = state.jax[this.id], i, m = scripts.length, |
| 227 |
script, prev, span, test, math, jax, ex, mex, scale; |
| 228 |
for (i = 0; i < m; i++) { |
| 229 |
script = scripts[i]; if (!script.parentNode) continue; |
| 230 |
if (!this.initialized) {this.InitializeMML()} |
| 231 |
// |
| 232 |
// Remove any existing output |
| 233 |
// |
| 234 |
prev = script.previousSibling; |
| 235 |
if (prev && prev.className === "MathJax_MathML") {prev.parentNode.removeChild(prev)} |
| 236 |
// |
| 237 |
// Add the MathJax span |
| 238 |
// |
| 239 |
jax = script.MathJax.elementJax; if (!jax) continue; |
| 240 |
math = jax.root; jax.NativeMML = {}; |
| 241 |
var type = (math.Get("display") === "block" ? "div" : "span"); |
| 242 |
span = HTML.Element(type,{ |
| 243 |
className: "MathJax_MathML", id:jax.inputID+"-Frame" |
| 244 |
},[["span",{ |
| 245 |
className:"MathJax_MathContainer", isMathJax: true, jaxID:this.id, |
| 246 |
style:{position:"relative", display:"inline-block", "white-space":"nowrap"} |
| 247 |
}, [["span",{isMathJax:true, style:{display:"inline-block"}}]] // for Firefox hover and zoom |
| 248 |
]]); |
| 249 |
script.parentNode.insertBefore(span,script); |
| 250 |
// |
| 251 |
// Add the test span for determining scales |
| 252 |
// |
| 253 |
if (!isMSIE) {script.parentNode.insertBefore(this.EmExSpan.cloneNode(true),script)} |
| 254 |
} |
| 255 |
// |
| 256 |
// Determine the scaling factors for each script |
| 257 |
// (this only requires one reflow rather than a reflow for each equation) |
| 258 |
// |
| 259 |
for (i = 0; i < m; i++) { |
| 260 |
script = scripts[i]; if (!script.parentNode) continue; |
| 261 |
jax = script.MathJax.elementJax; if (!jax) continue; |
| 262 |
if (!isMSIE) { |
| 263 |
test = script.previousSibling; |
| 264 |
ex = test.firstChild.offsetWidth/60; |
| 265 |
mex = test.lastChild.offsetWidth/60; |
| 266 |
if (ex === 0 || ex === "NaN") {ex = this.defaultEx; mex = this.defaultMEx} |
| 267 |
scale = (this.config.matchFontHeight && mex > 1 ? ex/mex : 1); |
| 268 |
scale = Math.floor(Math.max(this.config.minScaleAdjust/100,scale) * this.config.scale); |
| 269 |
jax.NativeMML.ex = ex; jax.NativeMML.mex = mex; |
| 270 |
} else {scale = 100} |
| 271 |
jax.NativeMML.fontSize = scale+"%"; |
| 272 |
jax.NativeMML.scale = scale/100; |
| 273 |
} |
| 274 |
// |
| 275 |
// Remove the test spans used for determining scales |
| 276 |
// |
| 277 |
if (!isMSIE) { |
| 278 |
for (i = 0; i < m; i++) { |
| 279 |
script = scripts[i]; |
| 280 |
if (script.parentNode && script.MathJax.elementJax) { |
| 281 |
script.parentNode.removeChild(script.previousSibling); |
| 282 |
} |
| 283 |
} |
| 284 |
} |
| 285 |
}, |
| 286 |
|
| 287 |
// |
| 288 |
// Add a SPAN to use as a container, and render the math into it |
| 289 |
// |
| 290 |
Translate: function (script) { |
| 291 |
if (!script.parentNode) return; |
| 292 |
// |
| 293 |
// Get the jax and the container and set the size |
| 294 |
// |
| 295 |
var jax = script.MathJax.elementJax, math = jax.root; |
| 296 |
var span = document.getElementById(jax.inputID+"-Frame"); if (!span) return; |
| 297 |
var container = span.firstChild, mspan = container.firstChild; |
| 298 |
this.ex = jax.NativeMML.ex || this.defaultEx; |
| 299 |
this.scale = jax.NativeMML.scale || 1; |
| 300 |
if (this.scale !== 1) {span.style.fontSize = jax.NativeMML.fontSize} |
| 301 |
// |
| 302 |
// Convert to MathML (if restarted, remove any partial math) |
| 303 |
// |
| 304 |
try {math.toNativeMML(mspan,jax)} catch (err) { |
| 305 |
if (err.restart) {while (mspan.firstChild) {mspan.removeChild(mspan.firstChild)}} |
| 306 |
throw err; |
| 307 |
} |
| 308 |
// |
| 309 |
// Add event handlers |
| 310 |
// |
| 311 |
if (isMSIE) { |
| 312 |
if (container.addEventListener) { |
| 313 |
for (var id in this.MSIE9events) {if (this.MSIE9events.hasOwnProperty(id)) { |
| 314 |
container.addEventListener(id,this.MSIE9event,true); |
| 315 |
}} |
| 316 |
} else { |
| 317 |
var config = (this.config.showMathMenuMSIE != null ? this : HUB).config; |
| 318 |
if (config.showMathMenuMSIE && !this.settings.mpContext && !this.settings.mpMouse) |
| 319 |
{this.MSIEoverlay(container)} else |
| 320 |
{container.style.position = ""; mspan.firstChild.onmousedown = this.MSIEaltMenu} |
| 321 |
} |
| 322 |
} else { |
| 323 |
container.oncontextmenu = EVENT.Menu; |
| 324 |
container.onmouseover = EVENT.Mouseover; |
| 325 |
container.onmouseout = EVENT.Mouseout; |
| 326 |
container.onmousedown = EVENT.Mousedown; |
| 327 |
container.onclick = EVENT.Click; |
| 328 |
container.ondblclick = EVENT.DblClick; |
| 329 |
// Added for keyboard accessible menu. |
| 330 |
container.onkeydown = EVENT.Keydown; |
| 331 |
container.tabIndex = HUB.getTabOrder(jax); |
| 332 |
if (HUB.Browser.noContextMenu) { |
| 333 |
container.ontouchstart = TOUCH.start; |
| 334 |
container.ontouchend = TOUCH.end; |
| 335 |
} |
| 336 |
} |
| 337 |
}, |
| 338 |
|
| 339 |
postTranslate: function (state) { |
| 340 |
if (this.forceReflow) { |
| 341 |
// |
| 342 |
// Firefox messes up some mtable's when they are dynamically created |
| 343 |
// but gets them right on a reflow, so force reflow by toggling a stylesheet |
| 344 |
// |
| 345 |
var sheet = (document.styleSheets||[])[0]||{}; |
| 346 |
sheet.disabled = true; sheet.disabled = false; |
| 347 |
} |
| 348 |
}, |
| 349 |
|
| 350 |
// |
| 351 |
// Remove MathML preceding the script |
| 352 |
// |
| 353 |
Remove: function (jax) { |
| 354 |
var span = jax.SourceElement(); if (!span) return; |
| 355 |
span = span.previousSibling; if (!span) return; |
| 356 |
if (span.className.match(/MathJax_MathML/)) {span.parentNode.removeChild(span)} |
| 357 |
}, |
| 358 |
// |
| 359 |
// The namespace to use for MML |
| 360 |
// |
| 361 |
MMLnamespace: "http://www.w3.org/1998/Math/MathML", |
| 362 |
|
| 363 |
isFullWidth: function (node) { |
| 364 |
if (!node) return; |
| 365 |
var width = node.getAttribute("width") || |
| 366 |
(String(node.getAttribute("style")).match(/(?:^| )width: *([^; ]*)/)||[])[1]; |
| 367 |
if (width) return !!width.match(/%/); |
| 368 |
if (node.nodeName.match(/^(semantics|math|mstyle)$/)) { |
| 369 |
width = this.isFullWidth(node.firstChild); |
| 370 |
} else if (node.nodeName.toLowerCase() === "mrow") { |
| 371 |
for (var i = 0, m = node.childNodes.length; i < m && !width; i++) |
| 372 |
width = this.isFullWidth(node.childNodes[i]); |
| 373 |
} |
| 374 |
if (width) { |
| 375 |
var style = "width:100%; "+(node.getAttribute("style")||""); |
| 376 |
node.setAttribute("style",style.replace(/ +$/,"")); |
| 377 |
} |
| 378 |
return width; |
| 379 |
}, |
| 380 |
|
| 381 |
// |
| 382 |
// For MSIE, we must overlay the MathPlayer object to trap the events |
| 383 |
// (since they can't be cancelled when the events are on the <math> tag |
| 384 |
// itself). The events we DON'T want are transferred to the math element, |
| 385 |
// and the others are handled directly. |
| 386 |
// |
| 387 |
MSIEoverlay: function (span) { |
| 388 |
var math = span.firstChild; |
| 389 |
if (math.nodeName.toLowerCase() === "span") {math = math.firstChild} |
| 390 |
var bbox = this.getHoverBBox(null,math,{}); |
| 391 |
HTML.addElement(span,"span",{ |
| 392 |
style:{display:"inline-block", width:0, height:0, position:"relative"} |
| 393 |
},[["span",{isMathJax: true, className: "MathJax_MathPlayer_Overlay", |
| 394 |
style:{ |
| 395 |
display:"inline-block", position:"absolute", |
| 396 |
left:HOVER.Px(-bbox.w), top:HOVER.Px(-bbox.h-(bbox.y||0)-1), |
| 397 |
width:HOVER.Px(bbox.w), height:HOVER.Px(bbox.h+bbox.d), cursor:"pointer", |
| 398 |
"background-color":"white", filter:"alpha(opacity=0)" |
| 399 |
} |
| 400 |
}]]); |
| 401 |
HUB.Insert(span,{ |
| 402 |
msieMath: math, |
| 403 |
onmousedown: this.MSIEevent, oncontextmenu: this.MSIEevent, onclick: this.MSIEevent, |
| 404 |
onmouseup: this.MSIEevent, onmousemove: this.MSIEevent, ondblclick: this.MSIEevent, |
| 405 |
onmouseover: this.MSIEevent, onmouseout: this.MSIEevent |
| 406 |
}); |
| 407 |
}, |
| 408 |
MSIEevents: { |
| 409 |
mousedown:"Mousedown", contextmenu:"ContextMenu", click:"Click", |
| 410 |
mouseup:"Mouseup", mousemove:"Mousemove", dblclick: "DblClick", |
| 411 |
mouseover:"Mouseover", mouseout:"Mouseout" |
| 412 |
}, |
| 413 |
MSIEevent: function () { |
| 414 |
var event = window.event; |
| 415 |
var type = nMML.MSIEevents[event.type]; |
| 416 |
if (nMML[type] && nMML[type](event,this) === false) {return false} |
| 417 |
if (ZOOM && ZOOM.HandleEvent(event,type,this) === false) {return false} |
| 418 |
if (event.srcElement.className === "MathJax_MathPlayer_Overlay" && this.msieMath.fireEvent) { |
| 419 |
// |
| 420 |
// For now, ignore all other events. This will disable MathPlayer's zoom |
| 421 |
// feature, but also its <maction> support. |
| 422 |
// |
| 423 |
if (type === "ContextMenu" || type === "Mouseover" || type === "Mouseout") |
| 424 |
{this.msieMath.fireEvent("on"+event.type,event)} |
| 425 |
} |
| 426 |
return EVENT.False(event); |
| 427 |
}, |
| 428 |
MSIEaltMenu: function () { |
| 429 |
var container = this.parentNode.parentNode; |
| 430 |
while (!container.jaxID) {container = container.parentNode} |
| 431 |
EVENT.AltContextMenu(window.event,container); |
| 432 |
}, |
| 433 |
|
| 434 |
MSIE9events: { |
| 435 |
contextmenu:"Menu", click:"Click", dblclick: "DblClick", |
| 436 |
mouseup:"False", mouseover:"Mouseover", mouseout:"Mouseout" |
| 437 |
}, |
| 438 |
MSIE9event: function (event) { |
| 439 |
if (event.type === "contextmenu" && nMML.settings.mpContext) {return true} |
| 440 |
if (event.type === "mouseup" && nMML.settings.mpMouse) {return true} |
| 441 |
if (event.type === "click" && nMML.settings.mpContext) |
| 442 |
{return EVENT.AltContextMenu(event,this)} |
| 443 |
var type = nMML.MSIE9events[event.type]; |
| 444 |
return EVENT[type].call(this,event); |
| 445 |
}, |
| 446 |
|
| 447 |
getJaxFromMath: function (math) { |
| 448 |
math = math.parentNode; |
| 449 |
do {math = math.nextSibling} while (math && math.nodeName.toLowerCase() !== "script"); |
| 450 |
return HUB.getJaxFor(math); |
| 451 |
}, |
| 452 |
getHoverSpan: function (jax,math) {return math.firstChild}, |
| 453 |
getHoverBBox: function (jax,span,math) {return EVENT.getBBox(span.parentNode)}, |
| 454 |
|
| 455 |
Zoom: function (jax,span,math,Mw,Mh) { |
| 456 |
jax.root.toNativeMML(span); |
| 457 |
if (this.msieIE8HeightBug) {span.style.position = "absolute"} |
| 458 |
if (nMML.widthBug) {span.style.width = span.parentNode.style.width = ""} |
| 459 |
if (span.parentNode.style.width.match(/%$/)) |
| 460 |
{span.parentNode.style.minWidth = Math.ceil(3*Mh/4)+"px"} // for full-width tables |
| 461 |
var mW = math.offsetWidth || math.scrollWidth, |
| 462 |
mH = math.offsetHeight || math.scrollHeight; |
| 463 |
var zW = span.offsetWidth, zH = span.offsetHeight; |
| 464 |
if (nMML.widthBug || span.style.width.match(/%/)) { |
| 465 |
// |
| 466 |
// FF doesn't get width of <math> right, so get it from <mrow> |
| 467 |
// |
| 468 |
var W = span.firstChild.firstChild.scrollWidth; |
| 469 |
if (W > zW) {zW = W; span.parentNode.style.width = span.style.minWidth = zW + "px";} |
| 470 |
} |
| 471 |
if (this.msieIE8HeightBug) {span.style.position = ""} |
| 472 |
return {Y:-EVENT.getBBox(span.parentNode).h, mW:mW, mH:mH, zW:zW, zH:zH} |
| 473 |
}, |
| 474 |
|
| 475 |
NAMEDSPACE: { |
| 476 |
negativeveryverythinmathspace: "-.0556em", |
| 477 |
negativeverythinmathspace: "-.1111em", |
| 478 |
negativethinmathspace: "-.1667em", |
| 479 |
negativemediummathspace: "-.2222em", |
| 480 |
negativethickmathspace: "-.2778em", |
| 481 |
negativeverythickmathspace: "-.3333em", |
| 482 |
negativeveryverythickmathspace: "-.3889em", |
| 483 |
veryverythinmathspace: ".0556em", |
| 484 |
verythinmathspace: ".1111em", |
| 485 |
thinmathspace: ".1667em", |
| 486 |
mediummathspace: ".2222em", |
| 487 |
thickmathspace: ".2778em", |
| 488 |
verythickmathspace: ".3333em", |
| 489 |
veryverythickmathspace: ".3889em" |
| 490 |
} |
| 491 |
}); |
| 492 |
|
| 493 |
HUB.Register.StartupHook("mml Jax Ready",function () { |
| 494 |
|
| 495 |
MML = MathJax.ElementJax.mml; |
| 496 |
|
| 497 |
MML.mbase.Augment({ |
| 498 |
// |
| 499 |
// Add a MathML tag of the correct type, and set its attributes |
| 500 |
// then populate it with its children and append it to the parent |
| 501 |
// |
| 502 |
toNativeMML: function (parent) { |
| 503 |
var tag = this.NativeMMLelement(this.type); |
| 504 |
this.NativeMMLattributes(tag); |
| 505 |
for (var i = 0, m = this.data.length; i < m; i++) { |
| 506 |
if (this.data[i]) {this.data[i].toNativeMML(tag)} |
| 507 |
else {tag.appendChild(this.NativeMMLelement("mrow"))} |
| 508 |
} |
| 509 |
parent.appendChild(tag); |
| 510 |
}, |
| 511 |
// |
| 512 |
// Look for attributes that are different from the defaults |
| 513 |
// and set those in the tag's attribute list |
| 514 |
// |
| 515 |
NativeMMLattributes: function (tag) { |
| 516 |
var defaults = (this.type === "mstyle" ? MML.math.prototype.defaults : this.defaults); |
| 517 |
var names = (this.attrNames||MML.copyAttributeNames), |
| 518 |
skip = MML.skipAttributes, copy = MML.copyAttributes; |
| 519 |
if (!this.attrNames) { |
| 520 |
for (var id in defaults) {if (!skip[id] && !copy[id] && defaults.hasOwnProperty(id)) { |
| 521 |
if (this[id] != null && this[id] !== defaults[id]) { |
| 522 |
if (this.Get(id,null,1) !== this[id]) |
| 523 |
tag.setAttribute(id,this.NativeMMLattribute(this[id])); |
| 524 |
} |
| 525 |
}} |
| 526 |
} |
| 527 |
for (var i = 0, m = names.length; i < m; i++) { |
| 528 |
if (copy[names[i]] === 1 && !defaults.hasOwnProperty(names[i])) continue; |
| 529 |
var value = (this.attr||{})[names[i]]; if (value == null) {value = this[names[i]]} |
| 530 |
if (value != null) {tag.setAttribute(names[i],this.NativeMMLattribute(value))} |
| 531 |
} |
| 532 |
this.NativeMMLclass(tag); |
| 533 |
}, |
| 534 |
NativeMMLclass: function (tag) { |
| 535 |
var CLASS = []; if (this["class"]) {CLASS.push(this["class"])} |
| 536 |
if (this.isa(MML.TeXAtom)) { |
| 537 |
var TEXCLASS = ["ORD","OP","BIN","REL","OPEN","CLOSE","PUNCT","INNER","VCENTER"][this.texClass]; |
| 538 |
if (TEXCLASS) { |
| 539 |
CLASS.push("MJX-TeXAtom-"+TEXCLASS) |
| 540 |
if (TEXCLASS === "OP" && !this.movablelimits) CLASS.push("MJX-fixedlimits"); |
| 541 |
} |
| 542 |
} |
| 543 |
if (this.mathvariant && this.NativeMMLvariants[this.mathvariant]) |
| 544 |
{CLASS.push("MJX"+this.mathvariant)} |
| 545 |
if (this.variantForm) {CLASS.push("MJX-variant")} |
| 546 |
if (CLASS.length) {tag.setAttribute("class",CLASS.join(" "))} |
| 547 |
}, |
| 548 |
NativeMMLattribute: function (value) { |
| 549 |
value = String(value); |
| 550 |
if (nMML.NAMEDSPACE[value]) {value = nMML.NAMEDSPACE[value]} // MP doesn't do negative spaces |
| 551 |
else if (value.match(/^\s*(([-+])?(\d+(\.\d*)?|\.\d+))\s*mu\s*$/)) |
| 552 |
{value = (RegExp.$2||"")+((1/18)*RegExp.$3).toFixed(3).replace(/\.?0+$/,"")+"em"} // FIXME: should take scriptlevel into account |
| 553 |
else if (this.NativeMMLvariants[value]) {value = this.NativeMMLvariants[value]} |
| 554 |
return value; |
| 555 |
}, |
| 556 |
NativeMMLvariants: { |
| 557 |
"-tex-caligraphic": MML.VARIANT.SCRIPT, |
| 558 |
"-tex-caligraphic-bold": MML.VARIANT.BOLDSCRIPT, |
| 559 |
"-tex-oldstyle": MML.VARIANT.NORMAL, |
| 560 |
"-tex-oldstyle-bold": MML.VARIANT.BOLD, |
| 561 |
"-tex-mathit": MML.VARIANT.ITALIC |
| 562 |
}, |
| 563 |
// |
| 564 |
// Create a MathML element |
| 565 |
// |
| 566 |
NativeMMLelement: function (type) { |
| 567 |
var math = ( HUB.Browser.mpNamespace ? document.createElement("m:"+type) : |
| 568 |
(document.createElementNS ? document.createElementNS(nMML.MMLnamespace,type) : |
| 569 |
document.createElement(type))); |
| 570 |
math.isMathJax = true; |
| 571 |
return math; |
| 572 |
} |
| 573 |
}); |
| 574 |
|
| 575 |
MML.mrow.Augment({ |
| 576 |
// |
| 577 |
// Make inferred rows not include an mrow tag |
| 578 |
// |
| 579 |
toNativeMML: function (parent) { |
| 580 |
var i, m; |
| 581 |
if (this.inferred && this.parent.inferRow) { |
| 582 |
for (i = 0, m = this.data.length; i < m; i++) { |
| 583 |
if (this.data[i]) {this.data[i].toNativeMML(parent)} |
| 584 |
else {parent.appendChild(this.NativeMMLelement("mrow"))} |
| 585 |
} |
| 586 |
} else if (nMML.stretchyMoBug && (this.open || this.close)) { |
| 587 |
// |
| 588 |
// This element contains opening and/or closing fences. Opera is not |
| 589 |
// able to stretch <mo> operators, so let's use an <mfenced> element |
| 590 |
// instead. |
| 591 |
// |
| 592 |
var mfenced = this.NativeMMLelement("mfenced"); |
| 593 |
this.NativeMMLattributes(mfenced); |
| 594 |
i = 0, m = this.data.length; |
| 595 |
if (this.open) { mfenced.setAttribute("open", this.open); i++; } |
| 596 |
if (this.close) { mfenced.setAttribute("close", this.close); m--; } |
| 597 |
var tag = mfenced; |
| 598 |
if (m - i + 1 > 1) { |
| 599 |
// |
| 600 |
// If there are several children, put them in an <mrow> |
| 601 |
// |
| 602 |
tag = this.NativeMMLelement("mrow"); |
| 603 |
parent.appendChild(mfenced); |
| 604 |
parent = mfenced; |
| 605 |
} |
| 606 |
for (; i < m; i++) { |
| 607 |
if (this.data[i]) {this.data[i].toNativeMML(tag)} |
| 608 |
else {tag.appendChild(this.NativeMMLelement("mrow"))} |
| 609 |
} |
| 610 |
parent.appendChild(tag); |
| 611 |
} else { |
| 612 |
this.SUPER(arguments).toNativeMML.call(this,parent); |
| 613 |
} |
| 614 |
} |
| 615 |
}); |
| 616 |
|
| 617 |
MML.msubsup.Augment({ |
| 618 |
// |
| 619 |
// Use proper version of msub, msup, or msubsup, depending on |
| 620 |
// which items are present |
| 621 |
// |
| 622 |
toNativeMML: function (parent) { |
| 623 |
var type = this.type; |
| 624 |
if (this.data[this.sup] == null) {type = "msub"} |
| 625 |
if (this.data[this.sub] == null) {type = "msup"} |
| 626 |
var tag = this.NativeMMLelement(type); |
| 627 |
this.NativeMMLattributes(tag); |
| 628 |
if (this.data[0]) {delete this.data[0].inferred} |
| 629 |
for (var i = 0, m = this.data.length; i < m; i++) |
| 630 |
{if (this.data[i]) {this.data[i].toNativeMML(tag)}} |
| 631 |
parent.appendChild(tag); |
| 632 |
} |
| 633 |
}); |
| 634 |
|
| 635 |
MML.munderover.Augment({ |
| 636 |
// |
| 637 |
// Use proper version of munder, mover, or munderover, depending on |
| 638 |
// which items are present. Handle movablelimits on TeXAtom base. |
| 639 |
// |
| 640 |
toNativeMML: function (parent) { |
| 641 |
var type = this.type; |
| 642 |
var base = this.data[this.base]; |
| 643 |
if (base && base.isa(MML.TeXAtom) && base.movablelimits && !base.Get("displaystyle")) { |
| 644 |
type = "msubsup"; |
| 645 |
if (this.data[this.under] == null) {type = "msup"} |
| 646 |
if (this.data[this.over] == null) {type = "msub"} |
| 647 |
} else { |
| 648 |
if (this.data[this.under] == null) {type = "mover"} |
| 649 |
if (this.data[this.over] == null) {type = "munder"} |
| 650 |
} |
| 651 |
var tag = this.NativeMMLelement(type); |
| 652 |
this.NativeMMLattributes(tag); |
| 653 |
if (this.data[0]) {delete this.data[0].inferred} |
| 654 |
for (var i = 0, m = this.data.length; i < m; i++) |
| 655 |
{if (this.data[i]) {this.data[i].toNativeMML(tag)}} |
| 656 |
parent.appendChild(tag); |
| 657 |
} |
| 658 |
}); |
| 659 |
|
| 660 |
if (!isMSIE) { |
| 661 |
var SPLIT = HUB.SplitList; |
| 662 |
MML.mtable.Augment({ |
| 663 |
toNativeMML: function (parent) { |
| 664 |
var i, m; |
| 665 |
if (nMML.tableSpacingBug) { |
| 666 |
// |
| 667 |
// Parse the rowspacing/columnspacing. For convenience, we convert |
| 668 |
// them to a left/top padding value that will be applied to each |
| 669 |
// cell. The leftmost/topmost cells will use "0px". |
| 670 |
// |
| 671 |
var values = this.getValues("rowspacing", "columnspacing"); |
| 672 |
this.nMMLtopPadding = SPLIT("0px "+values.rowspacing); |
| 673 |
this.nMMLleftPadding = SPLIT("0px "+values.columnspacing); |
| 674 |
// |
| 675 |
// Transmit the top padding to each row. |
| 676 |
// If this.parent.nMML.topPadding does not contain enough value, |
| 677 |
// repeat the last one. |
| 678 |
// |
| 679 |
var tp = this.nMMLtopPadding, M = tp.length; |
| 680 |
for (i = 0, m = this.data.length; i < m; i++) { |
| 681 |
if (this.data[i]) |
| 682 |
{this.data[i].nMMLtopPadding = tp[i < M ? i : M-1]} |
| 683 |
} |
| 684 |
} |
| 685 |
if (nMML.tableLabelBug) { |
| 686 |
// |
| 687 |
// Look for labeled rows so we know how to handle them |
| 688 |
// |
| 689 |
for (i = 0, m = this.data.length; i < m; i++) { |
| 690 |
if (this.data[i] && this.data[i].isa(MML.mlabeledtr)) { |
| 691 |
var align = HUB.config.displayAlign.charAt(0), |
| 692 |
side = this.Get("side").charAt(0); |
| 693 |
this.nMMLhasLabels = true; |
| 694 |
this.nMMLlaMatch = (align === side); |
| 695 |
this.nMMLforceWidth = |
| 696 |
(align === "c" || !!((this.width||"").match("%"))); |
| 697 |
break; |
| 698 |
} |
| 699 |
} |
| 700 |
} |
| 701 |
// |
| 702 |
// Firefox < 13 doesn't handle width, so put it in styles instead |
| 703 |
// |
| 704 |
if (this.width && this.ffTableWidthBug) { |
| 705 |
var styles = (this.style||"").replace(/;\s*$/,"").split(";"); |
| 706 |
if (styles[0] === "") {styles.shift()} |
| 707 |
styles.push("width:"+this.width); |
| 708 |
this.style = styles.join(";"); |
| 709 |
} |
| 710 |
this.SUPER(arguments).toNativeMML.call(this,parent); |
| 711 |
// |
| 712 |
if (this.nMMLhasLabels) { |
| 713 |
var mtable = parent.firstChild; |
| 714 |
// |
| 715 |
// Add column attributes on the left when extra columns where inserted |
| 716 |
// |
| 717 |
if (this.nMMLforceWidth || side !== "r") { |
| 718 |
var n = (align !== "l" ? 1 : 0) + (side === "l" ? 1 : 0); |
| 719 |
if (n) { |
| 720 |
var attr = {columnalign:"left", columnwidth:"auto", |
| 721 |
columnspacing:"0px", columnlines:"none"}; |
| 722 |
for (var id in attr) {if (attr.hasOwnProperty(id) && this[id]) { |
| 723 |
var cols = [attr[id],attr[id]].slice(2-n).join(" ")+" "; |
| 724 |
mtable.setAttribute(id,cols+mtable.getAttribute(id)); |
| 725 |
}} |
| 726 |
} |
| 727 |
} |
| 728 |
// |
| 729 |
// Force the table width to 100% when needed |
| 730 |
// |
| 731 |
if (this.nMMLforceWidth || !this.nMMLlaMatch) |
| 732 |
{mtable.setAttribute("width","100%")} |
| 733 |
} |
| 734 |
} |
| 735 |
}); |
| 736 |
MML.mtr.Augment({ |
| 737 |
toNativeMML: function (parent) { |
| 738 |
this.SUPER(arguments).toNativeMML.call(this,parent); |
| 739 |
var mtr = parent.lastChild; |
| 740 |
if (nMML.tableSpacingBug) { |
| 741 |
// |
| 742 |
// Set the row/column spacing. If this.parent.nMMLleftPadding does |
| 743 |
// not contain enough value, repeat the last one. |
| 744 |
// |
| 745 |
var lp = this.parent.nMMLleftPadding, M = lp.length; |
| 746 |
for (var mtd = mtr.firstChild, i = 0; mtd; mtd = mtd.nextSibling, i++) { |
| 747 |
CELLSPACING(mtd,this.nMMLtopPadding,lp[i < M ? i : M-1]); |
| 748 |
} |
| 749 |
} |
| 750 |
|
| 751 |
if (nMML.tableLabelBug) { |
| 752 |
var forceWidth = this.parent.nMMLforceWidth, |
| 753 |
side = this.parent.Get("side").charAt(0), |
| 754 |
align = HUB.config.displayAlign.charAt(0); |
| 755 |
|
| 756 |
if (this.parent.nMMLhasLabels && mtr.firstChild) { |
| 757 |
// |
| 758 |
// If we add a label or padding column on the left of mlabeledtr, |
| 759 |
// mirror that here and remove padding from first table mtd |
| 760 |
// so the spacing is consistent with unlabeled equations |
| 761 |
// |
| 762 |
if (forceWidth || side !== "r") { |
| 763 |
NOPADDING("Left",mtr.firstChild); |
| 764 |
if (align !== "l") { |
| 765 |
mtr.insertBefore(this.NativeMMLelement("mtd"),mtr.firstChild) |
| 766 |
.setAttribute("style","padding:0"); |
| 767 |
} |
| 768 |
if (side === "l") { |
| 769 |
mtr.insertBefore(this.NativeMMLelement("mtd"),mtr.firstChild) |
| 770 |
.setAttribute("style","padding:0"); |
| 771 |
} |
| 772 |
} |
| 773 |
// |
| 774 |
// If columns were added on the right, remove mtd padding |
| 775 |
// so that spacing is consistent with unlabled equations |
| 776 |
// |
| 777 |
if (forceWidth || side !== "l") {NOPADDING("Right",mtr.lastChild)} |
| 778 |
} |
| 779 |
} |
| 780 |
} |
| 781 |
}); |
| 782 |
MML.mlabeledtr.Augment({ |
| 783 |
toNativeMML: function (parent) { |
| 784 |
var mtr = this.NativeMMLelement("mtr"); |
| 785 |
this.NativeMMLattributes(mtr); |
| 786 |
// |
| 787 |
// Add row data |
| 788 |
// |
| 789 |
for (var i = 1, m = this.data.length; i < m; i++) { |
| 790 |
if (this.data[i]) {this.data[i].toNativeMML(mtr)} |
| 791 |
else {mtr.appendChild(this.NativeMMLelement("mtd"))} |
| 792 |
} |
| 793 |
|
| 794 |
if (nMML.tableSpacingBug) { |
| 795 |
// |
| 796 |
// Set the row/column spacing. If this.parent.nMMLleftPadding does |
| 797 |
// not contain enough value, repeat the last one. |
| 798 |
// |
| 799 |
var lp = this.parent.nMMLleftPadding, M = lp.length; i = 0; |
| 800 |
for (var mtd = mtr.firstChild; mtd; mtd = mtd.nextSibling, i++) { |
| 801 |
CELLSPACING(mtd,this.nMMLtopPadding,lp[i < M ? i : M-1]); |
| 802 |
} |
| 803 |
} |
| 804 |
|
| 805 |
if (nMML.tableLabelBug && this.data[0]) { |
| 806 |
var side = this.parent.Get("side").charAt(0), |
| 807 |
align = HUB.config.displayAlign.charAt(0), |
| 808 |
indent = HUB.config.displayIndent; |
| 809 |
// |
| 810 |
// Create label and either set the column width (if label is on the |
| 811 |
// same side as the alignment), or use mpadded to hide the label |
| 812 |
// width |
| 813 |
// |
| 814 |
this.data[0].toNativeMML(mtr); |
| 815 |
var label = mtr.lastChild, pad = label; |
| 816 |
if (side === align) { |
| 817 |
label.setAttribute("style","width:"+indent); |
| 818 |
label.setAttribute("columnalign",HUB.config.displayAlign); |
| 819 |
} else { |
| 820 |
pad = this.NativeMMLelement("mpadded"); |
| 821 |
pad.setAttribute("style","width:0"); |
| 822 |
pad.setAttribute("width","0px"); |
| 823 |
pad.appendChild(label.firstChild); |
| 824 |
label.appendChild(pad); |
| 825 |
} |
| 826 |
NOPADDING("",label); mtr.removeChild(label); |
| 827 |
// |
| 828 |
// Get spacing to use for separation of label from main table |
| 829 |
// |
| 830 |
var width = 100, forceWidth = this.parent.nMMLforceWidth; |
| 831 |
if ((this.parent.width||"").match(/%/)) { |
| 832 |
width -= parseFloat(this.parent.width) |
| 833 |
}; |
| 834 |
var w = width; |
| 835 |
// |
| 836 |
// Add spacing (and possibly label) at the left if needed |
| 837 |
// |
| 838 |
if (forceWidth || side !== "r") { |
| 839 |
NOPADDING("Left",mtr.firstChild); |
| 840 |
if (align !== "l") { |
| 841 |
if (align === "c") {w /= 2}; width -= w; |
| 842 |
mtr.insertBefore(this.NativeMMLelement("mtd"),mtr.firstChild) |
| 843 |
.setAttribute("style","padding:0;width:"+w+"%"); |
| 844 |
} |
| 845 |
if (side === "l") {mtr.insertBefore(label,mtr.firstChild)} |
| 846 |
} |
| 847 |
// |
| 848 |
// Add spacing (and possibly label) at the right if needed |
| 849 |
// |
| 850 |
if (forceWidth || side !== "l") { |
| 851 |
NOPADDING("Right",mtr.lastChild); |
| 852 |
if (align !== "r") { |
| 853 |
mtr.appendChild(this.NativeMMLelement("mtd")) |
| 854 |
.setAttribute("style","padding:0;width:"+width+"%"); |
| 855 |
} |
| 856 |
if (side === "r") { |
| 857 |
if (side !== align) {pad.setAttribute("lspace","-1width")} |
| 858 |
mtr.appendChild(label); |
| 859 |
} |
| 860 |
} |
| 861 |
} |
| 862 |
// |
| 863 |
// Add row to table |
| 864 |
// |
| 865 |
parent.appendChild(mtr); |
| 866 |
} |
| 867 |
}); |
| 868 |
|
| 869 |
MML.mtd.Augment({ |
| 870 |
toNativeMML: function (parent) { |
| 871 |
var tag = parent.appendChild(this.NativeMMLelement(this.type)); |
| 872 |
this.NativeMMLattributes(tag); |
| 873 |
if (nMML.mtdWidthBug) { |
| 874 |
nMML.adjustWidths.push(tag); |
| 875 |
tag = tag.appendChild(this.NativeMMLelement("mrow")); |
| 876 |
} |
| 877 |
for (var i = 0, m = this.data.length; i < m; i++) { |
| 878 |
if (this.data[i]) {this.data[i].toNativeMML(tag)} |
| 879 |
else {tag.appendChild(this.NativeMMLelement("mrow"))} |
| 880 |
} |
| 881 |
} |
| 882 |
}); |
| 883 |
|
| 884 |
MML.mspace.Augment({ |
| 885 |
toNativeMML: function (parent) { |
| 886 |
this.SUPER(arguments).toNativeMML.call(this,parent); |
| 887 |
if (nMML.spaceWidthBug && this.width) { |
| 888 |
var mspace = parent.lastChild; |
| 889 |
var width = mspace.getAttribute("width"); |
| 890 |
var style = (mspace.getAttribute("style") || "").replace(/;?\s*/,"; "); |
| 891 |
mspace.setAttribute("style",style+"width:"+width); |
| 892 |
} |
| 893 |
} |
| 894 |
}); |
| 895 |
|
| 896 |
MML.mn.Augment({ |
| 897 |
NativeMMLremapMinus: function (text) {return text.replace(/^-/,"\u2212")}, |
| 898 |
toNativeMML: function (parent) { |
| 899 |
var tag = this.NativeMMLelement(this.type); |
| 900 |
this.NativeMMLattributes(tag); |
| 901 |
var remap = this.NativeMMLremapMinus; |
| 902 |
for (var i = 0, m = this.data.length; i < m; i++) { |
| 903 |
if (this.data[i]) { |
| 904 |
this.data[i].toNativeMML(tag,remap); |
| 905 |
remap = null; |
| 906 |
} |
| 907 |
} |
| 908 |
parent.appendChild(tag); |
| 909 |
} |
| 910 |
}); |
| 911 |
|
| 912 |
var fontDir = AJAX.fileURL(MathJax.OutputJax.fontDir+"/HTML-CSS/TeX/otf"); |
| 913 |
|
| 914 |
/* |
| 915 |
* Add fix for mathvariant issues |
| 916 |
*/ |
| 917 |
nMML.Augment({ |
| 918 |
config: { |
| 919 |
styles: { |
| 920 |
'[class="MJX-tex-oldstyle"]': {"font-family":"MathJax_Caligraphic, MathJax_Caligraphic-WEB"}, |
| 921 |
'[class="MJX-tex-oldstyle-bold"]': {"font-family":"MathJax_Caligraphic, MathJax_Caligraphic-WEB", "font-weight":"bold"}, |
| 922 |
'[class="MJX-tex-caligraphic"]': {"font-family":"MathJax_Caligraphic, MathJax_Caligraphic-WEB"}, |
| 923 |
'[class="MJX-tex-caligraphic-bold"]': {"font-family":"MathJax_Caligraphic, MathJax_Caligraphic-WEB", "font-weight":"bold"}, |
| 924 |
|
| 925 |
'@font-face /*1*/': { |
| 926 |
"font-family": "MathJax_Caligraphic-WEB", |
| 927 |
"src": "url('"+fontDir+"/MathJax_Caligraphic-Regular.otf')" |
| 928 |
}, |
| 929 |
'@font-face /*2*/': { |
| 930 |
"font-family": "MathJax_Caligraphic-WEB", "font-weight":"bold", |
| 931 |
"src": "url('"+fontDir+"/MathJax_Caligraphic-Bold.otf')" |
| 932 |
} |
| 933 |
} |
| 934 |
} |
| 935 |
}); |
| 936 |
if (!this.handlesVariants) { |
| 937 |
nMML.Augment({ |
| 938 |
config: { |
| 939 |
styles: { |
| 940 |
'[mathvariant="double-struck"]': {"font-family":"MathJax_AMS, MathJax_AMS-WEB"}, |
| 941 |
'[mathvariant="script"]': {"font-family":"MathJax_Script, MathJax_Script-WEB"}, |
| 942 |
'[mathvariant="fraktur"]': {"font-family":"MathJax_Fraktur, MathJax_Fraktur-WEB"}, |
| 943 |
'[mathvariant="bold-script"]': {"font-family":"MathJax_Script, MathJax_Caligraphic-WEB", "font-weight":"bold"}, |
| 944 |
'[mathvariant="bold-fraktur"]': {"font-family":"MathJax_Fraktur, MathJax_Fraktur-WEB", "font-weight":"bold"}, |
| 945 |
'[mathvariant="monospace"]': {"font-family":"monospace"}, |
| 946 |
'[mathvariant="sans-serif"]': {"font-family":"sans-serif"}, |
| 947 |
'[mathvariant="bold-sans-serif"]': {"font-family":"sans-serif", "font-weight":"bold"}, |
| 948 |
'[mathvariant="sans-serif-italic"]': {"font-family":"sans-serif", "font-style":"italic"}, |
| 949 |
'[mathvariant="sans-serif-bold-italic"]': {"font-family":"sans-serif", "font-style":"italic", "font-weight":"bold"}, |
| 950 |
|
| 951 |
'@font-face /*3*/': { |
| 952 |
"font-family": "MathJax_AMS-WEB", |
| 953 |
"src": "url('"+fontDir+"/MathJax_AMS-Regular.otf')" |
| 954 |
}, |
| 955 |
'@font-face /*4*/': { |
| 956 |
"font-family": "MathJax_Script-WEB", |
| 957 |
"src": "url('"+fontDir+"/MathJax_Script-Regular.otf')" |
| 958 |
}, |
| 959 |
'@font-face /*5*/': { |
| 960 |
"font-family": "MathJax_Fraktur-WEB", |
| 961 |
"src": "url('"+fontDir+"/MathJax_Fraktur-Regular.otf')" |
| 962 |
}, |
| 963 |
'@font-face /*6*/': { |
| 964 |
"font-family": "MathJax_Fraktur-WEB", "font-weight":"bold", |
| 965 |
"src": "url('"+fontDir+"/MathJax_Fraktur-Bold.otf')" |
| 966 |
} |
| 967 |
} |
| 968 |
} |
| 969 |
}); |
| 970 |
} |
| 971 |
} |
| 972 |
|
| 973 |
MML.math.Augment({ |
| 974 |
toNativeMML: function (parent,jax) { |
| 975 |
var tag = this.NativeMMLelement(this.type), math = tag; |
| 976 |
var annotate = (jax ? MathJax.InputJax[jax.inputJax].annotationEncoding : null); |
| 977 |
var i, m; |
| 978 |
nMML.adjustWidths = []; |
| 979 |
// |
| 980 |
// Some browsers don't seem to add the xmlns attribute, so do it by hand. |
| 981 |
// |
| 982 |
tag.setAttribute("xmlns",nMML.MMLnamespace); |
| 983 |
this.NativeMMLattributes(tag); |
| 984 |
// |
| 985 |
// Use an extra <mrow> in FF so that we can get the correct width |
| 986 |
// (the math element doesn't always have an accurate one, see below) |
| 987 |
// |
| 988 |
if (nMML.widthBug) {tag = tag.appendChild(this.NativeMMLelement("mrow"))} |
| 989 |
// |
| 990 |
// Addannotation if the input jax provides an annotation encoding |
| 991 |
// |
| 992 |
if (annotate) { |
| 993 |
tag = tag.appendChild(this.NativeMMLelement("semantics")) |
| 994 |
tag.appendChild(this.NativeMMLelement("mrow")); |
| 995 |
var annotation = tag.appendChild(this.NativeMMLelement("annotation")); |
| 996 |
annotation.appendChild(document.createTextNode(jax.originalText)); |
| 997 |
annotation.setAttribute("encoding",annotate); |
| 998 |
tag = tag.firstChild; // mrow |
| 999 |
} |
| 1000 |
// |
| 1001 |
// Add the children |
| 1002 |
// |
| 1003 |
for (i = 0, m = this.data.length; i < m; i++) { |
| 1004 |
if (this.data[i]) {this.data[i].toNativeMML(tag)} |
| 1005 |
else {tag.appendChild(this.NativeMMLelement("mrow"))} |
| 1006 |
} |
| 1007 |
// |
| 1008 |
// Look for a top-level mtable and if it has labels |
| 1009 |
// Make sure the containers have 100% width, when needed. |
| 1010 |
// If the label is on the same side as alignment, |
| 1011 |
// override the margin set by the stylesheet. |
| 1012 |
// |
| 1013 |
var mtable = ((this.data[0]||{data:[]}).data[0]||{}); |
| 1014 |
if (mtable.nMMLhasLabels) { |
| 1015 |
if (mtable.nMMLforceWidth || !mtable.nMMLlaMatch) { |
| 1016 |
tag.setAttribute("style","width:100%") // mrow node |
| 1017 |
if (annotate) tag.parentNode.setAttribute("style","width:100%"); // semantics node |
| 1018 |
}; |
| 1019 |
if (mtable.nMMLlaMatch) { |
| 1020 |
if (parent.parentNode.parentNode.nodeName.toLowerCase() === "div") { |
| 1021 |
parent.parentNode.parentNode.style |
| 1022 |
.setProperty("margin-"+HUB.config.displayAlign,"0px","important"); |
| 1023 |
} |
| 1024 |
} |
| 1025 |
} |
| 1026 |
// |
| 1027 |
// Check if container must have width set to 100% |
| 1028 |
// |
| 1029 |
var fullWidth = nMML.isFullWidth(math); |
| 1030 |
if (fullWidth) {parent.style.width = parent.parentNode.style.width = "100%"} |
| 1031 |
// |
| 1032 |
// Add the math to the page |
| 1033 |
// |
| 1034 |
parent.appendChild(math); |
| 1035 |
// |
| 1036 |
// Firefox can't seem to get the width of <math> elements right, so |
| 1037 |
// use an <mrow> to get the actual width and set the style on the |
| 1038 |
// parent element to match. Even if we set the <math> width properly, |
| 1039 |
// it doesn't seem to propagate up to the <span> correctly. |
| 1040 |
// |
| 1041 |
if (nMML.widthBug &&!fullWidth) { |
| 1042 |
// |
| 1043 |
// Convert size to ex's so that it scales properly if the print media |
| 1044 |
// has a different font size. |
| 1045 |
// |
| 1046 |
parent.style.width = (math.firstChild.scrollWidth/nMML.ex/nMML.scale).toFixed(3) + "ex"; |
| 1047 |
// |
| 1048 |
// Save size for later when we check if Web fonts have arrived |
| 1049 |
// |
| 1050 |
if (jax) {jax.NativeMML.scrollWidth = math.firstChild.scrollWidth} |
| 1051 |
} |
| 1052 |
if (nMML.adjustWidths.length) { |
| 1053 |
// |
| 1054 |
// Firefox gets the widths of <mtd> elements wrong, so run |
| 1055 |
// through them (now that the math is part of the page) and |
| 1056 |
// fix them up. Use ex's so that they print properly (see above). |
| 1057 |
// |
| 1058 |
var mtd = []; |
| 1059 |
for (i = 0, m = nMML.adjustWidths.length; i < m; i++) { |
| 1060 |
tag = nMML.adjustWidths[i]; |
| 1061 |
var style = tag.getAttribute("style") || ""; |
| 1062 |
if (!style.match(/(^|;)\s*min-width:/)) { |
| 1063 |
var width = tag.firstChild.scrollWidth; |
| 1064 |
mtd.push(width); |
| 1065 |
width = (width/nMML.ex).toFixed(3)+"ex"; |
| 1066 |
style = style.replace(/;?\s*$/,"; "); |
| 1067 |
tag.setAttribute("style",style+"min-width:"+width); |
| 1068 |
} |
| 1069 |
} |
| 1070 |
// |
| 1071 |
// Save the lists so that we can check them later for web font downloads |
| 1072 |
// |
| 1073 |
if (!jax) {jax = HUB.getJaxFor(parent)} |
| 1074 |
if (jax) {jax.NativeMML.mtds = mtd} |
| 1075 |
math.MathJaxMtds = nMML.adjustWidths; |
| 1076 |
nMML.adjustWidths = []; // clear it so we don't hold onto the DOM elements |
| 1077 |
} |
| 1078 |
} |
| 1079 |
}); |
| 1080 |
|
| 1081 |
MML.mfenced.Augment({ |
| 1082 |
toNativeMML: function (parent) { |
| 1083 |
if (!nMML.mfencedBug) { |
| 1084 |
this.SUPER(arguments).toNativeMML.call(this,parent); |
| 1085 |
return; |
| 1086 |
} |
| 1087 |
|
| 1088 |
// |
| 1089 |
// Some browsers do not handle <mfenced> very well. The MathML spec |
| 1090 |
// suggests this equivalent construction instead, so let's use it: |
| 1091 |
// <mrow> open, child1, sep1, child2, ... sep(N-1), childN, close</mrow> |
| 1092 |
// Opera is a bit special: it does not support stretchy <mo>, does not |
| 1093 |
// parse mfenced@open/mfenced@close very well, does not support |
| 1094 |
// mfenced@separators and only displays the first child of the <mfenced> |
| 1095 |
// element... For this browser, we will use this construction: |
| 1096 |
// <mfenced open="open" close="close"> |
| 1097 |
// <mrow>child1, sep1, child2, sep2, ..., sep(N-1), childN</mrow> |
| 1098 |
// </mfenced> |
| 1099 |
// |
| 1100 |
var isOpera = HUB.Browser.isOpera; |
| 1101 |
var i, m, operator; |
| 1102 |
|
| 1103 |
// |
| 1104 |
// parse the open, close and separators attributes. |
| 1105 |
// |
| 1106 |
var values = this.getValues("open","close","separators"); |
| 1107 |
values.open = values.open.replace(/^\s+/,"").replace(/\s+$/,""); |
| 1108 |
values.close = values.close.replace(/^\s+/,"").replace(/\s+$/,""); |
| 1109 |
values.separators = values.separators.replace(/\s+/g,"").split(""); |
| 1110 |
if (values.separators.length == 0) { |
| 1111 |
// |
| 1112 |
// No separators specified, do not use separators at all. |
| 1113 |
// |
| 1114 |
values.separators = null; |
| 1115 |
} else if (values.separators.length < this.data.length-1) { |
| 1116 |
// |
| 1117 |
// There are not enough separators, repeat the last one. |
| 1118 |
// |
| 1119 |
var s = values.separators[values.separators.length-1]; |
| 1120 |
for (i = this.data.length-1-values.separators.length; i > 0; i--) |
| 1121 |
{values.separators.push(s)} |
| 1122 |
} |
| 1123 |
|
| 1124 |
// |
| 1125 |
// Create an <mrow> container and attach the attributes of the |
| 1126 |
// <mfenced> element to it. Note: removeAttribute does not raise any |
| 1127 |
// exception when the attributes is absent. |
| 1128 |
// |
| 1129 |
var tag = this.NativeMMLelement(isOpera ? this.type : "mrow"); |
| 1130 |
this.NativeMMLattributes(tag); |
| 1131 |
tag.removeAttribute("separators"); |
| 1132 |
if (isOpera) { |
| 1133 |
tag.setAttribute("open", values.open); |
| 1134 |
tag.setAttribute("close", values.close); |
| 1135 |
if (this.data.length > 1) { |
| 1136 |
parent.appendChild(tag); parent = tag; |
| 1137 |
tag = this.NativeMMLelement("mrow"); |
| 1138 |
} |
| 1139 |
} else { |
| 1140 |
tag.removeAttribute("open"); |
| 1141 |
tag.removeAttribute("close"); |
| 1142 |
} |
| 1143 |
|
| 1144 |
if (!isOpera) { |
| 1145 |
// |
| 1146 |
// Append the opening fence |
| 1147 |
// |
| 1148 |
operator = this.NativeMMLelement("mo"); |
| 1149 |
operator.setAttribute("fence", "true"); |
| 1150 |
operator.textContent = values.open; |
| 1151 |
tag.appendChild(operator); |
| 1152 |
} |
| 1153 |
|
| 1154 |
// |
| 1155 |
// Append the content of the <mfenced> |
| 1156 |
// |
| 1157 |
for (i = 0, m = this.data.length; i < m; i++) { |
| 1158 |
if (values.separators && i > 0) { |
| 1159 |
operator = this.NativeMMLelement("mo"); |
| 1160 |
operator.setAttribute("separator", "true"); |
| 1161 |
operator.textContent = values.separators[i-1]; |
| 1162 |
tag.appendChild(operator); |
| 1163 |
} |
| 1164 |
if (this.data[i]) {this.data[i].toNativeMML(tag)} |
| 1165 |
else {tag.appendChild(this.NativeMMLelement("mrow"))} |
| 1166 |
} |
| 1167 |
|
| 1168 |
if (!isOpera) { |
| 1169 |
// |
| 1170 |
// Append the closing fence |
| 1171 |
// |
| 1172 |
operator = this.NativeMMLelement("mo"); |
| 1173 |
operator.setAttribute("fence", "true"); |
| 1174 |
operator.textContent = values.close; |
| 1175 |
tag.appendChild(operator); |
| 1176 |
} |
| 1177 |
|
| 1178 |
// finally, append the new element to the parent. |
| 1179 |
parent.appendChild(tag); |
| 1180 |
} |
| 1181 |
}); |
| 1182 |
|
| 1183 |
MML.TeXAtom.Augment({ |
| 1184 |
// |
| 1185 |
// Convert TeXatom to an mrow |
| 1186 |
// |
| 1187 |
toNativeMML: function (parent) { |
| 1188 |
// FIXME: Handle spacing using mpadded? |
| 1189 |
var tag = this.NativeMMLelement("mrow"); |
| 1190 |
this.NativeMMLattributes(tag); |
| 1191 |
this.data[0].toNativeMML(tag); |
| 1192 |
parent.appendChild(tag); |
| 1193 |
} |
| 1194 |
}); |
| 1195 |
|
| 1196 |
MML.chars.Augment({ |
| 1197 |
// |
| 1198 |
// Add a text node |
| 1199 |
// |
| 1200 |
toNativeMML: function (parent,remap) { |
| 1201 |
var text = this.toString(); |
| 1202 |
if (remap) text = remap(text); |
| 1203 |
parent.appendChild(document.createTextNode(text)); |
| 1204 |
} |
| 1205 |
}); |
| 1206 |
|
| 1207 |
MML.entity.Augment({ |
| 1208 |
// |
| 1209 |
// Add a text node |
| 1210 |
// |
| 1211 |
toNativeMML: function (parent) { |
| 1212 |
parent.appendChild(document.createTextNode(this.toString())); |
| 1213 |
} |
| 1214 |
}); |
| 1215 |
|
| 1216 |
MML.xml.Augment({ |
| 1217 |
// |
| 1218 |
// Insert the XML verbatim |
| 1219 |
// |
| 1220 |
toNativeMML: function (parent) { |
| 1221 |
for (var i = 0, m = this.data.length; i < m; i++) |
| 1222 |
{parent.appendChild(this.data[i].cloneNode(true))} |
| 1223 |
} |
| 1224 |
}); |
| 1225 |
|
| 1226 |
MML.mi.Augment({ |
| 1227 |
toNativeMML: function (parent) { |
| 1228 |
this.SUPER(arguments).toNativeMML.call(this,parent); |
| 1229 |
if (nMML.miItalicBug) { |
| 1230 |
if (this.Get("mathvariant") === MML.VARIANT.NORMAL) { |
| 1231 |
// |
| 1232 |
// When not explicitly specified, mathvariant is set to "italic" |
| 1233 |
// with single char mi and to "normal" with multiple char mi. |
| 1234 |
// Some browsers always set the default to "italic", so let's |
| 1235 |
// attach an explicit mathvariant="normal" attribute. |
| 1236 |
// |
| 1237 |
var mi = parent.lastChild; |
| 1238 |
mi.setAttribute("mathvariant",MML.VARIANT.NORMAL); |
| 1239 |
} |
| 1240 |
} |
| 1241 |
} |
| 1242 |
}); |
| 1243 |
|
| 1244 |
MML.mo.Augment({ |
| 1245 |
toNativeMML: function (parent) { |
| 1246 |
this.SUPER(arguments).toNativeMML.call(this,parent); |
| 1247 |
if (nMML.webkitMoSpacingBug) { |
| 1248 |
// |
| 1249 |
// WebKit does not support lspace/rspace values around operators |
| 1250 |
// (neither explicit nor given by the operator dictionary) and uses |
| 1251 |
// constant values instead. So let's modify the CSS properties here. |
| 1252 |
// |
| 1253 |
|
| 1254 |
var lspace = 0, rspace = 0, p = this.parent; |
| 1255 |
if (p && p.type === "mrow" && (p.inferred || !p.isEmbellished())) { |
| 1256 |
// |
| 1257 |
// Retrieve the values of lspace/rspace and convert named spaces. |
| 1258 |
// Other values (except unitless) will be parsed by the CSS engine. |
| 1259 |
// |
| 1260 |
var values = this.getValues("lspace", "rspace"); |
| 1261 |
lspace = values.lspace, rspace = values.rspace; |
| 1262 |
if (nMML.NAMEDSPACE[lspace]) {lspace = nMML.NAMEDSPACE[lspace]} |
| 1263 |
if (nMML.NAMEDSPACE[rspace]) {rspace = nMML.NAMEDSPACE[rspace]} |
| 1264 |
} |
| 1265 |
|
| 1266 |
// |
| 1267 |
// Now update -webkit-margin-start and -webkit-margin-end. |
| 1268 |
// |
| 1269 |
var mo = parent.lastChild; |
| 1270 |
var span = HTML.Element("span"); |
| 1271 |
span.style.cssText = (mo.getAttribute("style")||""); |
| 1272 |
span.style.setProperty("-webkit-margin-start", lspace); |
| 1273 |
span.style.setProperty("-webkit-margin-end", rspace); |
| 1274 |
mo.setAttribute("style",span.style.cssText); |
| 1275 |
} |
| 1276 |
} |
| 1277 |
}); |
| 1278 |
|
| 1279 |
MML.mmultiscripts.Augment({ |
| 1280 |
toNativeMML: function (parent) { |
| 1281 |
// |
| 1282 |
// Some browsers do not implement the mmultiscripts element. |
| 1283 |
// Try to emulate the support using basic script elements. |
| 1284 |
// |
| 1285 |
if (!nMML.mmultiscriptsBug || this.data.length === 0) { |
| 1286 |
this.SUPER(arguments).toNativeMML.call(this,parent); |
| 1287 |
return; |
| 1288 |
} |
| 1289 |
|
| 1290 |
// |
| 1291 |
// The children of the mmultiscripts will be wrapped in an mrow so that |
| 1292 |
// attributes and properties set on the original mmultiscripts will |
| 1293 |
// be reflected on this mrow element. |
| 1294 |
// |
| 1295 |
var tag = this.NativeMMLelement("mrow"); |
| 1296 |
this.NativeMMLattributes(tag); |
| 1297 |
|
| 1298 |
// |
| 1299 |
// Create the base |
| 1300 |
// |
| 1301 |
if (this.data[0]) {this.data[0].toNativeMML(tag)} |
| 1302 |
else {tag.appendChild(this.NativeMMLelement("mrow"))} |
| 1303 |
var base = tag.removeChild(tag.lastChild); |
| 1304 |
|
| 1305 |
// |
| 1306 |
// Process the postscript pairs |
| 1307 |
// |
| 1308 |
var m = this.data.length, i, msubsup; |
| 1309 |
for (i = 1; i < m; i+=2) { |
| 1310 |
if (this.data[i].type === "mprescripts") break; |
| 1311 |
|
| 1312 |
msubsup = this.NativeMMLelement("msubsup"); |
| 1313 |
msubsup.appendChild(base); |
| 1314 |
|
| 1315 |
// |
| 1316 |
// append the subscript |
| 1317 |
// |
| 1318 |
if (this.data[i]) {this.data[i].toNativeMML(msubsup)} |
| 1319 |
else {msubsup.appendChild(this.NativeMMLelement("mrow"))} |
| 1320 |
|
| 1321 |
// |
| 1322 |
// append the supscript |
| 1323 |
// |
| 1324 |
if (i+1 < m && this.data[i+1]) {this.data[i+1].toNativeMML(msubsup)} |
| 1325 |
else {msubsup.appendChild(this.NativeMMLelement("mrow"))} |
| 1326 |
|
| 1327 |
base = msubsup; |
| 1328 |
} |
| 1329 |
|
| 1330 |
tag.appendChild(base); |
| 1331 |
|
| 1332 |
// |
| 1333 |
// Process the prescript pairs |
| 1334 |
// |
| 1335 |
for (i++; i < m; i+=2) { |
| 1336 |
msubsup = this.NativeMMLelement("msubsup"); |
| 1337 |
msubsup.appendChild(this.NativeMMLelement("mrow")); |
| 1338 |
|
| 1339 |
// |
| 1340 |
// append the presubscript |
| 1341 |
// |
| 1342 |
if (this.data[i]) {this.data[i].toNativeMML(msubsup)} |
| 1343 |
else {msubsup.appendChild(this.NativeMMLelement("mrow"))} |
| 1344 |
|
| 1345 |
// |
| 1346 |
// append the presupscript |
| 1347 |
// |
| 1348 |
if (i+1 < m && this.data[i+1]) {this.data[i+1].toNativeMML(msubsup)} |
| 1349 |
else {msubsup.appendChild(this.NativeMMLelement("mrow"))} |
| 1350 |
|
| 1351 |
tag.insertBefore(msubsup, base); |
| 1352 |
} |
| 1353 |
|
| 1354 |
parent.appendChild(tag); |
| 1355 |
} |
| 1356 |
}); |
| 1357 |
|
| 1358 |
HUB.Register.StartupHook("TeX mathchoice Ready",function () { |
| 1359 |
MML.TeXmathchoice.Augment({ |
| 1360 |
// |
| 1361 |
// Get the MathML for the selected choice |
| 1362 |
// |
| 1363 |
toNativeMML: function (parent) {this.Core().toNativeMML(parent)} |
| 1364 |
}); |
| 1365 |
}); |
| 1366 |
|
| 1367 |
// |
| 1368 |
// Loading isn't complete until the element jax is modified, |
| 1369 |
// but can't call loadComplete within the callback for "mml Jax Ready" |
| 1370 |
// (it would call NativeMML's Require routine, asking for the mml jax again) |
| 1371 |
// so wait until after the mml jax has finished processing. |
| 1372 |
// |
| 1373 |
setTimeout(MathJax.Callback(["loadComplete",nMML,"jax.js"]),0); |
| 1374 |
}); |
| 1375 |
|
| 1376 |
|
| 1377 |
// |
| 1378 |
// Determine browser characteristics |
| 1379 |
// |
| 1380 |
HUB.Browser.Select({ |
| 1381 |
MSIE: function (browser) { |
| 1382 |
var mode = (document.documentMode || 0); |
| 1383 |
nMML.msieIE8HeightBug = (mode === 8); |
| 1384 |
}, |
| 1385 |
Opera: function (browser) { |
| 1386 |
nMML.stretchyMoBug = true; |
| 1387 |
nMML.tableLabelBug = true; |
| 1388 |
nMML.mfencedBug = true; |
| 1389 |
nMML.miBug = true; |
| 1390 |
nMML.mmultiscriptsBug = true; |
| 1391 |
}, |
| 1392 |
Firefox: function (browser) { |
| 1393 |
var is29 = browser.versionAtLeast("29.0"); |
| 1394 |
nMML.ffTableWidthBug = !browser.versionAtLeast("13.0"); // <mtable width="xx"> not implemented |
| 1395 |
nMML.forceReflow = !is29; // <mtable> with alignments set don't display properly without a reflow |
| 1396 |
nMML.widthBug = !is29; // <math> elements don't always get the correct width |
| 1397 |
nMML.mtdWidthBug = true; // <mtd> widths not properly determined |
| 1398 |
nMML.handlesVariants = is29; // FF >=29 handles all math variants |
| 1399 |
|
| 1400 |
// In Firefox < 20, the intrinsic width of <mspace> is not computed |
| 1401 |
// correctly and thus the element is displayed incorrectly in <mtable>. |
| 1402 |
nMML.spaceWidthBug = !browser.versionAtLeast("20.0"); |
| 1403 |
|
| 1404 |
// mtable@rowspacing/mtable@columnspacing not supported. |
| 1405 |
nMML.tableSpacingBug = !browser.versionAtLeast("33.0"); |
| 1406 |
nMML.tableLabelBug = true; // mlabeledtr is not implemented. |
| 1407 |
nMML.mfencedBug = true; // mfenced not displayed correctly |
| 1408 |
}, |
| 1409 |
Chrome: function (browser) { |
| 1410 |
nMML.tableSpacingBug = true; |
| 1411 |
nMML.tableLabelBug = true; |
| 1412 |
nMML.mfencedBug = true; |
| 1413 |
}, |
| 1414 |
Safari: function (browser) { |
| 1415 |
nMML.tableSpacingBug = true; |
| 1416 |
nMML.tableLabelBug = true; |
| 1417 |
nMML.mfencedBug = true; |
| 1418 |
nMML.miItalicBug = true; |
| 1419 |
nMML.webkitMoSpacingBug = true; |
| 1420 |
nMML.spaceWidthBug = true; |
| 1421 |
nMML.mmultiscriptsBug = true; |
| 1422 |
} |
| 1423 |
}); |
| 1424 |
|
| 1425 |
|
| 1426 |
HUB.Register.StartupHook("End Cookie",function () { |
| 1427 |
if (HUB.config.menuSettings.zoom !== "None") |
| 1428 |
{AJAX.Require("[MathJax]/extensions/MathZoom.js")} |
| 1429 |
}); |
| 1430 |
|
| 1431 |
})(MathJax.OutputJax.NativeMML, MathJax.Hub, MathJax.Ajax, MathJax.HTML); |