Skip to content

Commit a315394

Browse files
committed
WIP: implement family tree
1 parent 17ecd98 commit a315394

File tree

5 files changed

+20
-12
lines changed

5 files changed

+20
-12
lines changed

demo/family-tree.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
$(function() {
2121

2222
var datascource = [
23-
{ 'id': '1', 'name': 'Lao Ye', 'title': 'vice general manager', 'gender': 'male' },
23+
{ 'id': '1', 'name': 'Lao Ye', 'title': 'general manager', 'gender': 'male' },
2424
{
25-
'id': '2', 'name': 'Lao Lao', 'title': 'general manager', 'gender': 'female',
25+
'id': '2', 'name': 'Lao Lao', 'title': 'vice general manager', 'gender': 'female',
2626
'children': [
2727
[
2828
{ 'id': '3', 'name': 'Bo Miao', 'title': 'department manager', 'gender': 'female' },

dist/js/jquery.orgchart.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,10 +1467,14 @@
14671467
// Construct the single node in OrgChart or the multiple nodes in family tree
14681468
if (Array.isArray(data)) {
14691469
$.each(data, function () {
1470-
$nodeDiv = that.createNode(data);
1471-
$hierarchy.append($nodeDiv);
1472-
if (data.children && data.children.length) {
1473-
that.buildInferiorNodes($hierarchy, $nodeDiv, data, level);
1470+
$nodeDiv = that.createNode(this);
1471+
if ($hierarchy.children('.node').length) {
1472+
$hierarchy.children('.node:first').after($nodeDiv);
1473+
} else {
1474+
$hierarchy.append($nodeDiv);
1475+
}
1476+
if (this.children && this.children.length) {
1477+
that.buildInferiorNodes($hierarchy, $nodeDiv, this, level);
14741478
}
14751479
});
14761480
} else {

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/js/jquery.orgchart.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,10 +1467,14 @@
14671467
// Construct the single node in OrgChart or the multiple nodes in family tree
14681468
if (Array.isArray(data)) {
14691469
$.each(data, function () {
1470-
$nodeDiv = that.createNode(data);
1471-
$hierarchy.append($nodeDiv);
1472-
if (data.children && data.children.length) {
1473-
that.buildInferiorNodes($hierarchy, $nodeDiv, data, level);
1470+
$nodeDiv = that.createNode(this);
1471+
if ($hierarchy.children('.node').length) {
1472+
$hierarchy.children('.node:first').after($nodeDiv);
1473+
} else {
1474+
$hierarchy.append($nodeDiv);
1475+
}
1476+
if (this.children && this.children.length) {
1477+
that.buildInferiorNodes($hierarchy, $nodeDiv, this, level);
14741478
}
14751479
});
14761480
} else {

0 commit comments

Comments
 (0)