Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/diff/DiffTreeView.js
| Show All 15 Lines | JX.install('DiffTreeView', { | ||||
| members: { | members: { | ||||
| _node: null, | _node: null, | ||||
| _keys: null, | _keys: null, | ||||
| _tree: null, | _tree: null, | ||||
| _nodes: null, | _nodes: null, | ||||
| _dirty: false, | _dirty: false, | ||||
| _paths: null, | _paths: null, | ||||
| _selectedPath: null, | _selectedPath: null, | ||||
| _focusedPath: null, | |||||
| getNode: function() { | getNode: function() { | ||||
| if (!this._node) { | if (!this._node) { | ||||
| this._node = JX.$N('ul'); | var attrs = { | ||||
| className: 'diff-tree-view' | |||||
| }; | |||||
| this._node = JX.$N('ul', attrs); | |||||
| } | } | ||||
| if (this._dirty) { | if (this._dirty) { | ||||
| this.redraw(); | this.redraw(); | ||||
| } | } | ||||
| return this._node; | return this._node; | ||||
| }, | }, | ||||
| Show All 23 Lines | setSelectedPath: function(path) { | ||||
| path.setIsSelected(true); | path.setIsSelected(true); | ||||
| } | } | ||||
| this._selectedPath = path; | this._selectedPath = path; | ||||
| return this; | return this; | ||||
| }, | }, | ||||
| setFocusedPath: function(path) { | |||||
| if (this._focusedPath) { | |||||
| this._focusedPath.setIsFocused(false); | |||||
| this._focusedPath = null; | |||||
| } | |||||
| if (path) { | |||||
| path.setIsFocused(true); | |||||
| } | |||||
| this._focusedPath = path; | |||||
| return this; | |||||
| }, | |||||
| redraw: function() { | redraw: function() { | ||||
| if (!this._dirty) { | if (!this._dirty) { | ||||
| 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 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; | var path = tree.pathObject; | ||||
| if (!path) { | if (!path) { | ||||
| path = new JX.DiffPathView() | path = new JX.DiffPathView() | ||||
| .setPath(tree.parts); | .setPath(tree.parts); | ||||
| path.getIcon() | |||||
| .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]; | ||||
| ▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines | |||||