diff options
author | Hakim El Hattab <hakim.elhattab@gmail.com> | 2019-02-01 09:49:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-01 09:49:39 +0100 |
commit | d0337246f2a9f3a185af1a2f4fa8fcd20323174e (patch) | |
tree | f379f2d82b0653648271873f3d58d6fdf83edaa6 | |
parent | 2a9edd23e69ee63a8a4f85a273508114777fad2e (diff) | |
parent | 43d1c711078c94253770b3656b97dc67fc85f4c7 (diff) | |
download | perl-software-in-gnu-guix-d0337246f2a9f3a185af1a2f4fa8fcd20323174e.tar perl-software-in-gnu-guix-d0337246f2a9f3a185af1a2f4fa8fcd20323174e.tar.gz |
Merge pull request #2315 from dougalsutherland/slide-formats
allow custom slide numbering functions
-rw-r--r-- | js/reveal.js | 60 |
1 files changed, 34 insertions, 26 deletions
diff --git a/js/reveal.js b/js/reveal.js index 8e5d24f..8feb45d 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -3269,40 +3269,48 @@ * "h/v": horizontal / vertical slide number * "c": flattened slide number * "c/t": flattened slide number / total slides + * + * Alternatively, config.slideNumber can be a function returning a + * three-element array with arguments to formatSlideNumber(). */ function updateSlideNumber() { // Update slide number if enabled if( config.slideNumber && dom.slideNumber ) { - var value = []; + var value; var format = 'h.v'; - // Check if a custom number format is available - if( typeof config.slideNumber === 'string' ) { - format = config.slideNumber; - } - - // If there are ONLY vertical slides in this deck, always use - // a flattened slide number - if( !/c/.test( format ) && dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ).length === 1 ) { - format = 'c'; - } - - switch( format ) { - case 'c': - value.push( getSlidePastCount() + 1 ); - break; - case 'c/t': - value.push( getSlidePastCount() + 1, '/', getTotalSlides() ); - break; - case 'h/v': - value.push( indexh + 1 ); - if( isVerticalSlide() ) value.push( '/', indexv + 1 ); - break; - default: - value.push( indexh + 1 ); - if( isVerticalSlide() ) value.push( '.', indexv + 1 ); + if ( typeof config.slideNumber === 'function' ) { + value = config.slideNumber(); + } else { + // Check if a custom number format is available + if( typeof config.slideNumber === 'string' ) { + format = config.slideNumber; + } + + // If there are ONLY vertical slides in this deck, always use + // a flattened slide number + if( !/c/.test( format ) && dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ).length === 1 ) { + format = 'c'; + } + + value = []; + switch( format ) { + case 'c': + value.push( getSlidePastCount() + 1 ); + break; + case 'c/t': + value.push( getSlidePastCount() + 1, '/', getTotalSlides() ); + break; + case 'h/v': + value.push( indexh + 1 ); + if( isVerticalSlide() ) value.push( '/', indexv + 1 ); + break; + default: + value.push( indexh + 1 ); + if( isVerticalSlide() ) value.push( '.', indexv + 1 ); + } } dom.slideNumber.innerHTML = formatSlideNumber( value[0], value[1], value[2] ); |