Merge pull request #1263 from dpvc/issue1250

Use less-aggressive CSS for ltr and inline-block, and do Edge check within the extension.
This commit is contained in:
Davide P. Cervone 2015-09-14 06:59:40 -04:00
commit 54854f88c1
15 changed files with 794 additions and 238 deletions

View File

@ -2569,6 +2569,8 @@ MathJax.Hub.Startup = {
}
if (SETTINGS.FastPreview && !MathJax.Extension["fast-preview"])
MathJax.Hub.config.extensions.push("fast-preview.js");
if (config.menuSettings.assistiveMML && !MathJax.Extension.AssistiveMML)
MathJax.Hub.config.extensions.push("AssistiveMML.js");
},MathJax.Hub.config],
["Post",this.signal,"End Cookie"]
);
@ -3090,12 +3092,13 @@ MathJax.Hub.Startup = {
isMac: (navigator.platform.substr(0,3) === "Mac"),
isPC: (navigator.platform.substr(0,3) === "Win"),
isMSIE: ("ActiveXObject" in window && "clipboardData" in window),
isMsEdge: (!!AGENT.match(/Edge\//)),
isEdge: ("MSGestureEvent" in window && "chrome" in window &&
window.chrome.loadTimes == null),
isFirefox: (!!AGENT.match(/Gecko\//) && !AGENT.match(/like Gecko/)),
isSafari: (!!AGENT.match(/ (Apple)?WebKit\//) && !AGENT.match(/ like iPhone /) &&
(!window.chrome || window.chrome.loadTimes == null)),
isChrome: (window.chrome != null && window.chrome.loadTimes != null),
isOpera: (window.opera != null && window.opera.version != null),
(!window.chrome || window.chrome.app == null)),
isChrome: ("chrome" in window && window.chrome.loadTimes != null),
isOpera: ("opera" in window && window.opera.version != null),
isKonqueror: ("konqueror" in window && navigator.vendor == "KDE"),
versionAtLeast: function (v) {
var bv = (this.version).split('.'); v = (new String(v)).split('.');
@ -3123,7 +3126,7 @@ MathJax.Hub.Startup = {
HUB.Browser = HUB.Insert(new String(browser),BROWSERS);
var VERSION = new RegExp(
".*(Version/| Trident/.*; rv:)((?:\\d+\\.)+\\d+)|" + // for Safari, Opera10, and IE11+
".*("+browser+")"+(browser == "MSIE" ? " " : "/")+"((?:\\d+\\.)*\\d+)|"+ // for one of the main browser
".*("+browser+")"+(browser == "MSIE" ? " " : "/")+"((?:\\d+\\.)*\\d+)|"+ // for one of the main browsers
"(?:^|\\(| )([a-z][-a-z0-9._: ]+|(?:Apple)?WebKit)/((?:\\d+\\.)+\\d+)"); // for unrecognized browser
var MATCH = VERSION.exec(xAGENT) || ["","","","unknown","0.0"];
HUB.Browser.name = (MATCH[1] != "" ? browser : (MATCH[3] || MATCH[5]));
@ -3177,8 +3180,15 @@ MathJax.Hub.Startup = {
AGENT.match(/ Fennec\//) != null ||
AGENT.match(/Mobile/) != null);
},
Chrome: function (browser) {
browser.noContextMenu = browser.isMobile = !!navigator.userAgent.match(/ Mobile[ \/]/);
},
Opera: function (browser) {browser.version = opera.version()},
Edge: function (browser) {
browser.isMobile = !!navigator.userAgent.match(/ Phone/);
},
MSIE: function (browser) {
browser.isMobile = !!navigator.userAgent.match(/ Phone/);
browser.isIE9 = !!(document.documentMode && (window.performance || window.msPerformance));
MathJax.HTML.setScriptBug = !browser.isIE9 || document.documentMode < 9;
MathJax.Hub.msieHTMLCollectionBug = (document.documentMode < 9);

View File

@ -0,0 +1,127 @@
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/*************************************************************
*
* MathJax/extensions/AssistiveMML.js
*
* Implements an extension that inserts hidden MathML into the
* page for screen readers or other asistive technology.
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2015 The MathJax Consortium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
(function (AJAX,CALLBACK,HUB,HTML) {
var SETTINGS = HUB.config.menuSettings;
var AssistiveMML = MathJax.Extension["AssistiveMML"] = {
version: "2.6",
config: {
disabled: false,
styles: {
".MJX_Assistive_MathML": {
position:"absolute!important",
clip: (HUB.Browser.isMSIE && (document.documentMode||0) < 8 ?
"rect(1px 1px 1px 1px)" : "rect(1px, 1px, 1px, 1px)"),
padding: "1px 0 0 0!important",
border: "0!important",
height: "1px!important",
width: "1px!important",
overflow: "hidden!important",
display:"block!important"
}
}
},
Config: function () {
if (!this.config.disabled && SETTINGS.assistiveMML == null)
HUB.Config({menuSettings:{assistiveMML:true}});
AJAX.Styles(this.config.styles);
HUB.Register.MessageHook("End Math",function (msg) {AssistiveMML.EndMathHook(msg[1])});
},
//
// The hook for the End Math signal.
// This sets up a state object that lists the jax and index into the jax,
// and a dummy callback that is used to synchronizing with MathJax.
// It will be called when the jax are all processed, and that will
// let the MathJax queue continue (it will block until then).
//
EndMathHook: function (node) {
if (!SETTINGS.assistiveMML) return;
var state = {
jax: HUB.getAllJax(node), i: 0,
callback: MathJax.Callback({})
};
this.HandleMML(state);
return state.callback;
},
//
// For each jax in the state, look up the frame.
// If the jax doesn't use NativeMML and hasn't already been handled:
// Get the MathML for the jax, taking resets into account.
// Add a data-mathml attribute to the frame, and
// Create a span that is not visible on screen and put the MathML in it,
// and add it to the frame.
// When all the jax are processed, call the callback.
//
HandleMML: function (state) {
var m = state.jax.length, jax, mml, frame, span;
while (state.i < m) {
jax = state.jax[state.i];
frame = document.getElementById(jax.inputID+"-Frame");
if (jax.outputJax !== "NativeMML" && frame && !frame.getAttribute("data-mathml")) {
try {
mml = jax.root.toMathML("").replace(/\n */g,"").replace(/<!--.*?-->/g,"");
} catch (err) {
if (!err.restart) throw err; // an actual error
return MathJax.Callback.After(["HandleMML",this,state],err.restart);
}
frame.setAttribute("data-mathml",mml);
span = HTML.addElement(frame,"span",{
isMathJax: true, className: "MJX_Assistive_MathML"
});
span.innerHTML = mml;
frame.firstChild.setAttribute("aria-hidden","true");
span.setAttribute("aria-readonly","true");
}
state.i++;
}
state.callback();
}
};
HUB.Startup.signal.Post("AssistiveMML Ready");
})(MathJax.Ajax,MathJax.Callback,MathJax.Hub,MathJax.HTML);
//
// Make sure the toMathML extension is loaded before we signal
// the load complete for this extension. Then wait for the end
// of the user configuration before configuring this extension.
//
MathJax.Callback.Queue(
["Require",MathJax.Ajax,"[MathJax]/extensions/toMathML.js"],
["loadComplete",MathJax.Ajax,"[MathJax]/extensions/AssistiveMML.js"],
function () {
MathJax.Hub.Register.StartupHook("End Config",["Config",MathJax.Extension.AssistiveMML]);
}
);

