Merge pull request #2315 from dougalsutherland/slide-formats
allow custom slide numbering functions
This commit is contained in:
commit
d0337246f2
1 changed files with 32 additions and 24 deletions
56
js/reveal.js
56
js/reveal.js
|
@ -3269,40 +3269,48 @@
|
||||||
* "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';
|
||||||
|
|
||||||
// Check if a custom number format is available
|
if ( typeof config.slideNumber === 'function' ) {
|
||||||
if( typeof config.slideNumber === 'string' ) {
|
value = config.slideNumber();
|
||||||
format = 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
|
// If there are ONLY vertical slides in this deck, always use
|
||||||
// a flattened slide number
|
// a flattened slide number
|
||||||
if( !/c/.test( format ) && dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ).length === 1 ) {
|
if( !/c/.test( format ) && dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ).length === 1 ) {
|
||||||
format = 'c';
|
format = 'c';
|
||||||
}
|
}
|
||||||
|
|
||||||
switch( format ) {
|
value = [];
|
||||||
case 'c':
|
switch( format ) {
|
||||||
value.push( getSlidePastCount() + 1 );
|
case 'c':
|
||||||
break;
|
value.push( getSlidePastCount() + 1 );
|
||||||
case 'c/t':
|
break;
|
||||||
value.push( getSlidePastCount() + 1, '/', getTotalSlides() );
|
case 'c/t':
|
||||||
break;
|
value.push( getSlidePastCount() + 1, '/', getTotalSlides() );
|
||||||
case 'h/v':
|
break;
|
||||||
value.push( indexh + 1 );
|
case 'h/v':
|
||||||
if( isVerticalSlide() ) value.push( '/', indexv + 1 );
|
value.push( indexh + 1 );
|
||||||
break;
|
if( isVerticalSlide() ) value.push( '/', indexv + 1 );
|
||||||
default:
|
break;
|
||||||
value.push( indexh + 1 );
|
default:
|
||||||
if( isVerticalSlide() ) value.push( '.', indexv + 1 );
|
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] );
|
||||||
|
|
Loading…
Reference in a new issue