Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/diff/DiffTreeView.js
| Show First 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | redraw: function() { | ||||
| return; | return; | ||||
| } | } | ||||
| this._dirty = false; | this._dirty = false; | ||||
| var ii; | var ii; | ||||
| // For nodes which don't have a path object yet, build one. | // For nodes which don't have a path object yet, build one. | ||||
| var tree; | var tree; | ||||
| var path; | |||||
| var trees = []; | var trees = []; | ||||
| for (ii = 0; ii < this._keys.length; ii++) { | for (ii = 0; ii < this._keys.length; ii++) { | ||||
| var key = this._keys[ii]; | var key = this._keys[ii]; | ||||
| tree = this._nodes[key]; | tree = this._nodes[key]; | ||||
| var path = tree.pathObject; | path = tree.pathObject; | ||||
| if (!path) { | if (!path) { | ||||
| path = new JX.DiffPathView() | path = new JX.DiffPathView() | ||||
| .setPath(tree.parts); | .setPath(tree.parts); | ||||
| path.getIcon() | path.getIcon() | ||||
| .setIcon('fa-folder-open-o'); | .setIcon('fa-folder-open-o'); | ||||
| tree.pathObject = path; | tree.pathObject = path; | ||||
| } | } | ||||
| trees.push(tree); | trees.push(tree); | ||||
| } | } | ||||
| for (ii = 0; ii < trees.length; ii++) { | for (ii = 0; ii < trees.length; ii++) { | ||||
| tree = trees[ii]; | tree = trees[ii]; | ||||
| tree.displayRoot = null; | |||||
| tree.displayPath = null; | |||||
| tree.displayHide = false; | |||||
| } | |||||
| var child; | |||||
| for (ii = 0; ii < trees.length; ii++) { | |||||
| tree = trees[ii]; | |||||
| if (tree.childCount !== 1) { | |||||
| continue; | |||||
| } | |||||
| for (var k in tree.children) { | |||||
| if (tree.children.hasOwnProperty(k)) { | |||||
| child = tree.children[k]; | |||||
| break; | |||||
| } | |||||
| } | |||||
| if (child.pathObject.getChangeset()) { | |||||
| continue; | |||||
| } | |||||
| child.displayRoot = tree.displayRoot || tree; | |||||
| } | |||||
| for (ii = 0; ii < trees.length; ii++) { | |||||
| tree = trees[ii]; | |||||
| if (!tree.displayRoot) { | |||||
| continue; | |||||
| } | |||||
| if (!tree.displayRoot.displayPath) { | |||||
| tree.displayRoot.displayPath = [ | |||||
| tree.displayRoot.parts[tree.displayRoot.parts.length - 1] | |||||
| ]; | |||||
| } | |||||
| tree.displayRoot.displayPath.push(tree.parts[tree.parts.length - 1]); | |||||
| tree.displayHide = true; | |||||
| } | |||||
| for (ii = 0; ii < trees.length; ii++) { | |||||
| tree = trees[ii]; | |||||
| path = tree.pathObject; | |||||
| path.setHidden(!!tree.displayHide); | |||||
| if (tree.displayPath) { | |||||
| path.setDisplayPath(tree.displayPath.join('/')); | |||||
| } else { | |||||
| path.setDisplayPath(null); | |||||
| } | |||||
| } | |||||
| for (ii = 0; ii < trees.length; ii++) { | |||||
| tree = trees[ii]; | |||||
| if (!tree.parent) { | if (!tree.parent) { | ||||
| tree.depth = 0; | tree.depth = 0; | ||||
| } else { | } else { | ||||
| // If this node was collapsed into the parent node, don't increase | |||||
| // the tree depth. | |||||
| if (tree.displayHide) { | |||||
| tree.depth = tree.parent.depth; | |||||
| } else { | |||||
| tree.depth = tree.parent.depth + 1; | tree.depth = tree.parent.depth + 1; | ||||
| } | } | ||||
| } | |||||
| path = tree.pathObject; | |||||
| if (tree.childCount > 0) { | |||||
| path.setIsDirectory(true); | |||||
| } | |||||
| tree.pathObject.setDepth((tree.depth - 1)); | path.setDepth((tree.depth - 1)); | ||||
| } | } | ||||
| var nodes = []; | var nodes = []; | ||||
| for (ii = 0; ii < trees.length; ii++) { | for (ii = 0; ii < trees.length; ii++) { | ||||
| tree = trees[ii]; | tree = trees[ii]; | ||||
| nodes.push(tree.pathObject.getNode()); | nodes.push(tree.pathObject.getNode()); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 50 Lines • Show Last 20 Lines | |||||