aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authornava teja <navateja@navatejas-macbook.local>2014-06-08 00:59:29 +0530
committernava teja <navateja@navatejas-macbook.local>2014-06-08 00:59:29 +0530
commit75a53da9e54a462fe9bb313f2cd44320e0e4445a (patch)
tree65535a14156e1deaebdedf6b7461882f05a7ee37 /js
parent131c00689a4c7a18e5c991fc8102347e4594b5d4 (diff)
downloadfreenode-live-2017-presentation-75a53da9e54a462fe9bb313f2cd44320e0e4445a.tar
freenode-live-2017-presentation-75a53da9e54a462fe9bb313f2cd44320e0e4445a.tar.gz
Shows keyboard shorcuts overlay on pressing question mark
Diffstat (limited to 'js')
-rw-r--r--js/reveal.js65
1 files changed, 65 insertions, 0 deletions
diff --git a/js/reveal.js b/js/reveal.js
index 5cbb3ff..27fcb49 100644
--- a/js/reveal.js
+++ b/js/reveal.js
@@ -177,6 +177,20 @@ var Reveal = (function(){
startCount: 0,
captured: false,
threshold: 40
+ },
+
+ // Holds information about the keyboard shortcuts
+ keyboard_shortcuts = {
+ 'p': "Previous slide",
+ 'n': "Next slide",
+ 'h': "Navigate left",
+ 'l': "Navigate right",
+ 'k': "Navigate up",
+ 'j': "Navigate down",
+ 'Home': "First slide",
+ 'End': "Last slide",
+ 'b': "Pause",
+ 'f': "Fullscreen"
};
/**
@@ -646,6 +660,7 @@ var Reveal = (function(){
if( config.keyboard ) {
document.addEventListener( 'keydown', onDocumentKeyDown, false );
+ document.addEventListener( 'keypress', onDocumentKeyPress, false );
}
if( config.progress && dom.progress ) {
@@ -689,6 +704,7 @@ var Reveal = (function(){
eventsAreBound = false;
document.removeEventListener( 'keydown', onDocumentKeyDown, false );
+ document.removeEventListener( 'keypress', onDocumentKeyPress, false );
window.removeEventListener( 'hashchange', onWindowHashChange, false );
window.removeEventListener( 'resize', onWindowResize, false );
@@ -1020,6 +1036,44 @@ var Reveal = (function(){
}
/**
+ * Opens a overlay window for the keyboard shortcuts.
+ */
+ function openShortcutsOverlay() {
+
+ closePreview();
+
+ dom.preview = document.createElement( 'div' );
+ dom.preview.classList.add( 'preview-link-overlay' );
+ dom.wrapper.appendChild( dom.preview );
+
+ var html = '<h5>Keyboard Shortcuts</h5><br/>';
+ html += '<table> <th>KEY</th> <th>ACTION</th>';
+ for( var key in keyboard_shortcuts ) {
+ html += '<tr> <td>' + key + '</td> <td>' + keyboard_shortcuts[key] + '</td> </tr>'
+ }
+ html += '</table>';
+
+ dom.preview.innerHTML = [
+ '<header>',
+ '<a class="close" href="#"><span class="icon"></span></a>',
+ '</header>',
+ '<div class="viewport">',
+ '<div class="shortcuts">'+html+'</div>',
+ '</div>'
+ ].join('');
+
+ dom.preview.querySelector( '.close' ).addEventListener( 'click', function( event ) {
+ closePreview();
+ event.preventDefault();
+ }, false );
+
+ setTimeout( function() {
+ dom.preview.classList.add( 'visible' );
+ }, 1 );
+
+ }
+
+ /**
* Applies JavaScript-controlled layout rules to the
* presentation.
*/
@@ -2643,6 +2697,17 @@ var Reveal = (function(){
}
/**
+ * Handler for the document level 'keypress' event.
+ */
+
+ function onDocumentKeyPress( event ) {
+ // Check if the pressed key is question mark
+ if( event.shiftKey && event.charCode == 63 ) {
+ openShortcutsOverlay();
+ }
+ }
+
+ /**
* Handler for the document level 'keydown' event.
*/
function onDocumentKeyDown( event ) {