FIX: indent level of sort_fragments

This commit is contained in:
James Bergstra 2013-02-21 13:16:26 -05:00
parent c00de0a24d
commit e4016792dd
1 changed files with 25 additions and 24 deletions

View File

@ -138,30 +138,31 @@ var Reveal = (function(){
handled: false, handled: false,
threshold: 80 threshold: 80
}; };
/**
* Return a sorted fragments list, ordered by an increasing "fragment-pos" attribute. /**
* * Return a sorted fragments list, ordered by an increasing "fragment-pos" attribute.
* Fragments will be revealed in the order that they are returned by *
* this function, so you can use "fragment-pos" attributes to control * Fragments will be revealed in the order that they are returned by
* the order of fragment appearance. * this function, so you can use "fragment-pos" 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-pos" * To maintain a sensible default fragment order, fragments are presumed
* attribute to each node if such an attribute is not already present, * to be passed in document order. This function adds a "fragment-pos"
* and sets that attribute to an integer value which is the position of * attribute to each node if such an attribute is not already present,
* the fragment within the fragments list. * and sets that attribute to an integer value which is the position of
* * the fragment within the fragments list.
*/ *
function sort_fragments( fragments ) { */
var a = toArray(fragments) function sort_fragments( fragments ) {
a.forEach( function (el, idx) { var a = toArray(fragments)
if (!el.hasAttribute('fragment-pos')) { a.forEach( function (el, idx) {
el.setAttribute('fragment-pos', idx) }}) if (!el.hasAttribute('fragment-pos')) {
a.sort(function(l, r) { el.setAttribute('fragment-pos', idx) }})
return l.getAttribute( 'fragment-pos' ) a.sort(function(l, r) {
- r.getAttribute( 'fragment-pos') }) return l.getAttribute( 'fragment-pos' )
return a - r.getAttribute( 'fragment-pos') })
} return a
}
/** /**
* Starts up the presentation if the client is capable. * Starts up the presentation if the client is capable.