17 lines
11 KiB
JavaScript
17 lines
11 KiB
JavaScript
/*
|
|
* /MathJax/jax/output/NativeMML/jax.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(j,b,f,d){var e,h=b.Browser.isMSIE;var g,a,c,i;b.Register.StartupHook("MathZoom Ready",function(){i=MathJax.Extension.MathZoom});j.Augment({config:{styles:{}},settings:b.config.menuSettings,Startup:function(){g=MathJax.Extension.MathEvents.Event;a=MathJax.Extension.MathEvents.Touch;c=MathJax.Extension.MathEvents.Hover;this.ContextMenu=g.ContextMenu;this.Mousedown=g.AltContextMenu;this.Mouseover=c.Mouseover;this.Mouseout=c.Mouseout;this.Mousemove=c.Mousemove;return f.Styles(this.config.styles)},Config:function(){this.SUPER(arguments).Config.call(this);if(this.settings.scale){this.config.scale=this.settings.scale}if(b.config.displayAlign!=="center"){var m=b.config.displayAlign,k=b.config.displayIndent;var l={"text-align":m+"!important"};l["margin-"+m]=k+"!important";MathJax.Hub.Insert(this.config.styles,{"div.MathJax_MathML":l,"div.MathJax_MathML math":{"text-align":m},"div.MathJax_MathContainer > span":{"text-align":m+"!important"}})}this.require.push(MathJax.OutputJax.extensionDir+"/MathEvents.js")},InitializeMML:function(){this.initialized=true;if(b.Browser.isMSIE){try{var k=document.createElement("object");k.id="mathplayer";k.classid="clsid:32F66A20-7614-11D4-BD11-00104BD3F987";document.getElementsByTagName("head")[0].appendChild(k);document.namespaces.add("mjx","http://www.w3.org/1998/Math/MathML");document.namespaces.mjx.doImport("#mathplayer")}catch(l){alert("MathJax was not able to set up MathPlayer.\n\nIf MathPlayer is not installed, you need to install it first.\nOtherwise, your security settings may be preventing ActiveX \ncontrols from running. Use the Internet Options item under\nthe Tools menu and select the Security tab, then press the\nCustom Level button. Check that the settings for\n'Run ActiveX Controls', and 'Binary and script behaviors'\nare enabled.\n\nCurrently you will see error messages rather than\ntypeset mathematics.")}}},Translate:function(l){if(!l.parentNode){return}if(!this.initialized){this.InitializeMML()}var q=l.previousSibling;if(q&&String(q.className).match(/^MathJax(_MathML|_Display)?$/)){q.parentNode.removeChild(q)}var p=l.MathJax.elementJax.root;var o=(p.Get("display")==="block"?"div":"span");var n=d.Element(o,{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"}}]]]]),k=n.firstChild;p.toNativeMML(k.firstChild);l.parentNode.insertBefore(n,l);if(h){if(k.addEventListener){k.addEventListener("contextmenu",g.Menu,true);k.addEventListener("mouseover",g.Mouseover,true);k.addEventListener("mouseout",g.Mouseout,true);k.addEventListener("mousedown",g.Mousedown,true);k.addEventListener("mouseup",g.False,true);k.addEventListener("click",g.Click,true);k.addEventListener("dblclick",g.DblClick,true)}else{var m=(this.config.showMathMenuMSIE!=null?this:b).config;if(m.showMathMenuMSIE){this.MSIEoverlay(k)}}}else{k.oncontextmenu=g.Menu;k.onmouseover=g.Mouseover;k.onmouseout=g.Mouseout;k.onmousedown=g.Mousedown;k.onclick=g.Click;k.ondblclick=g.DblClick}},Remove:function(k){var l=k.SourceElement();if(!l){return}l=l.previousSibling;if(!l){return}if(l.className.match(/MathJax_MathML/)){l.parentNode.removeChild(l)}},MMLnamespace:"http://www.w3.org/1998/Math/MathML",MSIEoverlay:function(k){var l=k.firstChild;if(l.nodeName.toLowerCase()==="span"){l=l.firstChild}var m=this.getHoverBBox(null,l,{});d.addElement(k,"span",{style:{display:"inline-block",width:0,height:0,position:"relative"}},[["span",{isMathJax:true,className:"MathJax_MathPlayer_Overlay",style:{display:"inline-block",position:"absolute",left:c.Px(-m.w),top:c.Px(-m.h-(m.y||0)-1),width:c.Px(m.w),height:c.Px(m.h+m.d),cursor:"pointer","background-color":"white",filter:"alpha(opacity=0)"}}]]);b.Insert(k,{msieMath:l,onmousedown:this.MSIEevent,oncontextmenu:this.MSIEevent,onclick:this.MSIEevent,onmouseup:this.MSIEevent,onmousemove:this.MSIEevent,ondblclick:this.MSIEevent,onmouseover:this.MSIEevent,onmouseout:this.MSIEevent})},MSIEevents:{mousedown:"Mousedown",contextmenu:"ContextMenu",click:"Click",mouseup:"Mouseup",mousemove:"Mousemove",dblclick:"DblClick",mouseover:"Mouseover",mouseout:"Mouseout"},MSIEevent:function(){var l=window.event;var k=j.MSIEevents[l.type];if(j[k]&&j[k](l,this)===false){return false}if(i&&i.HandleEvent(l,k,this)===false){return false}if(l.srcElement.className==="MathJax_MathPlayer_Overlay"&&this.msieMath.fireEvent){this.msieMath.fireEvent("on"+l.type,l)}return g.False(l)},getJaxFromMath:function(k){if(k.className==="MathJax_MSIE_Overlay"){k=k.parentNode.parentNode}return b.getJaxFor(k.parentNode.nextSibling)},getHoverSpan:function(k,l){if(l.className==="MathJax_MSIE_Overlay"){return l.parentNode}return l.firstChild},getHoverBBox:function(k,l,m){var n=g.getBBox(l.parentNode);n.x=(m.className==="MathJax_MSIE_Overlay"?-n.w:0);return n},Zoom:function(o,r,p,k,n){o.toNativeMML(r,r);if(this.msieIE8HeightBug){r.style.position="absolute"}var l=p.offsetWidth||p.scrollWidth,s=p.offsetHeight||p.scrollHeight;var q=r.offsetWidth,m=r.offsetHeight;if(this.msieIE8HeightBug){r.style.position=""}return{Y:-g.getBBox(r.parentNode).h,mW:l,mH:s,zW:q,zH:m}},NAMEDSPACE:{negativeveryverythinmathspace:"-.0556em",negativeverythinmathspace:"-.1111em",negativethinmathspace:"-.1667em",negativemediummathspace:"-.2222em",negativethickmathspace:"-.2778em",negativeverythickmathspace:"-.3333em",negativeveryverythickmathspace:"-.3889em"}});b.Register.StartupHook("mml Jax Ready",function(){e=MathJax.ElementJax.mml;e.mbase.Augment({toNativeMML:function(p){var n=this.NativeMMLelement(this.type);this.NativeMMLattributes(n);for(var o=0,l=this.data.length;o<l;o++){if(this.data[o]){this.data[o].toNativeMML(n)}else{n.appendChild(this.NativeMMLelement("mrow"))}}p.appendChild(n)},NativeMMLattributes:function(n){var q=this.defaults;var s=this.NativeMMLcopyAttributes,p=this.NativeMMLskipAttributes;if(this.type==="mstyle"){q=e.math.prototype.defaults}for(var r in q){if(!p[r]&&q.hasOwnProperty(r)){if(this[r]!=null){n.setAttribute(r,this.NativeMMLattribute(r,this[r]))}}}for(var o=0,l=s.length;o<l;o++){if(this[s[o]]!=null){n.setAttribute(s[o],this.NativeMMLattribute(s[o],this[s[o]]))}}},NativeMMLcopyAttributes:["fontfamily","fontsize","fontweight","fontstyle","color","background","id","class","href","style"],NativeMMLskipAttributes:{texClass:1,useHeight:1,texprimestyle:1},NativeMMLattribute:function(m,l){l=String(l);if(j.NAMEDSPACE[l]){l=j.NAMEDSPACE[l]}else{if(l.match(/^\s*([-+]?(\d+(\.\d*)?|\.\d+))\s*mu\s*$/)){l=((1/18)*RegExp.$1)+"em"}else{if(l==="-tex-caligraphic"){l="script"}else{if(l==="-tex-oldstyle"){l="normal"}}}}return l},NativeMMLelement:function(l){var m=(h?document.createElement("mjx:"+l):document.createElementNS(j.MMLnamespace,l));m.isMathJax=true;return m}});e.mrow.Augment({toNativeMML:function(o){if(this.inferred&&this.parent.inferRow){for(var n=0,l=this.data.length;n<l;n++){if(this.data[n]){this.data[n].toNativeMML(o)}else{o.appendChild(this.NativeMMLelement("mrow"))}}}else{this.SUPER(arguments).toNativeMML.call(this,o)}}});e.msubsup.Augment({toNativeMML:function(q){var p=this.type;if(this.data[this.sup]==null){p="msub"}if(this.data[this.sub]==null){p="msup"}var n=this.NativeMMLelement(p);this.NativeMMLattributes(n);delete this.data[0].inferred;for(var o=0,l=this.data.length;o<l;o++){if(this.data[o]){this.data[o].toNativeMML(n)}}q.appendChild(n)}});e.munderover.Augment({toNativeMML:function(q){var p=this.type;if(this.data[this.under]==null){p="mover"}if(this.data[this.over]==null){p="munder"}var n=this.NativeMMLelement(p);this.NativeMMLattributes(n);delete this.data[0].inferred;for(var o=0,l=this.data.length;o<l;o++){if(this.data[o]){this.data[o].toNativeMML(n)}}q.appendChild(n)}});if(b.Browser.isFirefox){e.mtable.Augment({toNativeMML:function(l){if(this.width){var m=(this.style||"").replace(/;\s*$/,"").split(";");m.push("width:"+this.width);this.style=m.join(";")}this.SUPER(arguments).toNativeMML.call(this,l)}});e.mlabeledtr.Augment({toNativeMML:function(p){var n=this.NativeMMLelement("mtr");this.NativeMMLattributes(n);for(var o=1,l=this.data.length;o<l;o++){if(this.data[o]){this.data[o].toNativeMML(n)}else{n.appendChild(this.NativeMMLelement("mrow"))}}p.appendChild(n)}});var k=MathJax.Hub.config.root+"/fonts/HTML-CSS/TeX/otf";j.Augment({config:{styles:{'[mathvariant="double-struck"]':{"font-family":"MathJax_AMS"},'[mathvariant="script"]':{"font-family":"MathJax_Script"},'[mathvariant="fraktur"]':{"font-family":"MathJax_Fraktur"},'[mathvariant="-tex-oldstyle"]':{"font-family":"MathJax_Caligraphic"},'[mathvariant="-tex-oldstyle-bold"]':{"font-family":"MathJax_Caligraphic","font-weight":"bold"},'[mathvariant="-tex-caligraphic"]':{"font-family":"MathJax_Caligraphic"},'[mathvariant="-tex-caligraphic-bold"]':{"font-family":"MathJax_Caligraphic","font-weight":"bold"},'[mathvariant="bold-script"]':{"font-family":"MathJax_Script","font-weight":"bold"},'[mathvariant="bold-fraktur"]':{"font-family":"MathJax_Fraktur","font-weight":"bold"},'[mathvariant="monospace"]':{"font-family":"monospace"},'[mathvariant="sans-serif"]':{"font-family":"sansserif"},'[mathvariant="bold-sans-serif"]':{"font-family":"sansserif","font-weight":"bold"},'[mathvariant="sans-serif-italic"]':{"font-family":"sansserif","font-style":"italic"},'[mathvariant="sans-serif-bold-italic"]':{"font-family":"sansserif","font-style":"italic","font-weight":"bold"},"@font-face /*1*/":{"font-family":"MathJax_AMS",src:"local('MathJax_AMS'), url('"+k+"/MathJax_AMS-Regular.otf')"},"@font-face /*2*/":{"font-family":"MathJax_Script",src:"local('MathJax_Script'), url('"+k+"/MathJax_Script-Regular.otf')"},"@font-face /*3*/":{"font-family":"MathJax_Fraktur",src:"local('MathJax_Fraktur'), url('"+k+"/MathJax_Fraktur-Regular.otf')"},"@font-face /*4*/":{"font-family":"MathJax_Caligraphic",src:"local('MathJax_Caligraphic'), url('"+k+"/MathJax_Caligraphic-Regular.otf')"},"@font-face /*5*/":{"font-family":"MathJax_Fraktur","font-weight":"bold",src:"local('MathJax_Fraktur-Bold'), url('"+k+"/MathJax_Fraktur-Bold.otf')"},"@font-face /*6*/":{"font-family":"MathJax_Caligraphic","font-weight":"bold",src:"local('MathJax_Caligraphic-Bold'), url('"+k+"/MathJax_Caligraphic-Bold.otf')"}}}})}e.TeXAtom.Augment({toNativeMML:function(m){var l=this.NativeMMLelement("mrow");this.data[0].toNativeMML(l);m.appendChild(l)}});e.chars.Augment({toNativeMML:function(l){l.appendChild(document.createTextNode(this.toString()))}});e.entity.Augment({toNativeMML:function(l){l.appendChild(document.createTextNode(this.toString()))}});e.xml.Augment({toNativeMML:function(o){for(var n=0,l=this.data.length;n<l;n++){o.appendChild(this.data[n].cloneNode(true))}}});b.Register.StartupHook("TeX mathchoice Ready",function(){e.TeXmathchoice.Augment({toNativeMML:function(l){this.Core().toNativeMML(l)}})});setTimeout(MathJax.Callback(["loadComplete",j,"jax.js"]),0)});b.Browser.Select({MSIE:function(k){var l=(document.documentMode||0);j.msieIE8HeightBug=(l===8)},Opera:function(k){j.operaPositionBug=true}});b.Register.StartupHook("End Cookie",function(){if(b.config.menuSettings.zoom!=="None"){f.Require("[MathJax]/extensions/MathZoom.js")}})})(MathJax.OutputJax.NativeMML,MathJax.Hub,MathJax.Ajax,MathJax.HTML);
|
|
|