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

The MathJax librairy is detected and loaded by the framework.

parent 732ddb58
No related branches found
No related tags found
No related merge requests found
......@@ -77,12 +77,16 @@ def index():
path = os.path.join(server_path, 'static', 'plugin_extjs')
if not os.path.exists(path):
raise HTTP(500, 'The plugin extjs is not install !')
# is the plugin MatJax ?
path = os.path.join(server_path, 'static', 'plugin_mathjax')
withMathJax = (True if os.path.exists(path) else False)
# option debug
debug = "debug" in request.get_vars
# option script
script = (request.get_vars.script if "script" in request.get_vars else "default")
script = (request.vars.script if "script" in request.vars else "default")
if not script.endswith(".js"):
script = '%s.js' % script
......@@ -124,7 +128,7 @@ def index():
response.files.append(os.path.join(jpath, 'filter', 'NumericFilter.js'))
response.files.append(os.path.join(jpath, 'filter', 'StringFilter.js'))
# internationalization or localization
# internationalization or localization (fr, fr-fr, fr-ca, ...)
lg = T.accepted_language
if len(lg) == 5 and lg[0:2] == lg[3:5]: lg = lg[0:2]
response.files.append(os.path.join(extjs, 'src', 'locale', 'ext-lang-%s.js' % lg))
......@@ -145,7 +149,7 @@ def index():
# page view
response.view = plugins.dbui.page_view
return dict(debug=debug)
return dict(debug=debug, withMathJax=withMathJax)
def database():
......
......@@ -29,6 +29,12 @@ Ext.namespace('App');
*/
App.dburl = '/' + App.name + '/plugin_dbui/database';
/**
* @cfg {Boolean} App.withMathJax
* The plugin plugin MathJax is present
* This constants is defined by the server.
*/
/**
* @cfg {Object} App.cfgSvcMethods
* Ext.direct.Provider exposing methods for a web service.
......@@ -45,4 +51,12 @@ App.cfgSvcMethods = {
}
};
/**
* Helper function to load the MathJax librairy
* @param {Object} callback
*/
App.loadMathJax = function(callback){
var path = '/' + App.name + '/static/plugin_mathjax/MathJax.js';
Ext.Loader.load([path], callback);
};
/**
* Plugin to render mathematics formula.
* Plugin to render mathematics formula embeded in html content.
* The processing is performed by MathJax.
*
* @version $Id$
......@@ -12,39 +12,25 @@
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
// register an handler which is activated only once
// 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
* Handler to activates the MathJax processing
* when the html content of the panel is loaded.
*
* @param {Object} p an Ext.Panel
* @param {Ext.Panel} panel
*/
onPanelRender: function(p){
var updater = p.body.getUpdater();
onPanelRender: function(panel){
var updater = panel.body.getUpdater();
updater.on('update', this.onProcess);
},
/**
* Handler to run the mathJax processing
* @param {Object} el Ext.Element
* @param {Ext.Element} el
* @param {Object} o the response object
*/
onProcess: function(e, o){
......
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