instiki/public/MathJax/jax/output/NativeMML/jax.js

17 lines
10 KiB
JavaScript
Raw Normal View History

/*
2011-01-28 02:12:00 +01:00
* /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
*/
2011-01-28 02:12:00 +01:00
(function(b,e,d){var a,c=e.Browser.isMSIE;b.Augment({LEFTBUTTON:(c?1:0),MENUKEY:"altKey",noContextMenuBug:e.Browser.isKonequeror,msieQuirks:(c&&!(document.compatMode==="BackCompat")),config:{styles:{}},settings:e.config.menuSettings,Startup:function(){return MathJax.Ajax.Styles(this.config.styles)},Config:function(){this.SUPER(arguments).Config.call(this);if(this.settings.scale){this.config.scale=this.settings.scale}},Translate:function(g){if(!g.parentNode){return}var k=g.previousSibling;if(k&&String(k.className).match(/^MathJax(_MathML|_Display)?$/)){k.parentNode.removeChild(k)}var j=g.MathJax.elementJax.root;var i=(j.Get("display")==="block"?"div":"span");var h=document.createElement(i),f=h;h.className="MathJax_MathML";h.style.fontSize=this.config.scale+"%";if(c){f=MathJax.HTML.addElement(h,"span",{className:"MathJax_MathContainer",style:{display:"inline-block",position:"relative"}})}j.toNativeMML(f);g.parentNode.insertBefore(h,g);if(c){if(this.config.showMathMenuMSIE){this.MSIEoverlay(h)}}else{j=h.firstChild;j.oncontextmenu=this.ContextMenu;j.onmouseover=this.Mouseover;j.onmousedown=this.Mousedown;j.onclick=this.Click;j.ondblclick=this.DblClick}},Remove:function(f){var g=f.SourceElement();if(!g){return}g=g.previousSibling;if(!g){return}if(g.className.match(/MathJax_MathML/)){g.parentNode.removeChild(g)}},MMLnamespace:"http://www.w3.org/1998/Math/MathML",MSIEoverlay:function(m){var l=m.firstChild;m.style.position="absolute";var n=m.scrollHeight,h=m.offsetWidth;var j=MathJax.HTML.addElement(m,"img",{src:"about:blank",style:{width:0,height:n+"px"}});var f=m.scrollHeight-n;m.removeChild(j);m.style.position="";var k,i,g=(m.parentNode.nodeName.toLowerCase()==="div");if(g&&this.quirks){k=-n;i=Math.floor(-h/2)}else{k=f-n,i=-h}MathJax.HTML.addElement(m,"span",{style:{display:"inline-block",width:0,height:0,position:"relative"}},[["span",{style:{display:"inline-block",position:"absolute",left:i+"px",top:k+"px",width:l.offsetWidth+"px",height:n+"px",cursor:"pointer","background-color":"white",filter:"alpha(opacity=0)"},onmousedown:this.MSIEevent,oncontextmenu:this.MSIEevent,onclick:this.MSIEevent,onmousemove:this.MSIEevent,ondblclick:this.MSIEevent,onmouseover:this.MSIEevent,onmouseout:this.MSIEevent}]])},MSIEmath:function(f){var g=f.parentNode.previousSibling.firstChild;return(g.nodeName.toLowerCase()==="span"?g.firstChild:g)},MSIEevent:function(){var g=b.MSIEmath(this);var f=window.event;var h=b["MSIE"+f.type];if(h&&h.call(b,f,g,this)){return false}g.fireEvent("on"+f.type,f);return false},MSIEmousedown:function(h,g,f){if(h[this.MENUKEY]&&h.button===this.LEFTBUTTON&&this.settings.context!=="MathJax"){this.trapUp=this.trapClick=true;this.ContextMenu.call(f,h,true);return true}if(this.MSIEzoomKeys&&this.MSIEzoomKeys(h)){this.trapUp=true;return true}return false},MSIEcontextmenu:function(h,g,f){if(this.settings.context==="MathJax"){this.trapUp=this.trapClick=true;this.ContextMenu.call(f,h,true);return true}return false},ContextMenu:function(i,j){if(b.config.showMathMenu&&(b.settings.context==="MathJax"||j)){if(b.safariContextMenuBug){setTimeout("window.getSelection().empty()",0)}var g=MathJax.Menu;if(g){if(document.selection){setTimeout("document.selection.empty()",0)}var f=(c?this.parentNode.parentNode.nextSibling:this.parentNode.nextSibling);g.jax=e.getJaxFor(f);g.menu.items[1].menu.items[1].name=(g.jax.inputJax.id==="MathML"?"Original":g.jax.inputJax.id);delete b.trapClick;delete b.trapUp;return g.menu.Post(i)}else{if(!d.loadingMathMenu){d.loadingMathMenu=true;if(!i){i=window.event}var h={pageX:i.pageX,pageY:i.pageY,clientX:i.clientX,clientY:i.clientY};MathJax.Callback.Queue(d.Require("[MathJax]/extensions/MathMenu.js"),function(){delete d.loadingMathMenu},[this,arguments.callee,h,j])}if(!i){i=window.event}if(i.preventDefault){i.preventDefault()}if(i.stopPropagation){i.stopPropagation()}i.cancelBubble=true;i.returnValue=false;return false}}},Mousedown:function(f){if(b.config.showMathMenu){if(!f){f=window.event}if(b.settings.context==="MathJax"){if(!b.noContextMenuBug||f.button!==2){return}}else{if(!f[b.MENUKEY]||f.button!==b.L