From 8ac15451d948a822f0b8d9463e1ec47241e04edb Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Mon, 12 Feb 2018 17:39:51 +0100 Subject: [PATCH] JaxMath onload event moved to the right place --- frontend-js/src/main/js/Functions.js | 5 ----- .../src/main/js/map/window/ReactionInfoWindow.js | 7 +++++++ frontend-js/src/test/js/mocha-config.js | 10 +++++++++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/frontend-js/src/main/js/Functions.js b/frontend-js/src/main/js/Functions.js index 2efead8718..b2530bf5db 100644 --- a/frontend-js/src/main/js/Functions.js +++ b/frontend-js/src/main/js/Functions.js @@ -343,11 +343,6 @@ Functions.loadScript = function (url) { script.type = 'text/javascript'; script.src = url; script.onload = function () { - MathJax.Hub.Config({ - tex2jax: { - skipTags: ["script", "noscript", "style", "textarea", "pre", "code"] - } - }); resolve(); }; head.appendChild(script); diff --git a/frontend-js/src/main/js/map/window/ReactionInfoWindow.js b/frontend-js/src/main/js/map/window/ReactionInfoWindow.js index 200384d00e..cd95953aba 100644 --- a/frontend-js/src/main/js/map/window/ReactionInfoWindow.js +++ b/frontend-js/src/main/js/map/window/ReactionInfoWindow.js @@ -59,6 +59,13 @@ ReactionInfoWindow.prototype.createContentDiv = function () { } else { var kineticLaw = reaction.getKineticLaw(); return Functions.loadScript('https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML').then(function () { + return MathJax.Hub.Config({ + tex2jax: { + skipTags: ["script", "noscript", "style", "textarea", "pre", "code"] + } + }); + }).then(function () { + result.appendChild(Functions.createElement({type: "h4", content: "Kinetic law"})); if (kineticLaw.getMathMlPresentation() !== undefined) { diff --git a/frontend-js/src/test/js/mocha-config.js b/frontend-js/src/test/js/mocha-config.js index 0624a93c6f..eb9151b572 100644 --- a/frontend-js/src/test/js/mocha-config.js +++ b/frontend-js/src/test/js/mocha-config.js @@ -27,7 +27,15 @@ function mockBootstrap() { } before(function () { - require('../../main/js/Functions').loadScript = Promise.resolve; + require('../../main/js/Functions').loadScript = function () { + global.MathJax = { + Hub: { + Config: function () { + } + } + }; + return Promise.resolve(); + }; // requirejs.config({ // baseUrl: path.dirname(require.main.filename) + "/../../../" // }); -- GitLab