comments and failesafes for #531
authorHakim El Hattab <hakim.elhattab@gmail.com>
Tue, 13 Aug 2013 03:01:35 +0000 (23:01 -0400)
committerHakim El Hattab <hakim.elhattab@gmail.com>
Tue, 13 Aug 2013 03:01:35 +0000 (23:01 -0400)
examples/math.html
plugin/math/math.js

index 67fa54621efe0435e2282c5d919ba50c5374f086..d282f8a5e2891bbbe0a7f667776ba7d1a9b6437c 100644 (file)
@@ -38,6 +38,7 @@
 
                                <section>
                                        <h3>The Lorenz Equations</h3>
+
                                        \[\begin{aligned}
                                        \dot{x} &amp; = \sigma(y-x) \\
                                        \dot{y} &amp; = \rho x - y - xz \\
                        Reveal.initialize({
                                transition: 'linear',
 
+                               math: {
+                                       mode: 'TeX-AMS_HTML-full'
+                               },
+
                                dependencies: [
                                        { src: '../lib/js/classList.js', condition: function() { return !document.body.classList; } },
                                        { src: '../plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
index 8ab74fad095dca78f75706ae799c20cbdf14044e..b6bd82fb63449f943ef54603efd7b95392d1a584 100755 (executable)
@@ -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';
 
        // 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 );
+
+                       } );
+               }
 
        }