Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to ignore space used by collapsed nodes #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions jquery.jOrgChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@
chartElement : 'body',
depth : -1,
chartClass : "jOrgChart",
dragAndDrop: false
dragAndDrop: false,
ignoreSpace: false
};

var nodeCount = 0;
Expand Down Expand Up @@ -141,15 +142,16 @@
if($tr.hasClass('contracted')){
$this.css('cursor','n-resize');
$tr.removeClass('contracted').addClass('expanded');
$tr.nextAll("tr").css('visibility', '');
$tr.nextAll("tr").css(opts.ignoreSpace ? 'display' : 'visibility', '');

// Update the <li> appropriately so that if the tree redraws collapsed/non-collapsed nodes
// maintain their appearance
$node.removeClass('collapsed');
}else{
$this.css('cursor','s-resize');
$tr.removeClass('expanded').addClass('contracted');
$tr.nextAll("tr").css('visibility', 'hidden');
if(opts.ignoreSpace) { $tr.nextAll("tr").css('display', 'none'); }
else { $tr.nextAll("tr").css('visibility', 'hidden'); }

$node.addClass('collapsed');
}
Expand Down Expand Up @@ -211,7 +213,8 @@
$.each(classList, function(index,item) {
if (item == 'collapsed') {
console.log($node);
$nodeRow.nextAll('tr').css('visibility', 'hidden');
if(opts.ignoreSpace) { $nodeRow.nextAll('tr').css('display', 'none'); }
else { $nodeRow.nextAll('tr').css('visibility', 'hidden'); }
$nodeRow.removeClass('expanded');
$nodeRow.addClass('contracted');
$nodeDiv.css('cursor','s-resize');
Expand Down
3 changes: 2 additions & 1 deletion readme.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@ Source code with an example is available [here](https://github.com/wesnolte/jOrg

##Configuration

There are only 3 configuration options.
There are only 5 configuration options.

1. **chartElement** - used to specify which HTML element you'd like to append the OrgChart markup to. *[default='body']*
2. **depth** - tells the code what depth to parse to. The default value of "-1" instructs it to parse like it's 1999. *[default=-1]*
3. **chartClass** - the name of the style class that is assigned to the generated markup. *[default='jOrgChart']*
4. **dragAndDrop** - determines whether the drag-and-drop feature of tree node elements is enabled. *[default=false]*
5. **ignoreSpace** - if true, no space is used by collapsed nodes. if false, the width and height of the graph stays the same when collapsing nodes. *[default=false]*