|
3 | 3 | * https://github.com/dabeng/OrgChart |
4 | 4 | * |
5 | 5 | * Demos of jQuery OrgChart Plugin |
6 | | - * http://dabeng.github.io/OrgChart/local-datasource/ |
7 | | - * http://dabeng.github.io/OrgChart/ajax-datasource/ |
8 | | - * http://dabeng.github.io/OrgChart/ondemand-loading-data/ |
9 | | - * http://dabeng.github.io/OrgChart/option-createNode/ |
10 | | - * http://dabeng.github.io/OrgChart/export-orgchart/ |
11 | | - * http://dabeng.github.io/OrgChart/integrate-map/ |
| 6 | + * http://dabeng.github.io/OrgChart/ |
12 | 7 | * |
13 | 8 | * Copyright 2016, dabeng |
14 | 9 | * http://dabeng.github.io/ |
|
54 | 49 | return removeNodes.apply(this, Array.prototype.splice.call(arguments, 1)); |
55 | 50 | case 'getHierarchy': |
56 | 51 | return getHierarchy.apply(this, Array.prototype.splice.call(arguments, 1)); |
57 | | - case 'hideDescendants': |
58 | | - return hideDescendants.apply(this, Array.prototype.splice.call(arguments, 1)); |
59 | | - case 'showDescendants': |
60 | | - return showDescendants.apply(this, Array.prototype.splice.call(arguments, 1)); |
| 52 | + case 'hideParent': |
| 53 | + return hideParent.apply(this, Array.prototype.splice.call(arguments, 1)); |
| 54 | + case 'showParent': |
| 55 | + return showParent.apply(this, Array.prototype.splice.call(arguments, 1)); |
| 56 | + case 'hideChildren': |
| 57 | + return hideChildren.apply(this, Array.prototype.splice.call(arguments, 1)); |
| 58 | + case 'showChildren': |
| 59 | + return showChildren.apply(this, Array.prototype.splice.call(arguments, 1)); |
61 | 60 | case 'hideSiblings': |
62 | 61 | return hideSiblings.apply(this, Array.prototype.splice.call(arguments, 1)); |
63 | 62 | case 'showSiblings': |
|
353 | 352 | } |
354 | 353 |
|
355 | 354 | // recursively hide the ancestor node and sibling nodes of the specified node |
356 | | - function hideAncestorsSiblings($node) { |
| 355 | + function hideParent($node) { |
357 | 356 | var $temp = $node.closest('table').closest('tr').siblings(); |
358 | 357 | if ($temp.eq(0).find('.spinner').length) { |
359 | 358 | $node.closest('.orgchart').data('inAjax', false); |
|
377 | 376 | } |
378 | 377 | // if the current node has the parent node, hide it recursively |
379 | 378 | if ($parent.length && grandfatherVisible) { |
380 | | - hideAncestorsSiblings($parent); |
| 379 | + hideParent($parent); |
381 | 380 | } |
382 | 381 | } |
383 | 382 |
|
|
399 | 398 | } |
400 | 399 |
|
401 | 400 | // recursively hide the descendant nodes of the specified node |
402 | | - function hideDescendants($node) { |
| 401 | + function hideChildren($node) { |
403 | 402 | var $temp = $node.closest('tr').siblings(); |
404 | 403 | if ($temp.last().find('.spinner').length) { |
405 | 404 | $node.closest('.orgchart').data('inAjax', false); |
|
424 | 423 | } |
425 | 424 |
|
426 | 425 | // show the children nodes of the specified node |
427 | | - function showDescendants($node) { |
| 426 | + function showChildren($node) { |
428 | 427 | var $temp = $node.closest('tr').siblings(); |
429 | 428 | var isVerticalDesc = $temp.is('.verticalNodes') ? true : false; |
430 | 429 | var $descendants = isVerticalDesc |
|
652 | 651 | if ($parent.is('.slide')) { return; } |
653 | 652 | // hide the ancestor nodes and sibling nodes of the specified node |
654 | 653 | if (parentState.visible) { |
655 | | - hideAncestorsSiblings($node); |
| 654 | + hideParent($node); |
656 | 655 | $parent.one('transitionend', function() { |
657 | 656 | if (isInAction($node)) { |
658 | 657 | switchVerticalArrow($that); |
|
693 | 692 | if ($children.find('.node:visible').is('.slide')) { return; } |
694 | 693 | // hide the descendant nodes of the specified node |
695 | 694 | if (childrenState.visible) { |
696 | | - hideDescendants($node); |
| 695 | + hideChildren($node); |
697 | 696 | } else { // show the descendants |
698 | | - showDescendants($node); |
| 697 | + showChildren($node); |
699 | 698 | } |
700 | 699 | } else { // load the new children nodes of the specified node by ajax request |
701 | 700 | var nodeId = $that.parent()[0].id; |
|
1019 | 1018 | if (!$node.find('.symbol').length) { |
1020 | 1019 | $node.children('.title').prepend('<i class="fa '+ opts.parentNodeSymbol + ' symbol"></i>'); |
1021 | 1020 | } |
1022 | | - showDescendants($node); |
| 1021 | + showChildren($node); |
1023 | 1022 | } |
1024 | 1023 | }); |
1025 | 1024 | } |
|
0 commit comments