123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- var RevealNotes = (function() {
- function openNotes() {
- var jsFileLocation = document.querySelector('script[src$="notes.js"]').src;
- jsFileLocation = jsFileLocation.replace(/notes\.js(\?.*)?$/, '');
- var notesPopup = window.open( jsFileLocation + 'notes.html', 'reveal.js - Notes', 'width=1120,height=850' );
-
- Reveal.addEventListener( 'slidechanged', post );
-
- Reveal.addEventListener( 'fragmentshown', post );
-
- Reveal.addEventListener( 'fragmenthidden', post );
-
- function post() {
- var slideElement = Reveal.getCurrentSlide(),
- slideIndices = Reveal.getIndices(),
- messageData;
- var notes = slideElement.querySelector( 'aside.notes' ),
- nextindexh,
- nextindexv;
- if( slideElement.nextElementSibling && slideElement.parentNode.nodeName == 'SECTION' ) {
- nextindexh = slideIndices.h;
- nextindexv = slideIndices.v + 1;
- } else {
- nextindexh = slideIndices.h + 1;
- nextindexv = 0;
- }
- messageData = {
- notes : notes ? notes.innerHTML : '',
- indexh : slideIndices.h,
- indexv : slideIndices.v,
- indexf : slideIndices.f,
- nextindexh : nextindexh,
- nextindexv : nextindexv,
- markdown : notes ? typeof notes.getAttribute( 'data-markdown' ) === 'string' : false
- };
- notesPopup.postMessage( JSON.stringify( messageData ), '*' );
- }
-
- notesPopup.addEventListener( 'load', function( event ) {
- post();
- }, false );
- }
-
- if( window.location.search.match( /(\?|\&)notes/gi ) !== null ) {
- openNotes();
- }
-
- document.addEventListener( 'keydown', function( event ) {
-
-
- 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 };
- })();
|