|
3315 | 3315 |
|
3316 | 3316 | JSROOT.AssertPrerequisites('mathjax', function() { |
3317 | 3317 |
|
3318 | | - if (!JSROOT.mathjax_configured) { |
3319 | | - |
3320 | | - MathJax.Hub.Config({ jax: ["input/TeX", "output/SVG"], |
3321 | | - TeX: { extensions: ["color.js"] }, |
3322 | | - SVG: { mtextFontInherit: true, minScaleAdjust: 100, matchFontHeight: true, useFontCache: false } }); |
3323 | | - |
3324 | | - MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () { |
3325 | | - var VARIANT = MathJax.OutputJax.SVG.FONTDATA.VARIANT; |
3326 | | - VARIANT["normal"].fonts.unshift("MathJax_SansSerif"); |
3327 | | - VARIANT["bold"].fonts.unshift("MathJax_SansSerif-bold"); |
3328 | | - VARIANT["italic"].fonts.unshift("MathJax_SansSerif"); |
3329 | | - VARIANT["-tex-mathit"].fonts.unshift("MathJax_SansSerif"); |
3330 | | - }); |
3331 | | - |
3332 | | - MathJax.Hub.Configured(); |
3333 | | - |
3334 | | - JSROOT.mathjax_configured = true; |
3335 | | - } |
3336 | | - |
3337 | 3318 | MathJax.Hub.Typeset(element, ["FinishMathjax", painter, draw_g, fo_g]); |
3338 | 3319 |
|
3339 | 3320 | MathJax.Hub.Queue(["FinishMathjax", painter, draw_g, fo_g]); // repeat once again, while Typeset not always invoke callback |
|
9554 | 9535 |
|
9555 | 9536 | // ================= painter of raw text ======================================== |
9556 | 9537 |
|
9557 | | - JSROOT.RawTextPainter = function(txt) { |
9558 | | - JSROOT.TBasePainter.call(this); |
9559 | | - this.txt = txt; |
9560 | | - return this; |
9561 | | - } |
9562 | | - |
9563 | | - JSROOT.RawTextPainter.prototype = Object.create( JSROOT.TBasePainter.prototype ); |
9564 | | - |
9565 | | - JSROOT.RawTextPainter.prototype.RedrawObject = function(obj) { |
9566 | | - this.txt = obj; |
9567 | | - this.Draw(); |
9568 | | - return true; |
9569 | | - } |
9570 | 9538 |
|
9571 | | - JSROOT.RawTextPainter.prototype.Draw = function() { |
9572 | | - var txt = this.txt.value; |
9573 | | - if (txt==null) txt = "<undefined>"; |
| 9539 | + JSROOT.Painter.drawRawText = function(divid, txt, opt) { |
9574 | 9540 |
|
9575 | | - var mathjax = 'mathjax' in this.txt; |
| 9541 | + var painter = new JSROOT.TBasePainter(); |
| 9542 | + painter.txt = txt; |
| 9543 | + painter.SetDivId(divid); |
9576 | 9544 |
|
9577 | | - if (!mathjax && !('as_is' in this.txt)) { |
9578 | | - var arr = txt.split("\n"); txt = ""; |
9579 | | - for (var i = 0; i < arr.length; ++i) |
9580 | | - txt += "<pre>" + arr[i] + "</pre>"; |
| 9545 | + painter.RedrawObject = function(obj) { |
| 9546 | + this.txt = obj; |
| 9547 | + this.Draw(); |
| 9548 | + return true; |
9581 | 9549 | } |
9582 | 9550 |
|
9583 | | - var frame = this.select_main(); |
9584 | | - var main = frame.select("div"); |
9585 | | - if (main.empty()) |
9586 | | - main = frame.append("div").style('max-width','100%').style('max-height','100%').style('overflow','auto'); |
| 9551 | + painter.Draw = function() { |
| 9552 | + var txt = this.txt.value; |
| 9553 | + if (typeof txt != 'string') txt = "<undefined>"; |
9587 | 9554 |
|
9588 | | - main.html(txt); |
| 9555 | + var mathjax = this.txt.mathjax || (JSROOT.gStyle.MathJax>1); |
9589 | 9556 |
|
9590 | | - // (re) set painter to first child element |
9591 | | - this.SetDivId(this.divid); |
| 9557 | + if (!mathjax && !('as_is' in this.txt)) { |
| 9558 | + var arr = txt.split("\n"); txt = ""; |
| 9559 | + for (var i = 0; i < arr.length; ++i) |
| 9560 | + txt += "<pre>" + arr[i] + "</pre>"; |
| 9561 | + } |
9592 | 9562 |
|
9593 | | - if (!mathjax) return; |
| 9563 | + var frame = this.select_main(), |
| 9564 | + main = frame.select("div"); |
| 9565 | + if (main.empty()) |
| 9566 | + main = frame.append("div").style('max-width','100%').style('max-height','100%').style('overflow','auto'); |
| 9567 | + main.html(txt); |
9594 | 9568 |
|
9595 | | - var painter = this; |
9596 | | - if (painter.loading_mathjax) return; |
| 9569 | + // (re) set painter to first child element |
| 9570 | + this.SetDivId(this.divid); |
9597 | 9571 |
|
9598 | | - painter.loading_mathjax = true; |
9599 | | - JSROOT.AssertPrerequisites('mathjax', function() { |
9600 | | - delete painter.loading_mathjax; |
9601 | | - if (typeof MathJax == 'object') { |
9602 | | - MathJax.Hub.Queue(["Typeset", MathJax.Hub, frame.node()]); |
9603 | | - } |
9604 | | - }); |
9605 | | - } |
| 9572 | + if (mathjax) |
| 9573 | + JSROOT.AssertPrerequisites('mathjax', function() { |
| 9574 | + MathJax.Hub.Typeset(frame.node()); |
| 9575 | + }); |
| 9576 | + } |
9606 | 9577 |
|
9607 | | - JSROOT.Painter.drawRawText = function(divid, txt, opt) { |
9608 | | - var painter = new JSROOT.RawTextPainter(txt); |
9609 | | - painter.SetDivId(divid); |
9610 | 9578 | painter.Draw(); |
9611 | 9579 | return painter.DrawingReady(); |
9612 | 9580 | } |
|
0 commit comments