Skip to content

Commit c4a4c62

Browse files
committed
remove the option nodeChildren
1 parent 834c04c commit c4a4c62

File tree

5 files changed

+18
-25
lines changed

5 files changed

+18
-25
lines changed

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -514,9 +514,6 @@ $('#chartContainerId').orgchart(options);
514514
<tr>
515515
<td>depth</td><td>positive integer</td><td>no</td><td>999</td><td>It indicates the level that at the very beginning orgchart is expanded to.</td>
516516
</tr>
517-
<tr>
518-
<td>nodeChildren</td><td>string</td><td>no</td><td>"children"</td><td>It sets one property of datasource as children nodes collection.</td>
519-
</tr>
520517
<tr>
521518
<td>nodeTitle</td><td>string</td><td>no</td><td>"name"</td><td>It sets one property of datasource as text content of title section of orgchart node. In fact, users can create a simple orghcart with only nodeTitle option.</td>
522519
</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.1.2",
3+
"version": "1.1.3",
44
"homepage": "https://github.com/dabeng/OrgChart",
55
"authors": [
66
"dabeng <dabeng413@gmail.com>"

dist/js/jquery.orgchart.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
var defaultOptions = {
3030
'nodeTitle': 'name',
3131
'nodeId': 'id',
32-
'nodeChildren': 'children',
3332
'toggleSiblingsResp': false,
3433
'depth': 999,
3534
'chartClass': '',
@@ -75,7 +74,7 @@
7574
if (data instanceof $) { // ul datasource
7675
buildHierarchy($chart, buildJsonDS(data.children()), 0, opts);
7776
} else { // local json datasource
78-
buildHierarchy($chart, opts.ajaxURL ? data : attachRel(data, '00', opts), 0, opts);
77+
buildHierarchy($chart, opts.ajaxURL ? data : attachRel(data, '00'), 0, opts);
7978
}
8079
} else {
8180
$.ajax({
@@ -86,7 +85,7 @@
8685
}
8786
})
8887
.done(function(data, textStatus, jqXHR) {
89-
buildHierarchy($chart, opts.ajaxURL ? data : attachRel(data, '00', opts), 0, opts);
88+
buildHierarchy($chart, opts.ajaxURL ? data : attachRel(data, '00'), 0, opts);
9089
})
9190
.fail(function(jqXHR, textStatus, errorThrown) {
9291
console.log(errorThrown);
@@ -230,12 +229,11 @@
230229
return subObj;
231230
}
232231

233-
function attachRel(data, flags, opts) {
234-
var children = data[opts.nodeChildren]
235-
data.relationship = flags + (children && children.length > 0 ? 1 : 0);
236-
if (children) {
237-
children.forEach(function(item) {
238-
attachRel(item, '1' + (children.length > 1 ? 1 :0), opts);
232+
function attachRel(data, flags) {
233+
data.relationship = flags + (data.children && data.children.length > 0 ? 1 : 0);
234+
if (data.children) {
235+
data.children.forEach(function(item) {
236+
attachRel(item, '1' + (data.children.length > 1 ? 1 : 0));
239237
});
240238
}
241239
return data;
@@ -761,7 +759,7 @@
761759
function buildHierarchy ($appendTo, nodeData, level, opts, callback) {
762760
var $table;
763761
// Construct the node
764-
var $childNodes = nodeData[opts.nodeChildren];
762+
var $childNodes = nodeData.children;
765763
var hasChildren = $childNodes ? $childNodes.length : false;
766764
if (Object.keys(nodeData).length > 1) { // if nodeData has nested structure
767765
$table = $('<table>');

examples/js/jquery.orgchart.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
var defaultOptions = {
3030
'nodeTitle': 'name',
3131
'nodeId': 'id',
32-
'nodeChildren': 'children',
3332
'toggleSiblingsResp': false,
3433
'depth': 999,
3534
'chartClass': '',
@@ -75,7 +74,7 @@
7574
if (data instanceof $) { // ul datasource
7675
buildHierarchy($chart, buildJsonDS(data.children()), 0, opts);
7776
} else { // local json datasource
78-
buildHierarchy($chart, opts.ajaxURL ? data : attachRel(data, '00', opts), 0, opts);
77+
buildHierarchy($chart, opts.ajaxURL ? data : attachRel(data, '00'), 0, opts);
7978
}
8079
} else {
8180
$.ajax({
@@ -86,7 +85,7 @@
8685
}
8786
})
8887
.done(function(data, textStatus, jqXHR) {
89-
buildHierarchy($chart, opts.ajaxURL ? data : attachRel(data, '00', opts), 0, opts);
88+
buildHierarchy($chart, opts.ajaxURL ? data : attachRel(data, '00'), 0, opts);
9089
})
9190
.fail(function(jqXHR, textStatus, errorThrown) {
9291
console.log(errorThrown);
@@ -230,12 +229,11 @@
230229
return subObj;
231230
}
232231

233-
function attachRel(data, flags, opts) {
234-
var children = data[opts.nodeChildren]
235-
data.relationship = flags + (children && children.length > 0 ? 1 : 0);
236-
if (children) {
237-
children.forEach(function(item) {
238-
attachRel(item, '1' + (children.length > 1 ? 1 :0), opts);
232+
function attachRel(data, flags) {
233+
data.relationship = flags + (data.children && data.children.length > 0 ? 1 : 0);
234+
if (data.children) {
235+
data.children.forEach(function(item) {
236+
attachRel(item, '1' + (data.children.length > 1 ? 1 : 0));
239237
});
240238
}
241239
return data;
@@ -761,7 +759,7 @@
761759
function buildHierarchy ($appendTo, nodeData, level, opts, callback) {
762760
var $table;
763761
// Construct the node
764-
var $childNodes = nodeData[opts.nodeChildren];
762+
var $childNodes = nodeData.children;
765763
var hasChildren = $childNodes ? $childNodes.length : false;
766764
if (Object.keys(nodeData).length > 1) { // if nodeData has nested structure
767765
$table = $('<table>');

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.1.2",
3+
"version": "1.1.3",
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)