app/js/views/navTree.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) {
    function toggleChildren(node, open) {
      if (!open && node.children) {
        node._children = node.children;
        node.children = null;
      } else if (open && node._children) {
        node.children = node._children;
        node._children = null;
      }
    }
    function openAllChildren(node) {
      var children = node.children || node._children;
      if (children) {
        for (var i = 0; i < children.length; i++) {
          toggleChildren(children[i], true);
          openAllChildren(children[i]);
        }
      }
    }
    openAllChildren(this.root);
    function closeSiblings(node) {
      if (!node.parent) return;
      var siblings = node.parent.children;
      for (var i = 0; i < siblings.length; i++) {
        if (siblings[i].uri !== node.uri) {
          toggleChildren(siblings[i], false);
        }
      }
      closeSiblings(node.parent);
    }
    closeSiblings(d);
    this.render(this.root);
  }
function toggleNodeNav ( d ) { function toggleChildren ( node , open ) { if ( ! open && node . children ) { node . _children = node . children ; node . children = null ; } else if ( open && node . _children ) { node . children = node . _children ; node . _children = null ; } } function openAllChildren ( node ) { var children = node . children || node . _children ; if ( children ) { for ( var i = 0 ; i < children . length ; i ++ ) { toggleChildren ( children [ i ] , true ) ; openAllChildren ( children [ i ] ) ; } } } openAllChildren ( this . root ) ; function closeSiblings ( node ) { if ( ! node . parent ) return ; var siblings = node . parent . children ; for ( var i = 0 ; i < siblings . length ; i ++ ) { if ( siblings [ i ] . uri !== node . uri ) { toggleChildren ( siblings [ i ] , false ) ; } } closeSiblings ( node . parent ) ; } closeSiblings ( d ) ; this . render ( this . root ) ; }
open / close a branch of the tree
open / close a branch of the tree
//console.log(d); //open all nodes //console.log(node,open) //open all children //console.log("element",node.children[i]); //