diff --git a/Math.hooks.php b/Math.hooks.php index 65819a1..e315974 100644 --- a/Math.hooks.php +++ b/Math.hooks.php @@ -135,6 +135,7 @@ class MathHooks { $parser->getOutput()->addModules( array( 'ext.math.mathjax.enabler' ) ); } $parser->getOutput()->addModuleStyles( array( 'ext.math.styles' ) ); + $parser->getOutput()->addModules( array( 'ext.math.scripts' ) ); // Writes cache if rendering was successful $renderer->writeCache(); diff --git a/Math.php b/Math.php index c85bdb9..0314aaa 100644 --- a/Math.php +++ b/Math.php @@ -235,6 +235,11 @@ $wgResourceModules['ext.math.styles'] = array( 'remoteExtPath' => 'Math/modules', 'styles' => 'ext.math.css', ); +$wgResourceModules['ext.math.scripts'] = array( + 'localBasePath' => __DIR__ . '/modules', + 'remoteExtPath' => 'Math/modules', + 'scripts' => 'ext.math.js', +); // MathJax module // If you modify these arrays, update ext.math.mathjax.enabler.js to ensure diff --git a/MathMathML.php b/MathMathML.php index b57d738..332454b 100644 --- a/MathMathML.php +++ b/MathMathML.php @@ -424,6 +424,9 @@ class MathMathML extends MathRenderer { } else { $class .= 'inline'; } + if ( !$fallback) { + $class .= ' mwe-math-mathml-a11y'; + } return $class; } /** diff --git a/modules/ext.math.css b/modules/ext.math.css index d8bffee..6b9b32b 100644 --- a/modules/ext.math.css +++ b/modules/ext.math.css @@ -10,8 +10,8 @@ /* Default style for MathML. */ .mwe-math-mathml-inline { display: inline !important; } .mwe-math-mathml-display { display: block !important; margin-left: auto; margin-right: auto; } -.mwe-math-mathml-inline, .mwe-math-mathml-display { - /* We try to hide the MathML formula in a way that still makes it accessible to screen readers. */ +.mwe-math-mathml-a11y { + /* We try to hide the MathML formula in a way that still makes it accessible to accessibility tools. */ clip: rect(1px, 1px, 1px, 1px); overflow: hidden; position: absolute; @@ -59,7 +59,7 @@ img.mwe-math-fallback-png-display { display: block; } @-moz-document url-prefix() { /* For Gecko browsers, hide the SVG fallback and show the MathML instead. We override the style for SVG and MathML above */ - .mwe-math-mathml-inline, .mwe-math-mathml-display { + .mwe-math-mathml-a11y { clip: auto; overflow: visible; position: static; diff --git a/modules/ext.math.js b/modules/ext.math.js new file mode 100644 index 0000000..a043014 --- /dev/null +++ b/modules/ext.math.js @@ -0,0 +1,10 @@ +( function ( $ ) { + 'use strict'; + // If MathPlayer is installed we show the MathML rendering. + if (navigator.userAgent.indexOf('MathPlayer') > -1) { + $( '.mwe-math-mathml-a11y' ).removeClass( 'mwe-math-mathml-a11y' ); + $( 'img' ).removeClass( 'mwe-math-fallback-svg-inline mwe-math-fallback-svg-display' ); + } + // FIXME: for browsers without SVG support, the fallback should be + // updated to point to PNG images. +}( jQuery ) );