annotation-xml.js 1.6 KB

12345678910111213
  1. /*
  2. * /MathJax/jax/output/SVG/autoload/annotation-xml.js
  3. *
  4. * Copyright (c) 2009-2013 The MathJax Consortium
  5. *
  6. * Part of the MathJax library.
  7. * See http://www.mathjax.org for details.
  8. *
  9. * Licensed under the Apache License, Version 2.0;
  10. * you may not use this file except in compliance with the License.
  11. *
  12. * http://www.apache.org/licenses/LICENSE-2.0
  13. */MathJax.Hub.Register.StartupHook("SVG Jax Ready",function(){var f=MathJax.ElementJax.mml,e=MathJax.OutputJax.SVG,g=e.BBOX;g.FOREIGN=g.Subclass({type:"foreignObject",removeable:!1});f["annotation-xml"].Augment({toSVG:function(){var b=this.SVG();this.SVGhandleSpace(b);for(var d=this.Get("encoding"),c=0,a=this.data.length;c<a;c++)b.Add(this.data[c].toSVG(d),b.w,0);b.Clean();this.SVGhandleColor(b);this.SVGsaveData(b);return b}});f.xml.Augment({toSVG:function(b){var d=e.textSVG.parentNode;e.mathDiv.style.width="auto";d.insertBefore(this.div,e.textSVG);b=this.div.offsetWidth;var c=this.div.offsetHeight,a=MathJax.HTML.addElement(this.div,"span",{style:{display:"inline-block",overflow:"hidden",height:c+"px",width:"1px",marginRight:"-1px"}}),h=this.div.offsetHeight-c,c=c-h;this.div.removeChild(a);d.removeChild(this.div);e.mathDiv.style.width="";for(var d=1E3/e.em,a=g.FOREIGN({y:-c+"px",width:b+"px",height:c+h+"px",transform:"scale("+d+") matrix(1 0 0 -1 0 0)"}),k=0,f=this.data.length;k<f;k++)a.element.appendChild(this.data[k].cloneNode(!0));a.w=b*d;a.h=c*d;a.d=h*d;a.r=a.w;a.l=0;a.Clean();this.SVGsaveData(a);return a}});MathJax.Hub.Startup.signal.Post("SVG annotation-xml Ready");MathJax.Ajax.loadComplete(e.autoloadDir+"/annotation-xml.js")});