From 0388c96e6075657ee0aa0d7885c989bcea982320 Mon Sep 17 00:00:00 2001 From: Hakim El Hattab Date: Wed, 24 May 2017 10:05:16 +0200 Subject: 'showNotes' does nothing when there are no notes --- js/reveal.js | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/js/reveal.js b/js/reveal.js index 1f4ad1e..997337b 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -1051,12 +1051,8 @@ } if( config.showNotes ) { - dom.wrapper.classList.add( 'show-notes' ); dom.speakerNotes.setAttribute( 'data-layout', typeof config.showNotes === 'string' ? config.showNotes : 'inline' ); } - else { - dom.wrapper.classList.remove( 'show-notes' ); - } if( config.mouseWheel ) { document.addEventListener( 'DOMMouseScroll', onDocumentMouseScroll, false ); // FF @@ -2489,6 +2485,7 @@ updateSlideNumber(); updateSlidesVisibility(); updateBackground( true ); + updateNotesVisibility(); updateNotes(); formatEmbeddedContent(); @@ -2794,6 +2791,33 @@ } + /** + * Updates the visibility of the speaker notes sidebar that + * is used to share annotated slides. The notes sidebar is + * only visible if showNotes is true and there are notes on + * one or more slides in the deck. + */ + function updateNotesVisibility() { + + if( config.showNotes && hasNotes() ) { + dom.wrapper.classList.add( 'show-notes' ); + } + else { + dom.wrapper.classList.remove( 'show-notes' ); + } + + } + + /** + * Checks if there are speaker notes for ANY slide in the + * presentation. + */ + function hasNotes() { + + return dom.slides.querySelectorAll( '[data-notes], aside.notes' ).length > 0; + + } + /** * Updates the progress bar to reflect the current slide. */ -- cgit v1.2.3