Skip to content

Commit

Permalink
remove the option nodeChildren
Browse files Browse the repository at this point in the history
  • Loading branch information
dabeng committed Jul 29, 2016
1 parent 834c04c commit c4a4c62
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 25 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -514,9 +514,6 @@ $('#chartContainerId').orgchart(options);
<tr>
<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>
</tr>
<tr>
<td>nodeChildren</td><td>string</td><td>no</td><td>"children"</td><td>It sets one property of datasource as children nodes collection.</td>
</tr>
<tr>
<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>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "orgchart",
"version": "1.1.2",
"version": "1.1.3",
"homepage": "https://github.com/dabeng/OrgChart",
"authors": [
"dabeng <[email protected]>"
Expand Down
18 changes: 8 additions & 10 deletions dist/js/jquery.orgchart.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
var defaultOptions = {
'nodeTitle': 'name',
'nodeId': 'id',
'nodeChildren': 'children',
'toggleSiblingsResp': false,
'depth': 999,
'chartClass': '',
Expand Down Expand Up @@ -75,7 +74,7 @@
if (data instanceof $) { // ul datasource
buildHierarchy($chart, buildJsonDS(data.children()), 0, opts);
} else { // local json datasource
buildHierarchy($chart, opts.ajaxURL ? data : attachRel(data, '00', opts), 0, opts);
buildHierarchy($chart, opts.ajaxURL ? data : attachRel(data, '00'), 0, opts);
}
} else {
$.ajax({
Expand All @@ -86,7 +85,7 @@
}
})
.done(function(data, textStatus, jqXHR) {
buildHierarchy($chart, opts.ajaxURL ? data : attachRel(data, '00', opts), 0, opts);
buildHierarchy($chart, opts.ajaxURL ? data : attachRel(data, '00'), 0, opts);
})
.fail(function(jqXHR, textStatus, errorThrown) {
console.log(errorThrown);
Expand Down Expand Up @@ -230,12 +229,11 @@
return subObj;
}

function attachRel(data, flags, opts) {
var children = data[opts.nodeChildren]
data.relationship = flags + (children && children.length > 0 ? 1 : 0);
if (children) {
children.forEach(function(item) {
attachRel(item, '1' + (children.length > 1 ? 1 :0), opts);
function attachRel(data, flags) {
data.relationship = flags + (data.children && data.children.length > 0 ? 1 : 0);
if (data.children) {
data.children.forEach(function(item) {
attachRel(item, '1' + (data.children.length > 1 ? 1 : 0));
});
}
return data;
Expand Down Expand Up @@ -761,7 +759,7 @@
function buildHierarchy ($appendTo, nodeData, level, opts, callback) {
var $table;
// Construct the node
var $childNodes = nodeData[opts.nodeChildren];
var $childNodes = nodeData.children;
var hasChildren = $childNodes ? $childNodes.length : false;
if (Object.keys(nodeData).length > 1) { // if nodeData has nested structure
$table = $('<table>');
Expand Down
18 changes: 8 additions & 10 deletions examples/js/jquery.orgchart.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
var defaultOptions = {
'nodeTitle': 'name',
'nodeId': 'id',
'nodeChildren': 'children',
'toggleSiblingsResp': false,
'depth': 999,
'chartClass': '',
Expand Down Expand Up @@ -75,7 +74,7 @@
if (data instanceof $) { // ul datasource
buildHierarchy($chart, buildJsonDS(data.children()), 0, opts);
} else { // local json datasource
buildHierarchy($chart, opts.ajaxURL ? data : attachRel(data, '00', opts), 0, opts);
buildHierarchy($chart, opts.ajaxURL ? data : attachRel(data, '00'), 0, opts);
}
} else {
$.ajax({
Expand All @@ -86,7 +85,7 @@
}
})
.done(function(data, textStatus, jqXHR) {
buildHierarchy($chart, opts.ajaxURL ? data : attachRel(data, '00', opts), 0, opts);
buildHierarchy($chart, opts.ajaxURL ? data : attachRel(data, '00'), 0, opts);
})
.fail(function(jqXHR, textStatus, errorThrown) {
console.log(errorThrown);
Expand Down Expand Up @@ -230,12 +229,11 @@
return subObj;
}

function attachRel(data, flags, opts) {
var children = data[opts.nodeChildren]
data.relationship = flags + (children && children.length > 0 ? 1 : 0);
if (children) {
children.forEach(function(item) {
attachRel(item, '1' + (children.length > 1 ? 1 :0), opts);
function attachRel(data, flags) {
data.relationship = flags + (data.children && data.children.length > 0 ? 1 : 0);
if (data.children) {
data.children.forEach(function(item) {
attachRel(item, '1' + (data.children.length > 1 ? 1 : 0));
});
}
return data;
Expand Down Expand Up @@ -761,7 +759,7 @@
function buildHierarchy ($appendTo, nodeData, level, opts, callback) {
var $table;
// Construct the node
var $childNodes = nodeData[opts.nodeChildren];
var $childNodes = nodeData.children;
var hasChildren = $childNodes ? $childNodes.length : false;
if (Object.keys(nodeData).length > 1) { // if nodeData has nested structure
$table = $('<table>');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "orgchart",
"version": "1.1.2",
"version": "1.1.3",
"description": "Simple and direct organization chart(tree-like hierarchy) plugin based on pure DOM and jQuery.",
"main": "./dist/js/jquery.orgchart.js",
"style": [
Expand Down

1 comment on commit c4a4c62

@awulkan
Copy link

@awulkan awulkan commented on c4a4c62 Jul 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove this feature??

Please sign in to comment.