diff options
Diffstat (limited to 'plugin/notes')
-rw-r--r-- | plugin/notes/notes.html | 33 | ||||
-rw-r--r-- | plugin/notes/notes.js | 26 |
2 files changed, 42 insertions, 17 deletions
diff --git a/plugin/notes/notes.html b/plugin/notes/notes.html index 4c5b799..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 @@ <body> + <div id="connection-status">Loading speaker view...</div> + <div id="current-slide"></div> <div id="upcoming-slide"><span class="overlay-element label">Upcoming</span></div> <div id="speaker-controls"> @@ -340,8 +358,16 @@ setupLayout(); + var connectionStatus = document.querySelector( '#connection-status' ); + var connectionTimeout = setTimeout( function() { + connectionStatus.innerHTML = 'Error connecting to main window.<br>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 @@ -427,10 +453,17 @@ * 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.metaKey && event.keyCode === 82 ) ) { + event.preventDefault(); + return false; + } currentSlide.contentWindow.postMessage( JSON.stringify({ method: 'triggerKey', args: [ event.keyCode ] }), '*' ); } ); diff --git a/plugin/notes/notes.js b/plugin/notes/notes.js index 80fb6e2..a5b15b4 100644 --- a/plugin/notes/notes.js +++ b/plugin/notes/notes.js @@ -21,8 +21,13 @@ 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; + notesPopup.Reveal = window.Reveal; /** * Connect to the notes window through a postmessage handshake. @@ -131,22 +136,9 @@ 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 ); - - // 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(); + } ); } |