src/egonomy/static/egonomy/js/slideshow.js
changeset 207 43f08ce0e5aa
parent 204 1d22c4e915a9
child 219 6667fb5455d0
--- a/src/egonomy/static/egonomy/js/slideshow.js	Fri Jun 28 15:47:00 2013 +0200
+++ b/src/egonomy/static/egonomy/js/slideshow.js	Fri Jun 28 16:14:01 2013 +0200
@@ -71,13 +71,36 @@
         }
     }
     
-    function nextSlide() {
+    var playInterval, playing = false;
+    
+    function toggleSlideShow() {
+        clearInterval(playInterval);
+        playing = !playing;
+        var jqppbtn = $(".play-pause");
+        if (playing) {
+            jqppbtn.addClass("pause");
+            playInterval = setInterval(nextSlide,4000,false);
+        } else {
+            jqppbtn.removeClass("pause");
+        }
+        return false;
+    }
+    
+    function nextSlide(resetInterval) {
+        if (!!resetInterval && playing) {
+            playing = false;
+            toggleSlideShow();
+        }
         currentSlide = (currentSlide + 1) % slides.length;
         showSlide();
         return false;
     }
     
-    function prevSlide() {
+    function prevSlide(resetInterval) {
+        if (!!resetInterval && playing) {
+            playing = false;
+            toggleSlideShow();
+        }
         currentSlide = (currentSlide > 0 ? currentSlide - 1 : slides.length - 1);
         showSlide();
         return false;
@@ -126,20 +149,8 @@
         && typeof document.webkitIsFullScreen === "undefined") {
         $(".full-screen").remove();
     }
-    
-    var playInterval, playing = false;
-    
-    $(".play-pause").click(function() {
-        clearInterval(playInterval);
-        playing = !playing;
-        if (playing) {
-            $(this).addClass("pause");
-            playInterval = setInterval(nextSlide,4000);
-        } else {
-            $(this).removeClass("pause");
-        }
-        return false;
-    });
+        
+    $(".play-pause").click(toggleSlideShow);
     
     slides.forEach(function(slide, k) {
         if (!slide.path) {
@@ -158,4 +169,25 @@
     
     jqwin.resize(showSlide);
     
+    $(document).keydown(function(e) {
+        if (e.keyCode === 122) { // F11
+            fullScreen();
+            return false;
+        }
+        if (e.keyCode === 32) { // Space
+            jqControls.show();
+            resetTO();
+            toggleSlideShow();
+            return false;
+        }
+        if (e.keyCode === 37) { // Left-Arrow
+            prevSlide(true);
+            return false;
+        }
+        if (e.keyCode === 39) { // Right-Arrow
+            nextSlide(true);
+            return false;
+        }
+    });
+    
 });
\ No newline at end of file