commit 1e8ae72201b3a92d0b7da026316b60f370722468
parent 0c083deb4f5adbb6a7f037b24925b66d2dfdf629
Author: Davide P. Cervone <dpvc@union.edu>
Date: Fri, 11 Apr 2014 07:56:49 -0400
Merge branch 'zoom-fix' into develop. Issues #749, #460, #423.
Diffstat:
3 files changed, 48 insertions(+), 30 deletions(-)
diff --git a/unpacked/extensions/MathZoom.js b/unpacked/extensions/MathZoom.js
@@ -137,24 +137,26 @@
//
// Create the DOM elements for the zoom box
//
- var Mw = Math.floor(.85*document.body.clientWidth),
- Mh = Math.floor(.85*Math.max(document.body.clientHeight,document.documentElement.clientHeight));
+ var container = this.findContainer(math);
+ var Mw = Math.floor(.85*container.clientWidth),
+ Mh = Math.max(document.body.clientHeight,document.documentElement.clientHeight);
+ if (this.getOverflow(container) !== "visible") {Mh = Math.min(container.clientHeight,Mh)}
+ Mh = Math.floor(.85*Mh);
var div = HTML.Element(
"span",{id:"MathJax_ZoomFrame"},[
["span",{id:"MathJax_ZoomOverlay", onmousedown:this.Remove}],
["span",{
id:"MathJax_Zoom", onclick:this.Remove,
- style:{
- visibility:"hidden", fontSize:this.settings.zscale,
- "max-width":Mw+"px", "max-height":Mh+"px"
- }
+ style:{visibility:"hidden", fontSize:this.settings.zscale}
},[["span",{style:{display:"inline-block", "white-space":"nowrap"}}]]
]]
);
var zoom = div.lastChild, span = zoom.firstChild, overlay = div.firstChild;
math.parentNode.insertBefore(div,math); math.parentNode.insertBefore(math,div); // put div after math
if (span.addEventListener) {span.addEventListener("mousedown",this.Remove,true)}
-
+ var eW = zoom.offsetWidth || zoom.clientWidth; Mw -= eW; Mh -= eW;
+ zoom.style.maxWidth = Mw+"px"; zoom.style.maxHeight = Mh+"px";
+
if (this.msieTrapEventBug) {
var trap = HTML.Element("span",{id:"MathJax_ZoomEventTrap", onmousedown:this.Remove});
div.insertBefore(trap,zoom);
@@ -187,7 +189,7 @@
if (zoom.offsetWidth > Mw) {zoom.style.width = Mw+"px"; zoom.style.height = (bbox.zH+this.scrollSize)+"px"}
}
if (this.operaPositionBug) {zoom.style.width = Math.min(Mw,bbox.zW)+"px"} // Opera gets width as 0?
- if (zoom.offsetWidth && zoom.offsetWidth < Mw && zoom.offsetHeight < Mh)
+ if (zoom.offsetWidth > eW && zoom.offsetWidth-eW < Mw && zoom.offsetHeight-eW < Mh)
{zoom.style.overflow = "visible"} // don't show scroll bars if we don't need to
this.Position(zoom,bbox);
if (this.msieTrapEventBug) {
@@ -220,7 +222,9 @@
// Set the position of the zoom box and overlay
//
Position: function (zoom,bbox) {
+ zoom.style.display = "none"; // avoids getting excessive width in Resize()
var XY = this.Resize(), x = XY.x, y = XY.y, W = bbox.mW;
+ zoom.style.display = "";
var dx = -W-Math.floor((zoom.offsetWidth-W)/2), dy = bbox.Y;
zoom.style.left = Math.max(dx,10-x)+"px"; zoom.style.top = Math.max(dy,10-y)+"px";
if (!ZOOM.msiePositionBug) {ZOOM.SetWH()} // refigure overlay width/height
@@ -233,13 +237,8 @@
if (ZOOM.onresize) {ZOOM.onresize(event)}
var div = document.getElementById("MathJax_ZoomFrame"),
overlay = document.getElementById("MathJax_ZoomOverlay");
- var xy = ZOOM.getXY(div);
- var obj = div.parentNode, overflow = ZOOM.getOverflow(obj);
- while (obj.parentNode && obj !== document.body && overflow === "visible") {
- obj = obj.parentNode
- overflow = ZOOM.getOverflow(obj);
- }
- if (overflow !== "visible") {
+ var xy = ZOOM.getXY(div), obj = ZOOM.findContainer(div);
+ if (ZOOM.getOverflow(obj) !== "visible") {
overlay.scroll_parent = obj; // Save this for future reference.
var XY = ZOOM.getXY(obj); // Remove container position
xy.x -= XY.x; xy.y -= XY.y;
@@ -252,10 +251,17 @@
},
SetWH: function () {
var overlay = document.getElementById("MathJax_ZoomOverlay");
- overlay.style.width = overlay.style.height = "1px"; // so scrollWidth/Height will be right below
+ overlay.style.display = "none"; // so scrollWidth/Height will be right below
var doc = overlay.scroll_parent || document.documentElement || document.body;
overlay.style.width = doc.scrollWidth + "px";
overlay.style.height = Math.max(doc.clientHeight,doc.scrollHeight) + "px";
+ overlay.style.display = "";
+ },
+ findContainer: function (obj) {
+ var obj = obj.parentNode;
+ while (obj.parentNode && obj !== document.body && ZOOM.getOverflow(obj) === "visible")
+ {obj = obj.parentNode}
+ return obj;
},
//
// Look up CSS properties (use getComputeStyle if available, or currentStyle if not)
diff --git a/unpacked/jax/output/HTML-CSS/jax.js b/unpacked/jax/output/HTML-CSS/jax.js
@@ -772,7 +772,10 @@
this.outerEm = em / jax.HTMLCSS.scale;
emex.parentNode.removeChild(emex);
+ this.zoomScale = parseInt(HUB.config.menuSettings.zscale) / 100;
this.idPostfix = "-zoom"; jax.root.toHTML(span,span); this.idPostfix = "";
+ this.zoomScale = 1;
+
var width = jax.root.HTMLspanElement().bbox.width;
if (width) {
// Handle full-width displayed equations
@@ -954,7 +957,7 @@
if (length === MML.SIZE.BIG) {return 2}
if (length === MML.SIZE.SMALL) {return .71}
if (length === "infinity") {return HTMLCSS.BIGDIMEN}
- var factor = this.FONTDATA.TeX_factor;
+ var factor = this.FONTDATA.TeX_factor, emFactor = (HTMLCSS.zoomScale||1) / HTMLCSS.em;
if (length.match(/mathspace$/)) {return HTMLCSS.MATHSPACE[length]*factor}
var match = length.match(/^\s*([-+]?(?:\.\d+|\d+(?:\.\d*)?))?(pt|em|ex|mu|px|pc|in|mm|cm|%)?/);
var m = parseFloat(match[1]||"1"), unit = match[2];
@@ -962,12 +965,12 @@
if (unit === "em") {return m * factor}
if (unit === "ex") {return m * HTMLCSS.TeX.x_height * factor}
if (unit === "%") {return m / 100 * size}
- if (unit === "px") {return m / HTMLCSS.em}
- if (unit === "pt") {return m / 10 * factor} // 10 pt to an em
- if (unit === "pc") {return m * 1.2 * factor} // 12 pt to a pc
- if (unit === "in") {return m * this.pxPerInch / HTMLCSS.em}
- if (unit === "cm") {return m * this.pxPerInch / HTMLCSS.em / 2.54} // 2.54 cm to an inch
- if (unit === "mm") {return m * this.pxPerInch / HTMLCSS.em / 25.4} // 10 mm to a cm
+ if (unit === "px") {return m * emFactor}
+ if (unit === "pt") {return m / 10 * factor} // 10 pt to an em
+ if (unit === "pc") {return m * 1.2 * factor} // 12 pt to a pc
+ if (unit === "in") {return m * this.pxPerInch * emFactor}
+ if (unit === "cm") {return m * this.pxPerInch * emFactor / 2.54} // 2.54 cm to an inch
+ if (unit === "mm") {return m * this.pxPerInch * emFactor / 25.4} // 10 mm to a cm
if (unit === "mu") {return m / 18 * factor * mu} // 18mu to an em for the scriptlevel
return m*factor*size; // relative to given size (or 1em as default)
},
diff --git a/unpacked/jax/output/SVG/jax.js b/unpacked/jax/output/SVG/jax.js
@@ -417,13 +417,21 @@
emex.parentNode.removeChild(emex);
span.appendChild(this.textSVG);
- this.mathDIV = span;
+ this.mathDIV = span; this.zoomScale = parseInt(HUB.config.menuSettings.zscale) / 100;
this.idPostfix = "-zoom"; jax.root.toSVG(span,span); this.idPostfix = "";
+ this.zoomScale = 1;
span.removeChild(this.textSVG);
if (this.operaZoomRefresh)
{setTimeout(function () {span.firstChild.style.border="1px solid transparent"},1)}
//
+ // WebKit bug (issue #749)
+ //
+ if (span.offsetWidth < span.firstChild.offsetWidth) {
+ span.style.minWidth = span.firstChild.offsetWidth + "px";
+ math.style.minWidth = math.firstChild.offsetWidth + "px";
+ }
+ //
// Get height and width of zoomed math and original math
//
span.style.position = math.style.position = "absolute";
@@ -465,18 +473,19 @@
if (length === MML.SIZE.SMALL) {return 710}
if (length === "infinity") {return SVG.BIGDIMEN}
if (length.match(/mathspace$/)) {return 1000*SVG.MATHSPACE[length]}
+ var emFactor = (this.zoomScale || 1) / SVG.em;
var match = length.match(/^\s*([-+]?(?:\.\d+|\d+(?:\.\d*)?))?(pt|em|ex|mu|px|pc|in|mm|cm|%)?/);
var m = parseFloat(match[1]||"1") * 1000, unit = match[2];
if (size == null) {size = 1000}; if (mu == null) {mu = 1}
if (unit === "em") {return m}
if (unit === "ex") {return m * SVG.TeX.x_height/1000}
if (unit === "%") {return m / 100 * size / 1000}
- if (unit === "px") {return m / SVG.em}
- if (unit === "pt") {return m / 10} // 10 pt to an em
- if (unit === "pc") {return m * 1.2} // 12 pt to a pc
- if (unit === "in") {return m * this.pxPerInch / SVG.em}
- if (unit === "cm") {return m * this.pxPerInch / SVG.em / 2.54} // 2.54 cm to an inch
- if (unit === "mm") {return m * this.pxPerInch / SVG.em / 25.4} // 10 mm to a cm
+ if (unit === "px") {return m * emFactor}
+ if (unit === "pt") {return m / 10} // 10 pt to an em
+ if (unit === "pc") {return m * 1.2} // 12 pt to a pc
+ if (unit === "in") {return m * this.pxPerInch * emFactor}
+ if (unit === "cm") {return m * this.pxPerInch * emFactor / 2.54} // 2.54 cm to an inch
+ if (unit === "mm") {return m * this.pxPerInch * emFactor / 25.4} // 10 mm to a cm
if (unit === "mu") {return m / 18 * mu}
return m*size / 1000; // relative to given size (or 1em as default)
},