Skip to content

Instantly share code, notes, and snippets.

@darkwing
Created April 11, 2014 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darkwing/435b1c03057c62cf50fd to your computer and use it in GitHub Desktop.
Save darkwing/435b1c03057c62cf50fd to your computer and use it in GitHub Desktop.
(function($) {
$('math').length && !hasMathMLSupport() && (function() {
// Add CSS fallback
$('<link href="/media/css/libs/mathml.css" rel="stylesheet" type="text/css" />').appendTo(document.head);
// Add notification
$('#wikiArticle').prepend('<div class="notice"><p>Your browser does not support MathML.</p></div>');
});
// https://github.com/Modernizr/Modernizr/blob/master/feature-detects/mathml.js
function hasMathMLSupport() {
var $div = $('<div class="offscreen"><math><mspace height="23px" width="77px"/></math></div>').appendTo(document.body);
var box = $div.getBoundingClientRect();
$div.remove();
return Math.abs(box.height - 23) && Math.abs(box.width - 77);
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment