Clean up Zoom functions, in particular some of the IE complications; move getBBox to MathEvents

This commit is contained in:
Davide P. Cervone 2011-08-25 19:45:25 -04:00
parent 975fe6e679
commit acf080caae
20 changed files with 103 additions and 135 deletions

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

View File

@ -12,5 +12,5 @@
* http://www.apache.org/licenses/LICENSE-2.0
*/
MathJax.OutputJax["HTML-CSS"]=MathJax.OutputJax({id:"HTML-CSS",version:"1.1.12",directory:MathJax.OutputJax.directory+"/HTML-CSS",extensionDir:MathJax.OutputJax.extensionDir+"/HTML-CSS",autoloadDir:MathJax.OutputJax.directory+"/HTML-CSS/autoload",fontDir:MathJax.OutputJax.directory+"/HTML-CSS/fonts",webfontDir:MathJax.OutputJax.fontDir+"/HTML-CSS",config:{scale:100,minScaleAdjust:50,availableFonts:["STIX","TeX"],preferredFont:"TeX",webFont:"TeX",imageFont:"TeX",undefinedFamily:"STIXGeneral,'Arial Unicode MS',serif",styles:{".MathJax_Display":{"text-align":"center",margin:"1em 0em"},".MathJax .merror":{"background-color":"#FFFF88",color:"#CC0000",border:"1px solid #CC0000",padding:"1px 3px","font-family":"serif","font-style":"normal","font-size":"90%"},".MathJax_Preview":{color:"#888888"},"#MathJax_Tooltip":{"background-color":"InfoBackground",color:"InfoText",border:"1px solid black","box-shadow":"2px 2px 5px #AAAAAA","-webkit-box-shadow":"2px 2px 5px #AAAAAA","-moz-box-shadow":"2px 2px 5px #AAAAAA","-khtml-box-shadow":"2px 2px 5px #AAAAAA",filter:"progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color='gray', Positive='true')",padding:"3px 4px"}}}});if(MathJax.Hub.Browser.isMSIE&&document.documentMode>=9){delete MathJax.OutputJax["HTML-CSS"].config.styles["#MathJax_Tooltip"].filter}if(!MathJax.Hub.config.delayJaxRegistration){MathJax.OutputJax["HTML-CSS"].Register("jax/mml")}MathJax.Hub.Register.StartupHook("End Config",[function(b,c){var a=b.Insert({minBrowserVersion:{Firefox:3,Opera:9.52,MSIE:6,Chrome:0.3,Safari:2,Konqueror:4},inlineMathDelimiters:["$","$"],displayMathDelimiters:["$$","$$"],multilineDisplay:true,minBrowserTranslate:function(f){var e=b.getJaxFor(f),k=["[Math]"],j;var h=document.createElement("span",{className:"MathJax_Preview"});if(e.inputJax.id==="TeX"){if(e.root.Get("displaystyle")){j=a.displayMathDelimiters;k=[j[0]+e.originalText+j[1]];if(a.multilineDisplay){k=k[0].split(/\n/)}}else{j=a.inlineMathDelimiters;k=[j[0]+e.originalText.replace(/^\s+/,"").replace(/\s+$/,"")+j[1]]}}for(var g=0,d=k.length;g<d;g++){h.appendChild(document.createTextNode(k[g]));if(g<d-1){h.appendChild(document.createElement("br"))}}f.parentNode.insertBefore(h,f)}},(b.config["HTML-CSS"]||{}));if(b.Browser.version!=="0.0"&&!b.Browser.versionAtLeast(a.minBrowserVersion[b.Browser]||0)){c.Translate=a.minBrowserTranslate;b.Config({showProcessingMessages:false});MathJax.Message.Set("Your browser does not support MathJax",null,4000);b.Startup.signal.Post("MathJax not supported")}},MathJax.Hub,MathJax.OutputJax["HTML-CSS"]]);MathJax.OutputJax["HTML-CSS"].loadComplete("config.js");
MathJax.OutputJax["HTML-CSS"]=MathJax.OutputJax({id:"HTML-CSS",version:"1.1.13",directory:MathJax.OutputJax.directory+"/HTML-CSS",extensionDir:MathJax.OutputJax.extensionDir+"/HTML-CSS",autoloadDir:MathJax.OutputJax.directory+"/HTML-CSS/autoload",fontDir:MathJax.OutputJax.directory+"/HTML-CSS/fonts",webfontDir:MathJax.OutputJax.fontDir+"/HTML-CSS",config:{scale:100,minScaleAdjust:50,availableFonts:["STIX","TeX"],preferredFont:"TeX",webFont:"TeX",imageFont:"TeX",undefinedFamily:"STIXGeneral,'Arial Unicode MS',serif",styles:{".MathJax_Display":{"text-align":"center",margin:"1em 0em"},".MathJax .merror":{"background-color":"#FFFF88",color:"#CC0000",border:"1px solid #CC0000",padding:"1px 3px","font-family":"serif","font-style":"normal","font-size":"90%"},".MathJax_Preview":{color:"#888888"},"#MathJax_Tooltip":{"background-color":"InfoBackground",color:"InfoText",border:"1px solid black","box-shadow":"2px 2px 5px #AAAAAA","-webkit-box-shadow":"2px 2px 5px #AAAAAA","-moz-box-shadow":"2px 2px 5px #AAAAAA","-khtml-box-shadow":"2px 2px 5px #AAAAAA",filter:"progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color='gray', Positive='true')",padding:"3px 4px"}}}});if(MathJax.Hub.Browser.isMSIE&&document.documentMode>=9){delete MathJax.OutputJax["HTML-CSS"].config.styles["#MathJax_Tooltip"].filter}if(!MathJax.Hub.config.delayJaxRegistration){MathJax.OutputJax["HTML-CSS"].Register("jax/mml")}MathJax.Hub.Register.StartupHook("End Config",[function(b,c){var a=b.Insert({minBrowserVersion:{Firefox:3,Opera:9.52,MSIE:6,Chrome:0.3,Safari:2,Konqueror:4},inlineMathDelimiters:["$","$"],displayMathDelimiters:["$$","$$"],multilineDisplay:true,minBrowserTranslate:function(f){var e=b.getJaxFor(f),k=["[Math]"],j;var h=document.createElement("span",{className:"MathJax_Preview"});if(e.inputJax.id==="TeX"){if(e.root.Get("displaystyle")){j=a.displayMathDelimiters;k=[j[0]+e.originalText+j[1]];if(a.multilineDisplay){k=k[0].split(/\n/)}}else{j=a.inlineMathDelimiters;k=[j[0]+e.originalText.replace(/^\s+/,"").replace(/\s+$/,"")+j[1]]}}for(var g=0,d=k.length;g<d;g++){h.appendChild(document.createTextNode(k[g]));if(g<d-1){h.appendChild(document.createElement("br"))}}f.parentNode.insertBefore(h,f)}},(b.config["HTML-CSS"]||{}));if(b.Browser.version!=="0.0"&&!b.Browser.versionAtLeast(a.minBrowserVersion[b.Browser]||0)){c.Translate=a.minBrowserTranslate;b.Config({showProcessingMessages:false});MathJax.Message.Set("Your browser does not support MathJax",null,4000);b.Startup.signal.Post("MathJax not supported")}},MathJax.Hub,MathJax.OutputJax["HTML-CSS"]]);MathJax.OutputJax["HTML-CSS"].loadComplete("config.js");

