Merge pull request #615 from abanink/5118

5118 Implement MathJax JS hook to update contents after live update
This commit is contained in:
Hypolite Petovan 2018-06-13 16:43:56 -04:00 committed by GitHub
commit 194d1d167d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

5
mathjax/mathjax.js Normal file
View file

@ -0,0 +1,5 @@
Addon_registerHook("postprocess_liveupdate", "mathjax_postprocess_liveupdate");
function mathjax_postprocess_liveupdate()
{
MathJax.Hub.Queue(["Typeset", MathJax.Hub]);
}

View file

@ -16,13 +16,26 @@ function mathjax_install() {
Addon::registerHook('page_header', 'addon/mathjax/mathjax.php', 'mathjax_page_header'); 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', 'addon/mathjax/mathjax.php', 'mathjax_settings');
Addon::registerHook('addon_settings_post', 'addon/mathjax/mathjax.php', 'mathjax_settings_post'); 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'); logger('installed js_math addon');
} }
function mathjax_uninstall() { function mathjax_uninstall() {
Addon::unregisterHook('page_header', 'addon/mathjax/mathjax.php', 'mathjax_page_header'); 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', 'addon/mathjax/mathjax.php', 'mathjax_settings');
Addon::unregisterHook('addon_settings_post', 'addon/mathjax/mathjax.php', 'mathjax_settings_post'); 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_template_vars($a, &$arr)
{
if (!array_key_exists('addon_hooks',$arr['vars']))
{
$arr['vars']['addon_hooks'] = array();
}
$arr['vars']['addon_hooks'][] = "mathjax";
}
function mathjax_settings_post ($a, $post) { function mathjax_settings_post ($a, $post) {
if (! local_user()) if (! local_user())
return; return;