Physikerwelt has uploaded a new change for review. https://gerrit.wikimedia.org/r/112328
Change subject: Introduce orthogonal option to enable MathJax ...................................................................... Introduce orthogonal option to enable MathJax In the current version MathJax is bound to the MW_MATH_SOURCE rendering mode. This change makes the base mode user configurable. That means before MathJax is loaded the png fallback image could be displayed. ATTENTION: This change modifies global variables as follows: * $wgUseMathJax is removed. * MW_MATH_MATHJAX is deprecated. * $wgMathJax is introduced. Change-Id: Ibf705cb66754d04e4c7eafd1e98608b25d7dbb94 --- M Math.hooks.php M Math.php M modules/ext.math.mathjax.enabler.js 3 files changed, 20 insertions(+), 10 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Math refs/changes/28/112328/1 diff --git a/Math.hooks.php b/Math.hooks.php index 498c66b..7af3a0d 100644 --- a/Math.hooks.php +++ b/Math.hooks.php @@ -92,7 +92,8 @@ * @return string */ static function mathTagHook( $content, $attributes, $parser ) { - global $wgUseMathJax, $wgMathDisableTexFilter; + global $wgMathJax, $wgMathDisableTexFilter; + if ( trim( $content ) === '' ) { // bug 8372 return ''; @@ -122,7 +123,7 @@ $renderedMath = $renderer->render(); - if ( $wgUseMathJax && $mode == MW_MATH_MATHJAX ) { + if ( $wgMathJax ) { $parser->getOutput()->addModules( array( 'ext.math.mathjax.enabler' ) ); } @@ -140,13 +141,20 @@ * @return Boolean: true */ static function onGetPreferences( $user, &$defaultPreferences ) { + global $wgMathJax; $defaultPreferences['math'] = array( 'type' => 'radio', 'options' => array_flip( self::getMathNames() ), 'label' => ' ', 'section' => 'rendering/math', ); - + if ( $wgMathJax ) { + $defaultPreferences['mathJax'] = array( + 'type' => 'toggle', + 'label-message' => 'mw_math_mathjax', + 'section' => 'rendering/math', + ); + } return true; } diff --git a/Math.php b/Math.php index 8a437fe..bfb2428 100644 --- a/Math.php +++ b/Math.php @@ -37,7 +37,7 @@ define( 'MW_MATH_SOURCE', 3 ); define( 'MW_MATH_MODERN', 4 ); /// @deprecated define( 'MW_MATH_MATHML', 5 ); /// @deprecated -define( 'MW_MATH_MATHJAX', 6 ); /// new in 1.19/1.20 +define( 'MW_MATH_MATHJAX', 6 ); /// @deprecated define( 'MW_MATH_LATEXML', 7 ); /// new in 1.22 /**@}*/ @@ -99,15 +99,14 @@ $wgMathDirectory = false; /** - * Experimental option to use MathJax library to do client-side math rendering + * Enables the option to use MathJax library to do client-side math rendering * when JavaScript is available. In supporting browsers this makes nice output - * that's scalable for zooming, printing, and high-resolution displays. - * - * Not guaranteed to be stable at this time. + * that's scalable for zooming, printing, and high-resolution displays, even if + * the browsers do not support HTML5 (i.e. MathML). * * @todo Rename to $wgMathJax */ -$wgUseMathJax = false; +$wgMathJax = false; /** * Use of LaTeXML for details see diff --git a/modules/ext.math.mathjax.enabler.js b/modules/ext.math.mathjax.enabler.js index 7a07546..4f675da 100644 --- a/modules/ext.math.mathjax.enabler.js +++ b/modules/ext.math.mathjax.enabler.js @@ -3,6 +3,10 @@ */ /*global mathJax:true, MathJax:true */ ( function ( mw, $ ) { + + if( ! mw.user.options.get( 'mathJax' ) ) { + return true; + } if ( typeof mathJax === 'undefined' ) { mathJax = {}; } @@ -243,5 +247,4 @@ $( document ).ready( function () { mathJax.Load(); } ); - }( mediaWiki, jQuery ) ); -- To view, visit https://gerrit.wikimedia.org/r/112328 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibf705cb66754d04e4c7eafd1e98608b25d7dbb94 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Math Gerrit-Branch: math2_0_0 Gerrit-Owner: Physikerwelt <w...@physikerwelt.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits