diff --git a/README.md b/README.md index f1ef36c..03b7833 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,11 @@ # Jorgchart::Rails -TODO: Write a gem description +jOrgChart for Rails. Bundled up jOrgChart into something useable with the Rails 3.1 asset pipeline + +This gem include my forked version of jOrgChart (https://github.com/gdott9/jOrgChart/tree/my-master) which adds some features waiting to be merged. +Additionnal features : +* render list with multiple nodes on the first level (https://github.com/wesnolte/jOrgChart/pull/34) +* add an option to ignore space used by collapsed nodes (https://github.com/wesnolte/jOrgChart/pull/35) ## Installation @@ -18,7 +23,15 @@ Or install it yourself as: ## Usage -TODO: Write usage instructions here +In application.js +``` +//= require jquery.jorgchart +``` + +This gem comes with a stylesheet for default style. To use it, add the following line in application.css +``` +//= require jquery.jorgchart +``` ## Contributing diff --git a/vendor/assets/javascripts/jquery.jorgchart.js b/vendor/assets/javascripts/jquery.jorgchart.js index 9304d46..89791ba 100644 --- a/vendor/assets/javascripts/jquery.jorgchart.js +++ b/vendor/assets/javascripts/jquery.jorgchart.js @@ -99,7 +99,8 @@ chartElement : 'body', depth : -1, chartClass : "jOrgChart", - dragAndDrop: false + dragAndDrop: false, + ignoreSpace: false }; function buildNodes($list, $appendTo, opts) { @@ -160,7 +161,7 @@ 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
  • appropriately so that if the tree redraws collapsed/non-collapsed nodes // maintain their appearance @@ -168,7 +169,8 @@ }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'); } @@ -230,7 +232,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');