diff options
author | Hakim El Hattab <hakim.elhattab@gmail.com> | 2013-11-25 15:40:24 -0500 |
---|---|---|
committer | Hakim El Hattab <hakim.elhattab@gmail.com> | 2013-11-25 15:40:24 -0500 |
commit | d41a5ca87f56f922e5ab227ab4c51667d103dcdf (patch) | |
tree | 29643a56501d9650c3068438591d2e15ad401c2e /js/reveal.js | |
parent | 0fcff33a619c4d55a162be4325c8e22f34b0c57c (diff) | |
download | perl-software-in-gnu-guix-d41a5ca87f56f922e5ab227ab4c51667d103dcdf.tar perl-software-in-gnu-guix-d41a5ca87f56f922e5ab227ab4c51667d103dcdf.tar.gz |
update future classes when syncing
Diffstat (limited to 'js/reveal.js')
-rw-r--r-- | js/reveal.js | 174 |
1 files changed, 88 insertions, 86 deletions
diff --git a/js/reveal.js b/js/reveal.js index 14d5693..dc43a40 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -305,7 +305,7 @@ var Reveal = (function(){ setupDOM(); // Decorate the slide DOM elements with state classes (past/future) - setupSlides(); + formatSlides(); // Updates the presentation to match the current configuration values configure(); @@ -334,30 +334,6 @@ var Reveal = (function(){ } /** - * Iterates through and decorates slides DOM elements with - * appropriate classes. - */ - function setupSlides() { - - var horizontalSlides = toArray( document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) ); - horizontalSlides.forEach( function( horizontalSlide ) { - - var verticalSlides = toArray( horizontalSlide.querySelectorAll( 'section' ) ); - verticalSlides.forEach( function( verticalSlide, y ) { - - if( y > 0 ) verticalSlide.classList.add( 'future' ); - - sortFragments( verticalSlide.querySelectorAll( '.fragment' ) ); - - } ); - - if( verticalSlides.length === 0 ) sortFragments( horizontalSlide.querySelectorAll( '.fragment' ) ); - - } ); - - } - - /** * Finds and stores references to DOM elements which are * required by the presentation. If a required element is * not found, it is created. @@ -1032,67 +1008,6 @@ var Reveal = (function(){ } /** - * Return a sorted fragments list, ordered by an increasing - * "data-fragment-index" attribute. - * - * Fragments will be revealed in the order that they are returned by - * this function, so you can use the index attributes to control the - * order of fragment appearance. - * - * To maintain a sensible default fragment order, fragments are presumed - * to be passed in document order. This function adds a "fragment-index" - * attribute to each node if such an attribute is not already present, - * and sets that attribute to an integer value which is the position of - * the fragment within the fragments list. - */ - function sortFragments( fragments ) { - - fragments = toArray( fragments ); - - var ordered = [], - unordered = [], - sorted = []; - - // Group ordered and unordered elements - fragments.forEach( function( fragment, i ) { - if( fragment.hasAttribute( 'data-fragment-index' ) ) { - var index = parseInt( fragment.getAttribute( 'data-fragment-index' ), 10 ); - - if( !ordered[index] ) { - ordered[index] = []; - } - - ordered[index].push( fragment ); - } - else { - unordered.push( [ fragment ] ); - } - } ); - - // Append fragments without explicit indices in their - // DOM order - ordered = ordered.concat( unordered ); - - // Manually count the index up per group to ensure there - // are no gaps - var index = 0; - - // Push all fragments in their sorted order to an array, - // this flattens the groups - ordered.forEach( function( group ) { - group.forEach( function( fragment ) { - sorted.push( fragment ); - fragment.setAttribute( 'data-fragment-index', index ); - } ); - - index ++; - } ); - - return sorted; - - } - - /** * Applies JavaScript-controlled layout rules to the * presentation. */ @@ -1676,6 +1591,8 @@ var Reveal = (function(){ // Re-create the slide backgrounds createBackgrounds(); + formatSlides(); + updateControls(); updateProgress(); updateBackground( true ); @@ -1684,6 +1601,30 @@ var Reveal = (function(){ } /** + * Iterates through and decorates slides DOM elements with + * appropriate classes. + */ + function formatSlides() { + + var horizontalSlides = toArray( document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) ); + horizontalSlides.forEach( function( horizontalSlide ) { + + var verticalSlides = toArray( horizontalSlide.querySelectorAll( 'section' ) ); + verticalSlides.forEach( function( verticalSlide, y ) { + + if( y > 0 ) verticalSlide.classList.add( 'future' ); + + sortFragments( verticalSlide.querySelectorAll( '.fragment' ) ); + + } ); + + if( verticalSlides.length === 0 ) sortFragments( horizontalSlide.querySelectorAll( '.fragment' ) ); + + } ); + + } + + /** * Updates one dimension of slides by showing the slide * with the specified index. * @@ -2307,6 +2248,67 @@ var Reveal = (function(){ } /** + * Return a sorted fragments list, ordered by an increasing + * "data-fragment-index" attribute. + * + * Fragments will be revealed in the order that they are returned by + * this function, so you can use the index attributes to control the + * order of fragment appearance. + * + * To maintain a sensible default fragment order, fragments are presumed + * to be passed in document order. This function adds a "fragment-index" + * attribute to each node if such an attribute is not already present, + * and sets that attribute to an integer value which is the position of + * the fragment within the fragments list. + */ + function sortFragments( fragments ) { + + fragments = toArray( fragments ); + + var ordered = [], + unordered = [], + sorted = []; + + // Group ordered and unordered elements + fragments.forEach( function( fragment, i ) { + if( fragment.hasAttribute( 'data-fragment-index' ) ) { + var index = parseInt( fragment.getAttribute( 'data-fragment-index' ), 10 ); + + if( !ordered[index] ) { + ordered[index] = []; + } + + ordered[index].push( fragment ); + } + else { + unordered.push( [ fragment ] ); + } + } ); + + // Append fragments without explicit indices in their + // DOM order + ordered = ordered.concat( unordered ); + + // Manually count the index up per group to ensure there + // are no gaps + var index = 0; + + // Push all fragments in their sorted order to an array, + // this flattens the groups + ordered.forEach( function( group ) { + group.forEach( function( fragment ) { + sorted.push( fragment ); + fragment.setAttribute( 'data-fragment-index', index ); + } ); + + index ++; + } ); + + return sorted; + + } + + /** * Navigate to the specified slide fragment. * * @param {Number} index The index of the fragment that |