MCPcopy Index your code
hub / github.com/angular-ui-tree/angular-ui-tree / countSubTreeDepth

Function countSubTreeDepth

source/controllers/nodeCtrl.js:126–144  ·  view source on GitHub ↗

* Returns the depth of the deepest subtree under this node * @param scope a TreeNodesController scope object * @returns Depth of all nodes *beneath* this node. If scope belongs to a leaf node, the * result is 0 (it has no subtree).

(scope)

Source from the content-addressed store, hash-verified

124 * result is 0 (it has no subtree).
125 */
126 function countSubTreeDepth(scope) {
127 if (!scope) {
128 return 0;
129 }
130 var thisLevelDepth = 0,
131 childNodes = scope.childNodes(),
132 childNode,
133 childDepth,
134 i;
135 if (!childNodes || childNodes.length === 0) {
136 return 0;
137 }
138 for (i = childNodes.length - 1; i >= 0 ; i--) {
139 childNode = childNodes[i],
140 childDepth = 1 + countSubTreeDepth(childNode);
141 thisLevelDepth = Math.max(thisLevelDepth, childDepth);
142 }
143 return thisLevelDepth;
144 }
145
146 $scope.maxSubDepth = function () {
147 return $scope.$childNodesScope ? countSubTreeDepth($scope.$childNodesScope) : 0;

Callers 1

nodeCtrl.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected