diff options
author | Hakim El Hattab <hakim.elhattab@gmail.com> | 2015-01-16 13:48:13 +0100 |
---|---|---|
committer | Hakim El Hattab <hakim.elhattab@gmail.com> | 2015-01-16 13:48:13 +0100 |
commit | 5fb81b1b3cb058f3a9bbd5f190a12e44b47b8df2 (patch) | |
tree | a2e2721a00efdbad8db52bb0d861a4a4bea9c9dc /js | |
parent | 817bb3bf43879009ae445e52d4b6ef88053c5583 (diff) | |
download | fosdem-2018-presentation-5fb81b1b3cb058f3a9bbd5f190a12e44b47b8df2.tar fosdem-2018-presentation-5fb81b1b3cb058f3a9bbd5f190a12e44b47b8df2.tar.gz |
support for custom slide number formatting #965
Diffstat (limited to 'js')
-rw-r--r-- | js/reveal.js | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/js/reveal.js b/js/reveal.js index 867dd15..3ee2cd0 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -2331,19 +2331,33 @@ /** * Updates the slide number div to reflect the current slide. + * + * Slide number format can be defined as a string using the + * following variables: + * h: current slide's horizontal index + * v: current slide's vertical index + * c: current slide index (flattened) + * t: total number of slides (flattened) */ function updateSlideNumber() { // Update slide number if enabled if( config.slideNumber && dom.slideNumber) { - // Display the number of the page using 'indexh - indexv' format - var indexString = indexh; - if( indexv > 0 ) { - indexString += ' - ' + indexv; + // Default to only showing the current slide number + var format = 'c'; + + // Check if a custom slide number format is available + if( typeof config.slideNumber === 'string' ) { + format = config.slideNumber; } - dom.slideNumber.innerHTML = indexString; + var totalSlides = getTotalSlides(); + + dom.slideNumber.innerHTML = format.replace( /h/g, indexh ) + .replace( /v/g, indexv ) + .replace( /c/g, Math.round( getProgress() * totalSlides ) + 1 ) + .replace( /t/g, totalSlides + 1 ); } } |