commit 7342aebe664c7deed6dd844ef188adbd65f24c9d
parent d77687489869c987f5d61c97f308d5667ca2691b
Author: Davide P. Cervone <dpvc@union.edu>
Date: Wed, 9 Dec 2015 16:16:45 -0500
Allow page to enable/disable previews via API calls (for use with editor previews, for example).
Diffstat:
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/unpacked/extensions/fast-preview.js b/unpacked/extensions/fast-preview.js
@@ -33,6 +33,7 @@
var FastPreview = MathJax.Extension["fast-preview"] = {
version: "2.6.0-beta",
+ enabled: true,
//
// Configuration for the chunking of the main output
@@ -62,7 +63,7 @@
HUB.Config({"HTML-CSS": config.Chunks, CommonHTML: config.Chunks, SVG: config.Chunks});
}
HUB.Register.MessageHook("Begin Math Output",function () {
- if (!done && SETTINGS.FastPreview && SETTINGS.renderer !== "PreviewHTML") {
+ if (!done && SETTINGS.FastPreview && this.enabled && SETTINGS.renderer !== "PreviewHTML") {
update = HUB.processUpdateTime; delay = HUB.processUpdateDelay;
style = HUB.config.messageStyle;
HUB.processUpdateTime = config.updateTime;
@@ -81,13 +82,19 @@
}
});
},
+
+ //
+ // Allow page to override user settings (for things like editor previews)
+ //
+ Disable: function () {this.enabled = false},
+ Enable: function () {this.enabled = true},
//
// Insert a preview span, if there isn't one already,
// and call the PreviewHTML output jax to create the preview
//
Preview: function (data) {
- if (!SETTINGS.FastPreview || SETTINGS.renderer === "PreviewHTML") return;
+ if (!SETTINGS.FastPreview || !this.enabled || SETTINGS.renderer === "PreviewHTML") 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});