@@ -59,6 +59,8 @@ define(function (require, exports, module) {
5959 var CLICK_RENAME_MINIMUM = 500 ,
6060 RIGHT_MOUSE_BUTTON = 2 ,
6161 LEFT_MOUSE_BUTTON = 0 ;
62+
63+ var INDENTATION_WIDTH = 18 ;
6264
6365 /**
6466 * @private
@@ -108,6 +110,40 @@ define(function (require, exports, module) {
108110 return width ;
109111 }
110112
113+ /**
114+ * @private
115+ *
116+ * Create an appropriate div based thickness to indent the tree correctly.
117+ *
118+ * @param {int } depth - The depthness of the current node.
119+ * @return {ReactComponent } - The resulting div.
120+ */
121+ function _createThickness ( depth ) {
122+ return DOM . div ( {
123+ className : "thickness" ,
124+ style : {
125+ width : ( INDENTATION_WIDTH * depth ) + "px"
126+ }
127+ } ) ;
128+ }
129+
130+ /**
131+ * @private
132+ *
133+ * Create the arrow icons used for the folders indented correctly.
134+ *
135+ * @param {int } depth - The depthness of the current node.
136+ * @return {ReactComponent } - The resulting ins.
137+ */
138+ function _createAlignedIns ( depth ) {
139+ return DOM . ins ( {
140+ className : "jstree-icon" ,
141+ style : {
142+ marginLeft : ( INDENTATION_WIDTH * depth ) + "px"
143+ }
144+ } , " " ) ;
145+ }
146+
111147 /**
112148 * This is a mixin that provides rename input behavior. It is responsible for taking keyboard input
113149 * and invoking the correct action based on that input.
@@ -457,32 +493,40 @@ define(function (require, exports, module) {
457493 'context-node' : this . props . entry . get ( "context" )
458494 } ) ;
459495
496+ var liArgs = [
497+ {
498+ className : this . getClasses ( "jstree-leaf" ) ,
499+ onClick : this . handleClick ,
500+ onMouseDown : this . handleMouseDown ,
501+ onDoubleClick : this . handleDoubleClick
502+ } ,
503+ DOM . ins ( {
504+ className : "jstree-icon"
505+ } , " " ) ,
506+ ] ;
507+ var thickness = _createThickness ( this . props . depth ) ;
508+
460509 if ( this . props . entry . get ( "rename" ) ) {
461510 nameDisplay = fileRenameInput ( {
462511 actions : this . props . actions ,
463512 entry : this . props . entry ,
464513 name : this . props . name ,
465514 parentPath : this . props . parentPath
466515 } ) ;
516+
517+ liArgs . push ( thickness ) ;
467518 } else {
468519 // Need to flatten the argument list because getIcons returns an array
469520 var aArgs = _ . flatten ( [ {
470521 href : "#" ,
471522 className : fileClasses
472- } , this . getIcons ( ) , name , extension ] ) ;
523+ } , thickness , this . getIcons ( ) , name , extension ] ) ;
473524 nameDisplay = DOM . a . apply ( DOM . a , aArgs ) ;
474525 }
475526
476- return DOM . li ( {
477- className : this . getClasses ( "jstree-leaf" ) ,
478- onClick : this . handleClick ,
479- onMouseDown : this . handleMouseDown ,
480- onDoubleClick : this . handleDoubleClick
481- } ,
482- DOM . ins ( {
483- className : "jstree-icon"
484- } , " " ) ,
485- nameDisplay ) ;
527+ liArgs . push ( nameDisplay ) ;
528+
529+ return DOM . li . apply ( DOM . li , liArgs ) ;
486530 }
487531 } ) ) ;
488532
@@ -668,6 +712,7 @@ define(function (require, exports, module) {
668712 if ( isOpen && children ) {
669713 nodeClass = "open" ;
670714 childNodes = directoryContents ( {
715+ depth : this . props . depth + 1 ,
671716 parentPath : this . myPath ( ) ,
672717 contents : children ,
673718 extensions : this . props . extensions ,
@@ -698,11 +743,13 @@ define(function (require, exports, module) {
698743 } ) ;
699744 }
700745
746+ var thickness = _createThickness ( this . props . depth ) ;
747+
701748 // Need to flatten the arguments because getIcons returns an array
702749 var aArgs = _ . flatten ( [ {
703750 href : "#" ,
704751 className : directoryClasses
705- } , this . getIcons ( ) ] ) ;
752+ } , thickness , this . getIcons ( ) ] ) ;
706753 if ( ! entry . get ( "rename" ) ) {
707754 aArgs . push ( this . props . name ) ;
708755 }
@@ -714,9 +761,7 @@ define(function (require, exports, module) {
714761 onClick : this . handleClick ,
715762 onMouseDown : this . handleMouseDown
716763 } ,
717- DOM . ins ( {
718- className : "jstree-icon"
719- } , " " ) ,
764+ _createAlignedIns ( this . props . depth ) ,
720765 renameInput ,
721766 nameDisplay ,
722767 childNodes ) ;
@@ -764,6 +809,7 @@ define(function (require, exports, module) {
764809
765810 if ( FileTreeViewModel . isFile ( entry ) ) {
766811 return fileNode ( {
812+ depth : this . props . depth ,
767813 parentPath : this . props . parentPath ,
768814 name : name ,
769815 entry : entry ,
@@ -775,6 +821,7 @@ define(function (require, exports, module) {
775821 } ) ;
776822 } else {
777823 return directoryNode ( {
824+ depth : this . props . depth ,
778825 parentPath : this . props . parentPath ,
779826 name : name ,
780827 entry : entry ,
@@ -977,6 +1024,7 @@ define(function (require, exports, module) {
9771024 } ) ,
9781025 contents = directoryContents ( {
9791026 isRoot : true ,
1027+ depth : 1 ,
9801028 parentPath : this . props . parentPath ,
9811029 sortDirectoriesFirst : this . props . sortDirectoriesFirst ,
9821030 contents : this . props . treeData ,
0 commit comments