Stackedit/lib/MathJax/jax/output/NativeMML/jax.js

17 lines
15 KiB
JavaScript
Raw Normal View History

2013-05-12 00:48:25 +00:00
/*
* /MathJax/jax/output/NativeMML/jax.js
*
* Copyright (c) 2012 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:{".MathJax_MathML":{"font-style":"normal","font-weight":"normal","line-height":"normal","font-size":"100%","font-size-adjust":"none","text-indent":0,"text-align":"left","text-transform":"none","letter-spacing":"normal","word-spacing":"normal","word-wrap":"normal","white-space":"nowrap","float":"none",direction:"ltr",border:0,padding:0,margin:0},"span.MathJax_MathML":{display:"inline"},"div.MathJax_MathML":{display:"block"},".MathJax_mmlExBox":{display:"block",overflow:"hidden",height:"1px",width:"60ex",padding:0,border:0,margin:0}}},settings:b.config.menuSettings,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"}})}if(!this.require){this.require=[]}this.require.push(MathJax.OutputJax.extensionDir+"/MathEvents.js")},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;if(!h){this.EmExSpan=d.Element("span",{style:{position:"absolute","font-size-adjust":"none"}},[["div",{className:"MathJax_mmlExBox"}],["span",{className:"MathJax_MathML"}]]);e.math(e.mspace().With({width:"60ex"})).toNativeMML(this.EmExSpan.lastChild)}return f.Styles(this.config.styles)},InitializeMML:function(){this.initialized=true;if(h){try{if(!b.Browser.mpNamespace){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("m","http://www.w3.org/1998/Math/MathML");b.Browser.mpNamespace=true}if(!b.Browser.mpImported){document.namespaces.m.doImport("#mathplayer");b.Browser.mpImported=true}}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.")}}else{document.body.appendChild(this.EmExSpan);this.defaultEx=this.EmExSpan.firstChild.offsetWidth/60;this.defaultMEx=this.EmExSpan.lastChild.offsetWidth/60;document.body.removeChild(this.EmExSpan)}},preTranslate:function(l){var r=l.jax[this.id],s,n=r.length,w,p,y,u,x,k,t,q,o;for(s=0;s<n;s++){w=r[s];if(!w.parentNode){continue}if(!this.initialized){this.InitializeMML()}p=w.previousSibling;if(p&&p.className==="MathJax_MathML"){p.parentNode.removeChild(p)}k=w.MathJax.elementJax;if(!k){continue}x=k.root;k.NativeMML={};var v=(x.Get("display")==="block"?"div":"span");y=d.Element(v,{className:"MathJax_MathML",id:k.inputID+"-Frame"},[["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"}}]]]]);w.parentNode.insertBefore(y,w);if(!h){w.parentNode.insertBefore(this.EmExSpan.cloneNode(true),w)}}for(s=0;s<n;s++){w=r[s];if(!w.parentNode){continue}k=w.MathJax.elementJax;if(!k){continue}if(!h){u=w.previousSibling;y=u.previousSibling;t=u.firstChild.offsetWidth/60;q=u.lastChild.offsetWidth/60;if(t===0||t==="NaN"){t=this.defaultEx;q=this.defaultMEx}o=(q>1?t/q:1)*this.config.scale;o=Math.floor(Math.max(this.config.minScaleAdjust/100,o))}else{o=100}k.N