View File

@ -29,7 +29,13 @@
var STIXURL = "http://www.stixfonts.org/";
var MENU = MathJax.Menu;
var FALSE, KEY;
HUB.Register.StartupHook("MathEvents Ready",function () {
FALSE = MathJax.Extension.MathEvents.Event.False;
KEY = MathJax.Extension.MathEvents.Event.KEY;
});
var CONFIG = HUB.CombineConfig("HelpDialog",{
styles: {
@ -101,10 +107,10 @@
HELP.Post = function () {
this.div = MENU.Background(this);
var help = HTML.addElement(this.div,"div",{
id: "MathJax_Help"
id: "MathJax_Help", tabIndex: 0, onkeydown: HELP.Keydown
},LOCALE._("HelpDialog",[
["b",{style:{fontSize:"120%"}},[["Help","MathJax Help"]]],
["div",{id: "MathJax_HelpContent"},[
["div",{id: "MathJax_HelpContent", tabIndex: 0},[
["p",{},[["MathJax",
"*MathJax* is a JavaScript library that allows page authors to include " +
"mathematics within their web pages. As a reader, you don't need to do " +
@ -148,10 +154,13 @@
]
]],
["a",{href:"http://www.mathjax.org/"},["www.mathjax.org"]],
["span",{id: "MathJax_HelpClose", onclick: HELP.Remove},
["span",{id: "MathJax_HelpClose", onclick: HELP.Remove,
onkeydown: HELP.Keydown, tabIndex: 0,
"aria-label": "Close", "aria-describedby": "Close window"},
[["span",{},["\u00D7"]]]
]
]));
help.focus();
LOCALE.setCSS(help);
var doc = (document.documentElement||{});
var H = window.innerHeight || doc.clientHeight || doc.scrollHeight || 0;
@ -167,6 +176,15 @@
HELP.Remove = function (event) {
if (HELP.div) {document.body.removeChild(HELP.div); delete HELP.div}
};
HELP.Keydown = function(event) {
if (event.keyCode === KEY.ESCAPE ||
(this.id === "MathJax_HelpClose" &&
(event.keyCode === KEY.SPACE || event.keyCode === KEY.RETURN))) {
HELP.Remove(event);
MENU.CurrentNode().focus();
FALSE(event);
}
},
MathJax.Callback.Queue(
HUB.Register.StartupHook("End Config",{}), // wait until config is complete

View File

@ -4,20 +4,20 @@
/*************************************************************
*
* MathJax/extensions/MathEvents.js
*
*
* Implements the event handlers needed by the output jax to perform
* menu, hover, and other events.
*
* ---------------------------------------------------------------------
*
*
* Copyright (c) 2011-2015 The MathJax Consortium
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -27,12 +27,12 @@
(function (HUB,HTML,AJAX,CALLBACK,LOCALE,OUTPUT,INPUT) {
var VERSION = "2.5.0";
var EXTENSION = MathJax.Extension;
var ME = EXTENSION.MathEvents = {version: VERSION};
var SETTINGS = HUB.config.menuSettings;
var CONFIG = {
hover: 500, // time required to be considered a hover
frame: {
@ -41,7 +41,7 @@
bcolor: "#A6D", // frame border color
hwidth: "15px", // haze width
hcolor: "#83A" // haze color
},
},
button: {
x: -6, y: -3, // menu button offsets
wx: -2 // button offset for full-width equations
@ -99,16 +99,30 @@
}
};
//
// Common event-handling code
//
var EVENT = ME.Event = {
LEFTBUTTON: 0, // the event.button value for left button
RIGHTBUTTON: 2, // the event.button value for right button
MENUKEY: "altKey", // the event value for alternate context menu
/*************************************************************/
/*
* Enum element for key codes.
*/
KEY: {
RETURN: 13,
ESCAPE: 27,
SPACE: 32,
LEFT: 37,
UP: 38,
RIGHT: 39,
DOWN: 40
},
Mousedown: function (event) {return EVENT.Handler(event,"Mousedown",this)},
Mouseup: function (event) {return EVENT.Handler(event,"Mouseup",this)},
Mousemove: function (event) {return EVENT.Handler(event,"Mousemove",this)},
@ -117,7 +131,7 @@
Click: function (event) {return EVENT.Handler(event,"Click",this)},
DblClick: function (event) {return EVENT.Handler(event,"DblClick",this)},
Menu: function (event) {return EVENT.Handler(event,"ContextMenu",this)},
//
// Call the output jax's event handler or the zoom handler
//
@ -129,7 +143,7 @@
if (jax[type]) {return jax[type](event,math)}
if (EXTENSION.MathZoom) {return EXTENSION.MathZoom.HandleEvent(event,type,math)}
},
//
// Try to cancel the event in every way we can
//
@ -143,6 +157,15 @@
return false;
},
//
// Keydown event handler. Should only fire on Space key.
//
Keydown: function (event, math) {
if (event.keyCode === EVENT.KEY.SPACE) {
EVENT.ContextMenu(event, this);
};
},
//
// Load the contextual menu code, if needed, and post the menu
//
@ -165,7 +188,7 @@
}
//
// If the menu code is loaded,
// If the menu code is loaded,
// Check if localization needs loading;
// If not, post the menu, and return.
// Otherwise wait for the localization to load
@ -178,18 +201,18 @@
load = LOCALE.loadDomain("MathMenu");
if (!load) {
MENU.jax = jax;
var source = MENU.menu.Find("Show Math As").menu;
source.items[0].name = jax.sourceMenuTitle;
source.items[0].format = (jax.sourceMenuFormat||"MathML");
var source = MENU.menu.Find("Show Math As").submenu;
source.items[0].name = jax.sourceMenuTitle;
source.items[0].format = (jax.sourceMenuFormat||"MathML");
source.items[1].name = INPUT[jax.inputJax].sourceMenuTitle;
source.items[5].disabled = !INPUT[jax.inputJax].annotationEncoding;
//
//
// Try and find each known annotation format and enable the menu
// items accordingly.
//
var annotations = source.items[2]; annotations.disabled = true;
var annotationItems = annotations.menu.items;
var annotationItems = annotations.submenu.items;
annotationList = MathJax.Hub.Config.semanticsAnnotations;
for (var i = 0, m = annotationItems.length; i < m; i++) {
var name = annotationItems[i].name[1]
@ -226,7 +249,7 @@
);
return EVENT.False(event);
},
//
// Mousedown handler for alternate means of accessing menu
//
@ -243,26 +266,26 @@
return JAX.ContextMenu(event,math,true);
}
},
ClearSelection: function () {
if (ME.safariContextMenuBug) {setTimeout("window.getSelection().empty()",0)}
if (document.selection) {setTimeout("document.selection.empty()",0)}
},
getBBox: function (span) {
span.appendChild(ME.topImg);
var h = ME.topImg.offsetTop, d = span.offsetHeight-h, w = span.offsetWidth;
span.removeChild(ME.topImg);
return {w:w, h:h, d:d};
}
};
//
// Handle hover "discoverability"
//
var HOVER = ME.Hover = {
//
// Check if we are moving from a non-MathJax element to a MathJax one
// and either start fading in again (if it is fading out) or start the
@ -309,7 +332,7 @@
return EVENT.False(event);
}
},
//
// Clear the old timer and start a new one
//
@ -320,7 +343,7 @@
ClearHoverTimer: function () {
if (this.hoverTimer) {clearTimeout(this.hoverTimer); delete this.hoverTimer}
},
//
// Handle putting up the hover frame
//
@ -431,7 +454,7 @@
jax.hover.timer = setTimeout(CALLBACK(["HoverFade",this,jax]),(delay||CONFIG.fadeDelay));
}
},
//
// Handle a click on the menu button
//
@ -439,7 +462,7 @@
if (!event) {event = window.event}
return OUTPUT[this.jax].ContextMenu(event,this.math,true);
},
//
// Clear all hover timers
//
@ -449,7 +472,7 @@
HOVER.ClearHoverTimer();
delete jax.hover;
},
//
// Make a measurement in pixels
//
@ -469,9 +492,9 @@
}
};
//
// Handle touch events.
// Handle touch events.
//
// Use double-tap-and-hold as a replacement for context menu event.
// Use double-tap as a replacement for double click.
@ -480,7 +503,7 @@
last: 0, // time of last tap event
delay: 500, // delay time for double-click
//
// Check if this is a double-tap, and if so, start the timer
// for the double-tap and hold (to trigger the contextual menu)
@ -494,9 +517,9 @@
event.preventDefault();
}
},
//
// Check if there is a timeout pending, i.e., we have a
// Check if there is a timeout pending, i.e., we have a
// double-tap and were waiting to see if it is held long
// enough for the menu. Since we got the end before the
// timeout, it is a double-click, not a double-tap-and-hold.
@ -512,7 +535,7 @@
return EVENT.Handler((event.touches[0]||event.touch),"DblClick",this);
}
},
//
// If the timeout passes without an end event, we issue
// the contextual menu event.
@ -521,10 +544,10 @@
delete TOUCH.timeout; TOUCH.last = 0; TOUCH.up = false;
return EVENT.Handler((event.touches[0]||event.touch),"ContextMenu",math);
}
};
/*
/*
* //
* // Mobile screens are small, so use larger version of arrow
* //
@ -534,7 +557,7 @@
* CONFIG.button.x = -6;
* }
*/
//
// Set up browser-specific values
//
@ -557,7 +580,7 @@
ME.noContextMenuBug = true; // doesn't produce contextmenu event
}
});
//
// Used in measuring zoom and hover positions
//
@ -578,7 +601,7 @@
haze["-moz-box-shadow"] = haze["-khtml-box-shadow"] =
"0px 0px "+CONFIG.frame.hwidth+" "+CONFIG.frame.hcolor;
};
//
// Queue the events needed for startup
//
@ -590,6 +613,6 @@
["Post",HUB.Startup.signal,"MathEvents Ready"],
["loadComplete",AJAX,"[MathJax]/extensions/MathEvents.js"]
);
})(MathJax.Hub,MathJax.HTML,MathJax.Ajax,MathJax.Callback,
MathJax.Localization,MathJax.OutputJax,MathJax.InputJax);

