Skip to content

Commit efdf66c

Browse files
committed
WIP: implement family tree
1 parent 2bc359c commit efdf66c

File tree

8 files changed

+61
-8
lines changed

8 files changed

+61
-8
lines changed

demo/family-tree.html

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
{ 'id': '5', 'name': 'Su Miao', 'title': 'department manager', 'gender': 'female',
3434
'children': [
3535
[
36+
// { 'id': '6', 'name': 'Hei Hei', 'title': 'senior engineer', 'gender': 'male' },
3637
{ 'id': '7', 'name': 'Pang Pang', 'title': 'engineer', 'gender': 'female', 'outsider': true,
3738
'children': [
3839
[{ 'id': '8', 'name': 'Dan Dan', 'title': 'UE engineer', 'gender': 'female' }],
@@ -52,13 +53,19 @@
5253
[{ 'id': '15', 'name': 'Liu Dan', 'title': 'UE engineer', 'gender': 'female' }]
5354
]
5455
}
56+
],
57+
[
58+
{ 'id': '17', 'name': 'Er Hei', 'title': 'senior engineer', 'gender': 'male' },
59+
{ 'id': '16', 'name': 'Er Yuan', 'title': 'engineer', 'gender': 'female', 'outsider': true },
60+
61+
{ 'id': '17', 'name': 'San Yuan', 'title': 'engineer', 'gender': 'female', 'outsider': true },
5562
]
5663
]
5764
},
58-
{ 'id': '16', 'name': 'Tie Hua', 'title': 'senior engineer', 'gender': 'male', 'outsider': true }
65+
{ 'id': '18', 'name': 'Tie Hua', 'title': 'senior engineer', 'gender': 'male', 'outsider': true }
5966
],
60-
[{ 'id': '17', 'name': 'Hong Miao', 'title': 'department manager', 'gender': 'female' }],
61-
[{ 'id': '18', 'name': 'Chun Miao', 'title': 'department manager', 'gender': 'female' }]
67+
[{ 'id': '19', 'name': 'Hong Miao', 'title': 'department manager', 'gender': 'female' }],
68+
[{ 'id': '20', 'name': 'Chun Miao', 'title': 'department manager', 'gender': 'female' }]
6269
]
6370
}
6471
]

dist/css/jquery.orgchart.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,19 @@
9999
border-top: 2px solid rgba(217, 83, 79, 0.8);
100100
box-sizing: border-box;
101101
}
102+
/* 把本姓人首次出现位置的前面的连线去掉 */
103+
.orgchart .hierarchy:has(~ :nth-child(1 of .hierarchy.insider))::before {
104+
content: none;
105+
}
106+
107+
/* 把本姓人末次出现位置的后面的连线去掉 */
108+
.orgchart :nth-last-child(-n + 1 of .hierarchy.insider) ~ .hierarchy::before {
109+
content: none;
110+
}
111+
112+
.orgchart .hierarchy.spouse::before {
113+
/* top: 24px; */
114+
}
102115

103116
.orgchart .hierarchy:first-child::before,
104117
.orgchart .hierarchy.isSiblingsCollapsed.left-sibs::before {
@@ -142,6 +155,16 @@
142155
background-color: rgba(217, 83, 79, 0.8);
143156
}
144157

158+
.orgchart .hierarchy.spouse > .node + .node::before {
159+
content: "";
160+
position: absolute;
161+
top: 22px; /* 50% width of node - node's padding */
162+
left: -7px; /* nodes' gap - node's padding */
163+
width: 10px;
164+
height: 2px;
165+
background-color: rgba(217, 83, 79, 0.8);
166+
}
167+
145168
.orgchart ul li .node.allowedDrop {
146169
border-color: rgba(68, 157, 68, 0.9);
147170
}

dist/css/jquery.orgchart.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/jquery.orgchart.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1498,7 +1498,7 @@
14981498
}
14991499
} else {
15001500
// if there are more than two persons in a marriage, every node will be included in a single hierarchy
1501-
var $wrapper = $('<li class="hierarchy"></li>');
1501+
var $wrapper = $(`<li class="hierarchy${_this.length > 1 ? ' spouse' : ''}${this.outsider ? '' : ' insider'}"></li>`);
15021502
$wrapper.append($nodeDiv);
15031503
$hierarchy.append($wrapper);
15041504
if (this.children && this.children.length) {

dist/js/jquery.orgchart.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/jquery.orgchart.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/css/jquery.orgchart.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,19 @@
9999
border-top: 2px solid rgba(217, 83, 79, 0.8);
100100
box-sizing: border-box;
101101
}
102+
/* 把本姓人首次出现位置的前面的连线去掉 */
103+
.orgchart .hierarchy:has(~ :nth-child(1 of .hierarchy.insider))::before {
104+
content: none;
105+
}
106+
107+
/* 把本姓人末次出现位置的后面的连线去掉 */
108+
.orgchart :nth-last-child(-n + 1 of .hierarchy.insider) ~ .hierarchy::before {
109+
content: none;
110+
}
111+
112+
.orgchart .hierarchy.spouse::before {
113+
/* top: 24px; */
114+
}
102115

103116
.orgchart .hierarchy:first-child::before,
104117
.orgchart .hierarchy.isSiblingsCollapsed.left-sibs::before {
@@ -142,6 +155,16 @@
142155
background-color: rgba(217, 83, 79, 0.8);
143156
}
144157

158+
.orgchart .hierarchy.spouse > .node + .node::before {
159+
content: "";
160+
position: absolute;
161+
top: 22px; /* 50% width of node - node's padding */
162+
left: -7px; /* nodes' gap - node's padding */
163+
width: 10px;
164+
height: 2px;
165+
background-color: rgba(217, 83, 79, 0.8);
166+
}
167+
145168
.orgchart ul li .node.allowedDrop {
146169
border-color: rgba(68, 157, 68, 0.9);
147170
}

src/js/jquery.orgchart.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1498,7 +1498,7 @@
14981498
}
14991499
} else {
15001500
// if there are more than two persons in a marriage, every node will be included in a single hierarchy
1501-
var $wrapper = $('<li class="hierarchy"></li>');
1501+
var $wrapper = $(`<li class="hierarchy${_this.length > 1 ? ' spouse' : ''}${this.outsider ? '' : ' insider'}"></li>`);
15021502
$wrapper.append($nodeDiv);
15031503
$hierarchy.append($wrapper);
15041504
if (this.children && this.children.length) {

0 commit comments

Comments
 (0)