mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-12-12 16:05:09 +00:00
bc52c77d24
* Use string constants instead of integers * Derive new names from old via conversion of constant naming convention to CamelCase. * Replace old constant string e.g. 'MW_MATH_ABC_DEF' with new string 'abcDef' * Replace old constant value with new string. * Tests to demonstrates what is actually done. * Rename constants Bug: T106630 Bug: T106631 Bug: T87941 Change-Id: I6d1094ece79e912d9ddbef6681a25196c7a6e801
29 lines
1.3 KiB
JavaScript
29 lines
1.3 KiB
JavaScript
( function ( $ ) {
|
|
'use strict';
|
|
var img, url;
|
|
|
|
// If MathPlayer is installed we show the MathML rendering.
|
|
if (navigator.userAgent.indexOf('MathPlayer') > -1) {
|
|
$( '.mwe-math-mathml-a11y' ).removeClass( 'mwe-math-mathml-a11y' );
|
|
$( '.mwe-math-fallback-image-inline, .mwe-math-fallback-image-display' ).css( 'display', 'none' );
|
|
return;
|
|
}
|
|
|
|
// We verify whether SVG as <img> is supported and otherwise use the
|
|
// PNG fallback. See https://github.com/Modernizr/Modernizr/blob/master/feature-detects/svg/asimg.js
|
|
if (!document.implementation.hasFeature('http://www.w3.org/TR/SVG11/feature#Image', '1.1')) {
|
|
$( '.mwe-math-fallback-image-inline, .mwe-math-fallback-image-display' ).each(function() {
|
|
// Create a new PNG image to use as the fallback.
|
|
img = document.createElement('img');
|
|
url = this.style.backgroundImage.match(/url\('?([^']*)'?\)/)[1];
|
|
img.setAttribute( 'src', url.replace('mode=' + 'mathml', 'mode=' + 'png') );
|
|
img.setAttribute( 'class', 'tex mwe-math-fallback-image-' + ($( this ).hasClass('mwe-math-fallback-image-inline') ? 'inline' : 'display') );
|
|
img.setAttribute( 'aria-hidden', 'true' );
|
|
this.parentNode.insertBefore( img, this );
|
|
|
|
// Hide the SVG fallback.
|
|
$( this ).css( 'display', 'none' );
|
|
});
|
|
}
|
|
}( jQuery ) );
|