File diff suppressed because one or more lines are too long

View File

@ -12,5 +12,5 @@
* http://www.apache.org/licenses/LICENSE-2.0
*/
MathJax.OutputJax.NativeMML=MathJax.OutputJax({id:"NativeMML",version:"1.1.8",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.9",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");

File diff suppressed because one or more lines are too long

View File

@ -36,8 +36,8 @@
x: 3.5, y: 5, // frame padding and
bwidth: 1, // frame border width (in pixels)
bcolor: "#A6D", // frame border color
hwidth: "15px", // haze width
hcolor: "#83A", // haze color
hwidth: "15px", // haze width
hcolor: "#83A" // haze color
},
button: {
x: -4, y: -3, // menu button offsets
@ -186,6 +186,13 @@
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};
}
};
@ -268,7 +275,7 @@
show = (JAX.config.showMathMenu != null ? JAX : HUB).config.showMathMenu;
var dx = CONFIG.frame.x, dy = CONFIG.frame.y, dd = CONFIG.frame.bwidth; // frame size
if (ME.msieBorderWidthBug) {dd = 0}
jax.hover = {opacity:0, id: jax.inputID+"-Hover"};
jax.hover = {opacity:0, id:jax.inputID+"-Hover"};
//
// The frame and menu button
//
@ -464,19 +471,33 @@
//
HUB.Browser.Select({
MSIE: function (browser) {
var mode = (document.documentMode||0);
var mode = (document.documentMode || 0);
var isIE8 = browser.versionAtLeast("8.0");
ME.msieBorderWidthBug = (document.compatMode === "BackCompat"); // borders are inside offsetWidth/Height
ME.msieEventBug = browser.isIE9; // must get event from window even though event is passed
if (mode < 9) {EVENT.LEFTBUTTON = 1} // IE < 9 has wrong event.button values
ME.msieEventBug = browser.isIE9; // must get event from window even though event is passed
ME.msieAlignBug = (!isIE8 || mode < 8); // inline-block spans don't rest on baseline
if (mode < 9) {EVENT.LEFTBUTTON = 1} // IE < 9 has wrong event.button values
},
Safari: function (browser) {
ME.safariContextMenuBug = true; // selection can be started by contextmenu event
},
Opera: function (browser) {
ME.operaPositionBug = true; // position is wrong unless border is used
},
Konqueror: function (browser) {
ME.noContextMenuBug = true; // doesn't produce contextmenu event
}
});
//
// Used in measuring zoom and hover positions
//
ME.topImg = (ME.msieAlignBug ?
HTML.Element("img",{style:{width:0,height:0,position:"relative"},src:"about:blank"}) :
HTML.Element("span",{style:{width:0,height:0,display:"inline-block"}})
);
if (1 || ME.operaPositionBug/* || ME.msieTopBug*/) {ME.topImg.style.border="1px solid"}
//
// Get configuration from user
//

