2011-12-06 01:17:35 +00:00
|
|
|
/**
|
|
|
|
* From https://en.wikipedia.org/wiki/User:Nageh/mathJax.js
|
|
|
|
*/
|
|
|
|
|
2013-02-07 04:08:22 +00:00
|
|
|
if ( typeof mathJax === 'undefined' ) {
|
|
|
|
mathJax = {};
|
|
|
|
}
|
2011-12-06 01:17:35 +00:00
|
|
|
|
2013-01-18 11:48:25 +00:00
|
|
|
mathJax.version = '0.2';
|
2011-12-06 01:17:35 +00:00
|
|
|
|
|
|
|
mathJax.loaded = false;
|
|
|
|
|
|
|
|
mathJax.Config = function() {
|
|
|
|
MathJax.Hub.Config({
|
2012-03-01 01:57:44 +00:00
|
|
|
root: mediaWiki.config.get('wgExtensionAssetsPath') + '/Math/modules/MathJax',
|
2013-01-18 11:48:25 +00:00
|
|
|
config: ['TeX-AMS-texvc_HTML.js'],
|
|
|
|
'v1.0-compatible': false,
|
|
|
|
styles: { '.mtext': { 'font-family': 'sans-serif ! important', 'font-size': '80%' } },
|
|
|
|
displayAlign: 'left',
|
|
|
|
menuSettings: { zoom: 'Click' },
|
|
|
|
'HTML-CSS': { imageFont: null, availableFonts: ['TeX'] }
|
2011-12-06 01:17:35 +00:00
|
|
|
});
|
2012-03-01 02:00:16 +00:00
|
|
|
MathJax.OutputJax.fontDir = mathJax.fontDir = mediaWiki.config.get('wgExtensionAssetsPath') + '/Math/modules/MathJax/fonts';
|
2012-08-30 23:25:48 +00:00
|
|
|
};
|
2011-12-06 01:17:35 +00:00
|
|
|
|
|
|
|
mathJax.Load = function(element) {
|
2013-02-07 04:08:22 +00:00
|
|
|
if (this.loaded) {
|
2011-12-06 01:17:35 +00:00
|
|
|
return true;
|
2013-02-07 04:08:22 +00:00
|
|
|
}
|
2011-12-06 01:17:35 +00:00
|
|
|
|
2012-03-02 00:26:56 +00:00
|
|
|
// create configuration element
|
|
|
|
var config = 'mathJax.Config();';
|
|
|
|
var script = document.createElement( 'script' );
|
|
|
|
script.setAttribute( 'type', 'text/x-mathjax-config' );
|
2013-02-07 04:08:22 +00:00
|
|
|
if ( window.opera ) {
|
|
|
|
script.innerHTML = config;
|
|
|
|
} else {
|
|
|
|
script.text = config;
|
|
|
|
}
|
2012-03-02 00:26:56 +00:00
|
|
|
document.getElementsByTagName('head')[0].appendChild( script );
|
2011-12-06 01:17:35 +00:00
|
|
|
|
2012-03-02 00:26:56 +00:00
|
|
|
// create startup element
|
|
|
|
mediaWiki.loader.load('ext.math.mathjax');
|
2011-12-06 01:17:35 +00:00
|
|
|
|
2012-03-02 00:26:56 +00:00
|
|
|
this.loaded = true;
|
2011-12-06 01:17:35 +00:00
|
|
|
|
|
|
|
return false;
|
2012-08-30 23:25:48 +00:00
|
|
|
};
|
2011-12-06 01:17:35 +00:00
|
|
|
|
|
|
|
mathJax.Init = function() {
|
2013-01-18 11:48:25 +00:00
|
|
|
this.Load( document.getElementById('bodyContent') || document.body );
|
2011-12-06 01:17:35 +00:00
|
|
|
|
|
|
|
// compatibility with wikEd
|
2013-02-07 04:08:22 +00:00
|
|
|
if ( typeof(wikEd) == 'undefined' ) {
|
|
|
|
wikEd = {};
|
|
|
|
}
|
|
|
|
if ( typeof(wikEd.config) == 'undefined' ) {
|
|
|
|
wikEd.config = {};
|
|
|
|
}
|
|
|
|
if ( typeof(wikEd.config.previewHook) == 'undefined' ) {
|
|
|
|
wikEd.config.previewHook = [];
|
|
|
|
}
|
|
|
|
wikEd.config.previewHook.push( function(){
|
|
|
|
if (window.mathJax.Load(document.getElementById('wikEdPreviewBox') || document.body)) {
|
|
|
|
MathJax.Hub.Queue(['Typeset', MathJax.Hub, 'wikEdPreviewBox']);
|
|
|
|
}
|
|
|
|
} );
|
2011-12-06 01:17:35 +00:00
|
|
|
|
|
|
|
// compatibility with ajaxPreview
|
|
|
|
this.oldAjaxPreviewExec = window.ajaxPreviewExec;
|
|
|
|
window.ajaxPreviewExec = function(previewArea) {
|
2013-02-07 04:08:22 +00:00
|
|
|
if ( typeof(mathJax.oldAjaxPreviewExec) !== 'undefined' ) {
|
|
|
|
mathJax.oldAjaxPreviewExec(previewArea);
|
|
|
|
}
|
|
|
|
if ( mathJax.Load(previewArea) ) {
|
|
|
|
MathJax.Hub.Queue( ['Typeset', MathJax.Hub, previewArea] );
|
|
|
|
}
|
2013-01-18 11:48:25 +00:00
|
|
|
};
|
2012-08-30 23:25:48 +00:00
|
|
|
};
|
2011-12-06 01:17:35 +00:00
|
|
|
|
2012-02-21 04:03:00 +00:00
|
|
|
jQuery( document ).ready( function() {
|
|
|
|
mathJax.Init();
|
|
|
|
} );
|