/* * /MathJax/extensions/MathMenu.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(c,g,k,f,b){var p="2.0.1";var j=MathJax.Callback.Signal("menu");MathJax.Extension.MathMenu={version:p,signal:j};var n=c.Browser.isPC,l=c.Browser.isMSIE,e=((document.documentMode||0)>8);var i=(n?null:"5px");var o=c.CombineConfig("MathMenu",{delay:150,helpURL:"http://www.mathjax.org/help-v2/user/",closeImg:k.fileURL(b.imageDir+"/CloseX-31.png"),showRenderer:true,showMathPlayer:true,showFontMenu:false,showContext:false,showDiscoverable:false,windowSettings:{status:"no",toolbar:"no",locationbar:"no",menubar:"no",directories:"no",personalbar:"no",resizable:"yes",scrollbars:"yes",width:100,height:50},styles:{"#MathJax_About":{position:"fixed",left:"50%",width:"auto","text-align":"center",border:"3px outset",padding:"1em 2em","background-color":"#DDDDDD",color:"black",cursor:"default","font-family":"message-box","font-size":"120%","font-style":"normal","text-indent":0,"text-transform":"none","line-height":"normal","letter-spacing":"normal","word-spacing":"normal","word-wrap":"normal","white-space":"nowrap","float":"none","z-index":201,"border-radius":"15px","-webkit-border-radius":"15px","-moz-border-radius":"15px","-khtml-border-radius":"15px","box-shadow":"0px 10px 20px #808080","-webkit-box-shadow":"0px 10px 20px #808080","-moz-box-shadow":"0px 10px 20px #808080","-khtml-box-shadow":"0px 10px 20px #808080",filter:"progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color='gray', Positive='true')"},".MathJax_Menu":{position:"absolute","background-color":"white",color:"black",width:"auto",padding:(n?"2px":"5px 0px"),border:"1px solid #CCCCCC",margin:0,cursor:"default",font:"menu","text-align":"left","text-indent":0,"text-transform":"none","line-height":"normal","letter-spacing":"normal","word-spacing":"normal","word-wrap":"normal","white-space":"nowrap","float":"none","z-index":201,"border-radius":i,"-webkit-border-radius":i,"-moz-border-radius":i,"-khtml-border-radius":i,"box-shadow":"0px 10px 20px #808080","-webkit-box-shadow":"0px 10px 20px #808080","-moz-box-shadow":"0px 10px 20px #808080","-khtml-box-shadow":"0px 10px 20px #808080",filter:"progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color='gray', Positive='true')"},".MathJax_MenuItem":{padding:(n?"2px 2em":"1px 2em"),background:"transparent"},".MathJax_MenuTitle":{"background-color":"#CCCCCC",margin:(n?"-1px -1px 1px -1px":"-5px 0 0 0"),"text-align":"center","font-style":"italic","font-size":"80%",color:"#444444",padding:"2px 0",overflow:"hidden"},".MathJax_MenuArrow":{position:"absolute",right:".5em",color:"#666666","font-family":(l?"'Arial unicode MS'":null)},".MathJax_MenuActive .MathJax_MenuArrow":{color:"white"},".MathJax_MenuCheck":{position:"absolute",left:".7em","font-family":(l?"'Arial unicode MS'":null)},".MathJax_MenuRadioCheck":{position:"absolute",left:(n?"1em":".7em")},".MathJax_MenuLabel":{padding:(n?"2px 2em 4px 1.33em":"1px 2em 3px 1.33em"),"font-style":"italic"},".MathJax_MenuRule":{"border-top":(n?"1px solid #CCCCCC":"1px solid #DDDDDD"),margin:(n?"4px 1px 0px":"4px 3px")},".MathJax_MenuDisabled":{color:"GrayText"},".MathJax_MenuActive":{"background-color":(n?"Highlight":"#606872"),color:(n?"HighlightText":"white")},".MathJax_Menu_Close":{position:"absolute",width:"31px",height:"31px",top:"-15px",left:"-15px"}}});var h,d;c.Register.StartupHook("MathEvents Ready",function(){h=MathJax.Extension.MathEvents.Event.False;d=MathJax.Extension.MathEvents.Hover});var a=MathJax.Menu=MathJax.Object.Subclass({version:p,items:[],posted:false,title:null,margin:5,Init:function(q){this.items=[].slice.call(arguments,0)},With:function(q){if(q){c.Insert(this,q)}return this},Post:function(r,B){if(!r){r=window.event}var z=(!this.title?null:[["div",{className:"MathJax_MenuTitle"},[this.title]]]);var q=document.getElementById("MathJax_MenuFrame");if(!q){q=a.Background(this);delete m.lastItem;delete m.lastMenu;delete a.skipUp;j.Post(["post",a.jax])}var s=g.addElement(q,"div",{onmouseup:a.Mouseup,ondblclick:h,ondragstart:h,onselectstart:h,oncontextmenu:h,menuItem:this,className:"MathJax_Menu"},z);for(var u=0,t=this.items.length;udocument.body.offsetWidth-this.margin){A=document.body.offsetWidth-s.offsetWidth-this.margin}if(a.isMobile){A=Math.max(5,A-Math.floor(s.offsetWidth/2));w-=20}a.skipUp=r.isContextMenu}else{var v="left",C=B.offsetWidth;A=(a.isMobile?30:C-2);w=0;while(B&&B!==q){A+=B.offsetLeft;w+=B.offsetTop;B=B.parentNode}if(A+s.offsetWidth>document.body.offsetWidth-this.margin&&!a.isMobile){v="right";A=Math.max(this.margin,A-C-s.offsetWidth+6)}if(!n){s.style["borderRadiusTop"+v]=0;s.style["WebkitBorderRadiusTop"+v]=0;s.style["MozBorderRadiusTop"+v]=0;s.style["KhtmlBorderRadiusTop"+v]=0}}s.style.left=A+"px";s.style.top=w+"px";if(document.selection&&document.selection.empty){document.selection.empty()}return h(r)},Remove:function(q,r){j.Post(["unpost",a.jax]);var s=document.getElementById("MathJax_MenuFrame");if(s){s.parentNode.removeChild(s);if(this.msieFixedPositionBug){detachEvent("onresize",a.Resize)}}if(a.jax.hover){delete a.jax.hover.nofade;d.UnHover(a.jax)}return h(q)},Find:function(r){var t=[].slice.call(arguments,1);for(var s=0,q=this.items.length;s=0&&w.parentNode.menuItem!==v[q].menuItem){v[q].menuItem.posted=false;v[q].parentNode.removeChild(v[q]);q--}if(this.Timer&&!a.isMobile){this.Timer(u,w)}}},Mouseout:function(q,r){if(!this.menu||!this.menu.posted){this.Deactivate(r)}if(this.timer){clearTimeout(this.timer);delete this.timer}},Mouseup:function(q,r){return this.Remove(q,r)},Touchstart:function(q,r){return this.TouchEvent(q,r,"Mousedown")},Touchend:function(q,r){return this.TouchEvent(q,r,"Mouseup")},TouchEvent:function(r,s,q){if(this!==m.lastItem){if(m.lastMenu){a.Event(r,m.lastMenu,"Mouseout")}a.Event(r,s,"Mouseover",true);m.lastItem=this;m.lastMenu=s}if(this.nativeTouch){return null}a.Event(r,s,q);return false},Remove:function(q,r){r=r.parentNode.menuItem;return r.Remove(q,r)},Activate:function(q){this.Deactivate(q);q.className+=" MathJax_MenuActive"},Deactivate:function(q){q.className=q.className.replace(/ MathJax_MenuActive/,"")},With:function(q){if(q){c.Insert(this,q)}return this}});a.ITEM.COMMAND=a.ITEM.Subclass({action:function(){},Init:function(q,s,r){this.name=q;this.action=s;this.With(r)},Label:function(q,r){return[this.name]},Mouseup:function(q,r){if(!this.disabled){this.Remove(q,r);j.Post(["command",this]);this.action.call(this,q)}return h(q)}});a.ITEM.SUBMENU=a.ITEM.Subclass({menu:null,marker:(n&&!c.Browser.isSafari?"\u25B6":"\u25B8"),Init:function(q,s){this.name=q;var r=1;if(!(s instanceof a.ITEM)){this.With(s),r++}this.menu=a.apply(a,[].slice.call(arguments,r))},Label:function(q,r){this.menu.posted=false;return[this.name+" ",["span",{className:"MathJax_MenuArrow"},[this.marker]]]},Timer:function(q,r){if(this.timer){clearTimeout(this.timer)}q={clientX:q.clientX,clientY:q.clientY};this.timer=setTimeout(f(["Mouseup",this,q,r]),o.delay)},Touchend:function(r,t){var s=this.menu.posted;var q=this.SUPER(arguments).Touchend.apply(this,arguments);if(s){this.Deactivate(t);delete m.lastItem;delete m.lastMenu}return q},Mouseup:function(r,t){if(!this.disabled){if(!this.menu.posted){if(this.timer){clearTimeout(this.timer);delete this.timer}this.menu.Post(r,t)}else{var s=document.getElementById("MathJax_MenuFrame").childNodes,q=s.length-1;while(q>=0){var u=s[q];u.menuItem.posted=false;u.parentNode.removeChild(u);if(u.menuItem===this.menu){break}q--}}}return h(r)}});a.ITEM.RADIO=a.ITEM.Subclass({variable:null,marker:(n?"\u25CF":"\u2713"),Init:function(r,q,s){this.name=r;this.variable=q;this.With(s);if(this.value==null){this.value=this.name}},Label:function(r,s){var q={className:"MathJax_MenuRadioCheck"};if(o.settings[this.variable]!==this.value){q={style:{display:"none"}}}return[["span",q,[this.marker]]," "+this.name]},Mouseup:function(t,u){if(!this.disabled){var v=u.parentNode.childNodes;for(var r=0,q=v.length;r/g,">");if(a.isMobile){s.document.open();s.document.write("MathJax Equation Source");s.document.write("
"+z+"
");s.document.write("
");s.document.write("");s.document.close()}else{s.document.open();s.document.write("MathJax Equation Source");s.document.write("
"+z+"
");s.document.write("");s.document.close();var u=s.document.body.firstChild;var t=(s.outerHeight-s.innerHeight)||30,r=(s.outerWidth-s.innerWidth)||30;r=Math.min(Math.floor(0.5*screen.width),u.offsetWidth+r+25);t=Math.min(Math.floor(0.5*screen.height),u.offsetHeight+t+25);s.resizeTo(r,t);if(v&&v.screenX!=null){var q=Math.max(0,Math.min(v.screenX-Math.floor(r/2),screen.width-r-20)),A=Math.max(0,Math.min(v.screenY-Math.floor(t/2),screen.height-t-20));s.moveTo(q,A)}}delete a.ShowSource.w};a.Scale=function(){var r=b["HTML-CSS"],q=b.NativeMML;var t=(r?r.config.scale:q.config.scale);var s=prompt("Scale all mathematics (compared to surrounding text) by",t+"%");if(s){if(s.match(/^\s*\d+\s*%?\s*$/)){s=parseInt(s);if(s){if(s!==t){if(r){r.config.scale=s}if(q){q.config.scale=s}a.cookie.scale=s;a.saveCookie();c.Reprocess()}}else{alert("The scale should not be zero")}}else{alert("The scale should be a perentage (e.g., 120%)")}}};a.Zoom=function(){if(!MathJax.Extension.MathZoom){k.Require("[MathJax]/extensions/MathZoom.js")}};a.Renderer=function(){var r=c.outputJax["jax/mml"];if(r[0]!==o.settings.renderer){var u=c.Browser,t,q=a.Renderer.Messages,s;switch(o.settings.renderer){case"NativeMML":if(!o.settings.warnedMML){if(u.isChrome||(u.isSafari&&!u.versionAtLeast("5.0"))){t=q.MML.WebKit}else{if(u.isMSIE){if(!u.hasMathPlayer){t=q.MML.MSIE}}else{t=q.MML[u]}}s="warnedMML"}break;case"SVG":if(!o.settings.warnedSVG){if(u.isMSIE&&!e){t=q.SVG.MSIE}}break}if(t){t+="\n\nSwitch the renderer anyway?\n\n(Press OK to switch, CANCEL to continue with the current renderer)";a.cookie.renderer=r[0].id;a.saveCookie();if(!confirm(t)){return}if(s){a.cookie[s]=o.settings[s]=true}a.cookie.renderer=o.settings.renderer;a.saveCookie()}c.Queue(["setRenderer",c,o.settings.renderer,"jax/mml"],["Rerender",c])}};a.Renderer.Messages={MML:{WebKit:"Your browser doesn't seem to support MathML natively, so switching to MathML output may cause the mathematics on the page to become unreadable.",MSIE:"Internet Explorer requires the MathPlayer plugin in order to process MathML output.",Opera:"Opera's support for MathML is limited, so switching to MathML output may cause some expressions to render poorly.",Firefox:"Your browser's native MathML does not implement all the features used by MathJax, so some expressions may render improperly."},SVG:{MSIE:"SVG is not implemented in Internet Explorer prior to IE9, or when the browser is emulating IE8 or below. Switching to SVG output will cause the mathemtics to not display properly."}};a.Font=function(){var q=b["HTML-CSS"];if(!q){return}document.location.reload()};a.MPEvents=function(s){var r=o.settings.discoverable,q=a.MPEvents.Messages;if(!e){if(o.settings.mpMouse&&!confirm(q.IE8warning)){delete a.cookie.mpContext;delete o.settings.mpContext;delete a.cookie.mpMouse;delete o.settings.mpMouse;a.saveCookie();return}o.settings.mpContext=o.settings.mpMouse;a.cookie.mpContext=a.cookie.mpMouse=o.settings.mpMouse;a.saveCookie();MathJax.Hub.Queue(["Rerender",MathJax.Hub])}else{if(!r&&s.name==="Menu Events"&&o.settings.mpContext){alert(q.IE9warning)}}};a.MPEvents.Messages={IE8warning:"This will disable the MathJax menu and zoom features, but you can Alt-Click on an expression to obtain the MathJax menu instead.\n\nReally change the MathPlayer settings?",IE9warning:"The MathJax contextual menu will be disabled, but you can Alt-Click on an expression to obtain the MathJax menu instead."};c.Browser.Select({MSIE:function(q){var r=(document.compatMode==="BackCompat");var s=q.versionAtLeast("8.0")&&document.documentMode>7;a.Augment({margin:20,msieBackgroundBug:true,msieFixedPositionBug:(r||!s),msieAboutBug:r});if(e){delete o.styles["#MathJax_About"].filter;delete o.styles[".MathJax_Menu"].filter}},Firefox:function(q){a.skipMouseover=q.isMobile&&q.versionAtLeast("6.0");a.skipMousedown=q.isMobile}});a.isMobile=c.Browser.isMobile;a.noContextMenu=c.Browser.noContextMenu;c.Register.StartupHook("End Config",function(){o.settings=c.config.menuSettings;if(typeof(o.settings.showRenderer)!=="undefined"){o.showRenderer=o.settings.showRenderer}if(typeof(o.settings.showFontMenu)!=="undefined"){o.showFontMenu=o.settings.showFontMenu}if(typeof(o.settings.showContext)!=="undefined"){o.showContext=o.settings.showContext}a.getCookie();a.menu=a(m.SUBMENU("Show Math As",m.COMMAND("MathML Code",a.ShowSource,{nativeTouch:true,format:"MathML"}),m.COMMAND("Original Form",a.ShowSource,{nativeTouch:true}),m.RULE(),m.CHECKBOX("Show TeX hints in MathML","texHints")),m.RULE(),m.SUBMENU("Math Settings",m.SUBMENU("Zoom Trigger",m.RADIO("Hover","zoom",{action:a.Zoom}),m.RADIO("Click","zoom",{action:a.Zoom}),m.RADIO("Double-Click","zoom",{action:a.Zoom}),m.RADIO("No Zoom","zoom",{value:"None"}),m.RULE(),m.LABEL("Trigger Requires:"),m.CHECKBOX((c.Browser.isMac?"Option":"Alt"),"ALT"),m.CHECKBOX("Command","CMD",{hidden:!c.Browser.isMac}),m.CHECKBOX("Control","CTRL",{hidden:c.Browser.isMac}),m.CHECKBOX("Shift","Shift")),m.SUBMENU("Zoom Factor",m.RADIO("125%","zscale"),m.RADIO("133%","zscale"),m.RADIO("150%","zscale"),m.RADIO("175%","zscale"),m.RADIO("200%","zscale"),m.RADIO("250%","zscale"),m.RADIO("300%","zscale"),m.RADIO("400%","zscale")),m.RULE(),m.SUBMENU("Math Renderer",{hidden:!o.showRenderer},m.RADIO("HTML-CSS","renderer",{action:a.Renderer}),m.RADIO("MathML","renderer",{action:a.Renderer,value:"NativeMML"}),m.RADIO("SVG","renderer",{action:a.Renderer})),m.SUBMENU("MathPlayer",{hidden:!c.Browser.isMSIE||!o.showMathPlayer,disabled:!c.Browser.hasMathPlayer},m.LABEL("Let MathPlayer Handle:"),m.CHECKBOX("Menu Events","mpContext",{action:a.MPEvents,hidden:!e}),m.CHECKBOX("Mouse Events","mpMouse",{action:a.MPEvents,hidden:!e}),m.CHECKBOX("Mouse and Menu Events","mpMouse",{action:a.MPEvents,hidden:e})),m.SUBMENU("Font Preference",{hidden:!o.showFontMenu},m.LABEL("For HTML-CSS:"),m.RADIO("Auto","font",{action:a.Font}),m.RULE(),m.RADIO("TeX (local)","font",{action:a.Font}),m.RADIO("TeX (web)","font",{action:a.Font}),m.RADIO("TeX (image)","font",{action:a.Font}),m.RULE(),m.RADIO("STIX (local)","font",{action:a.Font})),m.SUBMENU("Contextual Menu",{hidden:!o.showContext},m.RADIO("MathJax","context"),m.RADIO("Browser","context")),m.COMMAND("Scale All Math ...",a.Scale),m.RULE().With({hidden:!o.showDiscoverable,name:"discover_rule"}),m.CHECKBOX("Highlight on Hover","discoverable",{hidden:!o.showDiscoverable})),m.RULE(),m.COMMAND("About MathJax",a.About),m.COMMAND("MathJax Help",a.Help));if(a.isMobile){(function(){var r=o.settings;var q=a.menu.Find("Math Settings","Zoom Trigger").menu;q.items[0].disabled=q.items[1].disabled=true;if(r.zoom==="Hover"||r.zoom=="Click"){r.zoom="None"}q.items=q.items.slice(0,4);if(navigator.appVersion.match(/[ (]Android[) ]/)){a.ITEM.SUBMENU.Augment({marker:"\u00BB"})}})()}});a.showRenderer=function(q){a.cookie.showRenderer=o.showRenderer=q;a.saveCookie();a.menu.Find("Math Settings","Math Renderer").hidden=!q};a.showMathPlayer=function(q){a.cookie.showMathPlayer=o.showMathPlayer=q;a.saveCookie();a.menu.Find("Math Settings","MathPlayer").hidden=!q};a.showFontMenu=function(q){a.cookie.showFontMenu=o.showFontMenu=q;a.saveCookie();a.menu.Find("Math Settings","Font Preference").hidden=!q};a.showContext=function(q){a.cookie.showContext=o.showContext=q;a.saveCookie();a.menu.Find("Math Settings","Contextual Menu").hidden=!q};a.showDiscoverable=function(q){a.cookie.showContext=o.showContext=q;a.saveCookie();a.menu.Find("Math Settings","Highlight on Hover").hidden=!q;a.menu.Find("Math Settings","discover_rule").hidden=!q};MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function(){if(!MathJax.OutputJax["HTML-CSS"].config.imageFont){a.menu.Find("Math Settings","Font Preference","TeX (image)").disabled=true}});f.Queue(c.Register.StartupHook("End Config",{}),["getImages",a],["Styles",k,o.styles],["Post",c.Startup.signal,"MathMenu Ready"],["loadComplete",k,"[MathJax]/extensions/MathMenu.js"])})(MathJax.Hub,MathJax.HTML,MathJax.Ajax,MathJax.CallBack,MathJax.OutputJax);