diff --git a/controllers/plugin_dbui.py b/controllers/plugin_dbui.py index 8ef6b644f4774c8e72b572630d4669de25f1282e..9966de259a005ceb4f78b5f0af85c4353ca39dda 100644 --- a/controllers/plugin_dbui.py +++ b/controllers/plugin_dbui.py @@ -27,7 +27,7 @@ App.REMOTE_API = { 'actions': %s }; App.storeCfgs = %s; -App.mathJax = '%s/MathJax.js'; """ +App.mathJax = %s; """ def call(): @@ -168,9 +168,13 @@ def get_api(): for table in cfgSvc.get_tables()['tables']: storeCfgs[table] = cfgSvc.get_jsonstore(table) - # determine if the MathJax plugin is there + # the MathJax plugin p_mathjax = dbui.get_plugin_path(globals(), 'plugin_mathjax') - + if p_mathjax: + p_mathjax = "'%s'" % os.path.join(p_mathjax, 'MathJax.js') + else: + p_mathjax = 'undefined' + # fill the javascript template app = request.application script = SCRIPT % (app, @@ -178,7 +182,7 @@ def get_api(): app, json.dumps(di), json.dumps(storeCfgs), - str(p_mathjax)) + p_mathjax) # return the response as a javascript response.headers['Content-Type'] = 'text/javascript' diff --git a/static/plugin_dbui/src/appbase.js b/static/plugin_dbui/src/appbase.js index 046462e6841a186b57164ef213683bbf3931f029..2eb7e06d8b00341f118419baa5807709f5dde1eb 100644 --- a/static/plugin_dbui/src/appbase.js +++ b/static/plugin_dbui/src/appbase.js @@ -21,15 +21,17 @@ Ext.namespace('App'); /** * @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. + * The path of the MathJax.js script. + * It is equal to undefined if it does not exist. + * This constants is defined by the server and should not be used directly. + * The plugin should be loaded with the function App.loadMathJax. */ /** * Helper function mimicking the encode_field function running on the server * (table, field) → TableField - * @param {Object} table - * @param {Object} field + * @param {String} table + * @param {String} field */ App.encodeField = function (table, field) { var t, f; @@ -42,13 +44,12 @@ App.encodeField = function (table, field) { * Helper function returning the App.data.DirectStore identifies by its id. * If the store does not exit it is created and register in the store manager. * - * NOTE: The storeId is defined by the server as a configuration option - * for each widget: combobox, form and grid. + * NOTE: The storeId is defined by the server for each widget. * The syntax of the storeId is "tableStore". * If the store does not exist, its configuration is extract from * the application constant App.storeCfgs.Then it is created and registered. * In the current frame work a unique store is associated to a database table. - * This property garanty that widget share the same store. + * This property guaranty that widget share the same store. * * @param {String} storeId */ @@ -116,11 +117,15 @@ App.isPlugin = function (component, ptype) { /** * Helper function to load the MathJax library - * @param {Object} callback + * The loading is an asynchronous operation. + * When finished the function callback is executed. + * If the library is not there the callback is executed to. + * @param {Function} callback + * @param {Object} scope scope for the callback */ App.loadMathJax = function (callback, scope) { - if (App.mathJax !== 'None') { + if (App.mathJax) { Ext.Loader.load([App.mathJax], callback, scope); } else {