|
@@ -77,9 +77,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
slideNumber: false,
|
|
|
|
|
|
|
|
@@ -855,17 +855,10 @@
|
|
|
|
|
|
layoutSlideContents( slideWidth, slideHeight );
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) ).forEach( function( hslide, h ) {
|
|
|
- hslide.setAttribute( 'data-index-h', h );
|
|
|
-
|
|
|
- if( hslide.classList.contains( 'stack' ) ) {
|
|
|
- toArray( hslide.querySelectorAll( 'section' ) ).forEach( function( vslide, v ) {
|
|
|
- vslide.setAttribute( 'data-index-h', h );
|
|
|
- vslide.setAttribute( 'data-index-v', v );
|
|
|
- } );
|
|
|
- }
|
|
|
+
|
|
|
+ var doingSlideNumbers = config.slideNumber && /all|print/i.test( config.showSlideNumber );
|
|
|
+ toArray( dom.wrapper.querySelectorAll( SLIDES_SELECTOR ) ).forEach( function( slide ) {
|
|
|
+ slide.setAttribute( 'data-slide-number', getSlideNumber( slide ) );
|
|
|
} );
|
|
|
|
|
|
|
|
@@ -936,14 +929,11 @@
|
|
|
}
|
|
|
|
|
|
|
|
|
- if( config.slideNumber && /all|print/i.test( config.showSlideNumber ) ) {
|
|
|
- var slideNumberH = parseInt( slide.getAttribute( 'data-index-h' ), 10 ) + 1,
|
|
|
- slideNumberV = parseInt( slide.getAttribute( 'data-index-v' ), 10 ) + 1;
|
|
|
-
|
|
|
+ if( doingSlideNumbers ) {
|
|
|
var numberElement = document.createElement( 'div' );
|
|
|
numberElement.classList.add( 'slide-number' );
|
|
|
numberElement.classList.add( 'slide-number-pdf' );
|
|
|
- numberElement.innerHTML = formatSlideNumber( slideNumberH, '.', slideNumberV );
|
|
|
+ numberElement.innerHTML = slide.getAttribute( 'data-slide-number' );
|
|
|
page.appendChild( numberElement );
|
|
|
}
|
|
|
|
|
@@ -2657,34 +2647,37 @@
|
|
|
}
|
|
|
|
|
|
|
|
|
- * Return a hash URL that will resolve to the current slide location.
|
|
|
+ * Return a hash URL that will resolve to the given slide location.
|
|
|
+ *
|
|
|
+ * @param {HTMLElement} [slide=currentSlide] The slide to link to
|
|
|
*/
|
|
|
- function locationHash() {
|
|
|
+ function locationHash( slide ) {
|
|
|
|
|
|
var url = '/';
|
|
|
|
|
|
|
|
|
- var id = currentSlide ? currentSlide.getAttribute( 'id' ) : null;
|
|
|
+ var s = slide || currentSlide;
|
|
|
+ var id = s ? s.getAttribute( 'id' ) : null;
|
|
|
if( id ) {
|
|
|
id = encodeURIComponent( id );
|
|
|
}
|
|
|
|
|
|
- var indexf;
|
|
|
- if( config.fragmentInURL ) {
|
|
|
- indexf = getIndices().f;
|
|
|
+ var index = getIndices( slide );
|
|
|
+ if( !config.fragmentInURL ) {
|
|
|
+ index.f = undefined;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- if( typeof id === 'string' && id.length && indexf === undefined ) {
|
|
|
+ if( typeof id === 'string' && id.length && index.f === undefined ) {
|
|
|
url = '/' + id;
|
|
|
}
|
|
|
|
|
|
else {
|
|
|
var hashIndexBase = config.hashOneBasedIndex ? 1 : 0;
|
|
|
- if( indexh > 0 || indexv > 0 || indexf !== undefined ) url += indexh + hashIndexBase;
|
|
|
- if( indexv > 0 || indexf !== undefined ) url += '/' + (indexv + hashIndexBase );
|
|
|
- if( indexf !== undefined ) url += '/' + indexf;
|
|
|
+ if( index.h > 0 || index.v > 0 || index.f !== undefined ) url += index.h + hashIndexBase;
|
|
|
+ if( index.v > 0 || index.f !== undefined ) url += '/' + (index.v + hashIndexBase );
|
|
|
+ if( index.f !== undefined ) url += '/' + index.f;
|
|
|
}
|
|
|
|
|
|
return url;
|
|
@@ -3428,46 +3421,56 @@
|
|
|
|
|
|
|
|
|
if( config.slideNumber && dom.slideNumber ) {
|
|
|
+ dom.slideNumber.innerHTML = getSlideNumber();
|
|
|
+ }
|
|
|
|
|
|
- var value;
|
|
|
- var format = 'h.v';
|
|
|
+ }
|
|
|
|
|
|
- if( typeof config.slideNumber === 'function' ) {
|
|
|
- value = config.slideNumber();
|
|
|
- }
|
|
|
- else {
|
|
|
-
|
|
|
- if( typeof config.slideNumber === 'string' ) {
|
|
|
- format = config.slideNumber;
|
|
|
- }
|
|
|
+
|
|
|
+ * Returns the HTML string corresponding to the current slide number,
|
|
|
+ * including formatting.
|
|
|
+ */
|
|
|
+ function getSlideNumber( slide ) {
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- if( !/c/.test( format ) && dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ).length === 1 ) {
|
|
|
- format = 'c';
|
|
|
- }
|
|
|
+ var value;
|
|
|
+ var format = 'h.v';
|
|
|
+ if( slide === undefined ) {
|
|
|
+ slide = currentSlide;
|
|
|
+ }
|
|
|
|
|
|
- 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 );
|
|
|
- }
|
|
|
+ if ( typeof config.slideNumber === 'function' ) {
|
|
|
+ value = config.slideNumber( slide );
|
|
|
+ } else {
|
|
|
+
|
|
|
+ if( typeof config.slideNumber === 'string' ) {
|
|
|
+ format = config.slideNumber;
|
|
|
}
|
|
|
|
|
|
- dom.slideNumber.innerHTML = formatSlideNumber( value[0], value[1], value[2] );
|
|
|
+
|
|
|
+
|
|
|
+ if( !/c/.test( format ) && dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ).length === 1 ) {
|
|
|
+ format = 'c';
|
|
|
+ }
|
|
|
+
|
|
|
+ value = [];
|
|
|
+ switch( format ) {
|
|
|
+ case 'c':
|
|
|
+ value.push( getSlidePastCount( slide ) + 1 );
|
|
|
+ break;
|
|
|
+ case 'c/t':
|
|
|
+ value.push( getSlidePastCount( slide ) + 1, '/', getTotalSlides() );
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ var indices = getIndices( slide );
|
|
|
+ value.push( indices.h + 1 );
|
|
|
+ var sep = format === 'h/v' ? '/' : '.';
|
|
|
+ if( isVerticalSlide( slide ) ) value.push( sep, indices.v + 1 );
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ var url = '#' + locationHash( slide );
|
|
|
+ return formatSlideNumber( value[0], value[1], value[2], url );
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -3477,11 +3480,14 @@
|
|
|
* @param {number} a Current slide
|
|
|
* @param {string} delimiter Character to separate slide numbers
|
|
|
* @param {(number|*)} b Total slides
|
|
|
+ * @param {HTMLElement} [url='#'+locationHash()] The url to link to
|
|
|
* @return {string} HTML string fragment
|
|
|
*/
|
|
|
- function formatSlideNumber( a, delimiter, b ) {
|
|
|
+ function formatSlideNumber( a, delimiter, b, url ) {
|
|
|
|
|
|
- var url = '#' + locationHash();
|
|
|
+ if( url === undefined ) {
|
|
|
+ url = '#' + locationHash();
|
|
|
+ }
|
|
|
if( typeof b === 'number' && !isNaN( b ) ) {
|
|
|
return '<a href="' + url + '">' +
|
|
|
'<span class="slide-number-a">'+ a +'</span>' +
|
|
@@ -4232,9 +4238,15 @@
|
|
|
* Returns the number of past slides. This can be used as a global
|
|
|
* flattened index for slides.
|
|
|
*
|
|
|
+ * @param {HTMLElement} [slide=currentSlide] The slide we're counting before
|
|
|
+ *
|
|
|
* @return {number} Past slide count
|
|
|
*/
|
|
|
- function getSlidePastCount() {
|
|
|
+ function getSlidePastCount( slide ) {
|
|
|
+
|
|
|
+ if( slide === undefined ) {
|
|
|
+ slide = currentSlide;
|
|
|
+ }
|
|
|
|
|
|
var horizontalSlides = toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) );
|
|
|
|
|
@@ -4250,7 +4262,7 @@
|
|
|
for( var j = 0; j < verticalSlides.length; j++ ) {
|
|
|
|
|
|
|
|
|
- if( verticalSlides[j].classList.contains( 'present' ) ) {
|
|
|
+ if( verticalSlides[j] === slide ) {
|
|
|
break mainLoop;
|
|
|
}
|
|
|
|
|
@@ -4259,7 +4271,7 @@
|
|
|
}
|
|
|
|
|
|
|
|
|
- if( horizontalSlide.classList.contains( 'present' ) ) {
|
|
|
+ if( horizontalSlide === slide ) {
|
|
|
break;
|
|
|
}
|
|
|
|