Add fullscreen mode
authorMichael Kühnel <mail@michael-kuehnel.de>
Sun, 14 Oct 2012 08:26:40 +0000 (10:26 +0200)
committerMichael Kühnel <mail@michael-kuehnel.de>
Sun, 14 Oct 2012 08:26:40 +0000 (10:26 +0200)
Handling the fullscreen functionality via the fullscreen JavaScript API.

Press »f« on the keyboard to enter fullscreen mode.

js/reveal.js

index 3dcedf0d6fb9fa40b82c3007cafd7485aa96d8dc..e95092e4aecf890df46f2a05a1415fa096aaeae7 100644 (file)
@@ -435,6 +435,8 @@ var Reveal = (function(){
                        case 13: isOverviewActive() ? deactivateOverview() : triggered = false; break;
                        // b, period
                        case 66: case 190: togglePause(); break;
+                       // f
+                       case 70: enterFullscreen(); break;
                        default:
                                triggered = false;
                }
@@ -1192,7 +1194,25 @@ var Reveal = (function(){
                // another timeout
                cueAutoSlide();
        }
-       
+
+       /**
+        * Handling the fullscreen functionality via the fullscreen API
+        * @see http://fullscreen.spec.whatwg.org/ 
+        * @see https://developer.mozilla.org/en-US/docs/DOM/Using_fullscreen_mode 
+        */
+       function enterFullscreen() {
+               var element = document.body;
+               
+               // Check which implementation is available
+               var requestMethod = element.requestFullScreen ||
+                                                       element.webkitRequestFullScreen ||
+                                                       element.mozRequestFullScreen ||
+                                                       element.msRequestFullScreen;
+               if (requestMethod) {
+                       requestMethod.apply(element);
+               }
+       }
+
        // Expose some methods publicly
        return {
                initialize: initialize,