From bb522c6efd9a02e611014038566b15feb28da0c8 Mon Sep 17 00:00:00 2001 From: Morgan Richomme Date: Mon, 23 May 2016 14:40:54 +0200 Subject: Add framework for presentations Change-Id: I8ba24fb4b2a3a6c8d8c69f15a1fd9259aea4ab6c Signed-off-by: Morgan Richomme --- docs/com/plugin/notes/notes.html | 407 +++++++++++++++++++++++++++++++++++++++ docs/com/plugin/notes/notes.js | 124 ++++++++++++ 2 files changed, 531 insertions(+) create mode 100755 docs/com/plugin/notes/notes.html create mode 100755 docs/com/plugin/notes/notes.js (limited to 'docs/com/plugin/notes') diff --git a/docs/com/plugin/notes/notes.html b/docs/com/plugin/notes/notes.html new file mode 100755 index 000000000..75f1b9b03 --- /dev/null +++ b/docs/com/plugin/notes/notes.html @@ -0,0 +1,407 @@ + + + + + + reveal.js - Slide Notes + + + + + + +
+
UPCOMING:
+
+
+

Time Click to Reset

+
+ 0:00 AM +
+
+ 00:00:00 +
+
+
+ + +
+ + + + + diff --git a/docs/com/plugin/notes/notes.js b/docs/com/plugin/notes/notes.js new file mode 100755 index 000000000..a0e8021ca --- /dev/null +++ b/docs/com/plugin/notes/notes.js @@ -0,0 +1,124 @@ +/** + * Handles opening of and synchronization with the reveal.js + * notes window. + * + * Handshake process: + * 1. This window posts 'connect' to notes window + * - Includes URL of presentation to show + * 2. Notes window responds with 'connected' when it is available + * 3. This window proceeds to send the current presentation state + * to the notes window + */ +var RevealNotes = (function() { + + function openNotes() { + var jsFileLocation = document.querySelector('script[src$="notes.js"]').src; // this js file path + jsFileLocation = jsFileLocation.replace(/notes\.js(\?.*)?$/, ''); // the js folder path + var notesPopup = window.open( jsFileLocation + 'notes.html', 'reveal.js - Notes', 'width=1100,height=700' ); + + /** + * Connect to the notes window through a postmessage handshake. + * Using postmessage enables us to work in situations where the + * origins differ, such as a presentation being opened from the + * file system. + */ + function connect() { + // Keep trying to connect until we get a 'connected' message back + var connectInterval = setInterval( function() { + notesPopup.postMessage( JSON.stringify( { + namespace: 'reveal-notes', + type: 'connect', + url: window.location.protocol + '//' + window.location.host + window.location.pathname + window.location.search, + state: Reveal.getState() + } ), '*' ); + }, 500 ); + + window.addEventListener( 'message', function( event ) { + var data = JSON.parse( event.data ); + if( data && data.namespace === 'reveal-notes' && data.type === 'connected' ) { + clearInterval( connectInterval ); + onConnected(); + } + } ); + } + + /** + * Posts the current slide data to the notes window + */ + function post() { + + var slideElement = Reveal.getCurrentSlide(), + notesElement = slideElement.querySelector( 'aside.notes' ); + + var messageData = { + namespace: 'reveal-notes', + type: 'state', + notes: '', + markdown: false, + whitespace: 'normal', + state: Reveal.getState() + }; + + // 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 an aside element + if( notesElement ) { + messageData.notes = notesElement.innerHTML; + messageData.markdown = typeof notesElement.getAttribute( 'data-markdown' ) === 'string'; + } + + notesPopup.postMessage( JSON.stringify( messageData ), '*' ); + + } + + /** + * Called once we have established a connection to the notes + * window. + */ + function onConnected() { + + // Monitor events that trigger a change in state + Reveal.addEventListener( 'slidechanged', post ); + Reveal.addEventListener( 'fragmentshown', post ); + Reveal.addEventListener( 'fragmenthidden', post ); + Reveal.addEventListener( 'overviewhidden', post ); + Reveal.addEventListener( 'overviewshown', post ); + Reveal.addEventListener( 'paused', post ); + Reveal.addEventListener( 'resumed', post ); + + // Post the initial state + post(); + + } + + connect(); + } + + if( !/receiver/i.test( window.location.search ) ) { + + // If the there's a 'notes' query set, open directly + if( window.location.search.match( /(\?|\&)notes/gi ) !== null ) { + openNotes(); + } + + // 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; + + if( event.keyCode === 83 ) { + event.preventDefault(); + openNotes(); + } + }, false ); + + } + + return { open: openNotes }; + +})(); -- cgit 1.2.3-korg