View File

@ -137,7 +137,7 @@
position:"absolute",
width: "31px", height: "31px",
top:"-15px", left:"-15px"
},
}
}
});

View File

@ -41,7 +41,7 @@
"-webkit-box-shadow":"5px 5px 15px #AAAAAA", // Safari 3 and Chrome
"-moz-box-shadow":"5px 5px 15px #AAAAAA", // Forefox 3.5
"-khtml-box-shadow":"5px 5px 15px #AAAAAA", // Konqueror
filter: "progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color='gray', Positive='true')" // IE
filter: "dropshadow(OffX=2, OffY=2, Color='gray', Positive='true')" // IE
},
//
@ -107,17 +107,14 @@
// Handle the actual zooming
//
Zoom: function (event,math) {
this.Remove(); HOVER.ClearHoverTimer();
EVENT.ClearSelection();
//
// Remove any other zoom and clear timers
//
this.Remove(); HOVER.ClearHoverTimer(); EVENT.ClearSelection();
//
// Find the jax and its type
// Find the jax
//
/*
* var parent = math.parentNode;
* if (parent.className === "MathJax_MathContainer") {parent = parent.parentNode}
* if (parent.parentNode.className === "MathJax_MathContainer") {parent = parent.parentNode.parentNode}
*/
var JAX = MathJax.OutputJax[math.jaxID];
var jax = JAX.getJaxFromMath(math), root = jax.root;
if (jax.hover) {HOVER.UnHover(jax)}
@ -134,7 +131,7 @@
},[
["span",{id:"MathJax_ZoomOverlay", onmousedown:this.Remove}],
["span",{
id:"MathJax_Zoom", onclick: this.Remove,
id:"MathJax_Zoom", onclick:this.Remove,
style:{
visibility:"hidden", fontSize:this.settings.zscale,
"max-width":Mw+"px", "max-height":Mh+"px"
@ -144,6 +141,7 @@
);
var zoom = div.lastChild, span = zoom.firstChild, overlay = div.firstChild;
math.parentNode.insertBefore(div,math);
if (span.addEventListener) {span.addEventListener("mousedown",this.Remove,true)}
//
// Display the zoomed math
@ -168,14 +166,12 @@
if (this.msiePositionBug) {
if (this.msieSizeBug)
{zoom.style.height = bbox.zH+"px"; zoom.style.width = bbox.zW+"px"} // IE8 gets the dimensions completely wrong
if (zoom.offsetHeight > Mh) {zoom.style.height = Mh+"px"} // IE doesn't do max-height?
if (zoom.offsetWidth > Mw) {zoom.style.width = Mw+"px"}
if (math.nextSibling) {math.parentNode.insertBefore(div,math.nextSibling)}
else {parent.appendChild(div)} // needs to be after to be above?
if (zoom.offsetHeight > Mh) {zoom.style.height = Mh+"px"; span.style.marginRight = "16px"} // IE doesn't do max-height?
if (zoom.offsetWidth > Mw) {zoom.style.width = Mw+"px"; span.style.marginBottom = "16px"}
}
if (this.operaPositionBug) {zoom.style.width = Math.min(Mw,bbox.zW)+"px"} // Opera gets width as 0?
if (zoom.offsetWidth <= Mw && zoom.offsetHeight <= Mh) {zoom.style.overflow = "visible"}
this.Position(zoom,bbox,(JAX.id === "MathML" && parent.nodeName.toLowerCase() === "div"));
if (zoom.offsetWidth < Mw && zoom.offsetHeight < Mh) {zoom.style.overflow = "visible"}
this.Position(zoom,bbox);
zoom.style.visibility = "";
//
@ -192,31 +188,11 @@
return FALSE(event);
},
//
// Get top offset from baseline
//
getTop: function (root,span,math,topBug,borderBug) {
span.appendChild(this.topImg);
var top = this.topImg.offsetTop;
if (topBug) {
// For IE, frame is not at the baseline, so remove extra height
var wrap = math.parentNode.style.whiteSpace;
math.parentNode.style.whiteSpace = "nowrap";
math.parentNode.insertBefore(this.topImg,math);
top -= this.topImg.offsetTop - span.parentNode.parentNode.offsetTop;
math.parentNode.style.whiteSpace = wrap;
}
if (borderBug) {top += Math.floor(.5*HTMLCSS.em)} // adjust for zoom box padding
this.topImg.parentNode.removeChild(this.topImg);
return top;
},
//
// Set the position of the zoom box and overlay
//
Position: function (zoom,bbox,MMLdisplay) {
Position: function (zoom,bbox) {
var XY = this.Resize(), x = XY.x, y = XY.y, W = bbox.mW;
if (this.msieIE8Bug) {W = -W}
var dx = -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";
},
@ -278,16 +254,14 @@
HUB.Browser.Select({
MSIE: function (browser) {
var quirks = (document.compatMode === "BackCompat");
var isIE8 = browser.versionAtLeast("8.0") && document.documentMode > 7;
var isIE9 = document.documentMode >= 9;
var mode = (document.documentMode || 0);
var isIE9 = (mode >= 9);
ZOOM.msiePositionBug = !isIE9;
ZOOM.msieSizeBug = browser.versionAtLeast("7.0") &&
(!document.documentMode || document.documentMode === 7 || document.documentMode === 8);
ZOOM.msieIE8Bug = isIE8 && (document.documentMode === 8);
ZOOM.msieZIndexBug = !isIE8;
ZOOM.msieInlineBlockAlignBug = (!isIE8 || quirks);
if (document.documentMode >= 9) {delete CONFIG.styles["#MathJax_Zoom"].filter}
(!document.documentMode || mode === 7 || mode === 8);
ZOOM.msieZIndexBug = (mode <= 7);
ZOOM.msieInlineBlockAlignBug = (mode <= 7);
if (isIE9) {delete CONFIG.styles["#MathJax_Zoom"].filter}
},
Opera: function (browser) {

View File

@ -443,19 +443,16 @@
//
// Re-render at larger size
//
span.className = "MathJax";
this.idPostfix = "-zoom";
this.getScales(span,span);
root.toHTML(span,span);
var bbox = root.HTMLspanElement().bbox;
this.idPostfix = "";
if (bbox.width) {
span.className = "MathJax"; this.getScales(span,span);
this.idPostfix = "-zoom"; root.toHTML(span,span); this.idPostfix = "";
var width = 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 child = document.getElementById(id).firstChild;
while (child && child.style.width !== bbox.width) {child = child.nextSibling}
while (child && child.style.width !== width) {child = child.nextSibling}
if (child) {child.style.width = "100%"}
}
//
@ -467,9 +464,7 @@
if (mW === 0) {mW = math.parentNode.offsetWidth}; // IE7 gets mW == 0?
span.style.position = math.style.position = "";
//
var ZOOM = MathJax.Extension.MathZoom;
return {Y:-ZOOM.getTop(root,span,math,ZOOM.msieTopBug,ZOOM.msieBorderBug),
mW:mW, mH:mH, zW:zW, zH:zH};
return {Y:-EVENT.getBBox(span).h, mW:mW, mH:mH, zW:zW, zH:zH};
},
initImg: function (span) {},
@ -2205,8 +2200,6 @@
msieClipRectBug: !isIE8,
msieNegativeSpaceBug: quirks,
msieCloneNodeBug: (isIE8 && browser.version === "8.0"),
msieTopBug: (!browser.versionAtLeast("8.0") || document.documentMode === 7),
msieBorderBug: (quirks && browser.versionAtLeast("8.0")),
negativeSkipBug: true,
msieIE6: !isIE7,
msieItalicWidthBug: true,

View File

@ -205,23 +205,19 @@
return math.firstChild;
},
getHoverBBox: function (jax,span,math) {
span = span.parentNode;
span.appendChild(this.topImg);
var h = this.topImg.offsetTop, d = span.offsetHeight-h, w = span.offsetWidth;
span.removeChild(this.topImg);
var x = (math.className === "MathJax_MSIE_Overlay" ? -w : 0);
return {w:w, h:h, d:d, x:x}
var bbox = EVENT.getBBox(span.parentNode);
bbox.x = (math.className === "MathJax_MSIE_Overlay" ? -bbox.w : 0);
return bbox;
},
Zoom: function (root,span,math) {
Zoom: function (root,span,math,Mw,Mh) {
root.toNativeMML(span,span);
var top = ZOOM.getTop(root,span.parentNode,math,this.msieTopBug,false);
if (this.msieIE8HeightBug) {span.style.position = "absolute"}
var mW = math.offsetWidth || math.scrollWidth,
mH = math.offsetHeight || math.scrollHeight;
var zW = span.offsetWidth, zH = span.offsetHeight;
if (this.msieIE8HeightBug) {span.style.position = ""}
return {Y:-top, mW:mW, mH:mH, zW:zW, zH:zH}
return {Y:-EVENT.getBBox(span.parentNode).h, mW:mW, mH:mH, zW:zW, zH:zH}
},
NAMEDSPACE: {
@ -492,30 +488,14 @@
//
HUB.Browser.Select({
MSIE: function (browser) {
var quirks = (document.compatMode === "BackCompat");
var mode = (document.documentMode || 0);
var isIE8 = browser.versionAtLeast("8.0");
nMML.Augment({
msieInlineBlockAlignBug: (!isIE8 || mode < 8 || quirks),
msieTopBug: (!isIE8 || mode === 7),
msieIE8HeightBug: (mode === 8),
msieTopBug: (!isIE8 || mode !== 8)
});
nMML.msieIE8HeightBug = (mode === 8);
},
Opera: function (browser) {
nMML.operaPositionBug = true;
}
});
//
// Used in measuring zoom and hover positions
//
nMML.topImg = (nMML.msieInlineBlockAlignBug ?
HTML.Element("img",{style:{width:0,height:0,position:"relative"},src:"about:blank"}) :
HTML.Element("span",{style:{width:0,height:0,display:"inline-block"}})
);
if (nMML.operaPositionBug || nMML.msieTopBug) {nMML.topImg.style.border="1px solid"}
HUB.Register.StartupHook("End Cookie",function () {
if (HUB.config.menuSettings.zoom !== "None")