Guest User

Untitled

a guest
Dec 14th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. public function userCheck(){
  2. $result = json_encode($this->array_filter_recursive($legs), JSON_PRETTY_PRINT);
  3. $this->load->view('tree/drag-drop', array('builder'=>$result));
  4. }
  5.  
  6. public function array_filter_recursive($arr, $cb = null) {
  7. if (empty($cb)) {
  8. $cb = function ($el) {
  9. return $el;
  10. };
  11. }
  12. $result = array();
  13. foreach($arr as $key => $val) {
  14. if (is_array($val)) $val = $this->array_filter_recursive($val, $cb);
  15. if ($cb($val)) $result[$key] = $val;
  16. }
  17. return $result;
  18. }
  19.  
  20. $(function() {
  21. var datascource = {
  22. 'name': '<?= $account[0]->first_name.' '.$account[0]->last_name ?>',
  23. 'title': '<?= $account[0]->gcn_id ?>',
  24. 'children':<?= $builder?>
  25. };
  26.  
  27. var oc = $('#chart-container').orgchart({
  28. 'data' : datascource,
  29. 'nodeContent': 'title',
  30. 'draggable': true,
  31. 'dropCriteria': function($draggedNode, $dragZone, $dropZone) {
  32. if($draggedNode.find('.content').text().indexOf('manager') > -1 && $dropZone.find('.content').text().indexOf('engineer') > -1) {
  33. return false;
  34. }
  35. return true;
  36. }
  37. });
  38.  
  39. oc.$chart.on('nodedropped.orgchart', function(event) {
  40. console.log('draggedNode:' + event.draggedNode.children('.title').text()
  41. + ', dragZone:' + event.dragZone.children('.title').text()
  42. + ', dropZone:' + event.dropZone.children('.title').text()
  43. );
  44. }); });
Add Comment
Please, Sign In to add comment