formatting and tweaks for #2104

This commit is contained in:
Hakim El Hattab 2018-10-04 13:26:16 +02:00
parent 8582c9aac8
commit d5cf3fa13c
4 changed files with 23 additions and 34 deletions

View file

@ -24,23 +24,8 @@
<body> <body>
<div class="reveal"> <div class="reveal">
<div class="slides"> <div class="slides">
<section data-timing="6"> <section>Slide 1</section>
Slide 1 <section>Slide 2</section>
<aside>
these are not notes
</aside>
<aside class="notes">
these are notes for the first slide
</aside>
</section>
<section>
Slide 2
<aside class="notes">
these are the nodes for the second slide
</aside>
</section>
</div> </div>
</div> </div>
@ -57,9 +42,7 @@
{ src: 'plugin/markdown/markdown.js' }, { src: 'plugin/markdown/markdown.js' },
{ src: 'plugin/notes/notes.js', async: true }, { src: 'plugin/notes/notes.js', async: true },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } } { src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }
], ]
controlsTutorial: false,
defaultTiming: 3
}); });
</script> </script>
</body> </body>

View file

@ -4099,18 +4099,20 @@
} }
/** /**
* Returns an array of objects where each object represents the attributes on its respective slide. * Returns an array of objects where each object represents the
* attributes on its respective slide.
*/ */
function getSlidesMetaInfo() { function getSlidesAttributes() {
var slides = getSlides(); return getSlides().map( function( slide ) {
return slides.map( function (slide) {
var meta = {}; var attributes = {};
for( var i = 0; i < slide.attributes.length; i++ ) { for( var i = 0; i < slide.attributes.length; i++ ) {
var attribute = slide.attributes[ i ]; var attribute = slide.attributes[ i ];
meta[ attribute.name ] = attribute.value; attributes[ attribute.name ] = attribute.value;
} }
return meta; return attributes;
} ); } );
} }
@ -5473,7 +5475,7 @@
// Returns an Array of objects representing the attributes on // Returns an Array of objects representing the attributes on
// the slides // the slides
getSlidesMetaInfo: getSlidesMetaInfo, getSlidesAttributes: getSlidesAttributes,
// Returns the total number of slides // Returns the total number of slides
getTotalSlides: getTotalSlides, getTotalSlides: getTotalSlides,

View file

@ -408,6 +408,7 @@
* Asynchronously calls the Reveal.js API of the main frame. * Asynchronously calls the Reveal.js API of the main frame.
*/ */
function callRevealApi( methodName, methodArguments, callback ) { function callRevealApi( methodName, methodArguments, callback ) {
var callId = ++lastRevealApiCallId; var callId = ++lastRevealApiCallId;
pendingCalls[callId] = callback; pendingCalls[callId] = callback;
window.opener.postMessage( JSON.stringify( { window.opener.postMessage( JSON.stringify( {
@ -417,6 +418,7 @@
methodName: methodName, methodName: methodName,
arguments: methodArguments arguments: methodArguments
} ), '*' ); } ), '*' );
} }
/** /**
@ -535,7 +537,7 @@
function getTimings( callback ) { function getTimings( callback ) {
callRevealApi( 'getSlidesMetaInfo', [], function ( slides ) { callRevealApi( 'getSlidesAttributes', [], function ( slideAttributes ) {
callRevealApi( 'getConfig', [], function ( config ) { callRevealApi( 'getConfig', [], function ( config ) {
var defaultTiming = config.defaultTiming; var defaultTiming = config.defaultTiming;
if (defaultTiming == null) { if (defaultTiming == null) {
@ -544,8 +546,8 @@
} }
var timings = []; var timings = [];
for ( var i in slides ) { for ( var i in slideAttributes ) {
var slide = slides[ i ]; var slide = slideAttributes[ i ];
var timing = defaultTiming; var timing = defaultTiming;
if( slide.hasOwnProperty( 'data-timing' )) { if( slide.hasOwnProperty( 'data-timing' )) {
var t = slide[ 'data-timing' ]; var t = slide[ 'data-timing' ];

View file

@ -56,17 +56,19 @@ var RevealNotes = (function() {
} }
/** /**
* Calls the specified Reveal.js method with the provided argument and then pushes the result to the notes * Calls the specified Reveal.js method with the provided argument
* frame. * and then pushes the result to the notes frame.
*/ */
function callRevealApi( methodName, methodArguments, callId ) { function callRevealApi( methodName, methodArguments, callId ) {
var result = Reveal[methodName].call(Reveal, methodArguments);
var result = Reveal[methodName].call( Reveal, methodArguments );
notesPopup.postMessage( JSON.stringify( { notesPopup.postMessage( JSON.stringify( {
namespace: 'reveal-notes', namespace: 'reveal-notes',
type: 'return', type: 'return',
result: result, result: result,
callId: callId callId: callId
} ), '*' ); } ), '*' );
} }
/** /**