diff --git a/resources/viewer/mathjax/MathJax.js b/resources/viewer/mathjax/MathJax.js index 689ef5a177..ff0a6ffb9a 100644 --- a/resources/viewer/mathjax/MathJax.js +++ b/resources/viewer/mathjax/MathJax.js @@ -45,9 +45,9 @@ if (window.MathJax) {window.MathJax = {AuthorConfig: window.MathJax}} // MathJax.isPacked = true; // This line is uncommented by the packer. -MathJax.version = "2.6.0"; -MathJax.fileversion = "2.6.0"; -MathJax.cdnVersion = "2.6.0"; // specifies a revision to break caching +MathJax.version = "2.6.1"; +MathJax.fileversion = "2.6.1"; +MathJax.cdnVersion = "2.6.1"; // specifies a revision to break caching MathJax.cdnFileVersions = {}; // can be used to specify revisions for individual files /**********************************************************/ @@ -1880,7 +1880,7 @@ MathJax.Hub = { showMathMenu: true, // attach math context menu to typeset math? showMathMenuMSIE: true, // separtely determine if MSIE should have math menu // (since the code for that is a bit delicate) - + menuSettings: { zoom: "None", // when to do MathZoom CTRL: false, // require CTRL for MathZoom? @@ -1889,13 +1889,16 @@ MathJax.Hub = { Shift: false, // require Shift? discoverable: false, // make math menu discoverable on hover? zscale: "200%", // the scaling factor for MathZoom - renderer: "", // set when Jax are loaded + renderer: null, // set when Jax are loaded font: "Auto", // what font HTML-CSS should use context: "MathJax", // or "Browser" for pass-through to browser menu - locale: "en", // the language to use for messages + locale: null, // the language to use for messages mpContext: false, // true means pass menu events to MathPlayer in IE mpMouse: false, // true means pass mouse events to MathPlayer in IE texHints: true, // include class names for TeXAtom elements + FastPreview: null, // use PreviewHTML output as preview? + assistiveMML: null, // include hidden MathML for screen readers? + inTabOrder: true, // set to false if math elements should be included in the tabindex semantics: false // add semantics tag with original form in MathML output }, @@ -2126,6 +2129,7 @@ MathJax.Hub = { if (script.MathJax.state !== STATE.PENDING) {this.scriptAction[action](script)} } if (!script.MathJax) {script.MathJax = {state: STATE.PENDING}} + if (script.MathJax.error) delete script.MathJax.error; if (script.MathJax.state !== STATE.PROCESSED) {state.scripts.push(script)} } } @@ -2349,7 +2353,8 @@ MathJax.Hub = { if (err.line||err.lineNumber) message += "\n"+LOCALIZE("ErrorLine","line: %1",err.line||err.lineNumber); message += "\n\n"+LOCALIZE("ErrorTips","Debugging tips: use %1, inspect %2 in the browser console","'unpacked/MathJax.js'","'MathJax.Hub.lastError'"); script.MathJax.error = MathJax.OutputJax.Error.Jax(message,script); - + if (script.MathJax.elementJax) + script.MathJax.error.inputID = script.MathJax.elementJax.inputID; // // Create the [Math Processing Error] span // @@ -2358,28 +2363,23 @@ MathJax.Hub = { var error = MathJax.HTML.Element("span", { className:"MathJax_Error", jaxID:"Error", isMathJax:true, id: script.MathJax.error.inputID+"-Frame" - },errorText); + },[["span",null,errorText]]); // // Attach the menu events // - if (MathJax.Extension.MathEvents) { - var EVENT = MathJax.Extension.MathEvents.Event; + MathJax.Ajax.Require("[MathJax]/extensions/MathEvents.js",function () { + var EVENT = MathJax.Extension.MathEvents.Event, + HUB = MathJax.Hub; error.oncontextmenu = EVENT.Menu; error.onmousedown = EVENT.Mousedown; error.onkeydown = EVENT.Keydown; - error.tabIndex = 0; - } else { - MathJax.Ajax.Require("[MathJax]/extensions/MathEvents.js",function () { - var EVENT = MathJax.Extension.MathEvents.Event; - error.oncontextmenu = EVENT.Menu; - error.onmousedown = EVENT.Mousedown; - error.keydown = EVENT.Keydown; - error.tabIndex = 0; - }); - } + error.tabIndex = HUB.getTabOrder(HUB.getJaxFor(script)); + }); // // Insert the error into the page and remove any preview // + var node = document.getElementById(error.id); + if (node) node.parentNode.removeChild(node); script.parentNode.insertBefore(error,script); if (script.MathJax.preview) {script.MathJax.preview.innerHTML = ""} // @@ -2462,6 +2462,10 @@ MathJax.Hub = { return dst; }, + getTabOrder: function(script) { + return this.config.menuSettings.inTabOrder ? 0 : -1; + }, + // Old browsers (e.g. Internet Explorer <= 8) do not support trim(). SplitList: ("trim" in String.prototype ? function (list) {return list.trim().split(/\s+/)} : diff --git a/resources/viewer/mathjax/extensions/AssistiveMML.js b/resources/viewer/mathjax/extensions/AssistiveMML.js index e9f1975171..fe53796148 100644 --- a/resources/viewer/mathjax/extensions/AssistiveMML.js +++ b/resources/viewer/mathjax/extensions/AssistiveMML.js @@ -29,9 +29,9 @@ var SETTINGS = HUB.config.menuSettings; var AssistiveMML = MathJax.Extension["AssistiveMML"] = { - version: "2.6.0", + version: "2.6.1", - config: { + config: HUB.CombineConfig("AssistiveMML",{ disabled: false, styles: { ".MJX_Assistive_MathML": { @@ -44,13 +44,22 @@ height: "1px!important", width: "1px!important", overflow: "hidden!important", - display:"block!important" + display:"block!important", + // + // Don't allow the assistive MathML become part of the selection + // + "-webkit-touch-callout": "none", + "-webkit-user-select": "none", + "-khtml-user-select": "none", + "-moz-user-select": "none", + "-ms-user-select": "none", + "user-select": "none" }, ".MJX_Assistive_MathML.MJX_Assistive_MathML_Block": { width: "100%!important" } } - }, + }), Config: function () { if (!this.config.disabled && SETTINGS.assistiveMML == null) @@ -115,7 +124,7 @@ } frame.setAttribute("data-mathml",mml); span = HTML.addElement(frame,"span",{ - isMathJax: true, + isMathJax: true, unselectable: "on", className: "MJX_Assistive_MathML" + (jax.root.Get("display") === "block" ? " MJX_Assistive_MathML_Block" : "") }); diff --git a/resources/viewer/mathjax/extensions/MathMenu.js b/resources/viewer/mathjax/extensions/MathMenu.js index caa69de335..34dbc4053d 100644 --- a/resources/viewer/mathjax/extensions/MathMenu.js +++ b/resources/viewer/mathjax/extensions/MathMenu.js @@ -27,7 +27,7 @@ */ (function (HUB,HTML,AJAX,CALLBACK,OUTPUT) { - var VERSION = "2.6.0"; + var VERSION = "2.6.1"; var SIGNAL = MathJax.Callback.Signal("menu"); // signal for menu events @@ -544,18 +544,12 @@ MENU.FocusNode(menu); }, Activate: function(event, menu) { - var jaxs = MENU.AllNodes(); - for (var j = 0, jax; jax = jaxs[j]; j++) { - jax.tabIndex = -1; - } + MENU.UnsetTabIndex(); MENU.posted = true; }, Unfocus: function() { MENU.ActiveNode().tabIndex = -1; - var jaxs = MENU.AllNodes(); - for (var j = 0, jax; jax = jaxs[j]; j++) { - jax.tabIndex = 0; - } + MENU.SetTabIndex(); MENU.FocusNode(MENU.CurrentNode()); MENU.posted = false; }, @@ -577,6 +571,26 @@ Left: function(event, menu) { MENU.MoveHorizontal(event, menu, function(x) {return x - 1;}); }, + UnsetTabIndex: function () { + var jaxs = MENU.AllNodes(); + for (var j = 0, jax; jax = jaxs[j]; j++) { + if (jax.tabIndex > 0) { + jax.oldTabIndex = jax.tabIndex; + } + jax.tabIndex = -1; + } + }, + SetTabIndex: function () { + var jaxs = MENU.AllNodes(); + for (var j = 0, jax; jax = jaxs[j]; j++) { + if (jax.oldTabIndex !== undefined) { + jax.tabIndex = jax.oldTabIndex + delete jax.oldTabIndex; + } else { + jax.tabIndex = HUB.getTabOrder(jax); + } + } + }, //TODO: Move to utility class. // Computes a mod n. @@ -1328,6 +1342,9 @@ } }; + /* + * Toggle assistive MML settings + */ MENU.AssistiveMML = function (item,restart) { var AMML = MathJax.Extension.AssistiveMML; if (!AMML) { @@ -1526,15 +1543,16 @@ ), ITEM.RULE(), ITEM.SUBMENU(["Renderer","Math Renderer"], {hidden:!CONFIG.showRenderer}, - ITEM.RADIO("HTML-CSS", "renderer", {action: MENU.Renderer}), - ITEM.RADIO("Common HTML","renderer", {action: MENU.Renderer, value:"CommonHTML"}), - ITEM.RADIO("Fast HTML", "renderer", {action: MENU.Renderer, value:"PreviewHTML"}), - ITEM.RADIO("MathML", "renderer", {action: MENU.Renderer, value:"NativeMML"}), - ITEM.RADIO("SVG", "renderer", {action: MENU.Renderer}), - ITEM.RADIO("PlainSource","renderer", {action: MENU.Renderer, value:"PlainSource"}), + ITEM.RADIO(["HTML-CSS","HTML-CSS"], "renderer", {action: MENU.Renderer}), + ITEM.RADIO(["CommonHTML","Common HTML"], "renderer", {action: MENU.Renderer, value:"CommonHTML"}), + ITEM.RADIO(["PreviewHTML","Preview HTML"],"renderer", {action: MENU.Renderer, value:"PreviewHTML"}), + ITEM.RADIO(["MathML","MathML"], "renderer", {action: MENU.Renderer, value:"NativeMML"}), + ITEM.RADIO(["SVG","SVG"], "renderer", {action: MENU.Renderer}), + ITEM.RADIO(["PlainSource","Plain Source"],"renderer", {action: MENU.Renderer, value:"PlainSource"}), ITEM.RULE(), - ITEM.CHECKBOX("Fast Preview", "FastPreview"), - ITEM.CHECKBOX("Assistive MathML", "assistiveMML", {action:MENU.AssistiveMML}) + ITEM.CHECKBOX(["FastPreview","Fast Preview"], "FastPreview"), + ITEM.CHECKBOX(["AssistiveMML","Assistive MathML"], "assistiveMML", {action:MENU.AssistiveMML}), + ITEM.CHECKBOX(["InTabOrder","Include in Tab Order"], "inTabOrder") ), ITEM.SUBMENU("MathPlayer", {hidden:!HUB.Browser.isMSIE || !CONFIG.showMathPlayer, disabled:!HUB.Browser.hasMathPlayer}, @@ -1561,7 +1579,7 @@ ITEM.RADIO(["NeoEulerWeb","Neo Euler (web)"], "font", {action: MENU.Font}) ), ITEM.SUBMENU(["ContextMenu","Contextual Menu"], {hidden:!CONFIG.showContext}, - ITEM.RADIO("MathJax", "context"), + ITEM.RADIO(["MathJax","MathJax"], "context"), ITEM.RADIO(["Browser","Browser"], "context") ), ITEM.COMMAND(["Scale","Scale All Math ..."],MENU.Scale), diff --git a/resources/viewer/mathjax/extensions/TeX/AMSmath.js b/resources/viewer/mathjax/extensions/TeX/AMSmath.js index 55b9860fd5..c0fd6b1572 100644 --- a/resources/viewer/mathjax/extensions/TeX/AMSmath.js +++ b/resources/viewer/mathjax/extensions/TeX/AMSmath.js @@ -25,7 +25,7 @@ */ MathJax.Extension["TeX/AMSmath"] = { - version: "2.6.0", + version: "2.6.1", number: 0, // current equation number startNumber: 0, // current starting equation number (for when equation is restarted) @@ -94,8 +94,8 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () { projlim: ['NamedOp','proj lim'], varliminf: ['Macro','\\mathop{\\underline{\\mmlToken{mi}{lim}}}'], varlimsup: ['Macro','\\mathop{\\overline{\\mmlToken{mi}{lim}}}'], - varinjlim: ['Macro','\\mathop{\\underrightarrow{\\mmlToken{mi}{lim}\\Rule{-1pt}{0pt}{1pt}}\\Rule{0pt}{0pt}{.45em}}'], - varprojlim: ['Macro','\\mathop{\\underleftarrow{\\mmlToken{mi}{lim}\\Rule{-1pt}{0pt}{1pt}}\\Rule{0pt}{0pt}{.45em}}'], + varinjlim: ['Macro','\\mathop{\\underrightarrow{\\mmlToken{mi}{lim}}}'], + varprojlim: ['Macro','\\mathop{\\underleftarrow{\\mmlToken{mi}{lim}}}'], DeclareMathOperator: 'HandleDeclareOp', operatorname: 'HandleOperatorName', diff --git a/resources/viewer/mathjax/extensions/toMathML.js b/resources/viewer/mathjax/extensions/toMathML.js index 7c0594f6a2..d06ad851ad 100644 --- a/resources/viewer/mathjax/extensions/toMathML.js +++ b/resources/viewer/mathjax/extensions/toMathML.js @@ -26,7 +26,7 @@ */ MathJax.Hub.Register.LoadHook("[MathJax]/jax/element/mml/jax.js",function () { - var VERSION = "2.6.0"; + var VERSION = "2.6.1"; var MML = MathJax.ElementJax.mml, SETTINGS = MathJax.Hub.config.menuSettings; @@ -78,7 +78,10 @@ MathJax.Hub.Register.LoadHook("[MathJax]/jax/element/mml/jax.js",function () { var CLASS = []; if (this["class"]) {CLASS.push(this["class"])} if (this.isa(MML.TeXAtom) && SETTINGS.texHints) { var TEXCLASS = ["ORD","OP","BIN","REL","OPEN","CLOSE","PUNCT","INNER","VCENTER"][this.texClass]; - if (TEXCLASS) {CLASS.push("MJX-TeXAtom-"+TEXCLASS)} + if (TEXCLASS) { + CLASS.push("MJX-TeXAtom-"+TEXCLASS) + if (TEXCLASS === "OP" && !this.movablelimits) CLASS.push("MJX-fixedlimits"); + } } if (this.mathvariant && this.toMathMLvariants[this.mathvariant]) {CLASS.push("MJX"+this.mathvariant)} @@ -186,8 +189,15 @@ MathJax.Hub.Register.LoadHook("[MathJax]/jax/element/mml/jax.js",function () { MML.munderover.Augment({ toMathML: function (space) { var tag = this.type; - if (this.data[this.under] == null) {tag = "mover"} - if (this.data[this.over] == null) {tag = "munder"} + var base = this.data[this.base]; + if (base && base.isa(MML.TeXAtom) && base.movablelimits && !base.Get("displaystyle")) { + type = "msubsup"; + if (this.data[this.under] == null) {tag = "msup"} + if (this.data[this.over] == null) {tag = "msub"} + } else { + if (this.data[this.under] == null) {tag = "mover"} + if (this.data[this.over] == null) {tag = "munder"} + } var attr = this.toMathMLattributes(); delete this.data[0].inferred; var data = []; diff --git a/resources/viewer/mathjax/jax/input/MathML/config.js b/resources/viewer/mathjax/jax/input/MathML/config.js index 55d127e4bb..25b8857757 100644 --- a/resources/viewer/mathjax/jax/input/MathML/config.js +++ b/resources/viewer/mathjax/jax/input/MathML/config.js @@ -27,7 +27,7 @@ MathJax.InputJax.MathML = MathJax.InputJax({ id: "MathML", - version: "2.6.0", + version: "2.6.1", directory: MathJax.InputJax.directory + "/MathML", extensionDir: MathJax.InputJax.extensionDir + "/MathML", entityDir: MathJax.InputJax.directory + "/MathML/entities", diff --git a/resources/viewer/mathjax/jax/input/MathML/jax.js b/resources/viewer/mathjax/jax/input/MathML/jax.js index df917f4802..58772053b5 100644 --- a/resources/viewer/mathjax/jax/input/MathML/jax.js +++ b/resources/viewer/mathjax/jax/input/MathML/jax.js @@ -76,7 +76,7 @@ var mml, type = node.nodeName.toLowerCase().replace(/^[a-z]+:/,""); var match = (CLASS.match(/(^| )MJX-TeXAtom-([^ ]*)/)); if (match) { - mml = this.TeXAtom(match[2]); + mml = this.TeXAtom(match[2],match[2] === "OP" && !CLASS.match(/MJX-fixedlimits/)); } else if (!(MML[type] && MML[type].isa && MML[type].isa(MML.mbase))) { MathJax.Hub.signal.Post(["MathML Jax - unknown node type",type]); return MML.Error(_("UnknownNodeType","Unknown node type: %1",type)); @@ -88,9 +88,9 @@ if (MATHML.config.useMathMLspacing) {mml.useMMLspacing = 0x08} return mml; }, - TeXAtom: function (mclass) { + TeXAtom: function (mclass,movablelimits) { var mml = MML.TeXAtom().With({texClass:MML.TEXCLASS[mclass]}); - if (mml.texClass === MML.TEXCLASS.OP) {mml.movesupsub = mml.movablelimits = true} + if (movablelimits) {mml.movesupsub = mml.movablelimits = true} return mml; }, CheckClass: function (mml,CLASS) { diff --git a/resources/viewer/mathjax/jax/input/TeX/config.js b/resources/viewer/mathjax/jax/input/TeX/config.js index 6b4828288c..22c2e78149 100644 --- a/resources/viewer/mathjax/jax/input/TeX/config.js +++ b/resources/viewer/mathjax/jax/input/TeX/config.js @@ -27,7 +27,7 @@ MathJax.InputJax.TeX = MathJax.InputJax({ id: "TeX", - version: "2.6.0", + version: "2.6.1", directory: MathJax.InputJax.directory + "/TeX", extensionDir: MathJax.InputJax.extensionDir + "/TeX", diff --git a/resources/viewer/mathjax/jax/input/TeX/jax.js b/resources/viewer/mathjax/jax/input/TeX/jax.js index 1c1f8f69f5..8463c8be36 100644 --- a/resources/viewer/mathjax/jax/input/TeX/jax.js +++ b/resources/viewer/mathjax/jax/input/TeX/jax.js @@ -1264,6 +1264,8 @@ {if (mo.defaults.hasOwnProperty(id) && mi[id] != null) {mo[id] = mi[id]}} for (id in MML.copyAttributes) {if (MML.copyAttributes.hasOwnProperty(id) && mi[id] != null) {mo[id] = mi[id]}} + mo.lspace = mo.rspace = "0"; // prevent mo from having space in NativeMML + mo.useMMLspacing &= ~(mo.SPACE_ATTR.lspace | mo.SPACE_ATTR.rspace); // don't count these explicit settings return mo; }, @@ -1367,6 +1369,7 @@ } op.movesupsub = (limits ? true : false); op.Core().movablelimits = false; + if (op.movablelimits) op.movablelimits = false; }, Over: function (name,open,close) { @@ -1452,10 +1455,12 @@ Overset: function (name) { var top = this.ParseArg(name), base = this.ParseArg(name); + if (base.movablelimits) base.movablelimits = false; this.Push(MML.mover(base,top)); }, Underset: function (name) { var bot = this.ParseArg(name), base = this.ParseArg(name); + if (base.movablelimits) base.movablelimits = false; this.Push(MML.munder(base,bot)); }, @@ -2021,7 +2026,6 @@ /* * Break up a string into text and math blocks - * @@@ FIXME: pass environment to TEX.Parse? @@@ */ InternalMath: function (text,level) { var def = (this.stack.env.font ? {mathvariant: this.stack.env.font} : {}); @@ -2031,7 +2035,7 @@ c = text.charAt(i++); if (c === '$') { if (match === '$' && braces === 0) { - mml.push(MML.TeXAtom(TEX.Parse(text.slice(k,i-1),{}).mml().With(def))); + mml.push(MML.TeXAtom(TEX.Parse(text.slice(k,i-1),{}).mml())); match = ''; k = i; } else if (match === '') { if (k < i-1) mml.push(this.InternalText(text.slice(k,i-1),def)); @@ -2057,7 +2061,7 @@ if (k < i-2) mml.push(this.InternalText(text.slice(k,i-2),def)); match = ')'; k = i; } else if (c === ')' && match === ')' && braces === 0) { - mml.push(MML.TeXAtom(TEX.Parse(text.slice(k,i-2),{}).mml().With(def))); + mml.push(MML.TeXAtom(TEX.Parse(text.slice(k,i-2),{}).mml())); match = ''; k = i; } else if (c.match(/[${}\\]/) && match === '') { i--; text = text.substr(0,i-1) + text.substr(i); // remove \ from \$, \{, \}, or \\ diff --git a/resources/viewer/mathjax/jax/output/SVG/config.js b/resources/viewer/mathjax/jax/output/SVG/config.js index 800db40826..b5282f790d 100644 --- a/resources/viewer/mathjax/jax/output/SVG/config.js +++ b/resources/viewer/mathjax/jax/output/SVG/config.js @@ -27,7 +27,7 @@ MathJax.OutputJax.SVG = MathJax.OutputJax({ id: "SVG", - version: "2.6.0", + version: "2.6.1", directory: MathJax.OutputJax.directory + "/SVG", extensionDir: MathJax.OutputJax.extensionDir + "/SVG", autoloadDir: MathJax.OutputJax.directory + "/SVG/autoload", diff --git a/resources/viewer/mathjax/jax/output/SVG/jax.js b/resources/viewer/mathjax/jax/output/SVG/jax.js index 021a37c2b4..ea221f1d7c 100644 --- a/resources/viewer/mathjax/jax/output/SVG/jax.js +++ b/resources/viewer/mathjax/jax/output/SVG/jax.js @@ -222,7 +222,7 @@ onmouseover:EVENT.Mouseover, onmouseout:EVENT.Mouseout, onmousemove:EVENT.Mousemove, onclick:EVENT.Click, ondblclick:EVENT.DblClick, // Added for keyboard accessible menu. - onkeydown: EVENT.Keydown, tabIndex: "0" + onkeydown: EVENT.Keydown, tabIndex: HUB.getTabOrder(jax) }); if (HUB.Browser.noContextMenu) { span.ontouchstart = TOUCH.start; @@ -1882,8 +1882,9 @@ toSVG: function (HW,D) { this.SVGgetStyles(); var values = this.getValues("displaystyle","accent","accentunder","align"); - if (!values.displaystyle && this.data[this.base] != null && - this.data[this.base].CoreMO().Get("movablelimits")) + var base = this.data[this.base]; + if (!values.displaystyle && base != null && + (base.movablelimits || base.CoreMO().Get("movablelimits"))) {return MML.msubsup.prototype.toSVG.call(this)} var svg = this.SVG(), scale = this.SVGgetScale(svg); this.SVGhandleSpace(svg); var boxes = [], stretch = [], box, i, m, W = -SVG.BIGDIMEN, WW = W; @@ -1909,8 +1910,8 @@ if (boxes[i].w > WW) {WW = boxes[i].w} }} var t = SVG.TeX.rule_thickness * this.mscale; - var base = boxes[this.base] || {w:0, h:0, d:0, H:0, D:0, l:0, r:0, y:0, scale:scale}; var x, y, z1, z2, z3, dw, k, delta = 0; + base = boxes[this.base] || {w:0, h:0, d:0, H:0, D:0, l:0, r:0, y:0, scale:scale}; if (base.ic) {delta = 1.3*base.ic + .05} // adjust faked IC to be more in line with expeted results for (i = 0, m = this.data.length; i < m; i++) { if (this.data[i] != null) {