View File

@ -80,7 +80,7 @@ MathJax.Hub.Register.StartupHook("MathML Jax Ready",function () {
*/
var BROWSER = MathJax.Hub.Browser;
var exslt = '';
if (BROWSER.isMsEdge || BROWSER.isMSIE) {
if (BROWSER.isEdge || BROWSER.isMSIE) {
exslt = 'urn:schemas-microsoft-com:xslt'
} else {
exslt = 'http://exslt.org/common';
@ -767,7 +767,16 @@ MathJax.Hub.Register.StartupHook("MathML Jax Ready",function () {
}
// Tweak CSS to avoid some browsers rearranging HTML output
MathJax.Ajax.Styles(".MathJax span { direction: ltr !important; display: inline-block !important;}");
MathJax.Ajax.Styles({
".MathJax .mi, .MathJax .mo, .MathJax .mn, .MathJax .mtext": {
direction: "ltr",
display: "inline-block"
},
".MathJax .ms, .MathJax .mspace, .MathJax .mglyph": {
direction: "ltr",
display: "inline-block"
}
});
MathJax.Hub.Startup.signal.Post("MathML mml3.js Ready");
});

File diff suppressed because it is too large Load Diff

View File

@ -134,14 +134,14 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
aligned: ['AlignedAMSArray',null,null,null,'rlrlrlrlrlrl',COLS([0,2,0,2,0,2,0,2,0,2,0]),".5em",'D'],
gathered: ['AlignedAMSArray',null,null,null,'c',null,".5em",'D'],
subarray: ['Array',null,null,null,null,COLS([0,0,0,0]),"0.1em",'S',1],
subarray: ['Array',null,null,null,null,COLS([0]),"0.1em",'S',1],
smallmatrix: ['Array',null,null,null,'c',COLS([1/3]),".2em",'S',1],
'equation': ['EquationBegin','Equation',true],
'equation*': ['EquationBegin','EquationStar',false],
eqnarray: ['AMSarray',null,true,true, 'rcl',MML.LENGTH.THICKMATHSPACE,".5em"],
'eqnarray*': ['AMSarray',null,false,true,'rcl',MML.LENGTH.THICKMATHSPACE,".5em"]
eqnarray: ['AMSarray',null,true,true, 'rcl',COLS([0]),".5em"],
'eqnarray*': ['AMSarray',null,false,true,'rcl',COLS([0]),".5em"]
},
delimiter: {

View File

@ -99,8 +99,8 @@ MathJax.Extension.mml2jax = {
}
for (var i = 0, m = math.length; i < m; i++) {
var parent = math[i].parentNode;
if (parent && parent.className !== preview && !math[i].prefix === !namespace)
{array.push(math[i])}
if (parent && parent.className !== preview &&
!parent.isMathJax && !math[i].prefix === !namespace) array.push(math[i]);
}
},

View File

@ -45,7 +45,7 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
//
var base, bbox;
if (stretch) {
base = node.getElementsByTagName("mjx-base")[0];
base = CHTML.getNode(node,"mjx-base");
} else {
this.CHTMLaddChild(node,0,{type:"mjx-base", noBBox:true, forceChild:true});
base = node.firstChild;
@ -137,10 +137,10 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
//
CHTMLgetScripts: function (BOX,BBOX,stretch,node) {
if (stretch) {
BOX.sub = node.getElementsByTagName("mjx-sub")[0];
BOX.sup = node.getElementsByTagName("mjx-sup")[0];
BOX.presub = node.getElementsByTagName("mjx-presub")[0];
BOX.presup = node.getElementsByTagName("mjx-presup")[0];
BOX.sub = CHTML.getNode(node,"mjx-sub");
BOX.sup = CHTML.getNode(node,"mjx-sup");
BOX.presub = CHTML.getNode(node,"mjx-presub");
BOX.presup = CHTML.getNode(node,"mjx-presup");
BBOX.sub = this.CHTMLbbox.sub;
BBOX.sup = this.CHTMLbbox.sup;
BBOX.presub = this.CHTMLbbox.presub;
@ -182,7 +182,7 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
BBOX = state.BBOX[type] = CHTML.BBOX.empty();
if (state.w) {
BOX.style.paddingLeft = CHTML.Em(state.w);
BBOX.w = BBOX.r = state.w;
BBOX.w = BBOX.r = state.w; BBOX.x = state.w;
}
}
data.toCommonHTML(BOX);
@ -198,7 +198,7 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
// right-justify the scripts, otherwise, left-justify them.
//
CHTMLpadScript: function (type,w,bbox,state) {
if (!bbox) bbox = {w:0, fake:1};
if (!bbox) bbox = {w:0, fake:1, rscale:1};
var BBOX = state.BBOX[type], dx = 0, dw = 0;
if (BBOX) {
if (bbox.rscale*bbox.w < w) {
@ -252,7 +252,7 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
CHTMLplaceSubSup: function (sub,sbox,sup,Sbox,x,delta,u,v,s) {
sub.style.paddingRight = CHTML.Em(s); sbox.w += s;
sup.style.paddingBottom = CHTML.Em(u+v-Sbox.d-sbox.h);
sup.style.paddingLeft = CHTML.Em(delta);
sup.style.paddingLeft = CHTML.Em(delta+(Sbox.x||0));
sup.style.paddingRight = CHTML.Em(s); Sbox.w += s;
sup.parentNode.style.verticalAlign = CHTML.Em(-v);
this.CHTML.combine(sbox,x,-v);
@ -272,7 +272,7 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
CHTMLplacePresubPresup: function (presub,pbox,presup,Pbox,delta,u,v,s) {
presub.style.paddingLeft = CHTML.Em(s);
presup.style.paddingBottom = CHTML.Em(u+v-Pbox.d-pbox.h);
presup.style.paddingLeft = CHTML.Em(delta+s);
presup.style.paddingLeft = CHTML.Em(delta+s+(Pbox.x||0));
presup.style.paddingRight = CHTML.Em(-delta);
presup.parentNode.style.verticalAlign = CHTML.Em(-v);
this.CHTML.combine(pbox,s,-v);

View File

@ -505,9 +505,9 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
//
if (end.length === 0) {
var NODE = this.CHTMLnodeElement(),
stack = NODE.getElementsByTagName("mjx-stack")[0],
sup = NODE.getElementsByTagName("mjx-sup")[0],
sub = NODE.getElementsByTagName("mjx-sub")[0];
stack = CHTML.getNode(NODE,"mjx-stack"),
sup = CHTML.getNode(NODE,"mjx-sup"),
sub = CHTML.getNode(NODE,"mjx-sub");
if (stack) node.appendChild(stack);
else if (sup) node.appendChild(sup);
else if (sub) node.appendChild(sub);
@ -569,9 +569,9 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
//
if (start.length < 1) {
NODE = this.CHTMLnodeElement();
var prestack = NODE.getElementsByTagName("mjx-prestack")[0],
presup = NODE.getElementsByTagName("mjx-presup")[0],
presub = NODE.getElementsByTagName("mjx-presub")[0];
var prestack = CHTML.getNode(NODE,"mjx-prestack"),
presup = CHTML.getNode(NODE,"mjx-presup"),
presub = CHTML.getNode(NODE,"mjx-presub");
if (prestack) node.appendChild(prestack);
else if (presup) node.appendChild(presup);
else if (presub) node.appendChild(presub);
@ -598,9 +598,9 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
//
if (end.length === 0) {
NODE = this.CHTMLnodeElement();
var stack = NODE.getElementsByTagName("mjx-stack")[0],
sup = NODE.getElementsByTagName("mjx-sup")[0],
sub = NODE.getElementsByTagName("mjx-sub")[0];
var stack = CHTML.getNode(NODE,"mjx-stack"),
sup = CHTML.getNode(NODE,"mjx-sup"),
sub = CHTML.getNode(NODE,"mjx-sub");
if (stack) node.appendChild(stack);
else if (sup) node.appendChild(sup);
else if (sub) node.appendChild(sub);

View File

@ -324,8 +324,9 @@
if (type.substr(0,4) === "mjx-") {
if (!def) def = {};
if (def.className) def.className = type+" "+def.className; else def.className = type;
type = "span";
}
return this.HTMLElement("span",def,content);
return this.HTMLElement(type,def,content);
},
addElement: function (node,type,def,content) {
return node.appendChild(this.Element(type,def,content));
@ -334,6 +335,22 @@
ucMatch: HTML.ucMatch,
setScript: HTML.setScript,
//
// This replaces node.getElementsByTagName(type)[0]
// and should be replaced by that if we go back to using
// custom tags
//
getNode: (document.getElementsByClassName ?
function (node,type) {return node.getElementsByClassName(type)[0]} :
function (node,type) {
var nodes = node.getElementsByTagName("span");
var name = RegExp("\\b"+type+"\\b");
for (var i = 0, m = nodes.length; i < m; i++) {
if (name.test(nodes[i].className)) return nodes[i];
}
}
),
/********************************************/
@ -360,7 +377,7 @@
// Remove any existing output
//
prev = script.previousSibling;
if (prev && prev.nodeName.toLowerCase() === "mjx-chtml")
if (prev && prev.className && String(prev.className).substr(0,9) === "mjx-chtml")
prev.parentNode.removeChild(prev);
//
// Add the node for the math and mark it as being processed
@ -371,7 +388,9 @@
id:jax.inputID+"-Frame", isMathJax:true, jaxID:this.id,
oncontextmenu:EVENT.Menu, onmousedown: EVENT.Mousedown,
onmouseover:EVENT.Mouseover, onmouseout:EVENT.Mouseout, onmousemove:EVENT.Mousemove,
onclick:EVENT.Click, ondblclick:EVENT.DblClick
onclick:EVENT.Click, ondblclick:EVENT.DblClick,
// Added for keyboard accessible menu.
onkeydown: EVENT.Keydown, tabIndex: "0"
});
if (jax.CHTML.display) {
//
@ -1325,7 +1344,7 @@
if (child) {
var type = options.childNodes;
if (type) {
if (type instanceof Array) type = type[i];
if (type instanceof Array) type = type[i]||"span";
node = CHTML.addElement(node,type);
}
cnode = child.toCommonHTML(node,options.childOptions);
@ -1664,6 +1683,9 @@
MML.math.Augment({
toCommonHTML: function (node) {
node = this.CHTMLdefaultNode(node);
var alttext = this.Get("alttext");
if (alttext && !node.getAttribute("aria-label")) node.setAttribute("aria-label",alttext);
if (!node.getAttribute("role")) node.setAttribute("role","math");
if (this.CHTML.pwidth) {
node.parentNode.style.width = this.CHTML.pwidth;
node.parentNode.style.minWidth = this.CHTML.mwidth;
@ -2029,9 +2051,9 @@
//
var base, under, over, nodes = [];
if (stretch) {
base = node.getElementsByTagName("mjx-op")[0];
under = node.getElementsByTagName("mjx-under")[0];
over = node.getElementsByTagName("mjx-over")[0];
base = CHTML.getNode(node,"mjx-op");
under = CHTML.getNode(node,"mjx-under");
over = CHTML.getNode(node,"mjx-over");
nodes[0] = base; nodes[1] = under||over; nodes[2] = over;
} else {
var types = ["mjx-op","mjx-under","mjx-over"];
@ -2229,9 +2251,9 @@
//
var base, sub, sup;
if (stretch) {
base = node.getElementsByTagName("mjx-base")[0];
sub = node.getElementsByTagName("mjx-sub")[0];
sup = node.getElementsByTagName("mjx-sup")[0];
base = CHTML.getNode(node,"mjx-base");
sub = CHTML.getNode(node,"mjx-sub");
sup = CHTML.getNode(node,"mjx-sup");
} else {
var types = ["mjx-base","mjx-sub","mjx-sup"];
if (this.sup === 1) types[1] = types[2];

View File

@ -344,7 +344,23 @@
"#MathJax_Tooltip *": {
filter: "none", opacity:1, background:"transparent" // for IE
},
// Focus elements for keyboard tabbing.
".MathJax:focus": (
(MathJax.Hub.Browser.isSafari || MathJax.Hub.Browser.isChrome) ? {
display:"inline-block",
outline:"none",
margin:"-3px",
padding:"3px",
"-webkit-box-shadow": "0px 0px 5px #345, inset 0px 0px 5px #345",
"box-shadow": "0px 0px 5px #345, inset 0px 0px 5px #345"
} : {
display:"inline-block",
outline:"none",
border:"1px dotted",
margin:"-1px"
}),
//
// Used for testing web fonts against the default font used while
// web fonts are loading
@ -569,8 +585,11 @@
span = div = this.Element("span",{
className:"MathJax", id:jax.inputID+"-Frame", isMathJax:true, jaxID:this.id,
oncontextmenu:EVENT.Menu, onmousedown: EVENT.Mousedown,
onmouseover:EVENT.Mouseover, onmouseout:EVENT.Mouseout, onmousemove:EVENT.Mousemove,
onclick:EVENT.Click, ondblclick:EVENT.DblClick
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"
});
if (HUB.Browser.noContextMenu) {
span.ontouchstart = TOUCH.start;
@ -2868,7 +2887,6 @@
var alttext = this.Get("alttext");
if (alttext && !span.getAttribute("aria-label")) span.setAttribute("aria-label",alttext);
if (!span.getAttribute("role")) span.setAttribute("role","math");
// span.setAttribute("tabindex",0); // causes focus outline, so disable for now
stack = HTMLCSS.createStack(span); box = HTMLCSS.createBox(stack);
// Move font-size from outer span to stack to avoid line separation
// problem in strict HTML mode

View File

@ -326,6 +326,9 @@
container.onmousedown = EVENT.Mousedown;
container.onclick = EVENT.Click;
container.ondblclick = EVENT.DblClick;
// Added for keyboard accessible menu.
container.onkeydown = EVENT.Keydown;
container.tabIndex = "0";
if (HUB.Browser.noContextMenu) {
container.ontouchstart = TOUCH.start;
container.ontouchend = TOUCH.end;

View File

@ -197,7 +197,9 @@
className:"MathJax_PHTML", id:jax.inputID+"-Frame", isMathJax:true, jaxID:this.id,
oncontextmenu:EVENT.Menu, onmousedown: EVENT.Mousedown,
onmouseover:EVENT.Mouseover, onmouseout:EVENT.Mouseout, onmousemove:EVENT.Mousemove,
onclick:EVENT.Click, ondblclick:EVENT.DblClick
onclick:EVENT.Click, ondblclick:EVENT.DblClick,
// Added for keyboard accessible menu.
onkeydown: EVENT.Keydown, tabIndex: "0"
});
if (HUB.Browser.noContextMenu) {
span.ontouchstart = TOUCH.start;

View File

@ -220,7 +220,9 @@
className:"MathJax_SVG", id:jax.inputID+"-Frame", isMathJax:true, jaxID:this.id,
oncontextmenu:EVENT.Menu, onmousedown: EVENT.Mousedown,
onmouseover:EVENT.Mouseover, onmouseout:EVENT.Mouseout, onmousemove:EVENT.Mousemove,
onclick:EVENT.Click, ondblclick:EVENT.DblClick
onclick:EVENT.Click, ondblclick:EVENT.DblClick,
// Added for keyboard accessible menu.
onkeydown: EVENT.Keydown, tabIndex: "0"
});
if (HUB.Browser.noContextMenu) {
span.ontouchstart = TOUCH.start;
@ -2098,9 +2100,8 @@
// Add it to the MathJax span
//
var alttext = this.Get("alttext");
if (alttext && !svg.element.getAttribute("aria-label")) span.setAttribute("aria-label",alttext);
if (!svg.element.getAttribute("role")) span.setAttribute("role","math");
// span.setAttribute("tabindex",0); // causes focus outline, so disable for now
if (alttext && !svg.element.getAttribute("aria-label")) svg.element.setAttribute("aria-label",alttext);
if (!svg.element.getAttribute("role")) svg.element.setAttribute("role","img");
span.appendChild(svg.element);
svg.element = null;
//