Merge pull request #2315 from dougalsutherland/slide-formats

allow custom slide numbering functions
This commit is contained in:
Hakim El Hattab 2019-02-01 09:49:39 +01:00 committed by GitHub
commit d0337246f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3269,15 +3269,21 @@
* "h/v": horizontal / vertical slide number * "h/v": horizontal / vertical slide number
* "c": flattened slide number * "c": flattened slide number
* "c/t": flattened slide number / total slides * "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() { function updateSlideNumber() {
// Update slide number if enabled // Update slide number if enabled
if( config.slideNumber && dom.slideNumber ) { if( config.slideNumber && dom.slideNumber ) {
var value = []; var value;
var format = 'h.v'; var format = 'h.v';
if ( typeof config.slideNumber === 'function' ) {
value = config.slideNumber();
} else {
// Check if a custom number format is available // Check if a custom number format is available
if( typeof config.slideNumber === 'string' ) { if( typeof config.slideNumber === 'string' ) {
format = config.slideNumber; format = config.slideNumber;
@ -3289,6 +3295,7 @@
format = 'c'; format = 'c';
} }
value = [];
switch( format ) { switch( format ) {
case 'c': case 'c':
value.push( getSlidePastCount() + 1 ); value.push( getSlidePastCount() + 1 );
@ -3304,6 +3311,7 @@
value.push( indexh + 1 ); value.push( indexh + 1 );
if( isVerticalSlide() ) value.push( '.', indexv + 1 ); if( isVerticalSlide() ) value.push( '.', indexv + 1 );
} }
}
dom.slideNumber.innerHTML = formatSlideNumber( value[0], value[1], value[2] ); dom.slideNumber.innerHTML = formatSlideNumber( value[0], value[1], value[2] );
} }