17 lines
7.4 KiB
JavaScript
17 lines
7.4 KiB
JavaScript
/*
|
|
* /MathJax/extensions/MathZoom.js
|
|
*
|
|
* Copyright (c) 2010 Design Science, Inc.
|
|
*
|
|
* Part of the MathJax library.
|
|
* See http://www.mathjax.org for details.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0;
|
|
* you may not use this file except in compliance with the License.
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*/
|
|
|
|
(function(a,d,f,c,i){var j="1.1.3";var h=a.CombineConfig("MathZoom",{delay:400,styles:{"#MathJax_Zoom":{position:"absolute","background-color":"#F0F0F0",overflow:"auto",display:"block","z-index":301,padding:".5em",border:"1px solid black",margin:0,"font-family":"serif","font-size":"85%","font-weight":"normal","font-style":"normal","text-align":"left","text-indent":0,"text-transform":"none","line-height":"normal","letter-spacing":"normal","word-spacing":"normal","word-wrap":"normal","white-space":"nowrap","float":"none","box-shadow":"5px 5px 15px #AAAAAA","-webkit-box-shadow":"5px 5px 15px #AAAAAA","-moz-box-shadow":"5px 5px 15px #AAAAAA","-khtml-box-shadow":"5px 5px 15px #AAAAAA",filter:"progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color='gray', Positive='true')"},"#MathJax_ZoomOverlay":{position:"absolute",left:0,top:0,"z-index":300,display:"inline-block",width:"100%",height:"100%",border:0,padding:0,margin:0,"background-color":"white",opacity:0,filter:"alpha(opacity=0)"}}});var e,b;MathJax.Hub.Register.StartupHook("MathEvents Ready",function(){e=MathJax.Extension.MathEvents.Event.False;b=MathJax.Extension.MathEvents.Hover});var g=MathJax.Extension.MathZoom={version:j,settings:a.config.menuSettings,HandleEvent:function(m,k,l){if(g.settings.CTRL&&!m.ctrlKey){return true}if(g.settings.ALT&&!m.altKey){return true}if(g.settings.CMD&&!m.metaKey){return true}if(g.settings.Shift&&!m.shiftKey){return true}if(!g[k]){return true}return g[k](m,l)},Click:function(l,k){if(this.settings.zoom==="Click"){return this.Zoom(k,l)}},DblClick:function(l,k){if(this.settings.zoom==="Double-Click"){return this.Zoom(k,l)}},Hover:function(l,k){if(this.settings.zoom==="Hover"){this.Zoom(k,l);return true}return false},Zoom:function(t,m){this.Remove();b.ClearHoverTimer();var w=t.parentNode;if(w.className==="MathJax_MathContainer"){w=w.parentNode}if(w.parentNode.className==="MathJax_MathContainer"){w=w.parentNode.parentNode}var r=(String(w.className).match(/^MathJax_(MathML|Display)$/)?w:t).nextSibling;var n=a.getJaxFor(r),s=n.root;var p=(c&&n.outputJax.isa(c.constructor)?"HTMLCSS":(i&&n.outputJax.isa(i.constructor)?"MathML":null));if(!p){return}if(n.hover){b.UnHover(n)}var k=Math.floor(0.85*document.body.clientWidth),q=Math.floor(0.85*document.body.clientHeight);var l=d.Element("span",{style:{position:"relative",display:"inline-block",height:0,width:0},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":k+"px","max-height":q+"px"}},[["span"]]]]);var y=l.lastChild,v=y.firstChild,o=l.firstChild;t.parentNode.insertBefore(l,t);if(this.msieZIndexBug){var u=d.Element("img",{src:"about:blank",id:"MathJax_ZoomTracker",style:{width:0,height:0,position:"relative"}});document.body.appendChild(l);l.style.position="absolute";l.style.zIndex=h.styles["#MathJax_ZoomOverlay"]["z-index"];l=u}var x=(this["Zoom"+p])(s,v,t);if(this.msiePositionBug){if(this.msieIE8Bug){v.style.position="absolute";y.style.height=v.offsetHeight;v.style.position="";if(y.offsetHeight<=q&&y.offsetWidth<=k){y.style.overflow="visible"}}if(this.msieWidthBug){y.style.width=Math.min(k,x.w)}else{if(x.w>k){y.style.width=k}}if(y.offsetHeight>q){y.style.Height=q+"px"}if(t.nextSibling){t.parentNode.insertBefore(l,t.nextSibling)}else{w.appendChild(l)}}else{if(this.operaPositionBug){y.style.width=Math.min(k,v.offsetWidth)+"px"}}this.Position(y,x,(p==="MathML"&&w.nodeName.toLowerCase()==="div"));y.style.visibility="";if(this.settings.zoom==="Hover"){o.onmouseover=this.Remove}if(window.addEventListener){addEventListener("resize",this.Resize,false)}else{if(window.attachEvent){attachEvent("onresize",this.Resize)}else{this.onresize=window.onresize;window.onresize=this.Resize}}return e(m)},ZoomHTMLCSS:function(p,r,q){r.className="MathJax";c.idPostfix="-zoom";c.getScales(r,r);p.toHTML(r,r);var s=p.HTMLspanElement().bbox;c.idPostfix="";if(s.width&&s.width!=="100%"){var k=Math.floor(0.85*document.body.clientWidth);r.style.width=k+"px";r.style.display="inline-block";var l=(p.id||"MathJax-Span-"+p.spanID)+"-zoom";var m=document.getElementById(l).firstChild;while(m&&m.style.width!==s.width){m=m.nextSibling}if(m){m.style.width="100%"}}r.appendChild(this.topImg);var o=this.topImg.offsetTop;r.removeChild(this.topImg);var n=(this.msieWidthBug?c.getW(q)*c.em:q.offsetWidth);return{w:s.w*c.em,Y:-o,W:n}},ZoomMathML:function(l,m,n){l.toNativeMML(m,m);var o;m.appendChild(this.topImg);o=this.topImg.offsetTop;m.removeChild(this.topImg);var k=(this.ffMMLwidthBug?n.parentNode:n).offsetWidth;return{w:m.offsetWidth,Y:-o,W:k}},Position:function(q,o,s){var l=this.Resize(),n=l.x,m=l.y,k=o.W;if(this.msiePositionBug){k=-k}if(s&&this.ffMMLcenterBug){k=0}var r=-Math.floor((q.offsetWidth-k)/2),p=o.Y;q.style.left=Math.max(r,20-n)+"px";q.style.top=Math.max(p,20-m)+"px"},Resize:function(m){if(g.onresize){g.onresize(m)}var k=0,p=0,o=document.getElementById("MathJax_ZoomFrame"),l=document.getElementById("MathJax_ZoomOverlay");var n=(g.msieZIndexBug?document.getElementById("MathJax_ZoomTracker"):o);if(g.operaPositionBug){o.style.border="1px solid"}if(n.offsetParent){do{k+=n.offsetLeft;p+=n.offsetTop}while(n=n.offsetParent)}if(g.operaPositionBug){o.style.border=""}if(g.msieZIndexBug){o.style.left=k+"px";o.style.top=p+"px"}l.style.left=(-k)+"px";l.style.top=(-p)+"px";if(g.msiePositionBug){setTimeout(g.SetWH,0)}else{g.SetWH()}return{x:k,y:p}},SetWH:function(){var k=document.getElementById("MathJax_ZoomOverlay");k.style.width=k.style.height="1px";k.style.width=document.body.scrollWidth+"px";k.style.height=document.body.scrollHeight+"px"},Remove:function(l){var m=document.getElementById("MathJax_ZoomFrame");if(m){m.parentNode.removeChild(m);m=document.getElementById("MathJax_ZoomTracker");if(m){m.parentNode.removeChild(m)}if(g.operaRefreshBug){var k=d.addElement(document.body,"div",{style:{position:"fixed",left:0,top:0,width:"100%",height:"100%",backgroundColor:"white",opacity:0},id:"MathJax_OperaDiv"});document.body.removeChild(k)}if(window.removeEventListener){removeEventListener("resize",g.Resize,false)}else{if(window.detachEvent){detachEvent("onresize",g.Resize)}else{window.onresize=g.onresize;delete g.onresize}}}return e(l)}};a.Browser.Select({MSIE:function(k){var l=(document.compatMode==="BackCompat");var m=k.versionAtLeast("8.0")&&document.documentMode>7;g.msiePositionBug=true;g.msieWidthBug=!l;g.msieIE8Bug=m;g.msieZIndexBug=!m;g.msieInlineBlockAlignBug=(!m||l);if(document.documentMode>=9){delete h.styles["#MathJax_Zoom"].filter}},Opera:function(k){g.operaPositionBug=true;g.operaRefreshBug=true},Firefox:function(k){g.ffMMLwidthBug=true;g.ffMMLcenterBug=true}});g.topImg=(g.msieInlineBlockAlignBug?d.Element("img",{style:{width:0,height:0},src:"about:blank"}):d.Element("span",{style:{width:0,height:0,display:"inline-block"}}));if(g.operaPositionBug){g.topImg.style.border="1px solid"}MathJax.Callback.Queue(["Styles",f,h.styles],["Post",a.Startup.signal,"MathZoom Ready"],["loadComplete",f,"[MathJax]/extensions/MathZoom.js"])})(MathJax.Hub,MathJax.HTML,MathJax.Ajax,MathJax.OutputJax["HTML-CSS"],MathJax.OutputJax.NativeMML);
|
|
|