lib/gollum/frontend/public/javascript/MathJax/jax/output/NativeMML/jax.js in gollum-1.1.1 vs lib/gollum/frontend/public/javascript/MathJax/jax/output/NativeMML/jax.js in gollum-1.2.0

- old
+ new

@@ -1,230 +1,18 @@ -/************************************************************* - * - * MathJax/jax/output/NativeMML/jax.js - * - * Implements the NativeMML OutputJax that displays mathematics - * using a browser's native MathML capabilities (if any). +/* + * ../SourceForge/trunk/mathjax/jax/output/NativeMML/jax.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 (the "License"); + * Licensed under the Apache License, Version 2.0; * 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 (MML,nMML) { - - nMML.Augment({ - // - // User can configure styles - // - config: {styles: {}}, - Startup: function () {return MathJax.Ajax.Styles(this.config.styles)}, - // - // Add a SPAN to use as a container, and render the math into it - // - Translate: function (script) { - var math = script.MathJax.elementJax.root; - var type = (math.Get("display") === "block" ? "div" : "span"); - var span = script.parentNode.insertBefore(document.createElement(type),script); - span.className = "MathJax_MathML"; - try {math.toNativeMML(span)} catch (err) { - if (err.restart) {span.parentNode.removeChild(span)} - throw err; - } - }, - // - // Remove MathML preceeding the script - // - Remove: function (jax) { - var span = jax.SourceElement(); if (!span) return; - span = span.previousSibling; if (!span) return; - if (span.className.match(/MathJax_MathML/)) {span.parentNode.removeChild(span)} - }, - // - // The namespace to use for MML - // - MMLnamespace: "http://www.w3.org/1998/Math/MathML" - }); - - MML.mbase.Augment({ - // - // Add a MathML tag of the correct type, and set its attributes - // then populate it with its children and append it to the parent - // - toNativeMML: function (parent) { - var tag = this.NativeMMLelement(this.type); - this.NativeMMLattributes(tag); - for (var i = 0, m = this.data.length; i < m; i++) { - if (this.data[i]) {this.data[i].toNativeMML(tag)} - else {tag.appendChild(this.NativeMMLelement("mrow"))} - } - parent.appendChild(tag); - }, - // - // Look for attributes that are different from the defaults - // and set those in the tag's attribute list - // - NativeMMLattributes: function (tag) { - var defaults = this.defaults, id; - var copy = this.NativeMMLcopyAttributes, - skip = this.NativeMMLskipAttributes; - if (this.type === "mstyle") {defaults = MML.math.prototype.defaults} - for (var id in defaults) {if (!skip[id] && defaults.hasOwnProperty(id)) { - if (this[id] != null) {tag.setAttribute(id,String(this[id]))} - }} - for (var i = 0, m = copy.length; i < m; i++) { - if (this[copy[i]] != null) {tag.setAttribute(copy[i],String(this[copy[i]]))} - } - if (this.style) {tag.setAttribute("style",this.style)} - }, - NativeMMLcopyAttributes: [ - "fontfamily","fontsize","fontweight","fontstyle", - "color","background", - "id","class","href","style" - ], - NativeMMLskipAttributes: {texClass: 1, useHeight: 1, texprimestyle: 1}, - // - // Create a MathML element - // - NativeMMLelement: ( - MathJax.Hub.Browser.isMSIE ? - function (type) {return document.createElement("mjx:"+type)} : - function (type) {return document.createElementNS(nMML.MMLnamespace,type)} - ) - }); - - MML.mrow.Augment({ - // - // Make inferred rows not include an mrow tag - // - toNativeMML: function (parent) { - if (this.inferred && this.parent.inferRow) { - for (var i = 0, m = this.data.length; i < m; i++) { - if (this.data[i]) {this.data[i].toNativeMML(parent)} - else {parent.appendChild(this.NativeMMLelement("mrow"))} - } - } else { - this.SUPER(arguments).toNativeMML.call(this,parent); - } - } - }); - - MML.msubsup.Augment({ - // - // Use proper version of msub, msup, or msubsup, depending on - // which items are present - // - toNativeMML: function (parent) { - var type = this.type; - if (this.data[this.sup] == null) {type = "msub"} - if (this.data[this.sub] == null) {type = "msup"} - var tag = this.NativeMMLelement(type); - this.NativeMMLattributes(tag); - delete this.data[0].inferred; - for (var i = 0, m = this.data.length; i < m; i++) - {if (this.data[i]) {this.data[i].toNativeMML(tag)}} - parent.appendChild(tag); - } - }); - - MML.munderover.Augment({ - // - // Use proper version of munder, mover, or munderover, depending on - // which items are present - // - toNativeMML: function (parent) { - var type = this.type; - if (this.data[this.under] == null) {type = "mover"} - if (this.data[this.over] == null) {type = "munder"} - var tag = this.NativeMMLelement(type); - this.NativeMMLattributes(tag); - delete this.data[0].inferred; - for (var i = 0, m = this.data.length; i < m; i++) - {if (this.data[i]) {this.data[i].toNativeMML(tag)}} - parent.appendChild(tag); - } - }); - - if (MathJax.Hub.Browser.isFirefox) { - MML.mtable.Augment({ - toNativeMML: function (parent) { - // - // FF doesn't handle width, so put it in styles instead - // - if (this.width) { - var styles = (this.style||"").replace(/;\s*$/,"").split(";"); - styles.push("width:"+this.width); - this.style = styles.join(";"); - } - this.SUPER(arguments).toNativeMML.call(this,parent); - } - }); - MML.mlabeledtr.Augment({ - toNativeMML: function (parent) { - // - // FF doesn't handle mlabeledtr, so remove the label - // - var tag = this.NativeMMLelement("mtr"); - this.NativeMMLattributes(tag); - for (var i = 1, m = this.data.length; i < m; i++) { - if (this.data[i]) {this.data[i].toNativeMML(tag)} - else {tag.appendChild(this.NativeMMLelement("mrow"))} - } - parent.appendChild(tag); - } - }); - } - - MML.TeXAtom.Augment({ - // - // Convert TeXatom to an mrow - // - toNativeMML: function (parent) { - // FIXME: Handle spacing using mpadded? - var tag = this.NativeMMLelement("mrow"); - this.data[0].toNativeMML(tag); - parent.appendChild(tag); - } - }); - - MML.chars.Augment({ - // - // Add a text node - // - toNativeMML: function (parent) { - parent.appendChild(document.createTextNode(this.toString())); - } - }); - - MML.entity.Augment({ - // - // Add a text node - // - toNativeMML: function (parent) { - parent.appendChild(document.createTextNode(this.toString())); - } - }); - - MathJax.Hub.Register.StartupHook("TeX mathchoice Ready",function () { - MML.TeXmathchoice.Augment({ - // - // Get the MathML for the selected choice - // - toNativeMML: function (parent) {this.Core().toNativeMML(parent)} - }); - }); - - nMML.loadComplete("jax.js"); +MathJax.Unpack([ + ['(','function(','b,a,e,d){var c=e.Browser.isMSIE;','a.Augment({','LEFTBUTTON',':(c?1:0),MENUKEY:"altKey",','noContextMenuBug',':e.Browser.isKonequeror,msieQuirks:(c&&!(document.compatMode==="BackCompat")),','config:{styles',':{}},settings:','e.config.menuSettings',',Startup:','function(){','return ','MathJax.','Ajax.Styles(','this.config.','styles)},Config:',12,'this.SUPER(arguments).Config','.call(this',');if(','this.settings.scale','){',16,'scale=',22,'}},Translate:',1,'h){if(!h','.parentNode','){return','}var l=h','.previousSibling',';if(l&&String(l.className).match(/^MathJax(_MathML|_Display)?$/)){l',30,'.removeChild(','l)}var k=h.',14,'elementJax.root;var j=(k.Get("display")==="block"?"div":"span");var i=document.','createElement','(j),g=i;i.className="','MathJax_MathML','";i.style.fontSize=',16,'scale+"%";if(c){g=','MathJax.HTML.addElement(','i,"span",{className:"MathJax_MathContainer",','style:{display:"inline-block",','position:"relative','"}})}k.','toNativeMML(','g);h',30,'.insertBefore(i,h);if(c){if(',16,'showMathMenuMSIE){this.MSIEoverlay(i)}}else{k=i','.firstChild',';k.','oncontextmenu','=this.','ContextMenu',';k.','onmouseover',60,'Mouseover',';k.','onmousedown',60,'Mousedown;k.onclick',60,'Click',';k.','ondblclick',60,'DblClick','}},Remove:',1,'g){','var h=','g.SourceElement();if(!h',31,'}h=h',33,';if(!h',31,'}if(h.className.match(/',42,'/)){h',30,36,'h)}},MMLnamespace:"http://www.w3.org/1998/Math/MathML",MSIEoverlay:',1,'n){var m=n',57,';','n.style.position','="absolute";var o','=n.scrollHeight',',i=n.offsetWidth;var k=',46,'n,"img",{src:"about:blank",style:{','width:0,height:','o+"px"}});var g',98,'-o;n',36,'k);',96,'="";var l,j,h=(n',30,'.nodeName.toLowerCase()==="','div");if(h&&this.quirks){l=-o;j=Math.floor(-i/2)}else{l=g-o,j=-i}',46,'n,"span",{',48,102,'0,',49,'"}},[["span",{',48,'position:"absolute",left:j+"px",top:l+"px",width:m.offsetWidth+"px",height:o+"px",cursor:"pointer","background-color":"white",filter:"alpha(opacity=0)"},',67,':this.MSIEevent',',',59,123,',onclick',123,',onmousemove',123,',',73,123,',',63,123,',onmouseout',123,'}]])},MSIEmath:',1,'g){',79,'g',30,33,57,';return(h',111,'span"?h',57,':h)},MSIEevent:',12,79,'a.MSIEmath(this);var g','=window.event',';var i=a["MSIE"+g.type];if(i&&i.call(a,g,h,this)){','return false','}h.fireEvent("on"+g.type,g);',157,'},MSIEmousedown:',1,'i,h,g){if(','i[this.MENUKEY]&&i.button===this.',4,'&&this','.settings.context','!=="','MathJax"){this.trapUp=this.trapClick=true;this.ContextMenu.call(g,i,true);return true}','if(','this.MSIEzoomKeys','&&',170,'(i)){this.trapUp=true;',13,'true}',157,'},MSIEcontextmenu:',1,162,'this',166,'==="',168,157,'},',61,':',1,'j,k','){if(a.config.showMathMenu','&&(a',166,'==="MathJax','"||k)){if(a.safariContextMenuBug','){setTimeout("','window.getSelection().empty()",0)}',79,14,'Menu;if(h){if(','document.selection',195,200,'.empty()",0)}var g=(c?this',30,30,'.nextSibling',':this',30,206,');h.jax=e.getJaxFor(g);h.menu.items[1].menu.items[1].name=(','h.jax.inputJax.name','==="MathML"?"Original":',211,');','delete ','a.trapClick;',215,'a.trapUp;',13,'h.menu.Post(j)}else{if(!','d.loadingMathMenu','){',221,'=true;if(!j){j',155,'}var i={pageX:j.pageX,pageY:j.pageY,clientX:j.clientX,clientY:j.clientY};',14,'Callback.Queue(','d.Require("[MathJax]/extensions/','MathMenu.js"),',12,215,221,'},[this,arguments.callee,i,k])}if(!j){j',155,'}if(','j.preventDefault','){',237,'()}if(','j.stopPropagation','){',241,'()}j.cancelBubble=true;j.returnValue=false;',157,'}}},Mousedown:',1,'g',190,'){if(!g){g',155,'}if(a',166,193,'"){if(!a.',6,'||g.button!==2',31,'}}else{if(!g[a.MENUKEY]||g.button!==a.',4,31,'}}',13,'a.',61,20,',g,true)}},',65,':',1,'g){a.HandleEvent(g,"',65,'",this)},',71,':',1,271,71,273,75,':',1,271,75,273,'HandleEvent:',1,'i,g,h){},NAMEDSPACE:{negativeveryverythinmathspace:"-.0556em",negativeverythinmathspace:"-.1111em",negativethinmathspace:"-.1667em",negativemediummathspace:"-.2222em",negativethickmathspace:"-.2778em",negativeverythickmathspace:"-.3333em",negativeveryverythickmathspace:"-.3889em"}});b.mbase','.Augment({toNativeMML:function(','k){',79,'this.NativeMMLelement','(this.type);','this.NativeMMLattributes(h);','for(var j=','0',',g=this.data.length;j<g;j++){if(this.data[j]){this.data[j].toNativeMML(h',')}else{h','.appendChild(',292,'("mrow"))}}k',299,'h)},NativeMMLattributes:',1,'h){var l',60,'defaults;var o',60,'NativeMMLcopyAttributes',',k',60,'NativeMMLskipAttributes',';if(this.type==="mstyle"){l=b.math.prototype.defaults}for(var n in l){if(!k[n]&&l.hasOwnProperty(n)){if(this[n]!=','null){h.setAttribute(','n,this.','NativeMMLattribute','(n,this[n]))}}}',295,'0,g=o.length;j<g;j++){if(this[o[j]]!=',314,'o[j],this.',316,'(o[j],this[o[j]]))}}},',309,':["fontfamily","fontsize","fontweight","fontstyle","color","background","id","class","href","style"],',312,':{texClass:1,useHeight:1,texprimestyle:1},',316,':',1,'h,g){g=String(g);if(a.NAMEDSPACE[g]){g=a.NAMEDSPACE[g]}else{if(g.match(/^\\s*([-+]?(\\d+(\\.\\d*)?|\\.\\d+))\\s*mu\\s*$/)){g=((1/18)*RegExp.$1)+"em','"}else{if(g==="-tex-','caligraphic"){g','="script',332,'oldstyle"){g="normal"}}}}',13,'g},NativeMMLelement:(c?',1,'g){return document.',40,'("mjx:"+g)}:',1,340,'createElementNS(a.MMLnamespace,g)})});b.mrow',289,'j){if(this.inferred&&this.parent.inferRow){for(',79,'0,g',60,'data.length;h<g;h++){if(this.data[h]){this.data[h].',51,'j)}else{j',299,292,'("mrow"))}}}else{','this.SUPER(arguments).toNativeMML.call(this,','j)}}});b.msubsup',289,'l){var k=this.type;if(this.data[this.','sup',']==null){k="','msub','"}if(this.data[this.','sub',362,'msup"}',79,292,'(k);',294,215,'this.data[0].','inferred;',295,'0',297,')}}l',299,'h)}});b.munderover',289,360,'under',362,'mover',364,'over',362,'munder"}',79,292,370,294,215,373,'inferred;',295,'0',297,')}}l',299,'h)}});if(',14,'Hub.Browser.isFirefox){b.mtable',289,'g){if(this.width){var h=(this.style||"").replace(/;\\s*$/,"").split(";");h.push("width:"+this.width);this.style=h.join(";")}',357,'g)}});b.mlabeledtr',289,'k){',79,292,'("mtr");',294,295,'1',297,')}else{h',299,292,'("mrow"))}}k',299,'h)}});var f=',14,'Hub.config.root+"/fonts/HTML-CSS/TeX/otf";',3,8,':{\'[mathvariant="double-struck','"]\':{"font-family":"','MathJax_AMS','"},\'[mathvariant',334,429,'MathJax_Script',431,'="fraktur',429,'MathJax_Fraktur',431,'="-tex-oldstyle',429,'MathJax_Caligraphic',431,440,'-bold',429,442,'","font-weight":"bold"},\'[mathvariant','="-tex-caligraphic',429,442,431,449,445,429,442,448,'="bold-','script',429,434,448,458,'fraktur',429,438,448,'="','monospace',429,469,431,'="sans-serif',429,'sansserif',431,458,'sans-serif',429,475,448,473,'-italic',429,'sansserif","font-style":"italic',431,473,445,'-italic',429,485,'","font-weight":"bold','"},"@font-face /*1','*/":{"font-family":"',430,'",src:"local(\'',430,'\'), url(\'"+f+"/',430,'-Regular.otf\')"},"@font-face /*','2',494,434,496,434,498,434,500,'3',494,438,496,438,498,438,500,'4',494,442,496,442,498,442,500,'5',494,438,492,496,438,'-Bold',498,438,531,'.otf\')"},"@font-face /*6',494,442,492,496,442,531,498,442,531,'.otf\')"}}}})}b.TeXAtom',289,'h){var g=',292,'("mrow");',373,51,'g);h',299,'g)}});b.chars',289,'g){g.appendChild(document.createTextNode(this.toString()))}});','b.entity',289,556,14,'Hub.Register.StartupHook("TeX mathchoice Ready",',12,'b.TeXmathchoice',289,'g){this.Core().',51,'g)}})});if(',10,'.zoom!=="None"){',229,'MathZoom.js")}a.loadComplete("jax.js")})(',14,'ElementJax.mml,',14,'OutputJax.NativeMML,',14,'Hub,',14,'Ajax);'] +]); -})(MathJax.ElementJax.mml, MathJax.OutputJax.NativeMML);