Stackedit/public/libs/MathJax/extensions/MathEvents.js

17 lines
9.5 KiB
JavaScript
Raw Normal View History

2013-10-09 01:15:00 +00:00
/*
* /MathJax/extensions/MathEvents.js
*
* Copyright (c) 2009-2013 The MathJax Consortium
*
* 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(d,h,l,g,m,b,j){var q="2.2";var i=MathJax.Extension;var c=i.MathEvents={version:q};var k=d.config.menuSettings;var p={hover:500,frame:{x:3.5,y:5,bwidth:1,bcolor:"#A6D",hwidth:"15px",hcolor:"#83A"},button:{x:-4,y:-3,wx:-2,src:l.fileURL(b.imageDir+"/MenuArrow-15.png")},fadeinInc:0.2,fadeoutInc:0.05,fadeDelay:50,fadeoutStart:400,fadeoutDelay:15*1000,styles:{".MathJax_Hover_Frame":{"border-radius":".25em","-webkit-border-radius":".25em","-moz-border-radius":".25em","-khtml-border-radius":".25em","box-shadow":"0px 0px 15px #83A","-webkit-box-shadow":"0px 0px 15px #83A","-moz-box-shadow":"0px 0px 15px #83A","-khtml-box-shadow":"0px 0px 15px #83A",border:"1px solid #A6D ! important",display:"inline-block",position:"absolute"},".MathJax_Hover_Arrow":{position:"absolute",width:"15px",height:"11px",cursor:"pointer"}}};var n=c.Event={LEFTBUTTON:0,RIGHTBUTTON:2,MENUKEY:"altKey",Mousedown:function(r){return n.Handler(r,"Mousedown",this)},Mouseup:function(r){return n.Handler(r,"Mouseup",this)},Mousemove:function(r){return n.Handler(r,"Mousemove",this)},Mouseover:function(r){return n.Handler(r,"Mouseover",this)},Mouseout:function(r){return n.Handler(r,"Mouseout",this)},Click:function(r){return n.Handler(r,"Click",this)},DblClick:function(r){return n.Handler(r,"DblClick",this)},Menu:function(r){return n.Handler(r,"ContextMenu",this)},Handler:function(u,s,t){if(l.loadingMathMenu){return n.False(u)}var r=b[t.jaxID];if(!u){u=window.event}u.isContextMenu=(s==="ContextMenu");if(r[s]){return r[s](u,t)}if(i.MathZoom){return i.MathZoom.HandleEvent(u,s,t)}},False:function(r){if(!r){r=window.event}if(r){if(r.preventDefault){r.preventDefault()}if(r.stopPropagation){r.stopPropagation()}r.cancelBubble=true;r.returnValue=false}return false},ContextMenu:function(s,A,v){var x=b[A.jaxID],u=x.getJaxFromMath(A);var B=(x.config.showMathMenu!=null?x:d).config.showMathMenu;if(!B||(k.context!=="MathJax"&&!v)){return}if(c.msieEventBug){s=window.event||s}n.ClearSelection();f.ClearHoverTimer();if(u.hover){if(u.hover.remove){clearTimeout(u.hover.remove);delete u.hover.remove}u.hover.nofade=true}var t=MathJax.Menu;var C,z;if(t){if(t.loadingDomain){return n.False(s)}C=m.loadDomain("MathMenu");if(!C){t.jax=u;var r=t.menu.Find("Show Math As").menu;r.items[0].name=u.sourceMenuTitle;r.items[0].format=(u.sourceMenuFormat||"MathML");r.items[1].name=j[u.inputJax].sourceMenuTitle;var w=t.menu.Find("Math Settings","MathPlayer");w.hidden=!(u.outputJax==="NativeMML"&&d.Browser.hasMathPlayer);return t.menu.Post(s)}t.loadingDomain=true;z=function(){delete t.loadingDomain}}else{if(l.loadingMathMenu){return n.False(s)}l.loadingMathMenu=true;C=l.Require("[MathJax]/extensions/MathMenu.js");z=function(){delete l.loadingMathMenu;if(!MathJax.Menu){MathJax.Menu={}}}}var y={pageX:s.pageX,pageY:s.pageY,clientX:s.clientX,clientY:s.clientY};g.Queue(C,z,["ContextMenu",n,y,A,v]);return n.False(s)},AltContextMenu:function(t,s){var u=b[s.jaxID];var r=(u.config.showMathMenu!=null?u:d).config.showMathMenu;if(r){r=(u.config.showMathMenuMSIE!=null?u:d).config.showMathMenuMSIE;if(k.context==="MathJax"&&!k.mpContext&&r){if(!c.noContextMenuBug||t.button!==n.RIGHTBUTTON){return}}else{if(!t[n.MENUKEY]||t.button!==n.LEFTBUTTON){return}}return u.ContextMenu(t,s,true)}},ClearSelection:function(){if(c.safariContextMenuBug){setTimeout("window.getSelection().empty()",0)}if(document.selection){setTimeout("document.selection.empty()",0)}},getBBox:function(t){t.appendChild(c.topImg);var s=c.topImg.offsetTop,u=t.offsetHeight-s,r=t.offsetWidth;t.removeChild(c.topImg);return{w:r,h:s,d:u}}};var f=c.Hover={Mouseover:function(t,s){if(k.discoverable||k.zoom==="Hover"){var v=t.fromElement||t.relatedTarget,u=t.toElement||t.target;if(v&&u&&(v.isMathJax!=u.isMathJax||d.getJaxFor(v)!==d.getJaxFor(u))){var r=this.getJaxFromMath(s);if(r.hover){f.ReHover(r)}else{f.HoverTimer(r,s)}return n.False(t)}}},Mouseout:function(t,s){if(k.discoverable||k.zoom==="Hover"){var v=t.fromElement||t.relatedTarget,u=t.toElement||t.target;if(v&&u&&(v.isMathJax!=u.isMathJax||d.getJaxFor(v)!==d.getJaxFor(u))){var r=this.getJaxFromMath(s)