|
45 | 45 | childPrefix: "child-of-",
|
46 | 46 | clickableNodeNames: true,
|
47 | 47 | expandable: true,
|
48 |
| - indent: 19, |
| 48 | + indent: 7, |
49 | 49 | initialState: "collapsed",
|
50 | 50 | treeColumn: 0
|
51 | 51 | };
|
|
203 | 203 | // 3: +node+ should not be inserted as a child of +node+ itself.
|
204 | 204 |
|
205 | 205 | if($.inArray(node[0].id, ancestorNames) == -1 && (!parent || (destination.id != parent[0].id)) && destination.id != node[0].id) {
|
206 |
| - |
| 206 | + indent(node, ancestorsOf(node).length * options.indent * -1); // Remove indentation |
| 207 | + |
207 | 208 | if(parent) {node.removeClass(options.childPrefix + parent[0].id);}
|
208 | 209 |
|
209 | 210 | node.addClass(options.childPrefix + destination.id);
|
210 | 211 | move(node, destination); // Recursively move nodes to new location
|
211 |
| - // adjust node's padding' |
212 |
| - var cell = $($(destination).children("td")[options.treeColumn]); |
213 |
| - var padding = getPaddingLeft(cell) + options.indent; |
214 |
| - node.children("td:first")[options.treeColumn].style.paddingLeft = (padding-12) + "px"; |
215 |
| - // adust node's children's padding' |
216 |
| - var childPaddingLeft = padding - 12 + options.indent; |
217 |
| - var arrayCell=childrenOf(node); |
218 |
| - if(arrayCell==null)return; |
219 |
| - arrayCell.each(function(){ |
220 |
| - $(this).children("td:first")[options.treeColumn].style.paddingLeft = (childPaddingLeft-12) + "px"; |
221 |
| - }); |
| 212 | + indent(node, ancestorsOf(node).length * options.indent); |
222 | 213 | }
|
223 | 214 |
|
224 | 215 | return this;
|
|
268 | 259 | }
|
269 | 260 |
|
270 | 261 | function indent(node, value) {
|
271 |
| - var cell = $(node.children("td:first")[options.treeColumn]); |
| 262 | + var cell = $(node.children("td")[options.treeColumn]); |
272 | 263 | cell[0].style.paddingLeft = getPaddingLeft(cell) + value + "px";
|
273 | 264 |
|
274 | 265 | childrenOf(node).each(function() {
|
275 | 266 | indent($(this), value);
|
276 | 267 | });
|
277 | 268 | };
|
278 |
| - |
| 269 | + |
279 | 270 | function initEvent()
|
280 | 271 | {
|
281 | 272 | // Make visible that a row is clicked
|
|
440 | 431 | arrayCell.each(function() {
|
441 | 432 | if(first)
|
442 | 433 | {
|
443 |
| - $(this).children("td:first")[options.treeColumn].style.paddingLeft = (padding-12) + "px"; |
| 434 | + $(this).children("td:first")[options.treeColumn].style.paddingLeft = padding + "px"; |
444 | 435 | }
|
445 | 436 | else
|
446 | 437 | {
|
447 |
| - $(this).children("td:first")[options.treeColumn].style.paddingLeft = (padding-12) + "px"; |
| 438 | + $(this).children("td:first")[options.treeColumn].style.paddingLeft = padding + "px"; |
448 | 439 | }
|
449 | 440 | if(node.hasClass('expanded'))
|
450 | 441 | {
|
|
491 | 482 | var padding = getPaddingLeft(cell) + options.indent;
|
492 | 483 |
|
493 | 484 | childNodes.each(function() {
|
494 |
| - $(this).children("td:first")[options.treeColumn].style.paddingLeft = (padding-12) + "px"; |
| 485 | + $(this).children("td:first")[options.treeColumn].style.paddingLeft = padding + "px"; |
495 | 486 | });
|
496 | 487 |
|
497 | 488 | if(options.expandable) {
|
498 |
| - cell.prepend('<span style="margin-left: -' + options.indent + 'px; padding-left: ' + options.indent + 'px" class="expander"></span>'); |
| 489 | + cell.prepend('<span style="margin-left: -' + (options.indent+12) + 'px; padding-left: ' + (options.indent+12) + 'px" class="expander"></span>'); |
499 | 490 | $(cell[0].firstChild).click(function() {node.toggleBranch();});
|
500 | 491 |
|
501 | 492 | if(options.clickableNodeNames) {
|
|
0 commit comments