Skip to content
Snippets Groups Projects
Commit 7c9ea974 authored by Renaud Le Gac's avatar Renaud Le Gac
Browse files

Add a plugin to render math formula on panel content using MathJax.

parent 11752ff0
No related branches found
No related tags found
No related merge requests found
/**
* Plugin to render mathematics formula.
* The processing is performed by MathJax.
*
* @version $Id$
*
*/
Ext.namespace('App.panel');
App.panel.MathJax = Ext.extend(Object, {
init: function(panel){
// load MathJs and wait
try {
MathJax;
}
catch (ReferenceError) {
var task = new Ext.util.DelayedTask();
Ext.Loader.load(['/' + App.name + '/static/plugin_mathjax/MathJax.js'], function(){
task.cancel();
});
task.delay(5000);
}
// register a new listener when the panel is rendered for the first time
panel.on('render', this.onPanelRender, this, {single: true});
},
/**
* Handler to register a listener when the panel is rendered
* for the first time. The listener activates the MathJax processing
* when the html content of the panel is loaded.
*
* @param {Object} p an Ext.Panel
*/
onPanelRender: function(p){
var updater = p.body.getUpdater();
updater.on('update', this.onProcess);
},
/**
* Handler to run the mathJax processing
* @param {Object} el Ext.Element
* @param {Object} o the response object
*/
onProcess: function(e, o){
MathJax.Hub.PreProcess();
MathJax.Hub.Process();
},
});
Ext.preg('pPanelMathJax', App.panel.MathJax);
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment