merge prev/next navigation pull request with modifications
authorHakim El Hattab <hakim.elhattab@gmail.com>
Wed, 28 Mar 2012 05:16:16 +0000 (01:16 -0400)
committerHakim El Hattab <hakim.elhattab@gmail.com>
Wed, 28 Mar 2012 05:16:16 +0000 (01:16 -0400)
README.md
js/reveal.js

index 647d07c4d3a67375c067834aa1a8e7fe209b0263..1548b90e6d55a5ef781ce68201bbb1ae58d4b29d 100644 (file)
--- a/README.md
+++ b/README.md
@@ -66,6 +66,7 @@ Reveal.initialize({
 - Support for mouse wheel navigation ([naugtur](https://github.com/naugtur))
 - Delayed updates to URL hash to work around a bug in Chrome
 - Included a classList polyfill for IE9
+- Support for wireless presenter keys
 
 #### 1.1
 
index adc5278e2bd60423491f60753fad031d6757dcb9..885884f96dd18aeefbef19d1dfb5f54c21194a01 100644 (file)
@@ -659,22 +659,41 @@ var Reveal = (function(){
                        slide();
                }
        }
-    function navigatePrev() {
-        if( availableRoutes().up ) navigateUp();
-        else {
-            // Go to last slide in previous vertical stack
-            var pastSlides = document.querySelectorAll('#reveal .slides>section.past');
-            if( pastSlides.length > 0 ) {
-                var prevVerticalSlides = pastSlides[pastSlides.length - 1].querySelectorAll('section');
-                indexv = prevVerticalSlides.length > 0 ? prevVerticalSlides.length - 1 : 0;
-                indexh --;
-                slide();
-            }
-        }
-    }
-    function navigateNext() {
-        availableRoutes().down ? navigateDown() : navigateRight();
-    }
+
+       /**
+        * Navigates backwards, prioritized in the following order:
+        * 1) Previous fragment
+        * 2) Previous vertical slide
+        * 3) Previous horizontal slide
+        */
+       function navigatePrev() {
+               // Prioritize revealing fragments
+               if( previousFragment() === false ) {
+                       if( availableRoutes().up ) {
+                               navigateUp();
+                       }
+                       else {
+                               // Fetch the previous horizontal slide, if there is one
+                               var previousSlide = document.querySelector( '#reveal .slides>section.past:nth-child(' + indexh + ')' );
+
+                               if( previousSlide ) {
+                                       indexv = ( previousSlide.querySelectorAll('section').length + 1 ) || 0;
+                                       indexh --;
+                                       slide();
+                               }
+                       }
+               }
+       }
+
+       /**
+        * Same as #navigatePrev() but navigates forwards.
+        */
+       function navigateNext() {
+               // Prioritize revealing fragments
+               if( nextFragment() === false ) {
+                       availableRoutes().down ? navigateDown() : navigateRight();
+               }
+       }
        
        // Expose some methods publicly
        return {