/* * /MathJax/extensions/MathMenu.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 */ (function(b,c,f){var k="1.1.4";MathJax.Extension.MathMenu={version:k};var i=b.Browser.isPC,g=b.Browser.isMSIE;var e=(i?null:"5px");var j=b.CombineConfig("MathMenu",{delay:150,helpURL:"http://www.mathjax.org/help/user/",showRenderer:true,showFontMenu:false,showContext: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:(i?"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":e,"-webkit-border-radius":e,"-moz-border-radius":e,"-khtml-border-radius":e,"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:(i?"2px 2em":"1px 2em"),background:"transparent"},".MathJax_MenuTitle":{"background-color":"#CCCCCC",margin:(i?"-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":(g?"'Arial unicode MS'":null)},".MathJax_MenuActive .MathJax_MenuArrow":{color:"white"},".MathJax_MenuCheck":{position:"absolute",left:".7em","font-family":(g?"'Arial unicode MS'":null)},".MathJax_MenuRadioCheck":{position:"absolute",left:(i?"1em":".7em")},".MathJax_MenuLabel":{padding:(i?"2px 2em 4px 1.33em":"1px 2em 3px 1.33em"),"font-style":"italic"},".MathJax_MenuRule":{"border-top":(i?"1px solid #CCCCCC":"1px solid #DDDDDD"),margin:(i?"4px 1px 0px":"4px 3px")},".MathJax_MenuDisabled":{color:"GrayText"},".MathJax_MenuActive":{"background-color":(i?"Highlight":"#606872"),color:(i?"HighlightText":"white")}}});var d=function(l){if(!l){l=window.event}if(l){if(l.preventDefault){l.preventDefault()}if(l.stopPropagation){l.stopPropagation()}l.cancelBubble=true;l.returnValue=false}return false};var a=MathJax.Menu=MathJax.Object.Subclass({version:k,items:[],posted:false,title:null,margin:5,Init:function(l){this.items=[].slice.call(arguments,0)},With:function(l){if(l){b.Insert(this,l)}return this},Post:function(n,v){if(!n){n=window.event}var t=(!this.title?null:[["div",{className:"MathJax_MenuTitle"},[this.title]]]);var l=document.getElementById("MathJax_MenuFrame");if(!l){l=a.Background(this)}var o=c.addElement(l,"div",{onmouseup:a.Mouseup,ondblclick:this.False,ondragstart:this.False,onselectstart:this.False,oncontextmenu:this.False,menuItem:this,className:"MathJax_Menu"},t);for(var q=0,p=this.items.length;qdocument.body.offsetWidth-this.margin){u=document.body.offsetWidth-o.offsetWidth-this.margin}a.skipUp=true}else{var r="left",w=v.offsetWidth;u=v.offsetWidth-2;s=0;while(v&&v!==l){u+=v.offsetLeft;s+=v.offsetTop;v=v.parentNode}if(u+o.offsetWidth>document.body.offsetWidth-this.margin){r="right";u=Math.max(this.margin,u-w-o.offsetWidth+6)}if(!i){o.style["borderRadiusTop"+r]=0;o.style["WebkitBorderRadiusTop"+r]=0;o.style["MozBorderRadiusTop"+r]=0;o.style["KhtmlBorderRadiusTop"+r]=0}}o.style.left=u+"px";o.style.top=s+"px";if(document.selection&&document.selection.empty){document.selection.empty()}return this.False(n)},Remove:function(l,m){var n=document.getElementById("MathJax_MenuFrame");if(n){n.parentNode.removeChild(n);if(this.msieBackgroundBug){detachEvent("onresize",a.Resize)}}},Mouseup:function(l,m){if(a.skipUp){delete a.skipUp}else{this.Remove(l,m)}},False:d},{config:j,div:null,Remove:function(l){a.Event(l,this,"Remove")},Mouseover:function(l){a.Event(l,this,"Mouseover")},Mouseout:function(l){a.Event(l,this,"Mouseout")},Mousedown:function(l){a.Event(l,this,"Mousedown")},Mouseup:function(l){a.Event(l,this,"Mouseup")},Mousemove:function(l){a.Event(l,this,"Mousemove")},Event:function(n,o,l){if(!n){n=window.event}var m=o.menuItem;if(m&&m[l]){return m[l](n,o)}return null},BGSTYLE:{position:"absolute",left:0,top:0,"z-index":200,width:"100%",height:"100%",border:0,padding:0,margin:0},Background:function(m){var n=c.addElement(document.body,"div",{style:this.BGSTYLE,id:"MathJax_MenuFrame"},[["div",{style:this.BGSTYLE,menuItem:m,onmousedown:this.Remove}]]);var l=n.firstChild;if(m.msieBackgroundBug){l.style.backgroundColor="white";l.style.filter="alpha(opacity=0)";n.width=n.height=0;this.Resize();attachEvent("onresize",this.Resize)}else{l.style.position="fixed"}return n},Resize:function(){setTimeout(a.SetWH,0)},SetWH:function(){var l=document.getElementById("MathJax_MenuFrame");if(l){l=l.firstChild;l.style.width=l.style.height="1px";l.style.width=document.body.scrollWidth+"px";l.style.height=document.body.scrollHeight+"px"}},saveCookie:function(){c.Cookie.Set("menu",this.cookie)},getCookie:function(){this.cookie=c.Cookie.Get("menu")}});var h=a.ITEM=MathJax.Object.Subclass({name:"",Create:function(m){if(!this.hidden){var l={onmouseover:a.Mouseover,onmouseout:a.Mouseout,onmouseup:a.Mouseup,onmousedown:this.False,ondragstart:this.False,onselectstart:this.False,onselectend:this.False,className:"MathJax_MenuItem",menuItem:this};if(this.disabled){l.className+=" MathJax_MenuDisabled"}c.addElement(m,"div",l,this.Label(l,m))}},Mouseover:function(q,s){if(!this.disabled){this.Activate(s)}if(!this.menu||!this.menu.posted){var r=document.getElementById("MathJax_MenuFrame").childNodes,n=s.parentNode.childNodes;for(var o=0,l=n.length;o=0&&s.parentNode.menuItem!==r[l].menuItem){r[l].menuItem.posted=false;r[l].parentNode.removeChild(r[l]);l--}if(this.Timer){this.Timer(q,s)}}},Mouseout:function(l,m){if(!this.menu||!this.menu.posted){this.Deactivate(m)}if(this.timer){clearTimeout(this.timer);delete this.timer}},Mouseup:function(l,m){return this.Remove(l,m)},Remove:function(l,m){m=m.parentNode.menuItem;return m.Remove(l,m)},Activate:function(l){this.Deactivate(l);l.className+=" MathJax_MenuActive"},Deactivate:function(l){l.className=l.className.replace(/ MathJax_MenuActive/,"")},With:function(l){if(l){b.Insert(this,l)}return this},False:d});a.ITEM.COMMAND=a.ITEM.Subclass({action:function(){},Init:function(l,n,m){this.name=l;this.action=n;this.With(m)},Label:function(l,m){return[this.name]},Mouseup:function(l,m){if(!this.disabled){this.Remove(l,m);this.action.call(this,l)}return this.False(l)}});a.ITEM.SUBMENU=a.ITEM.Subclass({menu:null,marker:(i&&!b.Browser.isSafari?"\u25B6":"\u25B8"),Init:function(l,n){this.name=l;var m=1;if(!(n instanceof a.ITEM)){this.With(n),m++}this.menu=a.apply(a,[].slice.call(arguments,m))},Label:function(l,m){l.onmousemove=a.Mousemove;this.menu.posted=false;return[this.name+" ",["span",{className:"MathJax_MenuArrow"},[this.marker]]]},Timer:function(l,m){if(this.timer){clearTimeout(this.timer)}l={clientX:l.clientX,clientY:l.clientY};this.timer=setTimeout(MathJax.Callback(["Mouseup",this,l,m]),j.delay)},Mouseup:function(n,p){if(!this.disabled){if(!this.menu.posted){if(this.timer){clearTimeout(this.timer);delete this.timer}this.menu.Post(n,p)}else{var o=document.getElementById("MathJax_MenuFrame").childNodes,l=o.length-1;while(l>=0){var q=o[l];q.menuItem.posted=false;q.parentNode.removeChild(q);if(q.menuItem===this.menu){break}l--}}}return this.False(n)}});a.ITEM.RADIO=a.ITEM.Subclass({variable:null,marker:(i?"\u25CF":"\u2713"),Init:function(m,l,n){this.name=m;this.variable=l;this.With(n);if(this.value==null){this.value=this.name}},Label:function(m,n){var l={className:"MathJax_MenuRadioCheck"};if(j.settings[this.variable]!==this.value){l={style:{display:"none"}}}return[["span",l,[this.marker]]," "+this.name]},Mouseup:function(p,q){if(!this.disabled){var r=q.parentNode.childNodes;for(var n=0,l=r.length;n/g,">");n.document.open();n.document.write("MathJax Equation Source");n.document.write("
"+r+"
");n.document.write("");n.document.close();var p=n.document.body.firstChild;var o=(n.outerHeight-n.innerHeight)||30,m=(n.outerWidth-n.innerWidth)||30;m=Math.min(Math.floor(0.5*screen.width),p.offsetWidth+m+25);o=Math.min(Math.floor(0.5*screen.height),p.offsetHeight+o+25);n.resizeTo(m,o);if(q&&q.screenX!=null){var l=Math.max(0,Math.min(q.screenX-Math.floor(m/2),screen.width-m-20)),s=Math.max(0,Math.min(q.screenY-Math.floor(o/2),screen.height-o-20));n.moveTo(l,s)}delete a.ShowSource.w};a.Scale=function(){var m=MathJax.OutputJax["HTML-CSS"],l=MathJax.OutputJax.NativeMML;var o=(m?m.config.scale:l.config.scale);var n=prompt("Scale all mathematics (compared to surrounding text) by",o+"%");if(n){if(n.match(/^\s*\d+\s*%?\s*$/)){n=parseInt(n);if(n){if(n!==o){if(m){m.config.scale=n}if(l){l.config.scale=n}a.cookie.scale=n;a.saveCookie();b.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){f.Require("[MathJax]/extensions/MathZoom.js")}};a.Renderer=function(){var l=b.config.outputJax["jax/mml"];if(l[0]!==j.settings.renderer){MathJax.Callback.Queue(["Require",f,"[MathJax]/jax/output/"+j.settings.renderer+"/config.js"],["Post",b.Startup.signal,j.settings.renderer+" output selected"],[function(){var p=MathJax.OutputJax[j.settings.renderer];for(var o=0,n=l.length;o7;a.Augment({margin:20,msieBackgroundBug:(m||!n),msieAboutBug:m});if(document.documentMode>=9){delete j.styles["#MathJax_About"].filter;delete j.styles[".MathJax_Menu"].filter}}});b.Register.StartupHook("End Config",function(){j.settings=b.config.menuSettings;if(!j.settings.format){j.settings.format=(MathJax.InputJax.TeX?"Original":"MathML")}if(typeof(j.settings.showRenderer)!=="undefined"){j.showRenderer=j.settings.showRenderer}if(typeof(j.settings.showFontMenu)!=="undefined"){j.showFontMenu=j.settings.showFontMenu}if(typeof(j.settings.showContext)!=="undefined"){j.showContext=j.settings.showContext}a.getCookie();a.menu=a(h.COMMAND("Show Source",a.ShowSource),h.SUBMENU("Format",h.RADIO("MathML","format"),h.RADIO("Original","format",{value:"Original"})),h.RULE(),h.SUBMENU("Settings",h.SUBMENU("Zoom Trigger",h.RADIO("Hover","zoom",{action:a.Zoom}),h.RADIO("Click","zoom",{action:a.Zoom}),h.RADIO("Double-Click","zoom",{action:a.Zoom}),h.RADIO("No Zoom","zoom",{value:"None"}),h.RULE(),h.LABEL("Trigger Requires:"),h.CHECKBOX((b.Browser.isMac?"Option":"Alt"),"ALT"),h.CHECKBOX("Command","CMD",{hidden:!b.Browser.isMac}),h.CHECKBOX("Control","CTRL",{hidden:b.Browser.isMac}),h.CHECKBOX("Shift","Shift")),h.SUBMENU("Zoom Factor",h.RADIO("125%","zscale"),h.RADIO("133%","zscale"),h.RADIO("150%","zscale"),h.RADIO("175%","zscale"),h.RADIO("200%","zscale"),h.RADIO("250%","zscale"),h.RADIO("300%","zscale"),h.RADIO("400%","zscale")),h.RULE(),h.SUBMENU("Math Renderer",{hidden:!j.showRenderer},h.RADIO("HTML-CSS","renderer",{action:a.Renderer}),h.RADIO("MathML","renderer",{action:a.Renderer,value:"NativeMML"})),h.SUBMENU("Font Preference",{hidden:!j.showFontMenu},h.LABEL("For HTML-CSS:"),h.RADIO("Auto","font",{action:a.Font}),h.RULE(),h.RADIO("TeX (local)","font",{action:a.Font}),h.RADIO("TeX (web)","font",{action:a.Font}),h.RADIO("TeX (image)","font",{action:a.Font}),h.RULE(),h.RADIO("STIX (local)","font",{action:a.Font})),h.SUBMENU("Contextual Menu",{hidden:!j.showContext},h.RADIO("MathJax","context"),h.RADIO("Browser","context")),h.COMMAND("Scale All Math ...",a.Scale)),h.RULE(),h.COMMAND("About MathJax",a.About),h.COMMAND("MathJax Help",a.Help))});a.showRenderer=function(l){a.cookie.showRenderer=j.showRenderer=l;a.saveCookie();a.menu.items[3].menu.item[3].hidden=!l};a.showFontMenu=function(l){a.cookie.showFontMenu=j.showFontMenu=l;a.saveCookie();a.menu.items[3].menu.items[4].hidden=!l};a.showContext=function(l){a.cookie.showContext=j.showContext=l;a.saveCookie();a.menu.items[3].menu.items[5].hidden=!l};MathJax.Callback.Queue(["Styles",f,j.styles],["Post",b.Startup.signal,"MathMenu Ready"],["loadComplete",f,"[MathJax]/extensions/MathMenu.js"])})(MathJax.Hub,MathJax.HTML,MathJax.Ajax);