one more slide number format

This commit is contained in:
Hakim El Hattab 2015-10-29 12:39:51 +01:00
parent 0e779edb20
commit 42babeb4ef
2 changed files with 20 additions and 16 deletions

View file

@ -611,7 +611,8 @@ If you would like to display the page number of the current slide you can do so
Reveal.configure({ slideNumber: true }); Reveal.configure({ slideNumber: true });
// Slide number formatting can be configured using these variables: // Slide number formatting can be configured using these variables:
// "h/v": horizontal and vertical slide numbers (default) // "h.v": horizontal . vertical slide number (default)
// "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
Reveal.configure({ slideNumber: 'c/t' }); Reveal.configure({ slideNumber: 'c/t' });

View file

@ -609,7 +609,7 @@
var numberElement = document.createElement( 'div' ); var numberElement = document.createElement( 'div' );
numberElement.classList.add( 'slide-number' ); numberElement.classList.add( 'slide-number' );
numberElement.classList.add( 'slide-number-pdf' ); numberElement.classList.add( 'slide-number-pdf' );
numberElement.innerHTML = formatSlideNumber( slideNumberH, '/', slideNumberV ); numberElement.innerHTML = formatSlideNumber( slideNumberH, '.', slideNumberV );
background.appendChild( numberElement ); background.appendChild( numberElement );
} }
} }
@ -2538,7 +2538,8 @@
* Updates the slide number div to reflect the current slide. * Updates the slide number div to reflect the current slide.
* *
* The following slide number formats are available: * The following slide number formats are available:
* "h/v": horizontal and vertical slide numbers (default) * "h.v": horizontal . vertical slide number (default)
* "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
*/ */
@ -2548,25 +2549,27 @@
if( config.slideNumber && dom.slideNumber) { if( config.slideNumber && dom.slideNumber) {
var value = []; var value = [];
var format = 'h/v'; var format = 'h.v';
// 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;
} }
if( format === 'c' ) { switch( format ) {
case 'c':
value.push( getSlidePastCount() + 1 ); value.push( getSlidePastCount() + 1 );
} break;
else if( format === 'c/t' ) { case 'c/t':
value.push( getSlidePastCount() + 1, '/', getTotalSlides() ); value.push( getSlidePastCount() + 1, '/', getTotalSlides() );
} break;
else { case 'h/v':
value.push( indexh + 1 ); value.push( indexh + 1 );
if( isVerticalSlide() ) value.push( '/', indexv + 1 );
if( isVerticalSlide() ) { break;
value.push( '/', indexv + 1 ); default:
} value.push( indexh + 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] );