diff --git a/js/reveal.js b/js/reveal.js
index 725957a7..4224d80d 100644
--- a/js/reveal.js
+++ b/js/reveal.js
@@ -2957,10 +2957,7 @@
*
* @param {HTMLElement} slide
*/
- function syncSlide( slide ) {
-
- // Default to the current slide
- slide = slide || currentSlide;
+ function syncSlide( slide = currentSlide ) {
syncBackground( slide );
syncFragments( slide );
@@ -2980,10 +2977,7 @@
* @param {HTMLElement} slide
* @return {Array} a list of the HTML fragments that were synced
*/
- function syncFragments( slide ) {
-
- // Default to the current slide
- slide = slide || currentSlide;
+ function syncFragments( slide = currentSlide ) {
return sortFragments( slide.querySelectorAll( '.fragment' ) );
@@ -2995,11 +2989,9 @@
*/
function resetVerticalSlides() {
- var horizontalSlides = toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) );
- horizontalSlides.forEach( function( horizontalSlide ) {
+ getHorizontalSlides().forEach( function( horizontalSlide ) {
- var verticalSlides = toArray( horizontalSlide.querySelectorAll( 'section' ) );
- verticalSlides.forEach( function( verticalSlide, y ) {
+ toArray( horizontalSlide.querySelectorAll( 'section' ) ).forEach( ( verticalSlide, y ) => {
if( y > 0 ) {
verticalSlide.classList.remove( 'present' );
@@ -3020,11 +3012,10 @@
*/
function sortAllFragments() {
- var horizontalSlides = toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) );
- horizontalSlides.forEach( function( horizontalSlide ) {
+ getHorizontalSlides().forEach( horizontalSlide => {
- var verticalSlides = toArray( horizontalSlide.querySelectorAll( 'section' ) );
- verticalSlides.forEach( function( verticalSlide, y ) {
+ let verticalSlides = toArray( horizontalSlide.querySelectorAll( 'section' ) );
+ verticalSlides.forEach( ( verticalSlide, y ) => {
sortFragments( verticalSlide.querySelectorAll( '.fragment' ) );
@@ -3041,9 +3032,7 @@
*/
function shuffle() {
- var slides = toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) );
-
- slides.forEach( function( slide ) {
+ getHorizontalSlides().forEach( ( slide, i, slides ) => {
// Insert this slide next to another random slide. This may
// cause the slide to insert before itself but that's fine.
@@ -3070,10 +3059,10 @@
// Select all slides and convert the NodeList result to
// an array
- var slides = toArray( dom.wrapper.querySelectorAll( selector ) ),
+ let slides = toArray( dom.wrapper.querySelectorAll( selector ) ),
slidesLength = slides.length;
- var printMode = isPrintingPDF();
+ let printMode = isPrintingPDF();
if( slidesLength ) {
@@ -3089,14 +3078,12 @@
// Enforce max and minimum index bounds
index = Math.max( Math.min( index, slidesLength - 1 ), 0 );
- for( var i = 0; i < slidesLength; i++ ) {
- var element = slides[i];
+ for( let i = 0; i < slidesLength; i++ ) {
+ let element = slides[i];
- var reverse = config.rtl && !isVerticalSlide( element );
+ let reverse = config.rtl && !isVerticalSlide( element );
- element.classList.remove( 'past' );
- element.classList.remove( 'present' );
- element.classList.remove( 'future' );
+ element.classList.remove( 'past', 'present', 'future' );
// http://www.w3.org/html/wg/drafts/html/master/editing.html#the-hidden-attribute
element.setAttribute( 'hidden', '' );
@@ -3119,7 +3106,7 @@
if( config.fragments ) {
// Show all fragments in prior slides
- toArray( element.querySelectorAll( '.fragment' ) ).forEach( function( fragment ) {
+ toArray( element.querySelectorAll( '.fragment' ) ).forEach( fragment => {
fragment.classList.add( 'visible' );
fragment.classList.remove( 'current-fragment' );
} );
@@ -3131,9 +3118,8 @@
if( config.fragments ) {
// Hide all fragments in future slides
- toArray( element.querySelectorAll( '.fragment.visible' ) ).forEach( function( fragment ) {
- fragment.classList.remove( 'visible' );
- fragment.classList.remove( 'current-fragment' );
+ toArray( element.querySelectorAll( '.fragment.visible' ) ).forEach( fragment => {
+ fragment.classList.remove( 'visible', 'current-fragment' );
} );
}
}
@@ -3146,7 +3132,7 @@
// If this slide has a state associated with it, add it
// onto the current state of the deck
- var slideState = slides[index].getAttribute( 'data-state' );
+ let slideState = slides[index].getAttribute( 'data-state' );
if( slideState ) {
state = state.concat( slideState.split( ' ' ) );
}
@@ -3170,7 +3156,7 @@
// Select all slides and convert the NodeList result to
// an array
- var horizontalSlides = toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) ),
+ let horizontalSlides = getHorizontalSlides(),
horizontalSlidesLength = horizontalSlides.length,
distanceX,
distanceY;
@@ -3179,7 +3165,7 @@
// The number of steps away from the present slide that will
// be visible
- var viewDistance = isOverview() ? 10 : config.viewDistance;
+ let viewDistance = isOverview() ? 10 : config.viewDistance;
// Shorten the view distance on devices that typically have
// less resources
@@ -3192,10 +3178,10 @@
viewDistance = Number.MAX_VALUE;
}
- for( var x = 0; x < horizontalSlidesLength; x++ ) {
- var horizontalSlide = horizontalSlides[x];
+ for( let x = 0; x < horizontalSlidesLength; x++ ) {
+ let horizontalSlide = horizontalSlides[x];
- var verticalSlides = toArray( horizontalSlide.querySelectorAll( 'section' ) ),
+ let verticalSlides = toArray( horizontalSlide.querySelectorAll( 'section' ) ),
verticalSlidesLength = verticalSlides.length;
// Determine how far away this slide is from the present
@@ -3217,10 +3203,10 @@
if( verticalSlidesLength ) {
- var oy = getPreviousVerticalIndex( horizontalSlide );
+ let oy = getPreviousVerticalIndex( horizontalSlide );
- for( var y = 0; y < verticalSlidesLength; y++ ) {
- var verticalSlide = verticalSlides[y];
+ for( let y = 0; y < verticalSlidesLength; y++ ) {
+ let verticalSlide = verticalSlides[y];
distanceY = x === ( indexh || 0 ) ? Math.abs( ( indexv || 0 ) - y ) : Math.abs( y - oy );
@@ -3329,13 +3315,10 @@
* Returns the HTML string corresponding to the current slide number,
* including formatting.
*/
- function getSlideNumber( slide ) {
+ function getSlideNumber( slide = currentSlide ) {
- var value;
- var format = 'h.v';
- if( slide === undefined ) {
- slide = currentSlide;
- }
+ let value;
+ let format = 'h.v';
if ( typeof config.slideNumber === 'function' ) {
value = config.slideNumber( slide );
@@ -3360,14 +3343,14 @@
value.push( getSlidePastCount( slide ) + 1, '/', getTotalSlides() );
break;
default:
- var indices = getIndices( slide );
+ let indices = getIndices( slide );
value.push( indices.h + 1 );
- var sep = format === 'h/v' ? '/' : '.';
+ let sep = format === 'h/v' ? '/' : '.';
if( isVerticalSlide( slide ) ) value.push( sep, indices.v + 1 );
}
}
- var url = '#' + locationHash( slide );
+ let url = '#' + locationHash( slide );
return formatSlideNumber( value[0], value[1], value[2], url );
}
@@ -3382,22 +3365,19 @@
* @param {HTMLElement} [url='#'+locationHash()] The url to link to
* @return {string} HTML string fragment
*/
- function formatSlideNumber( a, delimiter, b, url ) {
+ function formatSlideNumber( a, delimiter, b, url = '#' + locationHash() ) {
- if( url === undefined ) {
- url = '#' + locationHash();
- }
if( typeof b === 'number' && !isNaN( b ) ) {
- return '' +
- ''+ a +'' +
- ''+ delimiter +'' +
- ''+ b +'' +
- '';
+ return `
+ ${a}
+ ${delimiter}
+ ${b}
+ `;
}
else {
- return '' +
- ''+ a +'' +
- '';
+ return `
+ ${a}
+ `;
}
}
@@ -3407,48 +3387,43 @@
*/
function updateControls() {
- var routes = availableRoutes();
- var fragments = availableFragments();
+ let routes = availableRoutes();
+ let fragments = availableFragments();
// Remove the 'enabled' class from all directions
- dom.controlsLeft.concat( dom.controlsRight )
- .concat( dom.controlsUp )
- .concat( dom.controlsDown )
- .concat( dom.controlsPrev )
- .concat( dom.controlsNext ).forEach( function( node ) {
- node.classList.remove( 'enabled' );
- node.classList.remove( 'fragmented' );
+ [...dom.controlsLeft, ...dom.controlsRight, ...dom.controlsUp, ...dom.controlsDown, ...dom.controlsPrev, ...dom.controlsNext].forEach( node => {
+ node.classList.remove( 'enabled', 'fragmented' );
// Set 'disabled' attribute on all directions
node.setAttribute( 'disabled', 'disabled' );
} );
// Add the 'enabled' class to the available routes; remove 'disabled' attribute to enable buttons
- if( routes.left ) dom.controlsLeft.forEach( function( el ) { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } );
- if( routes.right ) dom.controlsRight.forEach( function( el ) { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } );
- if( routes.up ) dom.controlsUp.forEach( function( el ) { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } );
- if( routes.down ) dom.controlsDown.forEach( function( el ) { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } );
+ if( routes.left ) dom.controlsLeft.forEach( el => { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } );
+ if( routes.right ) dom.controlsRight.forEach( el => { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } );
+ if( routes.up ) dom.controlsUp.forEach( el => { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } );
+ if( routes.down ) dom.controlsDown.forEach( el => { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } );
// Prev/next buttons
- if( routes.left || routes.up ) dom.controlsPrev.forEach( function( el ) { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } );
- if( routes.right || routes.down ) dom.controlsNext.forEach( function( el ) { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } );
+ if( routes.left || routes.up ) dom.controlsPrev.forEach( el => { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } );
+ if( routes.right || routes.down ) dom.controlsNext.forEach( el => { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } );
// Highlight fragment directions
if( currentSlide ) {
// Always apply fragment decorator to prev/next buttons
- if( fragments.prev ) dom.controlsPrev.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } );
- if( fragments.next ) dom.controlsNext.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } );
+ if( fragments.prev ) dom.controlsPrev.forEach( el => { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } );
+ if( fragments.next ) dom.controlsNext.forEach( el => { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } );
// Apply fragment decorators to directional buttons based on
// what slide axis they are in
if( isVerticalSlide( currentSlide ) ) {
- if( fragments.prev ) dom.controlsUp.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } );
- if( fragments.next ) dom.controlsDown.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } );
+ if( fragments.prev ) dom.controlsUp.forEach( el => { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } );
+ if( fragments.next ) dom.controlsDown.forEach( el => { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } );
}
else {
- if( fragments.prev ) dom.controlsLeft.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } );
- if( fragments.next ) dom.controlsRight.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } );
+ if( fragments.prev ) dom.controlsLeft.forEach( el => { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } );
+ if( fragments.next ) dom.controlsRight.forEach( el => { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } );
}
}
@@ -3493,21 +3468,19 @@
* @param {boolean} includeAll If true, the backgrounds of
* all vertical slides (not just the present) will be updated.
*/
- function updateBackground( includeAll ) {
+ function updateBackground( includeAll = false ) {
- var currentBackground = null;
+ let currentBackground = null;
// Reverse past/future classes when in RTL mode
- var horizontalPast = config.rtl ? 'future' : 'past',
+ let horizontalPast = config.rtl ? 'future' : 'past',
horizontalFuture = config.rtl ? 'past' : 'future';
// Update the classes of all backgrounds to match the
// states of their slides (past/present/future)
- toArray( dom.background.childNodes ).forEach( function( backgroundh, h ) {
+ toArray( dom.background.childNodes ).forEach( ( backgroundh, h ) => {
- backgroundh.classList.remove( 'past' );
- backgroundh.classList.remove( 'present' );
- backgroundh.classList.remove( 'future' );
+ backgroundh.classList.remove( 'past', 'present', 'future' );
if( h < indexh ) {
backgroundh.classList.add( horizontalPast );
@@ -3523,11 +3496,9 @@
}
if( includeAll || h === indexh ) {
- toArray( backgroundh.querySelectorAll( '.slide-background' ) ).forEach( function( backgroundv, v ) {
+ toArray( backgroundh.querySelectorAll( '.slide-background' ) ).forEach( ( backgroundv, v ) => {
- backgroundv.classList.remove( 'past' );
- backgroundv.classList.remove( 'present' );
- backgroundv.classList.remove( 'future' );
+ backgroundv.classList.remove( 'past', 'present', 'future' );
if( v < indexv ) {
backgroundv.classList.add( 'past' );
@@ -3559,10 +3530,10 @@
startEmbeddedContent( currentBackground );
- var currentBackgroundContent = currentBackground.querySelector( '.slide-background-content' );
+ let currentBackgroundContent = currentBackground.querySelector( '.slide-background-content' );
if( currentBackgroundContent ) {
- var backgroundImageURL = currentBackgroundContent.style.backgroundImage || '';
+ let backgroundImageURL = currentBackgroundContent.style.backgroundImage || '';
// Restart GIFs (doesn't work in Firefox)
if( /\.gif/i.test( backgroundImageURL ) ) {
@@ -3575,8 +3546,8 @@
// Don't transition between identical backgrounds. This
// prevents unwanted flicker.
- var previousBackgroundHash = previousBackground ? previousBackground.getAttribute( 'data-background-hash' ) : null;
- var currentBackgroundHash = currentBackground.getAttribute( 'data-background-hash' );
+ let previousBackgroundHash = previousBackground ? previousBackground.getAttribute( 'data-background-hash' ) : null;
+ let currentBackgroundHash = currentBackground.getAttribute( 'data-background-hash' );
if( currentBackgroundHash && currentBackgroundHash === previousBackgroundHash && currentBackground !== previousBackground ) {
dom.background.classList.add( 'no-transition' );
}
@@ -3588,7 +3559,7 @@
// If there's a background brightness flag for this slide,
// bubble it to the .reveal container
if( currentSlide ) {
- [ 'has-light-background', 'has-dark-background' ].forEach( function( classToBubble ) {
+ [ 'has-light-background', 'has-dark-background' ].forEach( classToBubble => {
if( currentSlide.classList.contains( classToBubble ) ) {
dom.wrapper.classList.add( classToBubble );
}
@@ -3599,7 +3570,7 @@
}
// Allow the first background to apply without transition
- setTimeout( function() {
+ setTimeout( () => {
dom.background.classList.remove( 'no-transition' );
}, 1 );
@@ -3613,10 +3584,10 @@
if( config.parallaxBackgroundImage ) {
- var horizontalSlides = dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ),
- verticalSlides = dom.wrapper.querySelectorAll( VERTICAL_SLIDES_SELECTOR );
+ let horizontalSlides = getHorizontalSlides(),
+ verticalSlides = getVerticalSlides();
- var backgroundSize = dom.background.style.backgroundSize.split( ' ' ),
+ let backgroundSize = dom.background.style.backgroundSize.split( ' ' ),
backgroundWidth, backgroundHeight;
if( backgroundSize.length === 1 ) {
@@ -3627,7 +3598,7 @@
backgroundHeight = parseInt( backgroundSize[1], 10 );
}
- var slideWidth = dom.background.offsetWidth,
+ let slideWidth = dom.background.offsetWidth,
horizontalSlideCount = horizontalSlides.length,
horizontalOffsetMultiplier,
horizontalOffset;
@@ -3641,7 +3612,7 @@
horizontalOffset = horizontalOffsetMultiplier * indexh * -1;
- var slideHeight = dom.background.offsetHeight,
+ let slideHeight = dom.background.offsetHeight,
verticalSlideCount = verticalSlides.length,
verticalOffsetMultiplier,
verticalOffset;
@@ -3797,8 +3768,8 @@
let transform = [];
- if( translate ) transform.push( 'translate('+delta.x+'px, '+delta.y+'px)' );
- if( scale ) transform.push( 'scale('+delta.scaleX+','+delta.scaleY+')' );
+ if( translate ) transform.push( `translate(${delta.x}px, ${delta.y}px)` );
+ if( scale ) transform.push( `scale(${delta.scaleX}, ${delta.scaleY})` );
fromProps.styles['transform'] = transform.join( ' ' );
fromProps.styles['transform-origin'] = 'top left';
@@ -4195,7 +4166,7 @@
function shouldPreload( element ) {
// Prefer an explicit global preload setting
- var preload = config.preloadIframes;
+ let preload = config.preloadIframes;
// If no global setting is available, fall back on the element's
// own preload setting
@@ -4213,15 +4184,13 @@
*
* @param {HTMLElement} slide Slide to show
*/
- function loadSlide( slide, options ) {
-
- options = options || {};
+ function loadSlide( slide, options = {} ) {
// Show the slide element
slide.style.display = config.display;
// Media elements with data-src attributes
- toArray( slide.querySelectorAll( 'img[data-src], video[data-src], audio[data-src], iframe[data-src]' ) ).forEach( function( element ) {
+ toArray( slide.querySelectorAll( 'img[data-src], video[data-src], audio[data-src], iframe[data-src]' ) ).forEach( element => {
if( element.tagName !== 'IFRAME' || shouldPreload( element ) ) {
element.setAttribute( 'src', element.getAttribute( 'data-src' ) );
element.setAttribute( 'data-lazy-loaded', '' );
@@ -4230,10 +4199,10 @@
} );
// Media elements with