Merge branch 'issue138' into v2.0-candidate (resolving conflicts, and fixing some issues with zoom and menus)
This commit is contained in:
commit
a675b397c7
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -12,5 +12,5 @@
|
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
|
||||
MathJax.OutputJax.NativeMML=MathJax.OutputJax({id:"NativeMML",version:"1.1.10",directory:MathJax.OutputJax.directory+"/NativeMML",extensionDir:MathJax.OutputJax.extensionDir+"/NativeMML",config:{scale:100,styles:{"DIV.MathJax_MathML":{"text-align":"center",margin:".75em 0px"}}}});if(!MathJax.Hub.config.delayJaxRegistration){MathJax.OutputJax.NativeMML.Register("jax/mml")}MathJax.OutputJax.NativeMML.loadComplete("config.js");
|
||||
MathJax.OutputJax.NativeMML=MathJax.OutputJax({id:"NativeMML",version:"1.1.11",directory:MathJax.OutputJax.directory+"/NativeMML",extensionDir:MathJax.OutputJax.extensionDir+"/NativeMML",config:{scale:100,minScaleAdjust:50,styles:{"DIV.MathJax_MathML":{"text-align":"center",margin:".75em 0px"}}}});if(!MathJax.Hub.config.delayJaxRegistration){MathJax.OutputJax.NativeMML.Register("jax/mml")}MathJax.OutputJax.NativeMML.loadComplete("config.js");
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -97,7 +97,7 @@
|
|||
// Call the output jax's event handler or the zoom handler
|
||||
//
|
||||
Handler: function (event,type,math) {
|
||||
if (AJAX.loadingMathMenu) {return False(event)}
|
||||
if (AJAX.loadingMathMenu) {return EVENT.False(event)}
|
||||
var jax = OUTPUT[math.jaxID];
|
||||
if (!event) {event = window.event}
|
||||
event.isContextMenu = (type === "ContextMenu");
|
||||
|
|
|
@ -123,7 +123,7 @@
|
|||
// Find the jax
|
||||
//
|
||||
var JAX = MathJax.OutputJax[math.jaxID];
|
||||
var jax = JAX.getJaxFromMath(math), root = jax.root;
|
||||
var jax = JAX.getJaxFromMath(math);
|
||||
if (jax.hover) {HOVER.UnHover(jax)}
|
||||
|
||||
//
|
||||
|
@ -170,7 +170,7 @@
|
|||
div = tracker;
|
||||
}
|
||||
|
||||
var bbox = JAX.Zoom(root,span,math,Mw,Mh);
|
||||
var bbox = JAX.Zoom(jax,span,math,Mw,Mh);
|
||||
|
||||
//
|
||||
// Fix up size and position for browsers with bugs (IE)
|
||||
|
|
|
@ -421,7 +421,7 @@
|
|||
jax = script.MathJax.elementJax;
|
||||
jax.HTMLCSS = {display: (jax.root.Get("display") === "block")}
|
||||
span = div = this.Element("span",{
|
||||
className:"MathJax", id:jax.inputID+"-Frame", isMathJax:true,
|
||||
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
|
||||
|
@ -458,10 +458,10 @@
|
|||
jax.HTMLCSS.isHidden = true;
|
||||
ex = jax.HTMLCSS.ex = test.firstChild.offsetWidth/60;
|
||||
}
|
||||
em = jax.HTMLCSS.em = test.lastChild.firstChild.offsetWidth/60;
|
||||
em = test.lastChild.firstChild.offsetWidth/60;
|
||||
scale = Math.floor(Math.max(this.config.minScaleAdjust/100,(ex/this.TeX.x_height)/em) * this.config.scale);
|
||||
jax.HTMLCSS.scale = scale/100; jax.HTMLCSS.fontSize = scale+"%";
|
||||
jax.HTMLCSS.marginScale = 1;
|
||||
jax.HTMLCSS.marginScale = 1; jax.HTMLCSS.em = jax.HTMLCSS.outerEm = em;
|
||||
}
|
||||
//
|
||||
// If we need to determine MSIE margin scaling,
|
||||
|
@ -593,24 +593,33 @@
|
|||
},
|
||||
getHoverSpan: function (jax) {return jax.root.HTMLspanElement()},
|
||||
getHoverBBox: function (jax,span) {
|
||||
var bbox = span.bbox, em = jax.outerEm;
|
||||
var bbox = span.bbox, em = jax.HTMLCSS.outerEm;
|
||||
var BBOX = {w:bbox.w*em, h:bbox.h*em, d:bbox.d*em};
|
||||
if (bbox.width) {BBOX.width = bbox.width}
|
||||
return BBOX;
|
||||
},
|
||||
|
||||
Zoom: function (root,span,math,Mw,Mh) {
|
||||
Zoom: function (jax,span,math,Mw,Mh) {
|
||||
//
|
||||
// Re-render at larger size
|
||||
//
|
||||
span.className = "MathJax"; this.getScales(span,span);
|
||||
this.idPostfix = "-zoom"; root.toHTML(span,span); this.idPostfix = "";
|
||||
var width = root.HTMLspanElement().bbox.width;
|
||||
span.className = "MathJax"; //this.getScales(span,span);
|
||||
|
||||
//
|
||||
// get em sizes (taken from HTMLCSS.preTranslate)
|
||||
//
|
||||
var emex = span.appendChild(this.EmExSpan.cloneNode(true));
|
||||
var em = emex.lastChild.firstChild.offsetWidth/60;
|
||||
this.msieMarginScale = 1; this.em = MML.mbase.prototype.em = em; this.outerEm = em;
|
||||
emex.parentNode.removeChild(emex);
|
||||
|
||||
this.idPostfix = "-zoom"; jax.root.toHTML(span,span); this.idPostfix = "";
|
||||
var width = jax.root.HTMLspanElement().bbox.width;
|
||||
if (width) {
|
||||
// Handle full-width displayed equations
|
||||
// FIXME: this is a hack for now
|
||||
span.style.width = Math.floor(Mw-1.5*HTMLCSS.em)+"px"; span.style.display="inline-block";
|
||||
var id = (root.id||"MathJax-Span-"+root.spanID)+"-zoom";
|
||||
var id = (jax.root.id||"MathJax-Span-"+jax.root.spanID)+"-zoom";
|
||||
var child = document.getElementById(id).firstChild;
|
||||
while (child && child.style.width !== width) {child = child.nextSibling}
|
||||
if (child) {child.style.width = "100%"}
|
||||
|
|
|
@ -24,13 +24,14 @@
|
|||
|
||||
MathJax.OutputJax.NativeMML = MathJax.OutputJax({
|
||||
id: "NativeMML",
|
||||
version: "1.1.10",
|
||||
version: "1.1.11",
|
||||
directory: MathJax.OutputJax.directory + "/NativeMML",
|
||||
extensionDir: MathJax.OutputJax.extensionDir + "/NativeMML",
|
||||
|
||||
config: {
|
||||
scale: 100, // scaling factor for all math
|
||||
|
||||
minScaleAdjust: 50, // minimum scaling to adjust to surrounding text
|
||||
// (since the code for that is a bit delicate)
|
||||
styles: {
|
||||
"DIV.MathJax_MathML": {
|
||||
"text-align": "center",
|
||||
|
|
|
@ -33,7 +33,15 @@
|
|||
//
|
||||
// User can configure styles
|
||||
//
|
||||
config: {styles: {}},
|
||||
config: {
|
||||
styles: {
|
||||
".MathJax_mmlExBox": {
|
||||
display:"block", overflow:"hidden",
|
||||
height:"1px", width:"60ex",
|
||||
padding:0, border: 0, margin: 0
|
||||
}
|
||||
}
|
||||
},
|
||||
settings: HUB.config.menuSettings,
|
||||
|
||||
Startup: function () {
|
||||
|
@ -46,6 +54,17 @@
|
|||
this.Mouseover = HOVER.Mouseover;
|
||||
this.Mouseout = HOVER.Mouseout;
|
||||
this.Mousemove = HOVER.Mousemove;
|
||||
|
||||
// Used in preTranslate to get scaling factors
|
||||
this.EmExSpan = HTML.Element("span",
|
||||
{style:{position:"absolute","font-size-adjust":"none"}},
|
||||
[
|
||||
["span",{className:"MathJax_mmlExBox"}],
|
||||
["span",{className:"MathJax_MathML"}]
|
||||
]
|
||||
);
|
||||
MML.math(MML.mspace().With({width:"60ex"})).toNativeMML(this.EmExSpan.lastChild);
|
||||
|
||||
// Set up styles
|
||||
return AJAX.Styles(this.config.styles);
|
||||
},
|
||||
|
@ -99,26 +118,97 @@
|
|||
}
|
||||
},
|
||||
|
||||
preTranslate: function (state) {
|
||||
var scripts = state.jax[this.id], i, m = scripts.length,
|
||||
script, prev, span, test, math, jax, ex, mex, scale;
|
||||
for (i = 0; i < m; i++) {
|
||||
script = scripts[i]; if (!script.parentNode) continue;
|
||||
if (!this.initialized) {this.InitializeMML()}
|
||||
//
|
||||
// Remove any existing output
|
||||
//
|
||||
prev = script.previousSibling;
|
||||
if (prev && prev.className === "MathJax_MathML") {prev.parentNode.removeChild(prev)}
|
||||
//
|
||||
// Add the MathJax span
|
||||
//
|
||||
jax = script.MathJax.elementJax; math = jax.root; jax.NativeMML = {};
|
||||
var type = (math.Get("display") === "block" ? "div" : "span");
|
||||
span = HTML.Element(type,{className:"MathJax_MathML", id:jax.inputID+"-Frame"});
|
||||
span = HTML.Element(type,{
|
||||
className: "MathJax_MathML", id:jax.inputID+"-Frame"
|
||||
},[["span",{
|
||||
className:"MathJax_MathContainer", isMathJax: true, jaxID:this.id,
|
||||
style:{position:"relative", display:"inline-block", "white-space":"nowrap"}
|
||||
}, [["span",{isMathJax:true, style:{display:"inline-block"}}]] // for Firefox hover and zoom
|
||||
]]);
|
||||
script.parentNode.insertBefore(span,script);
|
||||
//
|
||||
// Add the test span for determining scales
|
||||
//
|
||||
if (!isMSIE) {script.parentNode.insertBefore(this.EmExSpan.cloneNode(true),script)}
|
||||
}
|
||||
//
|
||||
// Determine the scaling factors for each script
|
||||
// (this only requires one reflow rather than a reflow for each equation)
|
||||
//
|
||||
for (i = 0; i < m; i++) {
|
||||
script = scripts[i]; if (!script.parentNode) continue;
|
||||
jax = script.MathJax.elementJax;
|
||||
if (!isMSIE) {
|
||||
test = script.previousSibling; span = test.previousSibling;
|
||||
ex = test.firstChild.offsetWidth/60;
|
||||
mex = test.lastChild.offsetWidth/60;
|
||||
if (ex === 0 || ex === "NaN") {
|
||||
// can't read width, so move to hidden div for processing
|
||||
this.hiddenDiv.appendChild(script.previousSibling);
|
||||
jax.NativeMML.isHidden = true;
|
||||
ex = test.firstChild.offsetWidth/60;
|
||||
mex = test.lastChild.offsetWidth/60;
|
||||
}
|
||||
scale = (mex > 1 ? ex/mex : 1) * this.config.scale;
|
||||
scale = Math.floor(Math.max(this.config.minScaleAdjust/100,scale));
|
||||
} else {scale = 100}
|
||||
jax.NativeMML.fontSize = scale+"%";
|
||||
}
|
||||
//
|
||||
// Remove the test spans used for determining scales
|
||||
//
|
||||
if (!isMSIE) {
|
||||
for (i = 0; i < m; i++) {
|
||||
script = scripts[i]; if (!script.parentNode) continue;
|
||||
test = scripts[i].previousSibling;
|
||||
test.parentNode.removeChild(test);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
//
|
||||
// Add a SPAN to use as a container, and render the math into it
|
||||
//
|
||||
Translate: function (script) {
|
||||
if (!script.parentNode) return;
|
||||
if (!this.initialized) {this.InitializeMML()}
|
||||
var prev = script.previousSibling;
|
||||
if (prev && String(prev.className).match(/^MathJax(_MathML|_Display)?$/))
|
||||
{prev.parentNode.removeChild(prev)}
|
||||
var math = script.MathJax.elementJax.root;
|
||||
var type = (math.Get("display") === "block" ? "div" : "span");
|
||||
var span = HTML.Element(type,{
|
||||
className: "MathJax_MathML", style: {"font-size": this.config.scale+"%"}
|
||||
},[["span",{
|
||||
className:"MathJax_MathContainer", isMathJax: true, jaxID:this.id,
|
||||
style:{position:"relative", display:"inline-block", "white-space":"nowrap"}
|
||||
}, [["span",{isMathJax:true, style:{display:"inline-block"}}]] // for Firefox hover and zoom
|
||||
]]), container = span.firstChild;
|
||||
math.toNativeMML(container.firstChild);
|
||||
script.parentNode.insertBefore(span,script);
|
||||
//
|
||||
// Get the jax and the container and set the size
|
||||
//
|
||||
var jax = script.MathJax.elementJax, math = jax.root;
|
||||
var span = document.getElementById(jax.inputID+"-Frame"),
|
||||
container = span.firstChild, mspan = container.firstChild;
|
||||
span.style.fontSize = jax.NativeMML.fontSize;
|
||||
//
|
||||
// Convert to MathML (if restarted, remove any partial math)
|
||||
//
|
||||
try {math.toNativeMML(mspan)} catch (err) {
|
||||
if (err.restart) {while (mspan.firstChild) {mspan.removeChild(mspan.firstChild)}}
|
||||
throw err;
|
||||
}
|
||||
//
|
||||
// If it was hidden, put it in its proper place
|
||||
//
|
||||
if (jax.NativeMML.isHidden) {script.parentNode.insertBefore(div,script)}
|
||||
//
|
||||
// Add event handlers
|
||||
//
|
||||
if (isMSIE) {
|
||||
if (container.addEventListener) {
|
||||
container.addEventListener("contextmenu",EVENT.Menu,true);
|
||||
|
@ -203,8 +293,8 @@
|
|||
getHoverSpan: function (jax,math) {return math.firstChild},
|
||||
getHoverBBox: function (jax,span,math) {return EVENT.getBBox(span.parentNode)},
|
||||
|
||||
Zoom: function (root,span,math,Mw,Mh) {
|
||||
root.toNativeMML(span,span);
|
||||
Zoom: function (jax,span,math,Mw,Mh) {
|
||||
jax.root.toNativeMML(span,span);
|
||||
if (this.msieIE8HeightBug) {span.style.position = "absolute"}
|
||||
var mW = math.offsetWidth || math.scrollWidth,
|
||||
mH = math.offsetHeight || math.scrollHeight;
|
||||
|
|
Loading…
Reference in New Issue
Block a user