From 0305716511cdb509af24fc30687a35677aa7e8aa Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 30 Dec 2014 17:53:20 -0500 Subject: [PATCH] Allow configuration to disable CHTML-preivew, but still allow menu to override. Make loading of this page enable preview by default. Fix handling of preview color. Fix restart when CommonHTML config is loaded but jax.js isn't. --- unpacked/extensions/CHTML-preview.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/unpacked/extensions/CHTML-preview.js b/unpacked/extensions/CHTML-preview.js index 2c05bbfb2..9d373cbb7 100644 --- a/unpacked/extensions/CHTML-preview.js +++ b/unpacked/extensions/CHTML-preview.js @@ -53,13 +53,14 @@ "HTML-CSS": this.config.Chunks, SVG: this.config.Chunks, }); - MathJax.Ajax.Styles({".MathJax_Preview":{color:this.config.color}}); + MathJax.Ajax.Styles({".MathJax_Preview .MJXc-math":{color:this.config.color}}); var update, delay, style, done, saved; var config = this.config; + if (!config.disabled && SETTINGS.CHTMLpreview == null) + HUB.Config({menuSettings:{CHTMLpreview:true}}); HUB.Register.MessageHook("Begin Math Output",function () { - if (!done && !config.disabled && SETTINGS.CHTMLpreview && - SETTINGS.renderer !== "CommonHTML") { + if (!done && SETTINGS.CHTMLpreview && SETTINGS.renderer !== "CommonHTML") { update = HUB.processUpdateTime; delay = HUB.processUpdateDelay; style = HUB.config.messageStyle; HUB.processUpdateTime = config.updateTime; @@ -84,15 +85,14 @@ // and call the CommonHTML output jax to create the preview // Preview: function (data) { - if (this.config.disabled || !SETTINGS.CHTMLpreview || - SETTINGS.renderer === "CommonHTML") return; + if (!SETTINGS.CHTMLpreview || SETTINGS.renderer === "CommonHTML") return; var preview = data.script.MathJax.preview || data.script.previousSibling; if (!preview || preview.className !== MathJax.Hub.config.preRemoveClass) { preview = HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass}); data.script.parentNode.insertBefore(preview,data.script); data.script.MathJax.preview = preview; } - preview.innerHTML = ""; + preview.innerHTML = ""; preview.style.color = "inherit"; return this.postFilter(preview,data); }, postFilter: function (preview,data) { @@ -104,10 +104,11 @@ // if (!data.math.root.toCommonHTML) { var queue = MathJax.Callback.Queue(); - HUB.RestartAfter(queue.Push( + queue.Push( ["Require",MathJax.Ajax,"[MathJax]/jax/output/CommonHTML/config.js"], ["Require",MathJax.Ajax,"[MathJax]/jax/output/CommonHTML/jax.js"] - )); + ); + HUB.RestartAfter(queue.Push({})); } if (!err.restart) {throw err} // an actual error return MathJax.Callback.After(["postFilter",this,preview,data],err.restart);