diff options
author | Hakim El Hattab <hakim.elhattab@gmail.com> | 2013-08-12 23:01:35 -0400 |
---|---|---|
committer | Hakim El Hattab <hakim.elhattab@gmail.com> | 2013-08-12 23:01:35 -0400 |
commit | 39019040579208b87f620567eb722d70e310bc8f (patch) | |
tree | b1a2b4c4872a6871ad4b9ab371e3ce5f3ed03070 /plugin/math | |
parent | 69f7c0c69338a966841b3ecd4bd97df00bf28dbb (diff) | |
download | perl-software-in-gnu-guix-39019040579208b87f620567eb722d70e310bc8f.tar perl-software-in-gnu-guix-39019040579208b87f620567eb722d70e310bc8f.tar.gz |
comments and failesafes for #531
Diffstat (limited to 'plugin/math')
-rwxr-xr-x | plugin/math/math.js | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/plugin/math/math.js b/plugin/math/math.js index 8ab74fa..b6bd82f 100755 --- a/plugin/math/math.js +++ b/plugin/math/math.js @@ -4,7 +4,9 @@ * * @author Hakim El Hattab */ -(function(){ +var RevealMath = window.RevealMath || (function(){ + + var loaded = false; var config = Reveal.getConfig().math || {}; config.mode = config.mode || 'TeX-AMS_HTML-full'; @@ -16,32 +18,40 @@ // Detect when the script has loaded script.onload = onScriptLoad; + + // IE script.onreadystatechange = function() { if ( this.readyState === 'loaded' ) { onScriptLoad.call(); } } + // Normal browsers head.appendChild( script ); function onScriptLoad() { - MathJax.Hub.Config({ - messageStyle: 'none', - tex2jax: { inlineMath: [['$','$'],['\\(','\\)']] } - }); + // Conditioned just in case both onload and readystate fire + if( loaded === false ) { + loaded = true; - // Process any math inside of the current slide when navigating, - // this is important since it's not possible to typeset - // equations within invisible elements (far future or past). - Reveal.addEventListener( 'slidechanged', function( event ) { + MathJax.Hub.Config({ + messageStyle: 'none', + tex2jax: { inlineMath: [['$','$'],['\\(','\\)']] } + }); - // This will only typeset equations that have not yet been - // processed, as well as equations that have change since - // last being processed. - MathJax.Hub.Update( event.currentSlide ); + // Process any math inside of the current slide when navigating, + // this is needed since it's not possible to typeset equations + // within invisible elements (far future or past). + Reveal.addEventListener( 'slidechanged', function( event ) { - } ); + // This will only typeset equations that have not yet been + // processed, as well as equations that have change since + // last being processed. + MathJax.Hub.Update( event.currentSlide ); + + } ); + } } |