From b5fe8d61dd14552d8e8673e79701ca1ba0850ea3 Mon Sep 17 00:00:00 2001 From: Pascal Deklerck Date: Thu, 7 Jun 2018 22:37:40 +0200 Subject: [PATCH] 5118 Implement MathJax JS hook to update contents after live update --- mathjax/mathjax.js | 5 +++++ mathjax/mathjax.php | 7 +++++++ 2 files changed, 12 insertions(+) create mode 100644 mathjax/mathjax.js diff --git a/mathjax/mathjax.js b/mathjax/mathjax.js new file mode 100644 index 00000000..1ab5531b --- /dev/null +++ b/mathjax/mathjax.js @@ -0,0 +1,5 @@ +Addon_registerHook("postprocess","mathjax_postprocess_liveupdate"); +function mathjax_postprocess_liveupdate() +{ + MathJax.Hub.Queue(["Typeset",MathJax.Hub]); +} diff --git a/mathjax/mathjax.php b/mathjax/mathjax.php index 7d1a8134..37b2748c 100644 --- a/mathjax/mathjax.php +++ b/mathjax/mathjax.php @@ -16,12 +16,19 @@ function mathjax_install() { Addon::registerHook('page_header', 'addon/mathjax/mathjax.php', 'mathjax_page_header'); Addon::registerHook('addon_settings', 'addon/mathjax/mathjax.php', 'mathjax_settings'); Addon::registerHook('addon_settings_post', 'addon/mathjax/mathjax.php', 'mathjax_settings_post'); + Addon::registerHook('template_vars','addon/mathjax/mathjax.php', 'mathjax_template_vars'); logger('installed js_math addon'); } + +function mathjax_template_vars($a, &$arr) { + $arr['vars']['addon_hooks'][] = "mathjax"; +} + function mathjax_uninstall() { Addon::unregisterHook('page_header', 'addon/mathjax/mathjax.php', 'mathjax_page_header'); Addon::unregisterHook('addon_settings', 'addon/mathjax/mathjax.php', 'mathjax_settings'); Addon::unregisterHook('addon_settings_post', 'addon/mathjax/mathjax.php', 'mathjax_settings_post'); + Addon::unregisterHook('template_vars','addon/mathjax/mathjax.php', 'mathjax_template_vars'); } function mathjax_settings_post ($a, $post) { if (! local_user()) -- 2.39.5