Skip to content

Commit

Permalink
improved fragment notes support #1636
Browse files Browse the repository at this point in the history
  • Loading branch information
hakimel committed Jan 31, 2017
1 parent c49f76d commit f496613
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions plugin/notes/notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ var RevealNotes = (function() {
/**
* Posts the current slide data to the notes window
*/
function post(event) {
function post( event ) {

var slideElement = Reveal.getCurrentSlide(),
notesElement = slideElement.querySelector( 'aside.notes' );
notesElement = slideElement.querySelector( 'aside.notes' ),
fragmentElement = slideElement.querySelector( '.current-fragment' );

var messageData = {
namespace: 'reveal-notes',
Expand All @@ -64,21 +65,27 @@ var RevealNotes = (function() {
state: Reveal.getState()
};

// Look for notes defined in a fragment, if it is a fragmentshown event
if (event && event.hasOwnProperty('fragment')) {
var innerNotes = event.fragment.querySelector( 'aside.notes' );

if ( innerNotes) {
notesElement = innerNotes;
}
}

// Look for notes defined in a slide attribute
if( slideElement.hasAttribute( 'data-notes' ) ) {
messageData.notes = slideElement.getAttribute( 'data-notes' );
messageData.whitespace = 'pre-wrap';
}

// Look for notes defined in a fragment
if( fragmentElement ) {
var fragmentNotes = fragmentElement.querySelector( 'aside.notes' );
if( fragmentNotes ) {
notesElement = fragmentNotes;
}
else if( fragmentElement.hasAttribute( 'data-notes' ) ) {
messageData.notes = fragmentElement.getAttribute( 'data-notes' );
messageData.whitespace = 'pre-wrap';

// In case there are slide notes
notesElement = null;
}
}

// Look for notes defined in an aside element
if( notesElement ) {
messageData.notes = notesElement.innerHTML;
Expand Down

0 comments on commit f496613

Please sign in to comment.