/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */ /* vim: set ts=2 et sw=2 tw=80: */ /************************************************************* * * MathJax/extensions/MathMenu.js * * Implements a right-mouse (or CTRL-click) menu over mathematics * elements that gives the user the ability to copy the source, * change the math size, and zoom settings. * * --------------------------------------------------------------------- * * Copyright (c) 2010-2013 The MathJax Consortium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */(function(g,q,p,w,t){var u=MathJax.Callback.Signal("menu");MathJax.Extension.MathMenu={version:"2.2",signal:u};var k=function(a){return MathJax.Localization._.apply(MathJax.Localization,[["MathMenu",a]].concat([].slice.call(arguments,1)))},n=g.Browser.isPC,y=g.Browser.isMSIE,v=8<(document.documentMode||0),x=n?null:"5px",e=g.CombineConfig("MathMenu",{delay:150,closeImg:p.fileURL(t.imageDir+"/CloseX-31.png"),showRenderer:!0,showMathPlayer:!0,showFontMenu:!1,showContext:!1,showDiscoverable:!1,showLocale:!0,showLocaleURL:!1,windowSettings:{status:"no",toolbar:"no",locationbar:"no",menubar:"no",directories:"no",personalbar:"no",resizable:"yes",scrollbars:"yes",width:400,height:300,left:Math.round((screen.width-400)/2),top:Math.round((screen.height-300)/3)},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\x3d2, OffY\x3d2, Color\x3d'gray', Positive\x3d'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":x,"-webkit-border-radius":x,"-moz-border-radius":x,"-khtml-border-radius":x,"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\x3d2, OffY\x3d2, Color\x3d'gray', Positive\x3d'true')"},".MathJax_MenuItem":{padding:n?"2px 2em":"1px 2em",background:"transparent"},".MathJax_MenuArrow":{position:"absolute",right:".5em",color:"#666666","font-family":y?"'Arial unicode MS'":null},".MathJax_MenuActive .MathJax_MenuArrow":{color:"white"},".MathJax_MenuCheck":{position:"absolute",left:".7em","font-family":y?"'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"}}}),l,z;g.Register.StartupHook("MathEvents Ready",function(){l=MathJax.Extension.MathEvents.Event.False;z=MathJax.Extension.MathEvents.Hover});var b=MathJax.Menu=MathJax.Object.Subclass({version:"2.2",items:[],posted:!1,title:null,margin:5,Init:function(a){this.items=[].slice.call(arguments,0)},With:function(a){a&&g.Insert(this,a);return this},Post:function(a,f){a||(a=window.event);var d=document.getElementById("MathJax_MenuFrame");d||(d=b.Background(this),delete c.lastItem,delete c.lastMenu,delete b.skipUp,u.Post(["post",b.jax]));var m=q.addElement(d,"div",{onmouseup:b.Mouseup,ondblclick:l,ondragstart:l,onselectstart:l,oncontextmenu:l,menuItem:this,className:"MathJax_Menu"});MathJax.Localization.setCSS(m);for(var h=0,r=this.items.length;hdocument.body.offsetWidth-this.margin&&!b.isMobile&&(g="right",h=Math.max(this.margin,h-k-m.offsetWidth+6));n||(m.style["borderRadiusTop"+g]=0,m.style["WebkitBorderRadiusTop"+g]=0,m.style["MozBorderRadiusTop"+g]=0,m.style["KhtmlBorderRadiusTop"+g]=0)}else h+m.offsetWidth>document.body.offsetWidth-this.margin&&(h=document.body.offsetWidth-m.offsetWidth-this.margin),b.isMobile&&(h=Math.max(5,h-Math.floor(m.offsetWidth/2)),r-=20),b.skipUp=a.isContextMenu;m.style.left=h+"px";m.style.top=r+"px";document.selection&&document.selection.empty&&document.selection.empty();return l(a)},Remove:function(a,f){u.Post(["unpost",b.jax]);var d=document.getElementById("MathJax_MenuFrame");d&&(d.parentNode.removeChild(d),this.msieFixedPositionBug&&detachEvent("onresize",b.Resize));b.jax.hover&&(delete b.jax.hover.nofade,z.UnHover(b.jax));return l(a)},Find:function(a){return this.FindN(1,a,[].slice.call(arguments,1))},FindId:function(a){return this.FindN(0,a,[].slice.call(arguments,1))},FindN:function(a,b,d){for(var c=0,h=this.items.length;c/g,"\x26gt;");var e=k("EqSource","MathJax Equation Source");if(b.isMobile)d.document.open(),d.document.write("\x3chtml\x3e\x3chead\x3e\x3cmeta name\x3d'viewport' content\x3d'width\x3ddevice-width, initial-scale\x3d1.0' /\x3e\x3ctitle\x3e"+e+"\x3c/title\x3e\x3c/head\x3e\x3cbody style\x3d'font-size:85%'\x3e"),d.document.write("\x3cpre\x3e"+a+"\x3c/pre\x3e"),d.document.write("\x3chr\x3e\x3cinput type\x3d'button' value\x3d'"+k("Close","Close")+"' onclick\x3d'window.close()' /\x3e"),d.document.write("\x3c/body\x3e\x3c/html\x3e"),d.document.close();else{d.document.open();d.document.write("\x3chtml\x3e\x3chead\x3e\x3ctitle\x3e"+e+"\x3c/title\x3e\x3c/head\x3e\x3cbody style\x3d'font-size:85%'\x3e");d.document.write("\x3ctable\x3e\x3ctr\x3e\x3ctd\x3e\x3cpre\x3e"+a+"\x3c/pre\x3e\x3c/td\x3e\x3c/tr\x3e\x3c/table\x3e");d.document.write("\x3c/body\x3e\x3c/html\x3e");d.document.close();var h=d.document.body.firstChild;setTimeout(function(){var a=d.outerHeight-d.innerHeight||30,b=d.outerWidth-d.innerWidth||30,b=Math.max(100,Math.min(Math.floor(.5*screen.width),h.offsetWidth+b+25)),a=Math.max(40,Math.min(Math.floor(.5*screen.height),h.offsetHeight+a+25));d.resizeTo(b,a);c&&null!=c.screenX&&(b=Math.max(0,Math.min(c.screenX-Math.floor(b/2),screen.width-b-20)),a=Math.max(0,Math.min(c.screenY-Math.floor(a/2),screen.height-a-20)),d.moveTo(b,a))},50)}};b.Scale=function(){var a=t["HTML-CSS"],c=t.NativeMML,d=t.SVG,e=(a||c||d||{config:{scale:100}}).config.scale,h=prompt(k("ScaleMath","Scale all mathematics (compared to surrounding text) by"),e+"%");h&&(h.match(/^\s*\d+(\.\d*)?\s*%?\s*$/)?(h=parseFloat(h))?h!==e&&(a&&(a.config.scale=h),c&&(c.config.scale=h),d&&(d.config.scale=h),b.cookie.scale=h,b.saveCookie(),g.Reprocess()):alert(k("NonZeroScale","The scale should not be zero")):alert(k("PercentScale","The scale should be a percentage (e.g., 120%%)")))};b.Zoom=function(){MathJax.Extension.MathZoom||p.Require("[MathJax]/extensions/MathZoom.js")};b.Renderer=function(){var a=g.outputJax["jax/mml"];if(a[0]!==e.settings.renderer){var c=g.Browser,d,m=b.Renderer.Messages,h;switch(e.settings.renderer){case "NativeMML":e.settings.warnedMML||(c.isChrome&&"24."!==c.version.substr(0,3)?d=m.MML.WebKit:c.isSafari&&!c.versionAtLeast("5.0")?d=m.MML.WebKit:c.isMSIE?c.hasMathPlayer||(d=m.MML.MSIE):d=m.MML[c],h="warnedMML");break;case "SVG":e.settings.warnedSVG||!c.isMSIE||v||(d=m.SVG.MSIE)}if(d){d=k(d[0],d[1]);d=d+"\n\n"+k("SwitchAnyway","Switch the renderer anyway?\n\n(Press OK to switch, CANCEL to continue with the current renderer)");b.cookie.renderer=a[0].id;b.saveCookie();if(!confirm(d)){b.cookie.renderer=e.settings.renderer=q.Cookie.Get("menu").renderer;b.saveCookie();return}h&&(b.cookie.warned=e.settings.warned=!0);b.cookie.renderer=e.settings.renderer;b.saveCookie()}g.Queue(["setRenderer",g,e.settings.renderer,"jax/mml"],["Rerender",g])}};b.Renderer.Messages={MML:{WebKit:["WebkitNativeMMLWarning","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:["MSIENativeMMLWarning","Internet Explorer requires the MathPlayer plugin in order to process MathML output."],Opera:["OperaNativeMMLWarning","Opera's support for MathML is limited, so switching to MathML output may cause some expressions to render poorly."],Safari:["SafariNativeMMLWarning","Your browser's native MathML does not implement all the features used by MathJax, so some expressions may not render properly."],Firefox:["FirefoxNativeMMLWarning","Your browser's native MathML does not implement all the features used by MathJax, so some expressions may not render properly."]},SVG:{MSIE:["MSIESVGWarning","SVG is not implemented in Internet Explorer prior to IE9 or when it is emulating IE8 or below. Switching to SVG output will cause the mathematics to not display properly."]}};b.Font=function(){t["HTML-CSS"]&&document.location.reload()};b.Locale=function(){MathJax.Localization.setLocale(e.settings.locale);MathJax.Hub.Queue(["Reprocess",MathJax.Hub])};b.LoadLocale=function(){var a=prompt(k("LoadURL","Load translation data from this URL:"));a&&(a.match(/\.js$/)||alert(k("BadURL","The URL should be for a javascript file that defines MathJax translation data. Javascript file names should end with '.js'")),p.Require(a,function(b){b!=p.STATUS.OK&&alert(k("BadData","Failed to load translation data from %1",a))}))};b.MPEvents=function(a){var c=e.settings.discoverable,d=b.MPEvents.Messages;v?!c&&"Menu Events"===a.name[1]&&e.settings.mpContext&&alert(k.apply(k,d.IE9warning)):e.settings.mpMouse&&!confirm(k.apply(k,d.IE8warning))?(delete b.cookie.mpContext,delete e.settings.mpContext,delete b.cookie.mpMouse,delete e.settings.mpMouse,b.saveCookie()):(e.settings.mpContext=e.settings.mpMouse,b.cookie.mpContext=b.cookie.mpMouse=e.settings.mpMouse,b.saveCookie(),MathJax.Hub.Queue(["Rerender",MathJax.Hub]))};b.MPEvents.Messages={IE8warning:["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:["IE9warning","The MathJax contextual menu will be disabled, but you can Alt-Click on an expression to obtain the MathJax menu instead."]};g.Browser.Select({MSIE:function(a){var c="BackCompat"===document.compatMode;a=a.versionAtLeast("8.0")&&7document.documentMode,msieFixedPositionBug:c||!a,msieAboutBug:c});v&&(delete e.styles["#MathJax_About"].filter,delete e.styles[".MathJax_Menu"].filter)},Firefox:function(a){b.skipMouseover=a.isMobile&&a.versionAtLeast("6.0");b.skipMousedown=a.isMobile}});b.isMobile=g.Browser.isMobile;b.noContextMenu=g.Browser.noContextMenu;b.CreateLocaleMenu=function(){if(b.menu){var a=b.menu.Find("Language").menu,e=a.items,d=[],g=MathJax.Localization.strings,h;for(h in g)g.hasOwnProperty(h)&&d.push(h);d=d.sort();a.items=[];h=0;for(var k=d.length;h