public/js/app.js
//open / close a branch of the tree
open / close a branch of the tree
open / close a branch of the tree
function toggleNodeNav(d, i) {
      var depth = d.depth;
      console.log("?", depth);
      var open = (d._children) ? true : false;
      function toggleChildren (node){
        if(((!open && node.depth >= depth) ||(open && node.depth > depth +1) ) && node.children){
          node._children = node.children;
          node.children = null;
        }else if(((open && node.depth <= depth) ) && node._children){
          node.children = node._children;
          node._children = null;
        }
      }
      function toggleAllChildren (node){
        var children = node.children || node._children;
        if(children){
          for (var i = 0; i < children.length; i++){
            toggleChildren(children[i]);
            toggleAllChildren(children[i]);
          }
        }
      }
      toggleAllChildren(this.root);
     this.render(this.root)
    }
function toggleNodeNav ( d , i ) { var depth = d . depth ; console . log ( "?" , depth ) ; var open = ( d . _children ) ? true : false ; function toggleChildren ( node ) { if ( ( ( ! open && node . depth >= depth ) || ( open && node . depth > depth + 1 ) ) && node . children ) { node . _children = node . children ; node . children = null ; } else if ( ( ( open && node . depth <= depth ) ) && node . _children ) { node . children = node . _children ; node . _children = null ; } } function toggleAllChildren ( node ) { var children = node . children || node . _children ; if ( children ) { for ( var i = 0 ; i < children . length ; i ++ ) { toggleChildren ( children [ i ] ) ; toggleAllChildren ( children [ i ] ) ; } } } toggleAllChildren ( this . root ) ; this . render ( this . root ) }
open / close a branch of the tree
open / close a branch of the tree
//open all nodes //goes through all children //