commit d128cfbd5d1682e5fe4927d049f7589c04915ceb
parent b137d2e65d9e3841c750c1b87657c2d68758a596
Author: Davide P. Cervone <dpvc@union.edu>
Date: Sun, 2 Nov 2014 10:03:26 -0500
Add menu item for fast preview, and check for it in the preview code. Make sure CHTML-preview.js is loaded in MathJax.js if the menu item is selected.
Diffstat:
3 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/unpacked/MathJax.js b/unpacked/MathJax.js
@@ -2466,6 +2466,8 @@ MathJax.Hub.Startup = {
}
jax.unshift(name);
}
+ if (config.menuSettings.CHTMLpreview && !MathJax.Extension["CHTML-preview"])
+ {MathJax.Hub.config.extensions.push("CHTML-preview.js")}
},MathJax.Hub.config],
["Post",this.signal,"End Cookie"]
);
diff --git a/unpacked/extensions/CHTML-preview.js b/unpacked/extensions/CHTML-preview.js
@@ -27,6 +27,8 @@
*/
(function (HUB,HTML) {
+
+ var SETTINGS = HUB.config.menuSettings;
var CHTMLpreview = MathJax.Extension["CHTML-preview"] = {
version: "1.0",
@@ -38,8 +40,9 @@
config: HUB.CombineConfig("CHTML-preview",{
Chunks: {EqnChunk: 10000, EqnChunkFactor: 1, EqnChunkDelay: 0},
color: "inherit",
- updateTime: 10, updateDelay: 50,
- messageStyle: "none"
+ updateTime: 10, updateDelay: 10,
+ messageStyle: "none",
+ disabled: false
}),
//
@@ -51,20 +54,22 @@
SVG: this.config.Chunks,
});
MathJax.Ajax.Styles({".MathJax_Preview":{color:this.config.color}});
- var update, delay, style, done;
+ var update, delay, style, done, saved;
var config = this.config;
HUB.Register.MessageHook("Begin Math Output",function () {
- if (!done) {
+ if (!done && !config.disabled && SETTINGS.CHTMLpreview &&
+ SETTINGS.renderer !== "CommonHTML") {
update = HUB.processUpdateTime; delay = HUB.processUpdateDelay;
style = HUB.config.messageStyle;
HUB.processUpdateTime = config.updateTime;
HUB.processUpdateDelay = config.updateDelay;
HUB.Config({messageStyle: config.messageStyle});
MathJax.Message.Clear(0,0);
+ saved = true;
}
});
HUB.Register.MessageHook("End Math Output",function () {
- if (!done) {
+ if (!done && saved) {
HUB.processUpdateTime = update;
HUB.processUpdateDelay = delay;
HUB.Config({messageStyle: style});
@@ -78,6 +83,8 @@
// and call the CommonHTML output jax to create the preview
//
Preview: function (data) {
+ if (this.config.disabled || !SETTINGS.CHTMLpreview ||
+ SETTINGS.renderer === "CommonHTML") return;
var preview = data.script.previousSibling;
if (!preview || preview.className !== MathJax.Hub.config.preRemoveClass) {
preview = HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass});
@@ -85,7 +92,6 @@
}
preview.innerHTML = "";
return this.postFilter(preview,data);
- return data;
},
postFilter: function (preview,data) {
try {
diff --git a/unpacked/extensions/MathMenu.js b/unpacked/extensions/MathMenu.js
@@ -964,7 +964,7 @@
"The MathJax contextual menu will be disabled, but you can " +
"Alt-Click on an expression to obtain the MathJax menu instead."]
};
-
+
/*************************************************************/
/*************************************************************/
@@ -1092,14 +1092,16 @@
ITEM.RADIO("HTML-CSS", "renderer", {action: MENU.Renderer}),
ITEM.RADIO("Fast HTML", "renderer", {action: MENU.Renderer, value:"CommonHTML"}),
ITEM.RADIO("MathML", "renderer", {action: MENU.Renderer, value:"NativeMML"}),
- ITEM.RADIO("SVG", "renderer", {action: MENU.Renderer})
+ ITEM.RADIO("SVG", "renderer", {action: MENU.Renderer}),
+ ITEM.RULE(),
+ ITEM.CHECKBOX("Fast Preview", "CHTMLpreview")
),
ITEM.SUBMENU("MathPlayer", {hidden:!HUB.Browser.isMSIE || !CONFIG.showMathPlayer,
disabled:!HUB.Browser.hasMathPlayer},
ITEM.LABEL(["MPHandles","Let MathPlayer Handle:"]),
ITEM.CHECKBOX(["MenuEvents","Menu Events"], "mpContext", {action: MENU.MPEvents, hidden:!isIE9}),
ITEM.CHECKBOX(["MouseEvents","Mouse Events"], "mpMouse", {action: MENU.MPEvents, hidden:!isIE9}),
- ITEM.CHECKBOX(["MenuAndMouse","Mouse and Menu Events"], "mpMouse", {action: MENU.MPEvents, hidden:isIE9})
+ ITEM.CHECKBOX(["MenuAndMouse","Mouse and Menu Events"], "mpMouse", {action: MENU.MPEvents, hidden:isIE9})
),
ITEM.SUBMENU(["FontPrefs","Font Preference"], {hidden:!CONFIG.showFontMenu},
ITEM.LABEL(["ForHTMLCSS","For HTML-CSS:"]),