function unnest( $columns ) {
    var queue = [],
        $node;

    // Push the root unordered list item into the queue.
    queue.push( $columns.children() );

    while( queue.length ) {
      $node = queue.shift();

      $node.children().each( function( item, el ) {
        var $child = $(this).children(),
            $ancestor = $(this).parent().parent();

        // Retain item hierarchy (because it is lost after flattening).
        if( $ancestor.length && ($(this).data( "ancestor" ) === undefined) ) {
          // Use addBack to reset all selection chains.
          $(this).siblings().addBack().data( "ancestor", $ancestor );
        }

        if( $child.length > 0 ) {
          queue.push( $child );
          $(this).data( "child", $child ).addClass( "parent" );
        }

        // Causes item siblings to have a flattened DOM lineage.
        $(this).parent().appendTo( $columns ).addClass( "column" );
      });
    }
  }
/** Convert nested lists into columns using breadth-first traversal. */
Convert nested lists into columns using breadth-first traversal.
Convert nested lists into columns using breadth - first traversal .
function unnest( $columns ) {
    var queue = [],
        $node;
    queue.push( $columns.children() );
    while( queue.length ) {
      $node = queue.shift();
      $node.children().each( function( item, el ) {
        var $child = $(this).children(),
            $ancestor = $(this).parent().parent();
        if( $ancestor.length && ($(this).data( "ancestor" ) === undefined) ) {
          $(this).siblings().addBack().data( "ancestor", $ancestor );
        }
        if( $child.length > 0 ) {
          queue.push( $child );
          $(this).data( "child", $child ).addClass( "parent" );
        }
        $(this).parent().appendTo( $columns ).addClass( "column" );
      });
    }
  }
function unnest ( $columns ) { var queue = [ ] , $node ; queue . push ( $columns . children ( ) ) ; while ( queue . length ) { $node = queue . shift ( ) ; $node . children ( ) . each ( function ( item , el ) { var $child = $ ( this ) . children ( ) , $ancestor = $ ( this ) . parent ( ) . parent ( ) ; if ( $ancestor . length && ( $ ( this ) . data ( "ancestor" ) === undefined ) ) { $ ( this ) . siblings ( ) . addBack ( ) . data ( "ancestor" , $ancestor ) ; } if ( $child . length > 0 ) { queue . push ( $child ) ; $ ( this ) . data ( "child" , $child ) . addClass ( "parent" ) ; } $ ( this ) . parent ( ) . appendTo ( $columns ) . addClass ( "column" ) ; } ) ; } }
Convert nested lists into columns using breadth-first traversal.
Convert nested lists into columns using breadth - first traversal .
// Push the root unordered list item into the queue. // Retain item hierarchy (because it is lost after flattening). // Use addBack to reset all selection chains. // Causes item siblings to have a flattened DOM lineage.