Skip to content

Commit 6ab86d4

Browse files
author
dabeng
committed
Expose the method hideParent & show Parent
1 parent b0f02e7 commit 6ab86d4

4 files changed

Lines changed: 57 additions & 22 deletions

File tree

README.md

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,43 @@ Removes the designated node and its descedant nodes.
630630
</table>
631631
##### .orgchart('getHierarchy')
632632
This method is designed to get the hierarchy relationships of orgchart for further processing. For example, after editing the orgchart, you could send the returned value of this method to server-side and save the new state of orghcart.
633-
##### .orgchart('hideDescendants',$node)
633+
##### .orgchart('hideParent',$node)
634+
This method allows you to hide programatically the parent node of any specific node(.node element), if it has
635+
<table>
636+
<tr>
637+
<th>Name</th>
638+
<th>Type</th>
639+
<th>Required</th>
640+
<th>Default</th>
641+
<th>Description</th>
642+
</tr>
643+
<tr>
644+
<td>$node</td>
645+
<td>JQuery Object</td>
646+
<td>Yes</td>
647+
<td>None</td>
648+
<td>Is the desired JQuery Object to hide its parent node. Of course, its sibling nodes will be hidden at the same time</td>
649+
</tr>
650+
</table>
651+
##### .orgchart('showParent',$node)
652+
This method allows you to show programatically the parent node of any specific node(.node element), if it has
653+
<table>
654+
<tr>
655+
<th>Name</th>
656+
<th>Type</th>
657+
<th>Required</th>
658+
<th>Default</th>
659+
<th>Description</th>
660+
</tr>
661+
<tr>
662+
<td>$node</td>
663+
<td>JQuery Object</td>
664+
<td>Yes</td>
665+
<td>None</td>
666+
<td>Is the desired JQuery Object to show its parent node</td>
667+
</tr>
668+
</table>
669+
##### .orgchart('hideChildren',$node)
634670
This method allows you to hide programatically the children of any specific node(.node element), if it has
635671
<table>
636672
<tr>
@@ -648,7 +684,7 @@ This method allows you to hide programatically the children of any specific node
648684
<td>Is the desired JQuery Object to hide its children nodes</td>
649685
</tr>
650686
</table>
651-
##### .orgchart('showDescendants',$node)
687+
##### .orgchart('showChildren',$node)
652688
This method allows you to show programatically the children of any specific node(.node element), if it has
653689
<table>
654690
<tr>

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "orgchart",
3-
"version": "1.2.9",
3+
"version": "1.3.0",
44
"homepage": "https://github.com/dabeng/OrgChart",
55
"authors": [
66
"dabeng <dabeng413@gmail.com>"

dist/js/jquery.orgchart.js

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@
33
* https://github.com/dabeng/OrgChart
44
*
55
* 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/
127
*
138
* Copyright 2016, dabeng
149
* http://dabeng.github.io/
@@ -54,10 +49,14 @@
5449
return removeNodes.apply(this, Array.prototype.splice.call(arguments, 1));
5550
case 'getHierarchy':
5651
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));
6160
case 'hideSiblings':
6261
return hideSiblings.apply(this, Array.prototype.splice.call(arguments, 1));
6362
case 'showSiblings':
@@ -353,7 +352,7 @@
353352
}
354353

355354
// recursively hide the ancestor node and sibling nodes of the specified node
356-
function hideAncestorsSiblings($node) {
355+
function hideParent($node) {
357356
var $temp = $node.closest('table').closest('tr').siblings();
358357
if ($temp.eq(0).find('.spinner').length) {
359358
$node.closest('.orgchart').data('inAjax', false);
@@ -377,7 +376,7 @@
377376
}
378377
// if the current node has the parent node, hide it recursively
379378
if ($parent.length && grandfatherVisible) {
380-
hideAncestorsSiblings($parent);
379+
hideParent($parent);
381380
}
382381
}
383382

@@ -399,7 +398,7 @@
399398
}
400399

401400
// recursively hide the descendant nodes of the specified node
402-
function hideDescendants($node) {
401+
function hideChildren($node) {
403402
var $temp = $node.closest('tr').siblings();
404403
if ($temp.last().find('.spinner').length) {
405404
$node.closest('.orgchart').data('inAjax', false);
@@ -424,7 +423,7 @@
424423
}
425424

426425
// show the children nodes of the specified node
427-
function showDescendants($node) {
426+
function showChildren($node) {
428427
var $temp = $node.closest('tr').siblings();
429428
var isVerticalDesc = $temp.is('.verticalNodes') ? true : false;
430429
var $descendants = isVerticalDesc
@@ -652,7 +651,7 @@
652651
if ($parent.is('.slide')) { return; }
653652
// hide the ancestor nodes and sibling nodes of the specified node
654653
if (parentState.visible) {
655-
hideAncestorsSiblings($node);
654+
hideParent($node);
656655
$parent.one('transitionend', function() {
657656
if (isInAction($node)) {
658657
switchVerticalArrow($that);
@@ -693,9 +692,9 @@
693692
if ($children.find('.node:visible').is('.slide')) { return; }
694693
// hide the descendant nodes of the specified node
695694
if (childrenState.visible) {
696-
hideDescendants($node);
695+
hideChildren($node);
697696
} else { // show the descendants
698-
showDescendants($node);
697+
showChildren($node);
699698
}
700699
} else { // load the new children nodes of the specified node by ajax request
701700
var nodeId = $that.parent()[0].id;
@@ -1019,7 +1018,7 @@
10191018
if (!$node.find('.symbol').length) {
10201019
$node.children('.title').prepend('<i class="fa '+ opts.parentNodeSymbol + ' symbol"></i>');
10211020
}
1022-
showDescendants($node);
1021+
showChildren($node);
10231022
}
10241023
});
10251024
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "orgchart",
3-
"version": "1.2.9",
3+
"version": "1.3.0",
44
"description": "Simple and direct organization chart(tree-like hierarchy) plugin based on pure DOM and jQuery.",
55
"main": "./dist/js/jquery.orgchart.js",
66
"style": [

0 commit comments

Comments
 (0)