From 7297474b2e683f6e6e382891b2ec36e7f22c0764 Mon Sep 17 00:00:00 2001 From: Greg Denehy Date: Sun, 30 Apr 2017 15:23:04 +0930 Subject: Added programatic support for custom key bindings with optional descriptions to be added to the help screen --- plugin/notes/notes.js | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'plugin/notes') diff --git a/plugin/notes/notes.js b/plugin/notes/notes.js index 202e73b..8980fb4 100644 --- a/plugin/notes/notes.js +++ b/plugin/notes/notes.js @@ -106,19 +106,7 @@ var RevealNotes = (function() { } // Open the notes when the 's' key is hit - document.addEventListener( 'keydown', function( event ) { - // Disregard the event if the target is editable or a - // modifier is present - if ( document.querySelector( ':focus' ) !== null || event.shiftKey || event.altKey || event.ctrlKey || event.metaKey ) return; - - // Disregard the event if keyboard is disabled - if ( Reveal.getConfig().keyboard === false ) return; - - if( event.keyCode === 83 ) { - event.preventDefault(); - openNotes(); - } - }, false ); + Reveal.addKeyBinding({code: 83, key: 'S', description: 'Speaker notes'}, openNotes); } -- cgit v1.2.3 From e48e1e19b97d99de107966dd3f8c431a89457972 Mon Sep 17 00:00:00 2001 From: Greg Denehy Date: Sun, 30 Apr 2017 16:35:35 +0930 Subject: Changed custom key binding config properties to use 'keyCode' instead of 'code' --- js/reveal.js | 4 ++-- plugin/notes/notes.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'plugin/notes') diff --git a/js/reveal.js b/js/reveal.js index 9d4444f..328edb0 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -1098,8 +1098,8 @@ * Add a custom key binding with optional description to be added to the help screen */ function addKeyBinding(binding, callback) { - if (typeof binding === 'object' && binding.code) { - registeredKeyBindings[binding.code] = { + if (typeof binding === 'object' && binding.keyCode) { + registeredKeyBindings[binding.keyCode] = { callback: callback, key: binding.key, description: binding.description diff --git a/plugin/notes/notes.js b/plugin/notes/notes.js index 8980fb4..6373d97 100644 --- a/plugin/notes/notes.js +++ b/plugin/notes/notes.js @@ -106,7 +106,7 @@ var RevealNotes = (function() { } // Open the notes when the 's' key is hit - Reveal.addKeyBinding({code: 83, key: 'S', description: 'Speaker notes'}, openNotes); + Reveal.addKeyBinding({keyCode: 83, key: 'S', description: 'Speaker notes'}, openNotes); } -- cgit v1.2.3 From e16508477ab541314452997d20aa6bdb5a8b0862 Mon Sep 17 00:00:00 2001 From: Greg Denehy Date: Sun, 30 Apr 2017 17:51:38 +0930 Subject: Fixed notes.js to account for upstream updates --- plugin/notes/notes.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'plugin/notes') diff --git a/plugin/notes/notes.js b/plugin/notes/notes.js index 1a35110..3f00eb6 100644 --- a/plugin/notes/notes.js +++ b/plugin/notes/notes.js @@ -131,10 +131,9 @@ var RevealNotes = (function() { } // Open the notes when the 's' key is hit - Reveal.addKeyBinding({keyCode: 83, key: 'S', description: 'Speaker notes'}, openNotes); - - // Show our keyboard shortcut in the reveal.js help overlay - if( window.Reveal ) Reveal.registerKeyboardShortcut( 'S', 'Speaker notes view' ); + Reveal.addKeyBinding({keyCode: 83, key: 'S', description: 'Speaker notes view'}, function() { + openNotes(); + } ); } -- cgit v1.2.3 From c0109d948f9d562899795abf15fae5c83c96f21e Mon Sep 17 00:00:00 2001 From: Thomas Weinert Date: Sat, 12 Aug 2017 13:38:46 +0200 Subject: Block F5 in speaker notes window, avoid disconnects --- plugin/notes/notes.html | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'plugin/notes') diff --git a/plugin/notes/notes.html b/plugin/notes/notes.html index 4c5b799..9922a29 100644 --- a/plugin/notes/notes.html +++ b/plugin/notes/notes.html @@ -427,10 +427,16 @@ * Forward keyboard events to the current slide window. * This enables keyboard events to work even if focus * isn't set on the current slide iframe. + * + * Block F5 default handling, it reloads and disconnects + * the speaker notes window. */ function setupKeyboard() { document.addEventListener( 'keydown', function( event ) { + if (event.keyCode === 116) { + event.preventDefault(); + } currentSlide.contentWindow.postMessage( JSON.stringify({ method: 'triggerKey', args: [ event.keyCode ] }), '*' ); } ); -- cgit v1.2.3 From 7a0b4a56f9fb63f85d14be1913e3f4384ee8d32c Mon Sep 17 00:00:00 2001 From: Hakim El Hattab Date: Mon, 4 Dec 2017 13:57:19 +0100 Subject: prevent cmd+r in notes window since reloading breaks the view #1958 --- plugin/notes/notes.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'plugin/notes') diff --git a/plugin/notes/notes.html b/plugin/notes/notes.html index 9922a29..5b75d73 100644 --- a/plugin/notes/notes.html +++ b/plugin/notes/notes.html @@ -434,8 +434,9 @@ function setupKeyboard() { document.addEventListener( 'keydown', function( event ) { - if (event.keyCode === 116) { + if( event.keyCode === 116 || ( event.metaKey && event.keyCode === 82 ) ) { event.preventDefault(); + return false; } currentSlide.contentWindow.postMessage( JSON.stringify({ method: 'triggerKey', args: [ event.keyCode ] }), '*' ); } ); -- cgit v1.2.3 From 5771ae39f091966e603d3e1e5e64fbc0f387be64 Mon Sep 17 00:00:00 2001 From: Hakim El Hattab Date: Tue, 24 Apr 2018 14:23:28 +0200 Subject: speaker view has visible connection status, times out with error after 5s --- plugin/notes/notes.html | 26 ++++++++++++++++++++++++++ plugin/notes/notes.js | 5 +++++ 2 files changed, 31 insertions(+) (limited to 'plugin/notes') diff --git a/plugin/notes/notes.html b/plugin/notes/notes.html index 5b75d73..0c4eca5 100644 --- a/plugin/notes/notes.html +++ b/plugin/notes/notes.html @@ -34,6 +34,22 @@ z-index: 2; } + #connection-status { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 20; + padding: 30% 20% 20% 20%; + font-size: 18px; + color: #222; + background: #fff; + text-align: center; + box-sizing: border-box; + line-height: 1.4; + } + .overlay-element { height: 34px; line-height: 34px; @@ -288,6 +304,8 @@ +
Loading speaker view...
+
Upcoming
@@ -340,8 +358,16 @@ setupLayout(); + var connectionStatus = document.querySelector( '#connection-status' ); + var connectionTimeout = setTimeout( function() { + connectionStatus.innerHTML = 'Error connecting to main window.
Please try closing and reopening the speaker view.'; + }, 5000 ); + window.addEventListener( 'message', function( event ) { + clearTimeout( connectionTimeout ); + connectionStatus.style.display = 'none'; + var data = JSON.parse( event.data ); // The overview mode is only useful to the reveal.js instance diff --git a/plugin/notes/notes.js b/plugin/notes/notes.js index 3f00eb6..7622858 100644 --- a/plugin/notes/notes.js +++ b/plugin/notes/notes.js @@ -21,6 +21,11 @@ var RevealNotes = (function() { var notesPopup = window.open( notesFilePath, 'reveal.js - Notes', 'width=1100,height=700' ); + if( !notesPopup ) { + alert( 'Speaker view popup failed to open. Please make sure popups are allowed and reopen the speaker view.' ); + return; + } + // Allow popup window access to Reveal API notesPopup.Reveal = this.Reveal; -- cgit v1.2.3 From ee63b2ac607133d7fd41081f7c015e347ada518f Mon Sep 17 00:00:00 2001 From: Greg Denehy Date: Sat, 5 May 2018 17:38:37 +0930 Subject: Fixed notes timer when speaker notes window opened via RevealNotes.open() --- plugin/notes/notes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugin/notes') diff --git a/plugin/notes/notes.js b/plugin/notes/notes.js index 7622858..a5b15b4 100644 --- a/plugin/notes/notes.js +++ b/plugin/notes/notes.js @@ -27,7 +27,7 @@ var RevealNotes = (function() { } // Allow popup window access to Reveal API - notesPopup.Reveal = this.Reveal; + notesPopup.Reveal = window.Reveal; /** * Connect to the notes window through a postmessage handshake. -- cgit v1.2.3