17 lines
12 KiB
JavaScript
17 lines
12 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(i,b,f,d){var e,h=b.Browser.isMSIE;var g,a,c;i.Augment({LEFTBUTTON:(h?1:0),MENUKEY:"altKey",noContextMenuBug:b.Browser.isKonequeror,msieQuirks:(h&&!(document.compatMode==="BackCompat")),msieEventBug:b.Browser.isIE9,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 l=b.config.displayAlign,j=b.config.displayIndent;var k={"text-align":l+"!important"};k["margin-"+l]=j+"!important";MathJax.Hub.Insert(this.config.styles,{"div.MathJax_MathML":k,"div.MathJax_MathML math":{"text-align":l},"div.MathJax_MathContainer > span":{"text-align":l+"!important"}})}this.require.push(MathJax.OutputJax.extensionDir+"/MathEvents.js")},InitializeMML:function(){this.initialized=true;if(b.Browser.isMSIE){try{var j=document.createElement("object");j.id="mathplayer";j.classid="clsid:32F66A20-7614-11D4-BD11-00104BD3F987";document.getElementsByTagName("head")[0].appendChild(j);document.namespaces.add("mjx","http://www.w3.org/1998/Math/MathML");document.namespaces.mjx.doImport("#mathplayer")}catch(k){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(k){if(!k.parentNode){return}if(!this.initialized){this.InitializeMML()}var p=k.previousSibling;if(p&&String(p.className).match(/^MathJax(_MathML|_Display)?$/)){p.parentNode.removeChild(p)}var o=k.MathJax.elementJax.root;var n=(o.Get("display")==="block"?"div":"span");var m=d.Element(n,{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"}}]]]]),j=m.firstChild;o.toNativeMML(j.firstChild);k.parentNode.insertBefore(m,k);if(h){if(j.addEventListener){j.addEventListener("contextmenu",g.Menu,true);j.addEventListener("mouseover",g.Mouseover,true);j.addEventListener("mouseout",g.Mouseout,true);j.addEventListener("mousedown",g.Mousedown,true);j.addEventListener("mouseup",g.False,true);j.addEventListener("click",g.Click,true);j.addEventListener("dblclick",g.DblClick,true)}else{var l=(this.config.showMathMenuMSIE!=null?this:b).config;if(l.showMathMenuMSIE){this.MSIEoverlay(j)}}}else{j.oncontextmenu=g.Menu;j.onmouseover=g.Mouseover;j.onmouseout=g.Mouseout;j.onmousedown=g.Mousedown;j.onclick=g.Click;j.ondblclick=g.DblClick}},Remove:function(j){var k=j.SourceElement();if(!k){return}k=k.previousSibling;if(!k){return}if(k.className.match(/MathJax_MathML/)){k.parentNode.removeChild(k)}},MMLnamespace:"http://www.w3.org/1998/Math/MathML",MSIEoverlay:function(j){var k=j.firstChild;if(k.nodeName.toLowerCase()==="span"){k=k.firstChild}var l=this.getHoverBBox(null,k,{});d.addElement(j,"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(-l.w),top:c.Px(-l.h-(l.y||0)-1),width:c.Px(l.w),height:c.Px(l.h+l.d),cursor:"pointer","background-color":"white",filter:"alpha(opacity=0)"}}]]);b.Insert(j,{msieMath:k,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 k=window.event;var j=i.MSIEevents[k.type];if(i[j]&&i[j](k,this)===false){return false}if(MathJax.Extension.MathZoom&&MathJax.Extension.MathZoom.HandleEvent(k,j,this)===false){return false}if(k.srcElement.className==="MathJax_MathPlayer_Overlay"&&this.msieMath.fireEvent){this.msieMath.fireEvent("on"+k.type,k)}return g.False(k)},getJaxFromMath:function(j){if(j.className==="MathJax_MSIE_Overlay"){j=j.parentNode.parentNode}return b.getJaxFor(j.parentNode.nextSibling)},getHoverSpan:function(j,k){if(k.className==="MathJax_MSIE_Overlay"){return k.parentNode}return k.firstChild},getHoverBBox:function(l,n,o){n=n.parentNode;n.appendChild(this.topImg);var m=this.topImg.offsetTop,p=n.offsetHeight-m,k=n.offsetWidth;n.removeChild(this.topImg);var j=(o.className==="MathJax_MSIE_Overlay"?-k:0);return{w:k,h:m,d:p,x:j}},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(o){var l=this.NativeMMLelement(this.type);this.NativeMMLattributes(l);for(var n=0,k=this.data.length;n<k;n++){if(this.data[n]){this.data[n].toNativeMML(l)}else{l.appendChild(this.NativeMMLelement("mrow"))}}o.appendChild(l)},NativeMMLattributes:function(l){var p=this.defaults;var r=this.NativeMMLcopyAttributes,o=this.NativeMMLskipAttributes;if(this.type==="mstyle"){p=e.math.prototype.defaults}for(var q in p){if(!o[q]&&p.hasOwnProperty(q)){if(this[q]!=null){l.setAttribute(q,this.NativeMMLattribute(q,this[q]))}}}for(var n=0,k=r.length;n<k;n++){if(this[r[n]]!=null){l.setAttribute(r[n],this.NativeMMLattribute(r[n],this[r[n]]))}}},NativeMMLcopyAttributes:["fontfamily","fontsize","fontweight","fontstyle","color","background","id","class","href","style"],NativeMMLskipAttributes:{texClass:1,useHeight:1,texprimestyle:1},NativeMMLattribute:function(l,k){k=String(k);if(i.NAMEDSPACE[k]){k=i.NAMEDSPACE[k]}else{if(k.match(/^\s*([-+]?(\d+(\.\d*)?|\.\d+))\s*mu\s*$/)){k=((1/18)*RegExp.$1)+"em"}else{if(k==="-tex-caligraphic"){k="script"}else{if(k==="-tex-oldstyle"){k="normal"}}}}return k},NativeMMLelement:function(k){var l=(h?document.createElement("mjx:"+k):document.createElementNS(i.MMLnamespace,k));l.isMathJax=true;return l}});e.mrow.Augment({toNativeMML:function(n){if(this.inferred&&this.parent.inferRow){for(var l=0,k=this.data.length;l<k;l++){if(this.data[l]){this.data[l].toNativeMML(n)}else{n.appendChild(this.NativeMMLelement("mrow"))}}}else{this.SUPER(arguments).toNativeMML.call(this,n)}}});e.msubsup.Augment({toNativeMML:function(p){var o=this.type;if(this.data[this.sup]==null){o="msub"}if(this.data[this.sub]==null){o="msup"}var l=this.NativeMMLelement(o);this.NativeMMLattributes(l);delete this.data[0].inferred;for(var n=0,k=this.data.length;n<k;n++){if(this.data[n]){this.data[n].toNativeMML(l)}}p.appendChild(l)}});e.munderover.Augment({toNativeMML:function(p){var o=this.type;if(this.data[this.under]==null){o="mover"}if(this.data[this.over]==null){o="munder"}var l=this.NativeMMLelement(o);this.NativeMMLattributes(l);delete this.data[0].inferred;for(var n=0,k=this.data.length;n<k;n++){if(this.data[n]){this.data[n].toNativeMML(l)}}p.appendChild(l)}});if(b.Browser.isFirefox){e.mtable.Augment({toNativeMML:function(k){if(this.width){var l=(this.style||"").replace(/;\s*$/,"").split(";");l.push("width:"+this.width);this.style=l.join(";")}this.SUPER(arguments).toNativeMML.call(this,k)}});e.mlabeledtr.Augment({toNativeMML:function(o){var l=this.NativeMMLelement("mtr");this.NativeMMLattributes(l);for(var n=1,k=this.data.length;n<k;n++){if(this.data[n]){this.data[n].toNativeMML(l)}else{l.appendChild(this.NativeMMLelement("mrow"))}}o.appendChild(l)}});var j=MathJax.Hub.config.root+"/fonts/HTML-CSS/TeX/otf";i.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('"+j+"/MathJax_AMS-Regular.otf')"},"@font-face /*2*/":{"font-family":"MathJax_Script",src:"local('MathJax_Script'), url('"+j+"/MathJax_Script-Regular.otf')"},"@font-face /*3*/":{"font-family":"MathJax_Fraktur",src:"local('MathJax_Fraktur'), url('"+j+"/MathJax_Fraktur-Regular.otf')"},"@font-face /*4*/":{"font-family":"MathJax_Caligraphic",src:"local('MathJax_Caligraphic'), url('"+j+"/MathJax_Caligraphic-Regular.otf')"},"@font-face /*5*/":{"font-family":"MathJax_Fraktur","font-weight":"bold",src:"local('MathJax_Fraktur-Bold'), url('"+j+"/MathJax_Fraktur-Bold.otf')"},"@font-face /*6*/":{"font-family":"MathJax_Caligraphic","font-weight":"bold",src:"local('MathJax_Caligraphic-Bold'), url('"+j+"/MathJax_Caligraphic-Bold.otf')"}}}})}e.TeXAtom.Augment({toNativeMML:function(l){var k=this.NativeMMLelement("mrow");this.data[0].toNativeMML(k);l.appendChild(k)}});e.chars.Augment({toNativeMML:function(k){k.appendChild(document.createTextNode(this.toString()))}});e.entity.Augment({toNativeMML:function(k){k.appendChild(document.createTextNode(this.toString()))}});e.xml.Augment({toNativeMML:function(n){for(var l=0,k=this.data.length;l<k;l++){n.appendChild(this.data[l].cloneNode(true))}}});b.Register.StartupHook("TeX mathchoice Ready",function(){e.TeXmathchoice.Augment({toNativeMML:function(k){this.Core().toNativeMML(k)}})});setTimeout(MathJax.Callback(["loadComplete",i,"jax.js"]),0)});b.Browser.Select({MSIE:function(j){var k=(document.compatMode==="BackCompat");var l=j.versionAtLeast("8.0")&&document.documentMode>7;i.msieInlineBlockAlignBug=(!l||k);i.msieTopBug=(!j.versionAtLeast("8.0")||document.documentMode===7)},Opera:function(j){i.operaPositionBug=true}});i.topImg=(i.msieInlineBlockAlignBug?d.Element("img",{style:{width:0,height:0,position:"relative"},src:"about:blank"}):d.Element("span",{style:{width:0,height:0,display:"inline-block"}}));if(i.operaPositionBug||i.msieTopBug){i.topImg.style.border="1px solid"}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);
|
|
|