/* * /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(l,u,m,p,w,r,x){var t=MathJax.Extension,g=t.MathEvents={version:"2.2"},n=l.config.menuSettings,d={hover:500,frame:{x:3.5,y:5,bwidth:1,bcolor:"#A6D",hwidth:"15px",hcolor:"#83A"},button:{x:-4,y:-3,wx:-2,src:m.fileURL(r.imageDir+"/MenuArrow-15.png")},fadeinInc:.2,fadeoutInc:.05,fadeDelay:50,fadeoutStart:400,fadeoutDelay:15E3,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"}}},e=g.Event={LEFTBUTTON:0,RIGHTBUTTON:2,MENUKEY:"altKey",Mousedown:function(a){return e.Handler(a,"Mousedown",this)},Mouseup:function(a){return e.Handler(a,"Mouseup",this)},Mousemove:function(a){return e.Handler(a,"Mousemove",this)},Mouseover:function(a){return e.Handler(a,"Mouseover",this)},Mouseout:function(a){return e.Handler(a,"Mouseout",this)},Click:function(a){return e.Handler(a,"Click",this)},DblClick:function(a){return e.Handler(a,"DblClick",this)},Menu:function(a){return e.Handler(a,"ContextMenu",this)},Handler:function(a,c,b){if(m.loadingMathMenu)return e.False(a);var q=r[b.jaxID];a||(a=window.event);a.isContextMenu="ContextMenu"===c;if(q[c])return q[c](a,b);if(t.MathZoom)return t.MathZoom.HandleEvent(a,c,b)},False:function(a){a||(a=window.event);a&&(a.preventDefault&&a.preventDefault(),a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0,a.returnValue=!1);return!1},ContextMenu:function(a,c,b){var q=r[c.jaxID],f=q.getJaxFromMath(c);if((null!=q.config.showMathMenu?q:l).config.showMathMenu&&("MathJax"===n.context||b)){g.msieEventBug&&(a=window.event||a);e.ClearSelection();k.ClearHoverTimer();f.hover&&(f.hover.remove&&(clearTimeout(f.hover.remove),delete f.hover.remove),f.hover.nofade=!0);var d=MathJax.Menu;if(d){if(d.loadingDomain)return e.False(a);q=w.loadDomain("MathMenu");if(!q)return d.jax=f,c=d.menu.Find("Show Math As").menu,c.items[0].name=f.sourceMenuTitle,c.items[0].format=f.sourceMenuFormat||"MathML",c.items[1].name=x[f.inputJax].sourceMenuTitle,d.menu.Find("Math Settings","MathPlayer").hidden=!("NativeMML"===f.outputJax&&l.Browser.hasMathPlayer),d.menu.Post(a);d.loadingDomain=!0;f=function(){delete d.loadingDomain}}else{if(m.loadingMathMenu)return e.False(a);m.loadingMathMenu=!0;q=m.Require("[MathJax]/extensions/MathMenu.js");f=function(){delete m.loadingMathMenu;MathJax.Menu||(MathJax.Menu={})}}p.Queue(q,f,["ContextMenu",e,{pageX:a.pageX,pageY:a.pageY,clientX:a.clientX,clientY:a.clientY},c,b]);return e.False(a)}},AltContextMenu:function(a,c){var b=r[c.jaxID],d=(null!=b.config.showMathMenu?b:l).config.showMathMenu;if(d){d=(null!=b.config.showMathMenuMSIE?b:l).config.showMathMenuMSIE;if("MathJax"===n.context&&!n.mpContext&&d){if(!g.noContextMenuBug||a.button!==e.RIGHTBUTTON)return}else if(!a[e.MENUKEY]||a.button!==e.LEFTBUTTON)return;return b.ContextMenu(a,c,!0)}},ClearSelection:function(){g.safariContextMenuBug&&setTimeout("window.getSelection().empty()",0);document.selection&&setTimeout("document.selection.empty()",0)},getBBox:function(a){a.appendChild(g.topImg);var c=g.topImg.offsetTop,b=a.offsetHeight-c,d=a.offsetWidth;a.removeChild(g.topImg);return{w:d,h:c,d:b}}},k=g.Hover={Mouseover:function(a,c){if(n.discoverable||"Hover"===n.zoom){var b=a.fromElement||a.relatedTarget,d=a.toElement||a.target;if(b&&d&&(b.isMathJax!=d.isMathJax||l.getJaxFor(b)!==l.getJaxFor(d)))return b=this.getJaxFromMath(c),b.hover?k.ReHover(b):k.HoverTimer(b,c),e.False(a)}},Mouseout:function(a,c){if(n.discoverable||"Hover"===n.zoom){var b=a.fromElement||a.relatedTarget,d=a.toElement||a.target;if(b&&d&&(b.isMathJax!=d.isMathJax||l.getJaxFor(b)!==l.getJaxFor(d)))return b=this.getJaxFromMath(c),b.hover?k.UnHover(b):k.ClearHoverTimer(),e.False(a)}},Mousemove:function(a,c){if(n.discoverable||"Hover"===n.zoom){var b=this.getJaxFromMath(c);if(!b.hover&&(k.lastX!=a.clientX||k.lastY!=a.clientY))return k.lastX=a.clientX,k.lastY=a.clientY,k.HoverTimer(b,c),e.False(a)}},HoverTimer:function(a,c){this.ClearHoverTimer();this.hoverTimer=setTimeout(p(["Hover",this,a,c]),d.hover)},ClearHoverTimer:function(){this.hoverTimer&&(clearTimeout(this.hoverTimer),delete this.hoverTimer)},Hover:function(a,c){if(!t.MathZoom||!t.MathZoom.Hover({},c)){var b=r[a.outputJax],e=b.getHoverSpan(a,c),f=b.getHoverBBox(a,e,c),h=(null!=b.config.showMathMenu?b:l).config.showMathMenu,k=d.frame.x,n=d.frame.y,m=d.frame.bwidth;g.msieBorderWidthBug&&(m=0);a.hover={opacity:0,id:a.inputID+"-Hover"};var p=u.Element("span",{id:a.hover.id,isMathJax:!0,style:{display:"inline-block",width:0,height:0,position:"relative"}},[["span",{className:"MathJax_Hover_Frame",isMathJax:!0,style:{display:"inline-block",position:"absolute",top:this.Px(-f.h-n-m-(f.y||0)),left:this.Px(-k-m+(f.x||0)),width:this.Px(f.w+2*k),height:this.Px(f.h+f.d+2*n),opacity:0,filter:"alpha(opacity\x3d0)"}}]]),b=u.Element("span",{isMathJax:!0,id:a.hover.id+"Menu",style:{display:"inline-block","z-index":1,width:0,height:0,position:"relative"}},[["img",{className:"MathJax_Hover_Arrow",isMathJax:!0,math:c,src:d.button.src,onclick:this.HoverMenu,jax:b.id,style:{left:this.Px(f.w+k+m+(f.x||0)+d.button.x),top:this.Px(-f.h-n-m-(f.y||0)-d.button.y),opacity:0,filter:"alpha(opacity\x3d0)"}}]]);f.width&&(p.style.width=b.style.width=f.width,p.style.marginRight=b.style.marginRight="-"+f.width,p.firstChild.style.width=f.width,b.firstChild.style.left="",b.firstChild.style.right=this.Px(d.button.wx));e.parentNode.insertBefore(p,e);h&&e.parentNode.insertBefore(b,e);e.style&&(e.style.position="relative");this.ReHover(a)}},ReHover:function(a){a.hover.remove&&clearTimeout(a.hover.remove);a.hover.remove=setTimeout(p(["UnHover",this,a]),d.fadeoutDelay);this.HoverFadeTimer(a,d.fadeinInc)},UnHover:function(a){a.hover.nofade||this.HoverFadeTimer(a,-d.fadeoutInc,d.fadeoutStart)},HoverFade:function(a){delete a.hover.timer;a.hover.opacity=Math.max(0,Math.min(1,a.hover.opacity+a.hover.inc));a.hover.opacity=Math.floor(1E3*a.hover.opacity)/1E3;var c=document.getElementById(a.hover.id),b=document.getElementById(a.hover.id+"Menu");c.firstChild.style.opacity=a.hover.opacity;c.firstChild.style.filter="alpha(opacity\x3d"+Math.floor(100*a.hover.opacity)+")";b&&(b.firstChild.style.opacity=a.hover.opacity,b.firstChild.style.filter=c.style.filter);1!==a.hover.opacity&&(0Math.abs(a)?"0px":a.toFixed(2).replace(/\.?0+$/,"")+"px"},getImages:function(){(new Image).src=d.button.src}},h=g.Touch={last:0,delay:500,start:function(a){var c=(new Date).getTime(),b=c-h.lastc;9>c&&(e.LEFTBUTTON=1)},Safari:function(a){g.safariContextMenuBug=!0},Opera:function(a){g.operaPositionBug=!0},Konqueror:function(a){g.noContextMenuBug=!0}});g.topImg=g.msieAlignBug?u.Element("img",{style:{width:0,height:0,position:"relative"},src:"about:blank"}):u.Element("span",{style:{width:0,height:0,display:"inline-block"}});g.operaPositionBug&&(g.topImg.style.border="1px solid");g.config=d=l.CombineConfig("MathEvents",d);p.Queue(l.Register.StartupHook("End Config",{}),[function(){var a=d.styles[".MathJax_Hover_Frame"];a.border=d.frame.bwidth+"px solid "+d.frame.bcolor+" ! important";a["box-shadow"]=a["-webkit-box-shadow"]=a["-moz-box-shadow"]=a["-khtml-box-shadow"]="0px 0px "+d.frame.hwidth+" "+d.frame.hcolor}],["getImages",k],["Styles",m,d.styles],["Post",l.Startup.signal,"MathEvents Ready"],["loadComplete",m,"[MathJax]/extensions/MathEvents.js"])})(MathJax.Hub,MathJax.HTML,MathJax.Ajax,MathJax.Callback,MathJax.Localization,MathJax.OutputJax,MathJax.InputJax);