Merge branch 'preview-disable' into develop

This commit is contained in:
Davide P. Cervone 2015-12-11 16:14:37 -05:00
commit 3737c8d84b
2 changed files with 16 additions and 2 deletions

View File

@ -29,10 +29,12 @@
(function (HUB,HTML,BROWSER) { (function (HUB,HTML,BROWSER) {
var SETTINGS = HUB.config.menuSettings; var SETTINGS = HUB.config.menuSettings;
var JAX = MathJax.OutputJax;
var msieColorBug = BROWSER.isMSIE && (document.documentMode||0) < 8; var msieColorBug = BROWSER.isMSIE && (document.documentMode||0) < 8;
var FastPreview = MathJax.Extension["fast-preview"] = { var FastPreview = MathJax.Extension["fast-preview"] = {
version: "2.6.0-beta", version: "2.6.0-beta",
enabled: true,
// //
// Configuration for the chunking of the main output // Configuration for the chunking of the main output
@ -62,7 +64,7 @@
HUB.Config({"HTML-CSS": config.Chunks, CommonHTML: config.Chunks, SVG: config.Chunks}); HUB.Config({"HTML-CSS": config.Chunks, CommonHTML: config.Chunks, SVG: config.Chunks});
} }
HUB.Register.MessageHook("Begin Math Output",function () { HUB.Register.MessageHook("Begin Math Output",function () {
if (!done && SETTINGS.FastPreview && SETTINGS.renderer !== "PreviewHTML") { if (!done && FastPreview.Active()) {
update = HUB.processUpdateTime; delay = HUB.processUpdateDelay; update = HUB.processUpdateTime; delay = HUB.processUpdateDelay;
style = HUB.config.messageStyle; style = HUB.config.messageStyle;
HUB.processUpdateTime = config.updateTime; HUB.processUpdateTime = config.updateTime;
@ -82,12 +84,23 @@
}); });
}, },
//
// Allow page to override user settings (for things like editor previews)
//
Disable: function () {this.enabled = false},
Enable: function () {this.enabled = true},
Active: function () {
return SETTINGS.FastPreview && this.enabled &&
!(JAX[SETTINGS.renderer]||{}).noFastPreview;
},
// //
// Insert a preview span, if there isn't one already, // Insert a preview span, if there isn't one already,
// and call the PreviewHTML output jax to create the preview // and call the PreviewHTML output jax to create the preview
// //
Preview: function (data) { Preview: function (data) {
if (!SETTINGS.FastPreview || SETTINGS.renderer === "PreviewHTML") return; if (!this.Active()) return;
var preview = data.script.MathJax.preview || data.script.previousSibling; var preview = data.script.MathJax.preview || data.script.previousSibling;
if (!preview || preview.className !== MathJax.Hub.config.preRemoveClass) { if (!preview || preview.className !== MathJax.Hub.config.preRemoveClass) {
preview = HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass}); preview = HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass});

View File

@ -30,6 +30,7 @@ MathJax.OutputJax.PreviewHTML = MathJax.OutputJax({
version: "2.6.0-beta", version: "2.6.0-beta",
directory: MathJax.OutputJax.directory + "/PreviewHTML", directory: MathJax.OutputJax.directory + "/PreviewHTML",
extensionDir: MathJax.OutputJax.extensionDir + "/PreviewHTML", extensionDir: MathJax.OutputJax.extensionDir + "/PreviewHTML",
noFastPreview: true, // don't do fast preview for this output jax
config: { config: {
scale: 100, minScaleAdjust: 50, // global math scaling factor, and minimum adjusted scale factor scale: 100, minScaleAdjust: 50, // global math scaling factor, and minimum adjusted scale factor