From 1c938cc48ea7ac3666426bf5c1221bc57fb97afd Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Thu, 3 Dec 2015 08:02:08 -0500 Subject: [PATCH 1/2] Add CommonHTML to the 'Scale All Math' list. Issue #1324. --- unpacked/extensions/MathMenu.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/unpacked/extensions/MathMenu.js b/unpacked/extensions/MathMenu.js index db74048c8..6d393ab95 100644 --- a/unpacked/extensions/MathMenu.js +++ b/unpacked/extensions/MathMenu.js @@ -1213,8 +1213,9 @@ * Handle rescaling all the math */ MENU.Scale = function () { - var HTMLCSS = OUTPUT["HTML-CSS"], nMML = OUTPUT.NativeMML, SVG = OUTPUT.SVG; - var SCALE = (HTMLCSS||nMML||SVG||{config:{scale:100}}).config.scale; + var HTMLCSS = OUTPUT["HTML-CSS"], nMML = OUTPUT.NativeMML, + SVG = OUTPUT.SVG, CHTML = OUTPUT.CommonHTML; + var SCALE = (CHTML||HTMLCSS||nMML||SVG||{config:{scale:100}}).config.scale; var scale = prompt(_("ScaleMath","Scale all mathematics (compared to surrounding text) by"),SCALE+"%"); if (scale) { if (scale.match(/^\s*\d+(\.\d*)?\s*%?\s*$/)) { @@ -1222,10 +1223,12 @@ if (scale) { if (scale !== SCALE) { if (HTMLCSS) {HTMLCSS.config.scale = scale} + if (CHTML) {CHTML.config.scale = scale} if (nMML) {nMML.config.scale = scale} if (SVG) {SVG.config.scale = scale} MENU.cookie.scale = scale; - MENU.saveCookie(); HUB.Rerender(); + MENU.saveCookie(); + HUB.Queue(["Rerender",HUB]); } } else {alert(_("NonZeroScale","The scale should not be zero"))} } else {alert(_("PercentScale", From 0e4b3f05e265461bd39f8416c0399ccc2de2afa9 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Thu, 3 Dec 2015 08:11:39 -0500 Subject: [PATCH 2/2] Make scaling basd on a list rather than hard-coded if-then statements. Issue #1324 --- unpacked/extensions/MathMenu.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/unpacked/extensions/MathMenu.js b/unpacked/extensions/MathMenu.js index 6d393ab95..6d41d4bff 100644 --- a/unpacked/extensions/MathMenu.js +++ b/unpacked/extensions/MathMenu.js @@ -1213,20 +1213,23 @@ * Handle rescaling all the math */ MENU.Scale = function () { - var HTMLCSS = OUTPUT["HTML-CSS"], nMML = OUTPUT.NativeMML, - SVG = OUTPUT.SVG, CHTML = OUTPUT.CommonHTML; - var SCALE = (CHTML||HTMLCSS||nMML||SVG||{config:{scale:100}}).config.scale; + var JAX = ["CommonHTML","HTML-CSS","SVG","NativeMML","PreviewHTML"], m = JAX.length, + SCALE = 100, i, jax; + for (i = 0; i < m; i++) { + jax = OUTPUT[JAX[i]]; + if (jax) {SCALE = jax.config.scale; break} + } var scale = prompt(_("ScaleMath","Scale all mathematics (compared to surrounding text) by"),SCALE+"%"); if (scale) { if (scale.match(/^\s*\d+(\.\d*)?\s*%?\s*$/)) { scale = parseFloat(scale); if (scale) { if (scale !== SCALE) { - if (HTMLCSS) {HTMLCSS.config.scale = scale} - if (CHTML) {CHTML.config.scale = scale} - if (nMML) {nMML.config.scale = scale} - if (SVG) {SVG.config.scale = scale} - MENU.cookie.scale = scale; + for (i = 0; i < m; i++) { + jax = OUTPUT[JAX[i]]; + if (jax) jax.config.scale = scale; + } + MENU.cookie.scale = HUB.config.scale = scale; MENU.saveCookie(); HUB.Queue(["Rerender",HUB]); }