diff options
author | Hakim El Hattab <hakim.elhattab@gmail.com> | 2018-06-11 12:16:41 +0200 |
---|---|---|
committer | Hakim El Hattab <hakim.elhattab@gmail.com> | 2018-06-11 12:16:41 +0200 |
commit | a86146180f62f38ccbdc9da68fd38ebee5da074a (patch) | |
tree | 6e0f3105aac41722aa1f67a51c60f7252c0b52ce /js | |
parent | a9e95e7e6c033d6232416b2ae0cbc40844adafc2 (diff) | |
parent | 08e0f5e47b73d01f5afa82e79b9046a2a694855d (diff) | |
download | perl-software-in-gnu-guix-a86146180f62f38ccbdc9da68fd38ebee5da074a.tar perl-software-in-gnu-guix-a86146180f62f38ccbdc9da68fd38ebee5da074a.tar.gz |
Merge branch 'master' of https://github.com/koehlma/reveal.js into dev
Diffstat (limited to 'js')
-rw-r--r-- | js/reveal.js | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/js/reveal.js b/js/reveal.js index ed9db7b..926b1d9 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -787,14 +787,39 @@ numberElement.innerHTML = formatSlideNumber( slideNumberH, '.', slideNumberV ); page.appendChild( numberElement ); } + + // Copy page and show fragments one after another + if ( isPrintingPDFFragments() ) { + + var numberOfFragments = toArray( page.querySelectorAll( '.fragment' ) ).length; + + for ( var currentFragment = 0; currentFragment < numberOfFragments; currentFragment++ ) { + var clonedPage = page.cloneNode( true ); + page.parentNode.insertBefore( clonedPage, page.nextSibling ); + + toArray( sortFragments( clonedPage.querySelectorAll( '.fragment' ))).forEach( function ( fragment, fragmentIndex ) { + if ( fragmentIndex <= currentFragment ) { + fragment.classList.add( 'visible' ); + } else { + fragment.classList.remove( 'visible' ); + } + } ); + + page = clonedPage; + } + + } + // Show all fragments + else { + toArray( page.querySelectorAll( '.fragment' ) ).forEach( function( fragment ) { + fragment.classList.add( 'visible' ); + } ); + } + } } ); - // Show all fragments - toArray( dom.wrapper.querySelectorAll( SLIDES_SELECTOR + ' .fragment' ) ).forEach( function( fragment ) { - fragment.classList.add( 'visible' ); - } ); // Notify subscribers that the PDF layout is good to go dispatchEvent( 'pdf-ready' ); @@ -1638,6 +1663,15 @@ } /** + * Check if this instance is being used to print a PDF with fragments. + */ + function isPrintingPDFFragments() { + + return ( /print-pdf-fragments/gi ).test( window.location.search ); + + } + + /** * Hides the address bar if we're on a mobile device. */ function hideAddressBar() { |