Changeset 2185054
- Timestamp:
- 11/02/2019 08:13:45 PM (6 years ago)
- Location:
- slide/trunk
- Files:
-
- 5 edited
-
index.php (modified) (2 diffs)
-
readme.md (modified) (1 diff)
-
reveal/notes.min.js (modified) (1 diff)
-
speaker.js (modified) (2 diffs)
-
template.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
slide/trunk/index.php
r2185015 r2185054 5 5 * Plugin URI: https://wordpress.org/plugins/slide/ 6 6 * Description: Allows you to create presentations with the block editor. 7 * Version: 0.0.3 67 * Version: 0.0.37 8 8 * Author: Ella van Durpe 9 9 * Author URI: https://ellavandurpe.com … … 167 167 plugins_url( 'reveal/notes.min.js', __FILE__ ), 168 168 array( 'slide-reveal' ), 169 '3.8.0',169 filemtime( dirname( __FILE__ ) . '/reveal/notes.min.js' ), 170 170 true 171 171 ); -
slide/trunk/readme.md
r2185015 r2185054 6 6 Requires PHP: 5.6 7 7 Tested up to: 5.3 8 Stable tag: 0.0.3 68 Stable tag: 0.0.37 9 9 License: GPL-2.0-or-later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
slide/trunk/reveal/notes.min.js
r2177669 r2185054 1 var RevealNotes=function(){var l=null;function e(e){if(!l||l.closed){if(!e){var t=document.querySelector('script[src$="notes.js"]').src;e=(t=t.replace(/notes\.js(\?.*)?$/,""))+"notes.html"}var o;if(l=window.open(e,"reveal.js - Notes","width=1100,height=700"))o=setInterval(function(){l.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(e){var t,a,n,s,r=JSON.parse(e.data);r&&"reveal-notes"===r.namespace&&"connected"===r.type&&(clearInterval(o),Reveal.addEventListener("slidechanged",i),Reveal.addEventListener("fragmentshown",i),Reveal.addEventListener("fragmenthidden",i),Reveal.addEventListener("overviewhidden",i),Reveal.addEventListener("overviewshown",i),Reveal.addEventListener("paused",i),Reveal.addEventListener("resumed",i),i()),r&&"reveal-notes"===r.namespace&&"call"===r.type&&(t=r.methodName,a=r.arguments,n=r.callId,s=Reveal[t].apply(Reveal,a),l.postMessage(JSON.stringify({namespace:"reveal-notes",type:"return",result:s,callId:n}),"*"))});else alert("Speaker view popup failed to open. Please make sure popups are allowed and reopen the speaker view.")}else l.focus();function i(e){var t=Reveal.getCurrentSlide(),a=t.querySelector("aside.notes"),n=t.querySelector(".current-fragment"),s={namespace:"reveal-notes",type:"state",notes:"",markdown:!1,whitespace:"normal",state:Reveal.getState()};if(t.hasAttribute("data-notes")&&(s.notes=t.getAttribute("data-notes"),s.whitespace="pre-wrap"),n){var r=n.querySelector("aside.notes");r?a=r:n.hasAttribute("data-notes")&&(s.notes=n.getAttribute("data-notes"),s.whitespace="pre-wrap",a=null)}a&&(s.notes=a.innerHTML,s.markdown="string"==typeof a.getAttribute("data-markdown")),l.postMessage(JSON.stringify(s),"*")}}return{init:function(){/receiver/i.test(window.location.search)||(null!==window.location.search.match(/(\?|\&)notes/gi)&&e(),Reveal.addKeyBinding({keyCode:83,key:"S",description:"Speaker notes view"},function(){e()}))},open:e}}();Reveal.registerPlugin("notes",RevealNotes); 1 /** 2 * Handles opening of and synchronization with the reveal.js 3 * notes window. 4 * 5 * Handshake process: 6 * 1. This window posts 'connect' to notes window 7 * - Includes URL of presentation to show 8 * 2. Notes window responds with 'connected' when it is available 9 * 3. This window proceeds to send the current presentation state 10 * to the notes window 11 */ 12 var RevealNotes = (function() { 13 14 var notesPopup = null; 15 16 window.addEventListener( 'unload', function() { 17 if ( notesPopup ) { 18 notesPopup.close(); 19 } 20 } ); 21 22 function openNotes( notesFilePath ) { 23 24 if (notesPopup && !notesPopup.closed) { 25 notesPopup.focus(); 26 return; 27 } 28 29 if( !notesFilePath ) { 30 var jsFileLocation = document.querySelector('script[src$="notes.js"]').src; // this js file path 31 jsFileLocation = jsFileLocation.replace(/notes\.js(\?.*)?$/, ''); // the js folder path 32 notesFilePath = jsFileLocation + 'notes.html'; 33 } 34 35 notesPopup = window.open( notesFilePath, 'reveal.js - Notes', 'width=1100,height=700' ); 36 37 if( !notesPopup ) { 38 alert( 'Speaker view popup failed to open. Please make sure popups are allowed and reopen the speaker view.' ); 39 return; 40 } 41 42 /** 43 * Connect to the notes window through a postmessage handshake. 44 * Using postmessage enables us to work in situations where the 45 * origins differ, such as a presentation being opened from the 46 * file system. 47 */ 48 function connect() { 49 // Keep trying to connect until we get a 'connected' message back 50 var connectInterval = setInterval( function() { 51 notesPopup.postMessage( JSON.stringify( { 52 namespace: 'reveal-notes', 53 type: 'connect', 54 url: window.location.protocol + '//' + window.location.host + window.location.pathname + window.location.search, 55 state: Reveal.getState() 56 } ), '*' ); 57 }, 500 ); 58 59 window.addEventListener( 'message', function( event ) { 60 var data = JSON.parse( event.data ); 61 if( data && data.namespace === 'reveal-notes' && data.type === 'connected' ) { 62 clearInterval( connectInterval ); 63 onConnected(); 64 } 65 if( data && data.namespace === 'reveal-notes' && data.type === 'call' ) { 66 callRevealApi( data.methodName, data.arguments, data.callId ); 67 } 68 } ); 69 } 70 71 /** 72 * Calls the specified Reveal.js method with the provided argument 73 * and then pushes the result to the notes frame. 74 */ 75 function callRevealApi( methodName, methodArguments, callId ) { 76 77 var result = Reveal[methodName].apply( Reveal, methodArguments ); 78 notesPopup.postMessage( JSON.stringify( { 79 namespace: 'reveal-notes', 80 type: 'return', 81 result: result, 82 callId: callId 83 } ), '*' ); 84 85 } 86 87 /** 88 * Posts the current slide data to the notes window 89 */ 90 function post( event ) { 91 92 var slideElement = Reveal.getCurrentSlide(), 93 notesElement = slideElement.querySelector( 'aside.notes' ), 94 fragmentElement = slideElement.querySelector( '.current-fragment' ); 95 96 var messageData = { 97 namespace: 'reveal-notes', 98 type: 'state', 99 notes: '', 100 markdown: false, 101 whitespace: 'normal', 102 state: Reveal.getState() 103 }; 104 105 // Look for notes defined in a slide attribute 106 if( slideElement.hasAttribute( 'data-notes' ) ) { 107 messageData.notes = slideElement.getAttribute( 'data-notes' ); 108 messageData.whitespace = 'pre-wrap'; 109 } 110 111 // Look for notes defined in a fragment 112 if( fragmentElement ) { 113 var fragmentNotes = fragmentElement.querySelector( 'aside.notes' ); 114 if( fragmentNotes ) { 115 notesElement = fragmentNotes; 116 } 117 else if( fragmentElement.hasAttribute( 'data-notes' ) ) { 118 messageData.notes = fragmentElement.getAttribute( 'data-notes' ); 119 messageData.whitespace = 'pre-wrap'; 120 121 // In case there are slide notes 122 notesElement = null; 123 } 124 } 125 126 // Look for notes defined in an aside element 127 if( notesElement ) { 128 messageData.notes = notesElement.innerHTML; 129 messageData.markdown = typeof notesElement.getAttribute( 'data-markdown' ) === 'string'; 130 } 131 132 notesPopup.postMessage( JSON.stringify( messageData ), '*' ); 133 134 } 135 136 /** 137 * Called once we have established a connection to the notes 138 * window. 139 */ 140 function onConnected() { 141 142 // Monitor events that trigger a change in state 143 Reveal.addEventListener( 'slidechanged', post ); 144 Reveal.addEventListener( 'fragmentshown', post ); 145 Reveal.addEventListener( 'fragmenthidden', post ); 146 Reveal.addEventListener( 'overviewhidden', post ); 147 Reveal.addEventListener( 'overviewshown', post ); 148 Reveal.addEventListener( 'paused', post ); 149 Reveal.addEventListener( 'resumed', post ); 150 151 // Post the initial state 152 post(); 153 154 } 155 156 connect(); 157 158 } 159 160 return { 161 init: function() { 162 163 if( !/receiver/i.test( window.location.search ) ) { 164 165 // If the there's a 'notes' query set, open directly 166 if( window.location.search.match( /(\?|\&)notes/gi ) !== null ) { 167 openNotes(); 168 } 169 170 // Open the notes when the 's' key is hit 171 Reveal.addKeyBinding({keyCode: 83, key: 'S', description: 'Speaker notes view'}, function() { 172 openNotes(); 173 } ); 174 175 } 176 177 }, 178 179 open: openNotes 180 }; 181 182 })(); 183 184 Reveal.registerPlugin( 'notes', RevealNotes ); -
slide/trunk/speaker.js
r2185011 r2185054 34 34 }); 35 35 36 window.opener.addEventListener('beforeunload', () => { 37 window.close(); 38 console.log( 'test' ); 39 }); 40 36 41 window.addEventListener('message', function (event) { 37 42 var data = JSON.parse(event.data); … … 48 53 handleStateMessage(data); 49 54 } else if (data.type === 'return') { 55 console.log( data, pendingCalls ); 50 56 pendingCalls[data.callId](data.result); 51 delete pendingCalls[data.callId];57 // delete pendingCalls[data.callId]; 52 58 } 53 59 // Messages sent by the reveal.js inside of the current slide preview -
slide/trunk/template.php
r2185006 r2185054 243 243 const svg = event.currentSlide.getAttribute( 'data-background-svg' ); 244 244 245 console.log( event );246 247 245 if ( ! svg ) { 248 246 return;
Note: See TracChangeset
for help on using the changeset viewer.