From 6d2fbc0a303e0f9a2519469d72563a870d3a52fb Mon Sep 17 00:00:00 2001 From: Renaud Le Gac <renaud.legac@free.fr> Date: Thu, 31 Mar 2011 20:27:41 +0000 Subject: [PATCH] Redesign the way we handle the plugin MathJax. Replace the constant App.withMathJax by App.mathJax with is the path to the mathjax script. Modified accordingly the function to load the library. --- controllers/plugin_dbui.py | 14 ++++++-------- static/plugin_dbui/src/appbase.js | 13 +++++++++---- static/plugin_dbui/src/appmgr.js | 6 +----- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/controllers/plugin_dbui.py b/controllers/plugin_dbui.py index 1d177065..8ef6b644 100644 --- a/controllers/plugin_dbui.py +++ b/controllers/plugin_dbui.py @@ -27,7 +27,7 @@ App.REMOTE_API = { 'actions': %s }; App.storeCfgs = %s; -App.withMathJax = %s; """ +App.mathJax = '%s/MathJax.js'; """ def call(): @@ -109,7 +109,7 @@ def debug(): """ # check the presence of the ExtJS plugin dbui = local_import('plugin_dbui') - pextjs = dbui.get_extjs_path(globals()) + pextjs = dbui.get_plugin_path(globals(), 'plugin_extjs') # internationalization (fr, fr-fr, fr-ca, ...) lg = dbui.get_language(globals()) @@ -169,10 +169,8 @@ def get_api(): storeCfgs[table] = cfgSvc.get_jsonstore(table) # determine if the MathJax plugin is there - server_path, client_path = dbui.get_reference_paths(globals()) - path = os.path.join(server_path, 'static', 'plugin_mathjax') - withMathJax = (True if os.path.exists(path) else False) - + p_mathjax = dbui.get_plugin_path(globals(), 'plugin_mathjax') + # fill the javascript template app = request.application script = SCRIPT % (app, @@ -180,7 +178,7 @@ def get_api(): app, json.dumps(di), json.dumps(storeCfgs), - str(withMathJax).lower()) + str(p_mathjax)) # return the response as a javascript response.headers['Content-Type'] = 'text/javascript' @@ -220,7 +218,7 @@ def index(): """ # check the presence of the ExtJS plugin dbui = local_import('plugin_dbui') - pextjs = dbui.get_extjs_path(globals()) + pextjs = dbui.get_plugin_path(globals(), 'plugin_extjs') # internationalization (fr, fr-fr, fr-ca, ...) lg = dbui.get_language(globals()) diff --git a/static/plugin_dbui/src/appbase.js b/static/plugin_dbui/src/appbase.js index 5de09f69..046462e6 100644 --- a/static/plugin_dbui/src/appbase.js +++ b/static/plugin_dbui/src/appbase.js @@ -20,8 +20,8 @@ Ext.namespace('App'); */ /** - * @cfg {Boolean} App.withMathJax - * The plugin plugin MathJax is present + * @cfg {Boolean} App.mathJax + * The path of the plugin MathJax. It is equal to None id not present. * This constants is defined by the server. */ @@ -119,7 +119,12 @@ App.isPlugin = function (component, ptype) { * @param {Object} callback */ App.loadMathJax = function (callback, scope) { - var path = '/' + App.name + '/static/plugin_mathjax/MathJax.js'; - Ext.Loader.load([path], callback, scope); + + if (App.mathJax !== 'None') { + Ext.Loader.load([App.mathJax], callback, scope); + + } else { + callback.call(scope); + } }; diff --git a/static/plugin_dbui/src/appmgr.js b/static/plugin_dbui/src/appmgr.js index 60215847..9cbc5ac7 100644 --- a/static/plugin_dbui/src/appmgr.js +++ b/static/plugin_dbui/src/appmgr.js @@ -29,11 +29,7 @@ App.Mgr = Ext.extend(Object, { App.Mgr.superclass.constructor.apply(this); // If the MathJax library is required load it - if (App.withMathJax) { - App.loadMathJax(this.configure, this); - } else { - this.configure(); - } + App.loadMathJax(this.configure, this); }, /** -- GitLab