orgchart 3.5.0 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,6 +21,17 @@
21
21
  this.$chartContainer = $(elem);
22
22
  this.opts = opts;
23
23
  this.defaultOptions = {
24
+ 'icons': {
25
+ 'theme': 'oci',
26
+ 'parentNode': 'oci-menu',
27
+ 'expandToUp': 'oci-chevron-up',
28
+ 'collapseToDown': 'oci-chevron-down',
29
+ 'collapseToLeft': 'oci-chevron-left',
30
+ 'expandToRight': 'oci-chevron-right',
31
+ 'collapsed': 'oci-plus-square',
32
+ 'expanded': 'oci-minus-square',
33
+ 'spinner': 'oci-spinner'
34
+ },
24
35
  'nodeTitle': 'name',
25
36
  'nodeId': 'id',
26
37
  'toggleSiblingsResp': false,
@@ -30,7 +41,6 @@
30
41
  'exportButtonName': 'Export',
31
42
  'exportFilename': 'OrgChart',
32
43
  'exportFileextension': 'png',
33
- 'parentNodeSymbol': 'oci-leader',
34
44
  'draggable': false,
35
45
  'direction': 't2b',
36
46
  'pan': false,
@@ -71,7 +81,7 @@
71
81
  this.buildHierarchy($root, this.options.ajaxURL ? data : this.attachRel(data, '00'));
72
82
  }
73
83
  } else {
74
- $chart.append('<i class="oci oci-spinner spinner"></i>');
84
+ $chart.append(`<i class="${this.options.icons.theme} ${this.options.icons.spinner} spinner"></i>`);
75
85
  $.ajax({
76
86
  'url': data,
77
87
  'dataType': 'json'
@@ -568,7 +578,7 @@
568
578
  $animatedNodes.closest('.hierarchy').addClass('isCollapsedDescendant');
569
579
  }
570
580
  if ($lowerLevel.is('.vertical') || $lowerLevel.find('.vertical').length) {
571
- $animatedNodes.find('.oci-minus-square').removeClass('oci-minus-square').addClass('oci-plus-square');
581
+ $animatedNodes.find(this.options.icons.expanded).removeClass(this.options.icons.expanded).addClass(this.options.icons.collapsed);
572
582
  }
573
583
  this.repaint($animatedNodes.get(0));
574
584
  $animatedNodes.addClass('sliding slide-up').eq(0).one('transitionend', { 'animatedNodes': $animatedNodes, 'lowerLevel': $lowerLevel, 'node': $node }, this.hideChildrenEnd.bind(this));
@@ -647,7 +657,7 @@
647
657
  event.data.visibleNodes.removeClass('sliding');
648
658
  if (this.isInAction($node)) {
649
659
  this.switchHorizontalArrow($node);
650
- $node.children('.topEdge').removeClass('oci-chevron-up').addClass('oci-chevron-down');
660
+ $node.children('.topEdge').removeClass(this.options.icons.expandToUp).addClass(this.options.icons.collapseToDown);
651
661
  }
652
662
  },
653
663
  //
@@ -702,7 +712,7 @@
702
712
  }
703
713
 
704
714
  $edge.addClass('hidden');
705
- $edge.parent().append('<i class="oci oci-spinner spinner"></i>')
715
+ $edge.parent().append(`<i class="${this.options.icons.theme} ${this.options.icons.spinner} spinner"></i>`)
706
716
  .children().not('.spinner').css('opacity', 0.2);
707
717
  $chart.data('inAjax', true);
708
718
  $('.oc-export-btn').prop('disabled', true);
@@ -719,11 +729,16 @@
719
729
  },
720
730
  // whether the cursor is hovering over the node
721
731
  isInAction: function ($node) {
722
- return $node.children('.edge').attr('class').indexOf('oci-') > -1 ? true : false;
732
+ return [
733
+ this.options.icons.expandToUp,
734
+ this.options.icons.collapseToDown,
735
+ this.options.icons.collapseToLeft,
736
+ this.options.icons.expandToRight
737
+ ].some((icon) => $node.children('.edge').attr('class').indexOf(icon) > -1);
723
738
  },
724
739
  //
725
740
  switchVerticalArrow: function ($arrow) {
726
- $arrow.toggleClass('oci-chevron-up').toggleClass('oci-chevron-down');
741
+ $arrow.toggleClass(`${this.options.icons.expandToUp} ${this.options.icons.collapseToDown}`);
727
742
  },
728
743
  //
729
744
  switchHorizontalArrow: function ($node) {
@@ -732,24 +747,24 @@
732
747
  var $prevSib = $node.parent().prev();
733
748
  if ($prevSib.length) {
734
749
  if ($prevSib.is('.hidden')) {
735
- $node.children('.leftEdge').addClass('oci-chevron-left').removeClass('oci-chevron-right');
750
+ $node.children('.leftEdge').addClass(opts.icons.collapseToLeft).removeClass(opts.icons.expandToRight);
736
751
  } else {
737
- $node.children('.leftEdge').addClass('oci-chevron-right').removeClass('oci-chevron-left');
752
+ $node.children('.leftEdge').addClass(opts.icons.expandToRight).removeClass(opts.icons.collapseToLeft);
738
753
  }
739
754
  }
740
755
  var $nextSib = $node.parent().next();
741
756
  if ($nextSib.length) {
742
757
  if ($nextSib.is('.hidden')) {
743
- $node.children('.rightEdge').addClass('oci-chevron-right').removeClass('oci-chevron-left');
758
+ $node.children('.rightEdge').addClass(opts.icons.expandToRight).removeClass(opts.icons.collapseToLeft);
744
759
  } else {
745
- $node.children('.rightEdge').addClass('oci-chevron-left').removeClass('oci-chevron-right');
760
+ $node.children('.rightEdge').addClass(opts.icons.collapseToLeft).removeClass(opts.icons.expandToRight);
746
761
  }
747
762
  }
748
763
  } else {
749
764
  var $sibs = $node.parent().siblings();
750
765
  var sibsVisible = $sibs.length ? !$sibs.is('.hidden') : false;
751
- $node.children('.leftEdge').toggleClass('oci-chevron-right', sibsVisible).toggleClass('oci-chevron-left', !sibsVisible);
752
- $node.children('.rightEdge').toggleClass('oci-chevron-left', sibsVisible).toggleClass('oci-chevron-right', !sibsVisible);
766
+ $node.children('.leftEdge').toggleClass(opts.icons.expandToRight, sibsVisible).toggleClass(opts.icons.collapseToLeft, !sibsVisible);
767
+ $node.children('.rightEdge').toggleClass(opts.icons.collapseToLeft, sibsVisible).toggleClass(opts.icons.expandToRight, !sibsVisible);
753
768
  }
754
769
  },
755
770
  //
@@ -767,10 +782,10 @@
767
782
  if (event.type === 'mouseenter') {
768
783
  if ($node.children('.toggleBtn').length) {
769
784
  flag = this.getNodeState($node, 'children').visible;
770
- $toggleBtn.toggleClass('oci-plus-square', !flag).toggleClass('oci-minus-square', flag);
785
+ $toggleBtn.toggleClass(this.options.icons.collapsed, !flag).toggleClass(this.options.icons.expanded, flag);
771
786
  }
772
787
  } else {
773
- $toggleBtn.removeClass('oci-plus-square oci-minus-square');
788
+ $toggleBtn.removeClass(`${this.options.icons.collapsed} ${this.options.icons.expanded}`);
774
789
  }
775
790
  } else {
776
791
  var $topEdge = $node.children('.topEdge');
@@ -780,17 +795,17 @@
780
795
  if (event.type === 'mouseenter') {
781
796
  if ($topEdge.length) {
782
797
  flag = this.getNodeState($node, 'parent').visible;
783
- $topEdge.toggleClass('oci-chevron-up', !flag).toggleClass('oci-chevron-down', flag);
798
+ $topEdge.toggleClass(this.options.icons.expandToUp, !flag).toggleClass(this.options.icons.collapseToDown, flag);
784
799
  }
785
800
  if ($bottomEdge.length) {
786
801
  flag = this.getNodeState($node, 'children').visible;
787
- $bottomEdge.toggleClass('oci-chevron-down', !flag).toggleClass('oci-chevron-up', flag);
802
+ $bottomEdge.toggleClass(this.options.icons.collapseToDown, !flag).toggleClass(this.options.icons.expandToUp, flag);
788
803
  }
789
804
  if ($leftEdge.length) {
790
805
  this.switchHorizontalArrow($node);
791
806
  }
792
807
  } else {
793
- $node.children('.edge').removeClass('oci-chevron-up oci-chevron-down oci-chevron-right oci-chevron-left');
808
+ $node.children('.edge').removeClass(`${this.options.icons.expandToUp} ${this.options.icons.collapseToDown} ${this.options.icons.collapseToLeft} ${this.options.icons.expandToRight}`);
794
809
  }
795
810
  }
796
811
  },
@@ -954,14 +969,14 @@
954
969
  var $descendants = $descWrapper.find('.node');
955
970
  var $children = $descWrapper.children().children('.node');
956
971
  if ($children.is('.sliding')) { return; }
957
- $toggleBtn.toggleClass('oci-plus-square oci-minus-square');
972
+ $toggleBtn.toggleClass(`${this.options.icons.collapsed} ${this.options.icons.expanded}`);
958
973
  if ($descendants.eq(0).is('.slide-up')) {
959
974
  $descWrapper.removeClass('hidden');
960
975
  this.repaint($children.get(0));
961
976
  $children.addClass('sliding').removeClass('slide-up').eq(0).one('transitionend', { 'vNodes': $children }, this.expandVNodesEnd);
962
977
  } else {
963
978
  $descendants.addClass('sliding slide-up').eq(0).one('transitionend', { 'vNodes': $descendants }, this.collapseVNodesEnd);
964
- $descendants.find('.toggleBtn').removeClass('oci-minus-square oci-plus-square');
979
+ $descendants.find('.toggleBtn').removeClass(`${this.options.icons.collapsed} ${this.options.icons.expanded}`);
965
980
  }
966
981
  },
967
982
  //
@@ -1138,14 +1153,14 @@
1138
1153
  // The folowing code snippets are used to process horizontal chart
1139
1154
  // firstly, deal with the hierarchy of drop zone
1140
1155
  if (!$dropZone.siblings('.nodes').length) { // if the drop zone is a leaf node
1141
- $dropZone.append('<i class="edge verticalEdge bottomEdge oci"></i>')
1156
+ $dropZone.append(`<i class="edge verticalEdge bottomEdge ${this.options.icons.theme}"></i>`)
1142
1157
  .after('<ul class="nodes"></ul>')
1143
1158
  .siblings('.nodes').append($dragged.find('.horizontalEdge').remove().end().closest('.hierarchy'));
1144
1159
  if ($dropZone.children('.title').length) {
1145
- $dropZone.children('.title').prepend('<i class="oci '+ this.$chart.data('options').parentNodeSymbol + ' symbol"></i>');
1160
+ $dropZone.children('.title').prepend(`<i class="${this.options.icons.theme} ${this.$chart.data('options').icons.parentNode} parentNodeSymbol"></i>`);
1146
1161
  }
1147
1162
  } else {
1148
- var horizontalEdges = '<i class="edge horizontalEdge rightEdge oci"></i><i class="edge horizontalEdge leftEdge oci"></i>';
1163
+ var horizontalEdges = `<i class="edge horizontalEdge rightEdge ${this.options.icons.theme}"></i><i class="edge horizontalEdge leftEdge ${this.options.icons.theme}"></i>`;
1149
1164
  if (!$dragged.find('.horizontalEdge').length) {
1150
1165
  $dragged.append(horizontalEdges);
1151
1166
  }
@@ -1160,7 +1175,7 @@
1160
1175
  $dragZone.siblings('.nodes').children('.hierarchy').find('.node:first')
1161
1176
  .find('.horizontalEdge').remove();
1162
1177
  } else if ($dragZone.siblings('.nodes').children('.hierarchy').length === 0) {
1163
- $dragZone.find('.bottomEdge, .symbol').remove()
1178
+ $dragZone.find('.bottomEdge, .parentNodeSymbol').remove()
1164
1179
  .end().siblings('.nodes').remove();
1165
1180
  }
1166
1181
  }
@@ -1348,25 +1363,24 @@
1348
1363
  var flags = data.relationship || '';
1349
1364
  if ((opts.verticalLevel && level >= opts.verticalLevel) || data.isVertical) {
1350
1365
  if (Number(flags.substr(2,1))) {
1351
- $nodeDiv.append('<i class="toggleBtn oci"></i>')
1352
- .children('.title').prepend('<i class="oci '+ opts.parentNodeSymbol + ' symbol"></i>');
1366
+ $nodeDiv.append(`<i class="toggleBtn ${opts.icons.theme}"></i>`)
1367
+ .children('.title').prepend(`<i class="${opts.icons.theme} ${opts.icons.parentNode} parentNodeSymbol"></i>`);
1353
1368
  }
1354
1369
  } else if (data.isHybrid) {
1355
1370
  if (Number(flags.substr(2,1))) {
1356
- $nodeDiv.append('<i class="edge verticalEdge bottomEdge oci"></i>')
1357
- .children('.title').prepend('<i class="oci '+ opts.parentNodeSymbol + ' symbol"></i>');
1371
+ $nodeDiv.append(`<i class="edge verticalEdge bottomEdge ${opts.icons.theme}"></i>`)
1372
+ .children('.title').prepend(`<i class="${opts.icons.theme} ${opts.icons.parentNode} parentNodeSymbol"></i>`);
1358
1373
  }
1359
1374
  } else {
1360
1375
  if (Number(flags.substr(0,1))) {
1361
- $nodeDiv.append('<i class="edge verticalEdge topEdge oci"></i>');
1376
+ $nodeDiv.append(`<i class="edge verticalEdge topEdge ${opts.icons.theme}"></i>`);
1362
1377
  }
1363
1378
  if(Number(flags.substr(1,1))) {
1364
- $nodeDiv.append('<i class="edge horizontalEdge rightEdge oci"></i>' +
1365
- '<i class="edge horizontalEdge leftEdge oci"></i>');
1379
+ $nodeDiv.append(`<i class="edge horizontalEdge rightEdge ${opts.icons.theme}"></i><i class="edge horizontalEdge leftEdge ${opts.icons.theme}"></i>`);
1366
1380
  }
1367
1381
  if(Number(flags.substr(2,1))) {
1368
- $nodeDiv.append('<i class="edge verticalEdge bottomEdge oci"></i>')
1369
- .children('.title').prepend('<i class="oci '+ opts.parentNodeSymbol + ' symbol"></i>');
1382
+ $nodeDiv.append(`<i class="edge verticalEdge bottomEdge ${opts.icons.theme}"></i>`)
1383
+ .children('.title').prepend(`<i class="${opts.icons.theme} ${opts.icons.parentNode} parentNodeSymbol"></i>`);
1370
1384
  }
1371
1385
  }
1372
1386
 
@@ -1446,16 +1460,16 @@
1446
1460
  // exposed method
1447
1461
  addChildren: function ($node, data) {
1448
1462
  this.buildChildNode($node.closest('.hierarchy'), data);
1449
- if (!$node.find('.symbol').length) {
1450
- $node.children('.title').prepend('<i class="oci '+ this.options.parentNodeSymbol + ' symbol"></i>');
1463
+ if (!$node.find('.parentNodeSymbol').length) {
1464
+ $node.children('.title').prepend(`<i class="${this.options.icons.theme} ${this.options.icons.parentNode} parentNodeSymbol"></i>`);
1451
1465
  }
1452
1466
  if ($node.closest('.nodes.vertical').length) {
1453
1467
  if (!$node.children('.toggleBtn').length) {
1454
- $node.append('<i class="toggleBtn oci"></i>');
1468
+ $node.append(`<i class="toggleBtn ${this.options.icons.theme}"></i>`);
1455
1469
  }
1456
1470
  } else {
1457
1471
  if (!$node.children('.bottomEdge').length) {
1458
- $node.append('<i class="edge verticalEdge bottomEdge oci"></i>');
1472
+ $node.append(`<i class="edge verticalEdge bottomEdge ${this.options.icons.theme}"></i>`);
1459
1473
  }
1460
1474
  }
1461
1475
  if (this.isInAction($node)) {
@@ -1474,7 +1488,7 @@
1474
1488
  addParent: function ($currentRoot, data) {
1475
1489
  this.buildParentNode($currentRoot, data);
1476
1490
  if (!$currentRoot.children('.topEdge').length) {
1477
- $currentRoot.children('.title').after('<i class="edge verticalEdge topEdge oci"></i>');
1491
+ $currentRoot.children('.title').after(`<i class="edge verticalEdge topEdge ${this.options.icons.theme}"></i>`);
1478
1492
  }
1479
1493
  if (this.isInAction($currentRoot)) {
1480
1494
  this.switchVerticalArrow($currentRoot.children('.topEdge'));
@@ -1505,11 +1519,11 @@
1505
1519
  this.buildSiblingNode($node.closest('.hierarchy'), data);
1506
1520
  $node.closest('.nodes').data('siblingsLoaded', true);
1507
1521
  if (!$node.children('.leftEdge').length) {
1508
- $node.children('.topEdge').after('<i class="edge horizontalEdge rightEdge oci"></i><i class="edge horizontalEdge leftEdge oci"></i>');
1522
+ $node.children('.topEdge').after(`<i class="edge horizontalEdge rightEdge ${this.options.icons.theme}"></i><i class="edge horizontalEdge leftEdge ${this.options.icons.theme}"></i>`);
1509
1523
  }
1510
1524
  if (this.isInAction($node)) {
1511
1525
  this.switchHorizontalArrow($node);
1512
- $node.children('.topEdge').removeClass('oci-chevron-up').addClass('oci-chevron-down');
1526
+ $node.children('.topEdge').removeClass(this.options.icons.expandToUp).addClass(this.options.icons.collapseToDown);
1513
1527
  }
1514
1528
  },
1515
1529
  // remove node and its descendent nodes
@@ -1594,10 +1608,10 @@
1594
1608
  if ((!isWebkit && !isFf) || isEdge) {
1595
1609
  window.navigator.msSaveBlob(canvas.msToBlob(), exportFilename + '.png');
1596
1610
  } else {
1597
- var selector = '.oci-download-btn' + (that.options.chartClass !== '' ? '.' + that.options.chartClass : '');
1611
+ var selector = '.download-btn' + (that.options.chartClass !== '' ? '.' + that.options.chartClass : '');
1598
1612
 
1599
1613
  if (!$chartContainer.find(selector).length) {
1600
- $chartContainer.append('<a class="oci-download-btn' + (that.options.chartClass !== '' ? ' ' + that.options.chartClass : '') + '"'
1614
+ $chartContainer.append('<a class="download-btn' + (that.options.chartClass !== '' ? ' ' + that.options.chartClass : '') + '"'
1601
1615
  + ' download="' + exportFilename + '.png"></a>');
1602
1616
  }
1603
1617
 
@@ -1615,7 +1629,7 @@
1615
1629
  var $chartContainer = this.$chartContainer;
1616
1630
  var $mask = $chartContainer.find('.mask');
1617
1631
  if (!$mask.length) {
1618
- $chartContainer.append('<div class="mask"><i class="oci oci-spinner spinner"></i></div>');
1632
+ $chartContainer.append(`<div class="mask"><i class="${this.options.icons.theme} ${this.options.icons.spinner} spinner"></i></div>`);
1619
1633
  } else {
1620
1634
  $mask.removeClass('hidden');
1621
1635
  }
@@ -1,2 +1,2 @@
1
- "use strict";!function(e){"object"==typeof module&&"object"==typeof module.exports?e(require("jquery"),window,document):e(jQuery,window,document)}(function(l,h,c,r){function t(e,t){this.$chartContainer=l(e),this.opts=t,this.defaultOptions={nodeTitle:"name",nodeId:"id",toggleSiblingsResp:!1,visibleLevel:999,chartClass:"",exportButton:!1,exportButtonName:"Export",exportFilename:"OrgChart",exportFileextension:"png",parentNodeSymbol:"oci-leader",draggable:!1,direction:"t2b",pan:!1,zoom:!1,zoominLimit:7,zoomoutLimit:.5}}t.prototype={init:function(e){var n=this,e=(this.options=l.extend({},this.defaultOptions,this.opts,e),this.$chartContainer),t=(this.$chart&&this.$chart.remove(),this.options.data),i=this.$chart=l("<div>",{data:{options:this.options},class:"orgchart"+(""!==this.options.chartClass?" "+this.options.chartClass:"")+("t2b"!==this.options.direction?" "+this.options.direction:""),click:function(e){l(e.target).closest(".node").length||i.find(".node.focused").removeClass("focused")}}),s=("undefined"!=typeof MutationObserver&&this.triggerInitEvent(),i.append(l('<ul class="nodes"><li class="hierarchy"></li></ul>')).find(".hierarchy"));return"object"===l.type(t)?t instanceof l?this.buildHierarchy(s,this.buildJsonDS(t.children()),0,this.options):this.buildHierarchy(s,this.options.ajaxURL?t:this.attachRel(t,"00")):(i.append('<i class="oci oci-spinner spinner"></i>'),l.ajax({url:t,dataType:"json"}).done(function(e,t,i){n.buildHierarchy(s,n.options.ajaxURL?e:n.attachRel(e,"00"),0,n.options)}).fail(function(e,t,i){console.log(i)}).always(function(){i.children(".spinner").remove()})),e.append(i),this.options.exportButton&&!l(".oc-export-btn").length&&this.attachExportButton(),this.options.pan&&this.bindPan(),this.options.zoom&&this.bindZoom(),this},triggerInitEvent:function(){var s=this,o=new MutationObserver(function(e){o.disconnect();e:for(var t=0;t<e.length;t++)for(var i=0;i<e[t].addedNodes.length;i++)if(e[t].addedNodes[i].classList.contains("orgchart")){s.options.initCompleted&&"function"==typeof s.options.initCompleted&&s.options.initCompleted(s.$chart);var n=l.Event("init.orgchart");s.$chart.trigger(n);break e}});o.observe(this.$chartContainer[0],{childList:!0})},triggerLoadEvent:function(e,t){t=l.Event("load-"+t+".orgchart");e.trigger(t)},triggerShowEvent:function(e,t){t=l.Event("show-"+t+".orgchart");e.trigger(t)},triggerHideEvent:function(e,t){t=l.Event("hide-"+t+".orgchart");e.trigger(t)},attachExportButton:function(){var t=this,e=l("<button>",{class:"oc-export-btn",text:this.options.exportButtonName,click:function(e){e.preventDefault(),t.export()}});this.$chartContainer.after(e)},setOptions:function(e,t){return"string"==typeof e&&("pan"===e&&(t?this.bindPan():this.unbindPan()),"zoom"===e)&&(t?this.bindZoom():this.unbindZoom()),"object"==typeof e&&(e.data?this.init(e):(void 0!==e.pan&&(e.pan?this.bindPan():this.unbindPan()),void 0!==e.zoom&&(e.zoom?this.bindZoom():this.unbindZoom()))),this},panStartHandler:function(e){var s=l(e.delegateTarget);if(l(e.target).closest(".node").length||e.touches&&1<e.touches.length)s.data("panning",!1);else{s.css("cursor","move").data("panning",!0);var t,i=0,n=0,o=s.css("transform"),a=("none"!==o&&(t=o.split(","),n=-1===o.indexOf("3d")?(i=parseInt(t[4]),parseInt(t[5])):(i=parseInt(t[12]),parseInt(t[13]))),0),r=0;if(e.targetTouches){if(1===e.targetTouches.length)a=e.targetTouches[0].pageX-i,r=e.targetTouches[0].pageY-n;else if(1<e.targetTouches.length)return}else a=e.pageX-i,r=e.pageY-n;s.on("mousemove touchmove",function(e){if(s.data("panning")){var t=0,i=0;if(e.targetTouches){if(1===e.targetTouches.length)t=e.targetTouches[0].pageX-a,i=e.targetTouches[0].pageY-r;else if(1<e.targetTouches.length)return}else t=e.pageX-a,i=e.pageY-r;var n,e=s.css("transform");"none"===e?-1===e.indexOf("3d")?s.css("transform","matrix(1, 0, 0, 1, "+t+", "+i+")"):s.css("transform","matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, "+t+", "+i+", 0, 1)"):(n=e.split(","),-1===e.indexOf("3d")?(n[4]=" "+t,n[5]=" "+i+")"):(n[12]=" "+t,n[13]=" "+i),s.css("transform",n.join(",")))}})}},panEndHandler:function(e){e.data.chart.data("panning")&&e.data.chart.data("panning",!1).css("cursor","default").off("mousemove")},bindPan:function(){this.$chartContainer.css("overflow","hidden"),this.$chart.on("mousedown touchstart",this.panStartHandler),l(c).on("mouseup touchend",{chart:this.$chart},this.panEndHandler)},unbindPan:function(){this.$chartContainer.css("overflow","auto"),this.$chart.off("mousedown touchstart",this.panStartHandler),l(c).off("mouseup touchend",this.panEndHandler)},zoomWheelHandler:function(e){var t=e.data.oc,e=(e.preventDefault(),1+(0<e.originalEvent.deltaY?-.2:.2));t.setChartScale(t.$chart,e)},zoomStartHandler:function(e){var t;e.touches&&2===e.touches.length&&((t=e.data.oc).$chart.data("pinching",!0),e=t.getPinchDist(e),t.$chart.data("pinchDistStart",e))},zoomingHandler:function(e){var t=e.data.oc;t.$chart.data("pinching")&&(e=t.getPinchDist(e),t.$chart.data("pinchDistEnd",e))},zoomEndHandler:function(e){var t,e=e.data.oc;e.$chart.data("pinching")&&(e.$chart.data("pinching",!1),0<(t=e.$chart.data("pinchDistEnd")-e.$chart.data("pinchDistStart"))?e.setChartScale(e.$chart,1.2):t<0&&e.setChartScale(e.$chart,.8))},bindZoom:function(){this.$chartContainer.on("wheel",{oc:this},this.zoomWheelHandler),this.$chartContainer.on("touchstart",{oc:this},this.zoomStartHandler),l(c).on("touchmove",{oc:this},this.zoomingHandler),l(c).on("touchend",{oc:this},this.zoomEndHandler)},unbindZoom:function(){this.$chartContainer.off("wheel",this.zoomWheelHandler),this.$chartContainer.off("touchstart",this.zoomStartHandler),l(c).off("touchmove",this.zoomingHandler),l(c).off("touchend",this.zoomEndHandler)},getPinchDist:function(e){return Math.sqrt((e.touches[0].clientX-e.touches[1].clientX)*(e.touches[0].clientX-e.touches[1].clientX)+(e.touches[0].clientY-e.touches[1].clientY)*(e.touches[0].clientY-e.touches[1].clientY))},setChartScale:function(e,t){var i,n=e.data("options"),s=e.css("transform"),o=1;"none"===s?e.css("transform","scale("+t+","+t+")"):(i=s.split(","),-1===s.indexOf("3d")?(o=Math.abs(h.parseFloat(i[3])*t))>n.zoomoutLimit&&o<n.zoominLimit&&e.css("transform",s+" scale("+t+","+t+")"):(o=Math.abs(h.parseFloat(i[1])*t))>n.zoomoutLimit&&o<n.zoominLimit&&e.css("transform",s+" scale3d("+t+","+t+", 1)"))},buildJsonDS:function(e){var t=this,i={name:e.contents().eq(0).text().trim(),relationship:(e.parent().parent().is("li")?"1":"0")+(e.siblings("li").length?1:0)+(e.children("ul").length?1:0)};return l.each(e.data(),function(e,t){i[e]=t}),e.children("ul").children().each(function(){i.children||(i.children=[]),i.children.push(t.buildJsonDS(l(this)))}),i},attachRel:function(t,e){var i=this;return t.relationship=e+(t.children&&0<t.children.length?1:0),t.children&&t.children.forEach(function(e){(t.isHybrid||t.isVertical)&&(e.isVertical=!0),i.attachRel(e,"1"+(1<t.children.length?1:0))}),t},loopChart:function(e,t){t=null!==t&&t!==r&&t;var i=this,e=e.find(".node:first"),n={id:e[0].id};return t&&l.each(e.data("nodeData"),function(e,t){n[e]=t}),e.siblings(".nodes").children().each(function(){n.children||(n.children=[]),n.children.push(i.loopChart(l(this),t))}),n},getHierarchy:function(e){var t;return e=null!==e&&e!==r&&e,void 0===this.$chart?"Error: orgchart does not exist":this.$chart.find(".node").length?(t=!0,this.$chart.find(".node").each(function(){if(!this.id)return t=!1}),t?this.loopChart(this.$chart,e):"Error: All nodes of orghcart to be exported must have data-id attribute!"):"Error: nodes do not exist"},getNodeState:function(e,t){var i={},n=!!e.closest("vertical").length;if("parent"===(t=t||"self")){if(n?(i=e.closest("ul").parents("ul")).length||(i=e.closest(".nodes")).length||(i=e.closest(".vertical").siblings(":first")):i=e.closest(".nodes").siblings(".node"),i.length)return i.is(".hidden")||!i.is(".hidden")&&i.closest(".nodes").is(".hidden")||!i.is(".hidden")&&i.closest(".vertical").is(".hidden")?{exist:!0,visible:!1}:{exist:!0,visible:!0}}else if("children"===t){if((i=n?e.parent().children("ul"):e.siblings(".nodes")).length)return i.is(".hidden")?{exist:!0,visible:!1}:{exist:!0,visible:!0}}else if("siblings"===t){if((i=n?e.closest("ul"):e.parent().siblings()).length&&(!n||1<i.children("li").length))return i.is(".hidden")||i.parent().is(".hidden")||n&&i.closest(".vertical").is(".hidden")?{exist:!0,visible:!1}:{exist:!0,visible:!0}}else if((i=e).length)return i.closest(".nodes").length&&i.closest(".nodes").is(".hidden")||i.closest(".hierarchy").length&&i.closest(".hierarchy").is(".hidden")||i.closest(".vertical").length&&(i.closest(".nodes").is(".hidden")||i.closest(".vertical").is(".hidden"))?{exist:!0,visible:!1}:{exist:!0,visible:!0};return{exist:!1,visible:!1}},getParent:function(e){return this.getRelatedNodes(e,"parent")},getChildren:function(e){return this.getRelatedNodes(e,"children")},getSiblings:function(e){return this.getRelatedNodes(e,"siblings")},getRelatedNodes:function(e,t){return e&&e instanceof l&&e.is(".node")?"parent"===t?e.closest(".nodes").siblings(".node"):"children"===t?e.siblings(".nodes").children(".hierarchy").find(".node:first"):"siblings"===t?e.closest(".hierarchy").siblings().find(".node:first"):l():l()},hideParentEnd:function(e){l(e.target).removeClass("sliding"),e.data.parent.addClass("hidden")},hideParent:function(e){var t=e.closest(".nodes").siblings(".node");t.find(".spinner").length&&e.closest(".orgchart").data("inAjax",!1),this.getNodeState(e,"siblings").visible&&this.hideSiblings(e),e.parent().addClass("isAncestorsCollapsed"),this.getNodeState(t).visible&&t.addClass("sliding slide-down").one("transitionend",{parent:t},this.hideParentEnd),this.getNodeState(t,"parent").visible&&this.hideParent(t)},showParentEnd:function(e){var t=e.data.node;l(e.target).removeClass("sliding"),this.isInAction(t)&&this.switchVerticalArrow(t.children(".topEdge"))},showParent:function(e){var t=e.closest(".nodes").siblings(".node").removeClass("hidden");e.closest(".hierarchy").removeClass("isAncestorsCollapsed"),this.repaint(t[0]),t.addClass("sliding").removeClass("slide-down").one("transitionend",{node:e},this.showParentEnd.bind(this))},stopAjax:function(e){e.find(".spinner").length&&e.closest(".orgchart").data("inAjax",!1)},isVisibleNode:function(e,t){return this.getNodeState(l(t)).visible},hideChildrenEnd:function(e){var t=e.data.node;e.data.animatedNodes.removeClass("sliding"),e.data.animatedNodes.closest(".nodes").addClass("hidden"),this.isInAction(t)&&this.switchVerticalArrow(t.children(".bottomEdge"))},hideChildren:function(e){e.closest(".hierarchy").addClass("isChildrenCollapsed");var t=e.siblings(".nodes"),i=(this.stopAjax(t),t.find(".node").filter(this.isVisibleNode.bind(this)));t.is(".vertical")||i.closest(".hierarchy").addClass("isCollapsedDescendant"),(t.is(".vertical")||t.find(".vertical").length)&&i.find(".oci-minus-square").removeClass("oci-minus-square").addClass("oci-plus-square"),this.repaint(i.get(0)),i.addClass("sliding slide-up").eq(0).one("transitionend",{animatedNodes:i,lowerLevel:t,node:e},this.hideChildrenEnd.bind(this))},showChildrenEnd:function(e){var t=e.data.node;e.data.animatedNodes.removeClass("sliding"),this.isInAction(t)&&this.switchVerticalArrow(t.children(".bottomEdge"))},showChildren:function(e){e.closest(".hierarchy").removeClass("isChildrenCollapsed");var t=e.siblings(".nodes"),i=t.is(".vertical"),t=(i?t.removeClass("hidden").find(".node"):t.removeClass("hidden").children(".hierarchy").find(".node:first")).filter(this.isVisibleNode.bind(this));i||(t.filter(":not(:only-child)").closest(".hierarchy").addClass("isChildrenCollapsed"),t.closest(".hierarchy").removeClass("isCollapsedDescendant")),this.repaint(t.get(0)),t.addClass("sliding").removeClass("slide-up").eq(0).one("transitionend",{node:e,animatedNodes:t},this.showChildrenEnd.bind(this))},hideSiblingsEnd:function(e){var t=e.data.node,i=e.data.nodeContainer,n=e.data.direction,n=n?"left"===n?i.prevAll(":not(.hidden)"):i.nextAll(":not(.hidden)"):i.siblings();e.data.animatedNodes.removeClass("sliding"),n.find(".node:gt(0)").filter(this.isVisibleNode.bind(this)).removeClass("slide-left slide-right").addClass("slide-up"),n.find(".nodes, .vertical").addClass("hidden").end().addClass("hidden"),this.isInAction(t)&&this.switchHorizontalArrow(t)},hideSiblings:function(e,t){var i=e.closest(".hierarchy").addClass("isSiblingsCollapsed"),n=(i.siblings().find(".spinner").length&&e.closest(".orgchart").data("inAjax",!1),t?"left"===t?i.addClass("left-sibs").prevAll(".isSiblingsCollapsed").removeClass("isSiblingsCollapsed left-sibs").end().prevAll().addClass("isCollapsedSibling isChildrenCollapsed").find(".node").filter(this.isVisibleNode.bind(this)).addClass("sliding slide-right"):i.addClass("right-sibs").nextAll(".isSiblingsCollapsed").removeClass("isSiblingsCollapsed right-sibs").end().nextAll().addClass("isCollapsedSibling isChildrenCollapsed").find(".node").filter(this.isVisibleNode.bind(this)).addClass("sliding slide-left"):(i.prevAll().find(".node").filter(this.isVisibleNode.bind(this)).addClass("sliding slide-right"),i.nextAll().find(".node").filter(this.isVisibleNode.bind(this)).addClass("sliding slide-left"),i.siblings().addClass("isCollapsedSibling isChildrenCollapsed")),i.siblings().find(".sliding"));n.eq(0).one("transitionend",{node:e,nodeContainer:i,direction:t,animatedNodes:n},this.hideSiblingsEnd.bind(this))},showSiblingsEnd:function(e){var t=e.data.node;e.data.visibleNodes.removeClass("sliding"),this.isInAction(t)&&(this.switchHorizontalArrow(t),t.children(".topEdge").removeClass("oci-chevron-up").addClass("oci-chevron-down"))},showRelatedParentEnd:function(e){l(e.target).removeClass("sliding")},showSiblings:function(e,t){var i=l(),n=e.closest(".hierarchy"),i=(t?"left"===t?n.prevAll():n.nextAll():e.closest(".hierarchy").siblings()).removeClass("hidden"),s=e.closest(".nodes").siblings(".node"),n=(t?(n.removeClass(t+"-sibs"),n.is("[class*=-sibs]")||n.removeClass("isSiblingsCollapsed"),i.removeClass("isCollapsedSibling "+t+"-sibs")):(e.closest(".hierarchy").removeClass("isSiblingsCollapsed"),i.removeClass("isCollapsedSibling")),this.getNodeState(e,"parent").visible||(e.closest(".hierarchy").removeClass("isAncestorsCollapsed"),s.removeClass("hidden"),this.repaint(s[0]),s.addClass("sliding").removeClass("slide-down").one("transitionend",this.showRelatedParentEnd)),i.find(".node").filter(this.isVisibleNode.bind(this)));this.repaint(n.get(0)),n.addClass("sliding").removeClass("slide-left slide-right"),n.eq(0).one("transitionend",{node:e,visibleNodes:n},this.showSiblingsEnd.bind(this))},startLoading:function(e){var t=this.$chart;return(void 0===t.data("inAjax")||!0!==t.data("inAjax"))&&(e.addClass("hidden"),e.parent().append('<i class="oci oci-spinner spinner"></i>').children().not(".spinner").css("opacity",.2),t.data("inAjax",!0),l(".oc-export-btn").prop("disabled",!0),!0)},endLoading:function(e){var t=e.parent();e.removeClass("hidden"),t.find(".spinner").remove(),t.children().removeAttr("style"),this.$chart.data("inAjax",!1),l(".oc-export-btn").prop("disabled",!1)},isInAction:function(e){return-1<e.children(".edge").attr("class").indexOf("oci-")},switchVerticalArrow:function(e){e.toggleClass("oci-chevron-up").toggleClass("oci-chevron-down")},switchHorizontalArrow:function(e){var t=this.options;t.toggleSiblingsResp&&(void 0===t.ajaxURL||e.closest(".nodes").data("siblingsLoaded"))?((t=e.parent().prev()).length&&(t.is(".hidden")?e.children(".leftEdge").addClass("oci-chevron-left").removeClass("oci-chevron-right"):e.children(".leftEdge").addClass("oci-chevron-right").removeClass("oci-chevron-left")),(t=e.parent().next()).length&&(t.is(".hidden")?e.children(".rightEdge").addClass("oci-chevron-right").removeClass("oci-chevron-left"):e.children(".rightEdge").addClass("oci-chevron-left").removeClass("oci-chevron-right"))):(t=!!(t=e.parent().siblings()).length&&!t.is(".hidden"),e.children(".leftEdge").toggleClass("oci-chevron-right",t).toggleClass("oci-chevron-left",!t),e.children(".rightEdge").toggleClass("oci-chevron-left",t).toggleClass("oci-chevron-right",!t))},repaint:function(e){e&&(e.style.offsetWidth=e.offsetWidth)},nodeEnterLeaveHandler:function(e){var t,i,n,s=l(e.delegateTarget),o=!1;s.closest(".nodes.vertical").length?(t=s.children(".toggleBtn"),"mouseenter"===e.type?s.children(".toggleBtn").length&&(o=this.getNodeState(s,"children").visible,t.toggleClass("oci-plus-square",!o).toggleClass("oci-minus-square",o)):t.removeClass("oci-plus-square oci-minus-square")):(t=s.children(".topEdge"),s.children(".rightEdge"),i=s.children(".bottomEdge"),n=s.children(".leftEdge"),"mouseenter"===e.type?(t.length&&(o=this.getNodeState(s,"parent").visible,t.toggleClass("oci-chevron-up",!o).toggleClass("oci-chevron-down",o)),i.length&&(o=this.getNodeState(s,"children").visible,i.toggleClass("oci-chevron-down",!o).toggleClass("oci-chevron-up",o)),n.length&&this.switchHorizontalArrow(s)):s.children(".edge").removeClass("oci-chevron-up oci-chevron-down oci-chevron-right oci-chevron-left"))},nodeClickHandler:function(e){this.$chart.find(".focused").removeClass("focused"),l(e.delegateTarget).addClass("focused")},loadNodes:function(t,e,i){var n=this;this.options;l.ajax({url:e,dataType:"json"}).done(function(e){n.$chart.data("inAjax")&&("parent"===t?l.isEmptyObject(e)||n.addParent(i.parent(),e):"children"===t?e.children.length&&n.addChildren(i.parent(),e[t]):n.addSiblings(i.parent(),e.siblings||e),n.triggerLoadEvent(i.parent(),t))}).fail(function(){console.log("Failed to get "+t+" data")}).always(function(){n.endLoading(i)})},HideFirstParentEnd:function(e){var e=e.data.topEdge,t=e.parent();this.isInAction(t)&&(this.switchVerticalArrow(e),this.switchHorizontalArrow(t))},topEdgeClickHandler:function(e){e.stopPropagation();var t,i=l(e.target),e=l(e.delegateTarget),n=this.getNodeState(e,"parent");n.exist?(t=e.closest(".nodes").siblings(".node")).is(".sliding")||(n.visible?(this.hideParent(e),t.one("transitionend",{topEdge:i},this.HideFirstParentEnd.bind(this)),this.triggerHideEvent(e,"parent")):(this.showParent(e),this.triggerShowEvent(e,"parent"))):this.startLoading(i)&&(n=this.options,t=l.isFunction(n.ajaxURL.parent)?n.ajaxURL.parent(e.data("nodeData")):n.ajaxURL.parent+e[0].id,this.loadNodes("parent",t,i))},bottomEdgeClickHandler:function(e){e.stopPropagation();var t=l(e.target),e=l(e.delegateTarget),i=this.getNodeState(e,"children");i.exist?e.siblings(".nodes").children().children(".node").is(".sliding")||(i.visible?(this.hideChildren(e),this.triggerHideEvent(e,"children")):(this.showChildren(e),this.triggerShowEvent(e,"children"))):this.startLoading(t)&&(i=this.options,i=l.isFunction(i.ajaxURL.children)?i.ajaxURL.children(e.data("nodeData")):i.ajaxURL.children+e[0].id,this.loadNodes("children",i,t))},hEdgeClickHandler:function(e){e.stopPropagation();var t,i,n=l(e.target),e=l(e.delegateTarget),s=this.options,o=this.getNodeState(e,"siblings");o.exist?e.closest(".hierarchy").siblings().find(".sliding").length||(s.toggleSiblingsResp?(t=e.closest(".hierarchy").prev(),i=e.closest(".hierarchy").next(),n.is(".leftEdge")?t.is(".hidden")?(this.showSiblings(e,"left"),this.triggerShowEvent(e,"siblings")):(this.hideSiblings(e,"left"),this.triggerHideEvent(e,"siblings")):i.is(".hidden")?(this.showSiblings(e,"right"),this.triggerShowEvent(e,"siblings")):(this.hideSiblings(e,"right"),this.triggerHideEvent(e,"siblings"))):o.visible?(this.hideSiblings(e),this.triggerHideEvent(e,"siblings")):(this.showSiblings(e),this.triggerShowEvent(e,"siblings"))):this.startLoading(n)&&(t=e[0].id,i=this.getNodeState(e,"parent").exist?l.isFunction(s.ajaxURL.siblings)?s.ajaxURL.siblings(e.data("nodeData")):s.ajaxURL.siblings+t:l.isFunction(s.ajaxURL.families)?s.ajaxURL.families(e.data("nodeData")):s.ajaxURL.families+t,this.loadNodes("siblings",i,n))},expandVNodesEnd:function(e){e.data.vNodes.removeClass("sliding")},collapseVNodesEnd:function(e){e.data.vNodes.removeClass("sliding").closest("ul").addClass("hidden")},toggleVNodes:function(e){var e=l(e.target),t=e.parent().next(),i=t.find(".node"),n=t.children().children(".node");n.is(".sliding")||(e.toggleClass("oci-plus-square oci-minus-square"),i.eq(0).is(".slide-up")?(t.removeClass("hidden"),this.repaint(n.get(0)),n.addClass("sliding").removeClass("slide-up").eq(0).one("transitionend",{vNodes:n},this.expandVNodesEnd)):(i.addClass("sliding slide-up").eq(0).one("transitionend",{vNodes:i},this.collapseVNodesEnd),i.find(".toggleBtn").removeClass("oci-minus-square oci-plus-square")))},createGhostNode:function(e){var t,i,n=l(e.target),s=this.options,e=e.originalEvent,o=/firefox/.test(h.navigator.userAgent.toLowerCase());if(c.querySelector(".ghost-node"))t=n.closest(".orgchart").children(".ghost-node").get(0),i=l(t).children().get(0);else{if(!(t=c.createElementNS("http://www.w3.org/2000/svg","svg")).classList)return;t.classList.add("ghost-node"),i=c.createElementNS("http://www.w3.org/2000/svg","rect"),t.appendChild(i),n.closest(".orgchart").append(t)}var a=n.closest(".orgchart").css("transform").split(","),r="t2b"===s.direction||"b2t"===s.direction,a=Math.abs(h.parseFloat(r?a[0].slice(a[0].indexOf("(")+1):a[1])),r=(t.setAttribute("width",r?n.outerWidth(!1):n.outerHeight(!1)),t.setAttribute("height",r?n.outerHeight(!1):n.outerWidth(!1)),i.setAttribute("x",5*a),i.setAttribute("y",5*a),i.setAttribute("width",120*a),i.setAttribute("height",40*a),i.setAttribute("rx",4*a),i.setAttribute("ry",4*a),i.setAttribute("stroke-width",+a),e.offsetX*a),d=e.offsetY*a;"l2r"===s.direction?(r=e.offsetY*a,d=e.offsetX*a):"r2l"===s.direction?(r=n.outerWidth(!1)-e.offsetY*a,d=e.offsetX*a):"b2t"===s.direction&&(r=n.outerWidth(!1)-e.offsetX*a,d=n.outerHeight(!1)-e.offsetY*a),o?(i.setAttribute("fill","rgb(255, 255, 255)"),i.setAttribute("stroke","rgb(191, 0, 0)"),(s=c.createElement("img")).src="data:image/svg+xml;utf8,"+(new XMLSerializer).serializeToString(t),e.dataTransfer.setDragImage(s,r,d)):e.dataTransfer.setDragImage&&e.dataTransfer.setDragImage(t,r,d)},getUpperLevel:function(e){return e.is(".node")?e.parents(".hierarchy").length:0},getLowerLevel:function(e){return e.is(".node")?e.closest(".hierarchy").find(".nodes").length+1:0},getLevelOrderNodes:function(e){if(!e)return[];var t=[],i=[];for(t.push(e);t.length;){for(var n=[],s=0;s<t.length;s++){var o=t.shift(),a=this.getChildren(o);a.length&&t.push(a.toArray().flat()),n.push(l(o))}i.push(n)}return i},filterAllowedDropNodes:function(i){var n=this.options,s=i.closest("[draggable]").hasClass("node"),o=i.closest(".nodes").siblings(".node"),a=i.closest(".hierarchy").find(".node");this.$chart.data("dragged",i).find(".node").each(function(e,t){s&&-1!==a.index(t)||n.dropCriteria&&!n.dropCriteria(i,o,l(t))||l(t).addClass("allowedDrop")})},dragstartHandler:function(e){e.originalEvent.dataTransfer.setData("text/html","hack for firefox"),"none"!==this.$chart.css("transform")&&this.createGhostNode(e),this.filterAllowedDropNodes(l(e.target))},dragoverHandler:function(e){l(e.delegateTarget).is(".allowedDrop")?e.preventDefault():e.originalEvent.dataTransfer.dropEffect="none"},dragendHandler:function(e){this.$chart.find(".allowedDrop").removeClass("allowedDrop")},dropHandler:async function(e){var t,i,n,s,o,e=l(e.delegateTarget),a=this.$chart.data("dragged");a.hasClass("node")?e.hasClass("allowedDrop")&&(t=a.closest(".nodes").siblings(".node"),i=l.Event("nodedrop.orgchart"),this.$chart.trigger(i,{draggedNode:a,dragZone:t,dropZone:e}),i.isDefaultPrevented()||(i=this.$chart.data("options").data,o=(s=new JSONDigger(i,this.$chart.data("options").nodeId,"children")).findOneNode({isHybrid:!0}),1<this.$chart.data("options").verticalLevel||o?(o=s.findNodeById(a.data("nodeData").id),n=Object.assign({},o),s.removeNode(o.id),(o=s.findNodeById(e.data("nodeData").id)).children?o.children.push(n):o.children=[n],this.init({data:i})):(e.siblings(".nodes").length?(s='<i class="edge horizontalEdge rightEdge oci"></i><i class="edge horizontalEdge leftEdge oci"></i>',a.find(".horizontalEdge").length||a.append(s),e.siblings(".nodes").append(a.closest(".hierarchy")),1===(o=a.closest(".hierarchy").siblings().find(".node:first")).length&&o.append(s)):(e.append('<i class="edge verticalEdge bottomEdge oci"></i>').after('<ul class="nodes"></ul>').siblings(".nodes").append(a.find(".horizontalEdge").remove().end().closest(".hierarchy")),e.children(".title").length&&e.children(".title").prepend('<i class="oci '+this.$chart.data("options").parentNodeSymbol+' symbol"></i>')),1===t.siblings(".nodes").children(".hierarchy").length?t.siblings(".nodes").children(".hierarchy").find(".node:first").find(".horizontalEdge").remove():0===t.siblings(".nodes").children(".hierarchy").length&&t.find(".bottomEdge, .symbol").remove().end().siblings(".nodes").remove()))):this.$chart.triggerHandler({type:"otherdropped.orgchart",draggedItem:a,dropZone:e})},touchstartHandler:function(e){this.touchHandled||e.touches&&1<e.touches.length||(this.touchHandled=!0,this.touchMoved=!1,e.preventDefault())},touchmoveHandler:function(e){var t;!this.touchHandled||e.touches&&1<e.touches.length||(e.preventDefault(),this.touchMoved||(this.filterAllowedDropNodes(l(e.currentTarget)),this.touchDragImage=this.createDragImage(e,this.$chart.data("dragged")[0])),this.touchMoved=!0,this.moveDragImage(e,this.touchDragImage),0<(e=l(c.elementFromPoint(e.touches[0].clientX,e.touches[0].clientY)).closest("div.node")).length&&(t=e[0],e.is(".allowedDrop"))?this.touchTargetNode=t:this.touchTargetNode=null)},touchendHandler:function(e){var t,i;this.touchHandled&&(this.destroyDragImage(),this.touchMoved?(this.touchTargetNode&&(t={delegateTarget:this.touchTargetNode},this.dropHandler(t),this.touchTargetNode=null),this.dragendHandler(e)):(t=e.changedTouches[0],(i=c.createEvent("MouseEvents")).initMouseEvent("click",!0,!0,h,1,t.screenX,t.screenY,t.clientX,t.clientY,e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,0,null),e.target.dispatchEvent(i)),this.touchHandled=!1)},createDragImage:function(e,t){var i=t.cloneNode(!0),t=(this.copyStyle(t,i),i.style.top=i.style.left="-9999px",t.getBoundingClientRect()),e=this.getTouchPoint(e);return this.touchDragImageOffset={x:e.x-t.left,y:e.y-t.top},i.style.opacity="0.5",c.body.appendChild(i),i},destroyDragImage:function(){this.touchDragImage&&this.touchDragImage.parentElement&&this.touchDragImage.parentElement.removeChild(this.touchDragImage),this.touchDragImageOffset=null,this.touchDragImage=null},copyStyle:function(e,t){["id","class","style","draggable"].forEach(function(e){t.removeAttribute(e)}),e instanceof HTMLCanvasElement&&((n=t).width=(i=e).width,n.height=i.height,n.getContext("2d").drawImage(i,0,0));for(var i,n,s=getComputedStyle(e),o=0;o<s.length;o++){var a=s[o];a.indexOf("transition")<0&&(t.style[a]=s[a])}t.style.pointerEvents="none";for(o=0;o<e.children.length;o++)this.copyStyle(e.children[o],t.children[o])},getTouchPoint:function(e){return{x:(e=e&&e.touches?e.touches[0]:e).clientX,y:e.clientY}},moveDragImage:function(i,n){var s;i&&n&&(s=this,requestAnimationFrame(function(){var e=s.getTouchPoint(i),t=n.style;t.position="absolute",t.pointerEvents="none",t.zIndex="999999",s.touchDragImageOffset&&(t.left=Math.round(e.x-s.touchDragImageOffset.x)+"px",t.top=Math.round(e.y-s.touchDragImageOffset.y)+"px")}))},bindDragDrop:function(e){e.on("dragstart",this.dragstartHandler.bind(this)).on("dragover",this.dragoverHandler.bind(this)).on("dragend",this.dragendHandler.bind(this)).on("drop",this.dropHandler.bind(this)).on("touchstart",this.touchstartHandler.bind(this)).on("touchmove",this.touchmoveHandler.bind(this)).on("touchend",this.touchendHandler.bind(this))},createNode:function(i){var n=this.options,e=i.level,t=(i.children&&i[n.nodeId]&&l.each(i.children,function(e,t){t.parentId=i[n.nodeId]}),l("<div"+(n.draggable?' draggable="true"':"")+(i[n.nodeId]?' id="'+i[n.nodeId]+'"':"")+(i.parentId?' data-parent="'+i.parentId+'"':"")+">").addClass("node "+(i.className||"")+(e>n.visibleLevel?" slide-up":""))),s=(n.nodeTemplate?t.append(n.nodeTemplate(i)):t.append('<div class="title">'+i[n.nodeTitle]+"</div>").append(void 0!==n.nodeContent?'<div class="content">'+(i[n.nodeContent]||"")+"</div>":""),l.extend({},i)),s=(delete s.children,t.data("nodeData",s),i.relationship||"");return n.verticalLevel&&e>=n.verticalLevel||i.isVertical?Number(s.substr(2,1))&&t.append('<i class="toggleBtn oci"></i>').children(".title").prepend('<i class="oci '+n.parentNodeSymbol+' symbol"></i>'):(i.isHybrid||(Number(s.substr(0,1))&&t.append('<i class="edge verticalEdge topEdge oci"></i>'),Number(s.substr(1,1))&&t.append('<i class="edge horizontalEdge rightEdge oci"></i><i class="edge horizontalEdge leftEdge oci"></i>')),Number(s.substr(2,1))&&t.append('<i class="edge verticalEdge bottomEdge oci"></i>').children(".title").prepend('<i class="oci '+n.parentNodeSymbol+' symbol"></i>')),t.on("mouseenter mouseleave",this.nodeEnterLeaveHandler.bind(this)),t.on("click",this.nodeClickHandler.bind(this)),t.on("click",".topEdge",this.topEdgeClickHandler.bind(this)),t.on("click",".bottomEdge",this.bottomEdgeClickHandler.bind(this)),t.on("click",".leftEdge, .rightEdge",this.hEdgeClickHandler.bind(this)),t.on("click",".toggleBtn",this.toggleVNodes.bind(this)),n.draggable&&(this.bindDragDrop(t),this.touchHandled=!1,this.touchMoved=!1,this.touchTargetNode=null),n.createNode&&n.createNode(t,i),t},buildHierarchy:function(e,t){var i,n,s=this,o=this.options,a=0,a=t.level||(t.level=e.parentsUntil(".orgchart",".nodes").length);2<Object.keys(t).length&&e.append(this.createNode(t)),t.children&&t.children.length&&(i=a+1>o.visibleLevel||t.collapsed!==r&&t.collapsed,o.verticalLevel&&a+1>=o.verticalLevel||t.isHybrid?(n=l('<ul class="nodes">'),i&&o.verticalLevel&&a+1>=o.verticalLevel&&n.addClass("hidden"),(o.verticalLevel&&a+1===o.verticalLevel||t.isHybrid)&&!e.closest(".vertical").length?e.append(n.addClass("vertical")):e.append(n)):(n=l('<ul class="nodes'+(i?" hidden":"")+'">'),2!==Object.keys(t).length&&i&&e.addClass("isChildrenCollapsed"),e.append(n)),l.each(t.children,function(){var e=l('<li class="hierarchy">');n.append(e),this.level=a+1,s.buildHierarchy(e,this)}))},buildChildNode:function(e,t){this.buildHierarchy(e,{children:t})},addChildren:function(e,t){this.buildChildNode(e.closest(".hierarchy"),t),e.find(".symbol").length||e.children(".title").prepend('<i class="oci '+this.options.parentNodeSymbol+' symbol"></i>'),e.closest(".nodes.vertical").length?e.children(".toggleBtn").length||e.append('<i class="toggleBtn oci"></i>'):e.children(".bottomEdge").length||e.append('<i class="edge verticalEdge bottomEdge oci"></i>'),this.isInAction(e)&&this.switchVerticalArrow(e.children(".bottomEdge"))},buildParentNode:function(e,t){t.relationship=t.relationship||"001";t=l('<ul class="nodes"><li class="hierarchy"></li></ul>').find(".hierarchy").append(this.createNode(t)).end();this.$chart.prepend(t).find(".hierarchy:first").append(e.closest("ul").addClass("nodes"))},addParent:function(e,t){this.buildParentNode(e,t),e.children(".topEdge").length||e.children(".title").after('<i class="edge verticalEdge topEdge oci"></i>'),this.isInAction(e)&&this.switchVerticalArrow(e.children(".topEdge"))},buildSiblingNode:function(e,t){var i,n=(l.isArray(t)?t:t.children).length,s=e.parent().is(".nodes")?e.siblings().length+1:1,n=s+n,n=1<n?Math.floor(n/2-1):0;e.closest(".nodes").parent().is(".hierarchy")?(this.buildChildNode(e.parent().closest(".hierarchy"),t),i=e.parent().closest(".hierarchy").children(".nodes:last").children(".hierarchy"),1<s?i.eq(0).before(e.siblings().addBack().unwrap()):i.eq(n).after(e.unwrap())):(this.buildHierarchy(e.parent().prepend(l('<li class="hierarchy">')).children(".hierarchy:first"),t),e.prevAll(".hierarchy").children(".nodes").children().eq(n).after(e))},addSiblings:function(e,t){this.buildSiblingNode(e.closest(".hierarchy"),t),e.closest(".nodes").data("siblingsLoaded",!0),e.children(".leftEdge").length||e.children(".topEdge").after('<i class="edge horizontalEdge rightEdge oci"></i><i class="edge horizontalEdge leftEdge oci"></i>'),this.isInAction(e)&&(this.switchHorizontalArrow(e),e.children(".topEdge").removeClass("oci-chevron-up").addClass("oci-chevron-down"))},removeNodes:function(e){var t=e.closest(".hierarchy").parent();t.parent().is(".hierarchy")?this.getNodeState(e,"siblings").exist?(e.closest(".hierarchy").remove(),1===t.children().length&&t.find(".node:first .horizontalEdge").remove()):t.siblings(".node").find(".bottomEdge").remove().end().end().remove():t.closest(".orgchart").remove()},hideDropZones:function(){this.$chart.find(".allowedDrop").removeClass("allowedDrop")},showDropZones:function(e){this.$chart.find(".node").each(function(e,t){l(t).addClass("allowedDrop")}),this.$chart.data("dragged",l(e))},processExternalDrop:function(e,t){t&&this.$chart.data("dragged",l(t)),e.closest(".node").triggerHandler({type:"drop"})},exportPDF:function(e,t){var i={},n=Math.floor(e.width),s=Math.floor(e.height);h.jsPDF||(h.jsPDF=h.jspdf.jsPDF),(i=s<n?new jsPDF({orientation:"landscape",unit:"px",format:[n,s]}):new jsPDF({orientation:"portrait",unit:"px",format:[s,n]})).addImage(e.toDataURL(),"png",0,0),i.save(t+".pdf")},exportPNG:function(e,t){var i="WebkitAppearance"in c.documentElement.style,n=!!h.sidebar,s="Microsoft Internet Explorer"===navigator.appName||"Netscape"===navigator.appName&&-1<navigator.appVersion.indexOf("Edge"),o=this.$chartContainer;!i&&!n||s?h.navigator.msSaveBlob(e.msToBlob(),t+".png"):(i=".oci-download-btn"+(""!==this.options.chartClass?"."+this.options.chartClass:""),o.find(i).length||o.append('<a class="oci-download-btn'+(""!==this.options.chartClass?" "+this.options.chartClass:"")+'" download="'+t+'.png"></a>'),o.find(i).attr("href",e.toDataURL())[0].click())},export:function(t,i){var n=this;if(t=void 0!==t?t:this.options.exportFilename,i=void 0!==i?i:this.options.exportFileextension,l(this).children(".spinner").length)return!1;var s=this.$chartContainer,e=s.find(".mask"),e=(e.length?e.removeClass("hidden"):s.append('<div class="mask"><i class="oci oci-spinner spinner"></i></div>'),s.addClass("canvasContainer").find('.orgchart:not(".hidden")').get(0)),o="l2r"===n.options.direction||"r2l"===n.options.direction;html2canvas(e,{width:o?e.clientHeight:e.clientWidth,height:o?e.clientWidth:e.clientHeight,onclone:function(e){l(e).find(".canvasContainer").css("overflow","visible").find('.orgchart:not(".hidden"):first').css("transform","")}}).then(function(e){s.find(".mask").addClass("hidden"),"pdf"===i.toLowerCase()?n.exportPDF(e,t):n.exportPNG(e,t),s.removeClass("canvasContainer")},function(){s.removeClass("canvasContainer")})}},l.fn.orgchart=function(e){return new t(this,e).init()}});
1
+ "use strict";!function(e){"object"==typeof module&&"object"==typeof module.exports?e(require("jquery"),window,document):e(jQuery,window,document)}(function(l,h,c,d){function t(e,t){this.$chartContainer=l(e),this.opts=t,this.defaultOptions={icons:{theme:"oci",parentNode:"oci-menu",expandToUp:"oci-chevron-up",collapseToDown:"oci-chevron-down",collapseToLeft:"oci-chevron-left",expandToRight:"oci-chevron-right",collapsed:"oci-plus-square",expanded:"oci-minus-square",spinner:"oci-spinner"},nodeTitle:"name",nodeId:"id",toggleSiblingsResp:!1,visibleLevel:999,chartClass:"",exportButton:!1,exportButtonName:"Export",exportFilename:"OrgChart",exportFileextension:"png",draggable:!1,direction:"t2b",pan:!1,zoom:!1,zoominLimit:7,zoomoutLimit:.5}}t.prototype={init:function(e){var n=this,e=(this.options=l.extend({},this.defaultOptions,this.opts,e),this.$chartContainer),t=(this.$chart&&this.$chart.remove(),this.options.data),i=this.$chart=l("<div>",{data:{options:this.options},class:"orgchart"+(""!==this.options.chartClass?" "+this.options.chartClass:"")+("t2b"!==this.options.direction?" "+this.options.direction:""),click:function(e){l(e.target).closest(".node").length||i.find(".node.focused").removeClass("focused")}}),s=("undefined"!=typeof MutationObserver&&this.triggerInitEvent(),i.append(l('<ul class="nodes"><li class="hierarchy"></li></ul>')).find(".hierarchy"));return"object"===l.type(t)?t instanceof l?this.buildHierarchy(s,this.buildJsonDS(t.children()),0,this.options):this.buildHierarchy(s,this.options.ajaxURL?t:this.attachRel(t,"00")):(i.append(`<i class="${this.options.icons.theme} ${this.options.icons.spinner} spinner"></i>`),l.ajax({url:t,dataType:"json"}).done(function(e,t,i){n.buildHierarchy(s,n.options.ajaxURL?e:n.attachRel(e,"00"),0,n.options)}).fail(function(e,t,i){console.log(i)}).always(function(){i.children(".spinner").remove()})),e.append(i),this.options.exportButton&&!l(".oc-export-btn").length&&this.attachExportButton(),this.options.pan&&this.bindPan(),this.options.zoom&&this.bindZoom(),this},triggerInitEvent:function(){var s=this,o=new MutationObserver(function(e){o.disconnect();e:for(var t=0;t<e.length;t++)for(var i=0;i<e[t].addedNodes.length;i++)if(e[t].addedNodes[i].classList.contains("orgchart")){s.options.initCompleted&&"function"==typeof s.options.initCompleted&&s.options.initCompleted(s.$chart);var n=l.Event("init.orgchart");s.$chart.trigger(n);break e}});o.observe(this.$chartContainer[0],{childList:!0})},triggerLoadEvent:function(e,t){t=l.Event("load-"+t+".orgchart");e.trigger(t)},triggerShowEvent:function(e,t){t=l.Event("show-"+t+".orgchart");e.trigger(t)},triggerHideEvent:function(e,t){t=l.Event("hide-"+t+".orgchart");e.trigger(t)},attachExportButton:function(){var t=this,e=l("<button>",{class:"oc-export-btn",text:this.options.exportButtonName,click:function(e){e.preventDefault(),t.export()}});this.$chartContainer.after(e)},setOptions:function(e,t){return"string"==typeof e&&("pan"===e&&(t?this.bindPan():this.unbindPan()),"zoom"===e)&&(t?this.bindZoom():this.unbindZoom()),"object"==typeof e&&(e.data?this.init(e):(void 0!==e.pan&&(e.pan?this.bindPan():this.unbindPan()),void 0!==e.zoom&&(e.zoom?this.bindZoom():this.unbindZoom()))),this},panStartHandler:function(e){var s=l(e.delegateTarget);if(l(e.target).closest(".node").length||e.touches&&1<e.touches.length)s.data("panning",!1);else{s.css("cursor","move").data("panning",!0);var t,i=0,n=0,o=s.css("transform"),a=("none"!==o&&(t=o.split(","),n=-1===o.indexOf("3d")?(i=parseInt(t[4]),parseInt(t[5])):(i=parseInt(t[12]),parseInt(t[13]))),0),d=0;if(e.targetTouches){if(1===e.targetTouches.length)a=e.targetTouches[0].pageX-i,d=e.targetTouches[0].pageY-n;else if(1<e.targetTouches.length)return}else a=e.pageX-i,d=e.pageY-n;s.on("mousemove touchmove",function(e){if(s.data("panning")){var t=0,i=0;if(e.targetTouches){if(1===e.targetTouches.length)t=e.targetTouches[0].pageX-a,i=e.targetTouches[0].pageY-d;else if(1<e.targetTouches.length)return}else t=e.pageX-a,i=e.pageY-d;var n,e=s.css("transform");"none"===e?-1===e.indexOf("3d")?s.css("transform","matrix(1, 0, 0, 1, "+t+", "+i+")"):s.css("transform","matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, "+t+", "+i+", 0, 1)"):(n=e.split(","),-1===e.indexOf("3d")?(n[4]=" "+t,n[5]=" "+i+")"):(n[12]=" "+t,n[13]=" "+i),s.css("transform",n.join(",")))}})}},panEndHandler:function(e){e.data.chart.data("panning")&&e.data.chart.data("panning",!1).css("cursor","default").off("mousemove")},bindPan:function(){this.$chartContainer.css("overflow","hidden"),this.$chart.on("mousedown touchstart",this.panStartHandler),l(c).on("mouseup touchend",{chart:this.$chart},this.panEndHandler)},unbindPan:function(){this.$chartContainer.css("overflow","auto"),this.$chart.off("mousedown touchstart",this.panStartHandler),l(c).off("mouseup touchend",this.panEndHandler)},zoomWheelHandler:function(e){var t=e.data.oc,e=(e.preventDefault(),1+(0<e.originalEvent.deltaY?-.2:.2));t.setChartScale(t.$chart,e)},zoomStartHandler:function(e){var t;e.touches&&2===e.touches.length&&((t=e.data.oc).$chart.data("pinching",!0),e=t.getPinchDist(e),t.$chart.data("pinchDistStart",e))},zoomingHandler:function(e){var t=e.data.oc;t.$chart.data("pinching")&&(e=t.getPinchDist(e),t.$chart.data("pinchDistEnd",e))},zoomEndHandler:function(e){var t,e=e.data.oc;e.$chart.data("pinching")&&(e.$chart.data("pinching",!1),0<(t=e.$chart.data("pinchDistEnd")-e.$chart.data("pinchDistStart"))?e.setChartScale(e.$chart,1.2):t<0&&e.setChartScale(e.$chart,.8))},bindZoom:function(){this.$chartContainer.on("wheel",{oc:this},this.zoomWheelHandler),this.$chartContainer.on("touchstart",{oc:this},this.zoomStartHandler),l(c).on("touchmove",{oc:this},this.zoomingHandler),l(c).on("touchend",{oc:this},this.zoomEndHandler)},unbindZoom:function(){this.$chartContainer.off("wheel",this.zoomWheelHandler),this.$chartContainer.off("touchstart",this.zoomStartHandler),l(c).off("touchmove",this.zoomingHandler),l(c).off("touchend",this.zoomEndHandler)},getPinchDist:function(e){return Math.sqrt((e.touches[0].clientX-e.touches[1].clientX)*(e.touches[0].clientX-e.touches[1].clientX)+(e.touches[0].clientY-e.touches[1].clientY)*(e.touches[0].clientY-e.touches[1].clientY))},setChartScale:function(e,t){var i,n=e.data("options"),s=e.css("transform"),o=1;"none"===s?e.css("transform","scale("+t+","+t+")"):(i=s.split(","),-1===s.indexOf("3d")?(o=Math.abs(h.parseFloat(i[3])*t))>n.zoomoutLimit&&o<n.zoominLimit&&e.css("transform",s+" scale("+t+","+t+")"):(o=Math.abs(h.parseFloat(i[1])*t))>n.zoomoutLimit&&o<n.zoominLimit&&e.css("transform",s+" scale3d("+t+","+t+", 1)"))},buildJsonDS:function(e){var t=this,i={name:e.contents().eq(0).text().trim(),relationship:(e.parent().parent().is("li")?"1":"0")+(e.siblings("li").length?1:0)+(e.children("ul").length?1:0)};return l.each(e.data(),function(e,t){i[e]=t}),e.children("ul").children().each(function(){i.children||(i.children=[]),i.children.push(t.buildJsonDS(l(this)))}),i},attachRel:function(t,e){var i=this;return t.relationship=e+(t.children&&0<t.children.length?1:0),t.children&&t.children.forEach(function(e){(t.isHybrid||t.isVertical)&&(e.isVertical=!0),i.attachRel(e,"1"+(1<t.children.length?1:0))}),t},loopChart:function(e,t){t=null!==t&&t!==d&&t;var i=this,e=e.find(".node:first"),n={id:e[0].id};return t&&l.each(e.data("nodeData"),function(e,t){n[e]=t}),e.siblings(".nodes").children().each(function(){n.children||(n.children=[]),n.children.push(i.loopChart(l(this),t))}),n},getHierarchy:function(e){var t;return e=null!==e&&e!==d&&e,void 0===this.$chart?"Error: orgchart does not exist":this.$chart.find(".node").length?(t=!0,this.$chart.find(".node").each(function(){if(!this.id)return t=!1}),t?this.loopChart(this.$chart,e):"Error: All nodes of orghcart to be exported must have data-id attribute!"):"Error: nodes do not exist"},getNodeState:function(e,t){var i={},n=!!e.closest("vertical").length;if("parent"===(t=t||"self")){if(n?(i=e.closest("ul").parents("ul")).length||(i=e.closest(".nodes")).length||(i=e.closest(".vertical").siblings(":first")):i=e.closest(".nodes").siblings(".node"),i.length)return i.is(".hidden")||!i.is(".hidden")&&i.closest(".nodes").is(".hidden")||!i.is(".hidden")&&i.closest(".vertical").is(".hidden")?{exist:!0,visible:!1}:{exist:!0,visible:!0}}else if("children"===t){if((i=n?e.parent().children("ul"):e.siblings(".nodes")).length)return i.is(".hidden")?{exist:!0,visible:!1}:{exist:!0,visible:!0}}else if("siblings"===t){if((i=n?e.closest("ul"):e.parent().siblings()).length&&(!n||1<i.children("li").length))return i.is(".hidden")||i.parent().is(".hidden")||n&&i.closest(".vertical").is(".hidden")?{exist:!0,visible:!1}:{exist:!0,visible:!0}}else if((i=e).length)return i.closest(".nodes").length&&i.closest(".nodes").is(".hidden")||i.closest(".hierarchy").length&&i.closest(".hierarchy").is(".hidden")||i.closest(".vertical").length&&(i.closest(".nodes").is(".hidden")||i.closest(".vertical").is(".hidden"))?{exist:!0,visible:!1}:{exist:!0,visible:!0};return{exist:!1,visible:!1}},getParent:function(e){return this.getRelatedNodes(e,"parent")},getChildren:function(e){return this.getRelatedNodes(e,"children")},getSiblings:function(e){return this.getRelatedNodes(e,"siblings")},getRelatedNodes:function(e,t){return e&&e instanceof l&&e.is(".node")?"parent"===t?e.closest(".nodes").siblings(".node"):"children"===t?e.siblings(".nodes").children(".hierarchy").find(".node:first"):"siblings"===t?e.closest(".hierarchy").siblings().find(".node:first"):l():l()},hideParentEnd:function(e){l(e.target).removeClass("sliding"),e.data.parent.addClass("hidden")},hideParent:function(e){var t=e.closest(".nodes").siblings(".node");t.find(".spinner").length&&e.closest(".orgchart").data("inAjax",!1),this.getNodeState(e,"siblings").visible&&this.hideSiblings(e),e.parent().addClass("isAncestorsCollapsed"),this.getNodeState(t).visible&&t.addClass("sliding slide-down").one("transitionend",{parent:t},this.hideParentEnd),this.getNodeState(t,"parent").visible&&this.hideParent(t)},showParentEnd:function(e){var t=e.data.node;l(e.target).removeClass("sliding"),this.isInAction(t)&&this.switchVerticalArrow(t.children(".topEdge"))},showParent:function(e){var t=e.closest(".nodes").siblings(".node").removeClass("hidden");e.closest(".hierarchy").removeClass("isAncestorsCollapsed"),this.repaint(t[0]),t.addClass("sliding").removeClass("slide-down").one("transitionend",{node:e},this.showParentEnd.bind(this))},stopAjax:function(e){e.find(".spinner").length&&e.closest(".orgchart").data("inAjax",!1)},isVisibleNode:function(e,t){return this.getNodeState(l(t)).visible},hideChildrenEnd:function(e){var t=e.data.node;e.data.animatedNodes.removeClass("sliding"),e.data.animatedNodes.closest(".nodes").addClass("hidden"),this.isInAction(t)&&this.switchVerticalArrow(t.children(".bottomEdge"))},hideChildren:function(e){e.closest(".hierarchy").addClass("isChildrenCollapsed");var t=e.siblings(".nodes"),i=(this.stopAjax(t),t.find(".node").filter(this.isVisibleNode.bind(this)));t.is(".vertical")||i.closest(".hierarchy").addClass("isCollapsedDescendant"),(t.is(".vertical")||t.find(".vertical").length)&&i.find(this.options.icons.expanded).removeClass(this.options.icons.expanded).addClass(this.options.icons.collapsed),this.repaint(i.get(0)),i.addClass("sliding slide-up").eq(0).one("transitionend",{animatedNodes:i,lowerLevel:t,node:e},this.hideChildrenEnd.bind(this))},showChildrenEnd:function(e){var t=e.data.node;e.data.animatedNodes.removeClass("sliding"),this.isInAction(t)&&this.switchVerticalArrow(t.children(".bottomEdge"))},showChildren:function(e){e.closest(".hierarchy").removeClass("isChildrenCollapsed");var t=e.siblings(".nodes"),i=t.is(".vertical"),t=(i?t.removeClass("hidden").find(".node"):t.removeClass("hidden").children(".hierarchy").find(".node:first")).filter(this.isVisibleNode.bind(this));i||(t.filter(":not(:only-child)").closest(".hierarchy").addClass("isChildrenCollapsed"),t.closest(".hierarchy").removeClass("isCollapsedDescendant")),this.repaint(t.get(0)),t.addClass("sliding").removeClass("slide-up").eq(0).one("transitionend",{node:e,animatedNodes:t},this.showChildrenEnd.bind(this))},hideSiblingsEnd:function(e){var t=e.data.node,i=e.data.nodeContainer,n=e.data.direction,n=n?"left"===n?i.prevAll(":not(.hidden)"):i.nextAll(":not(.hidden)"):i.siblings();e.data.animatedNodes.removeClass("sliding"),n.find(".node:gt(0)").filter(this.isVisibleNode.bind(this)).removeClass("slide-left slide-right").addClass("slide-up"),n.find(".nodes, .vertical").addClass("hidden").end().addClass("hidden"),this.isInAction(t)&&this.switchHorizontalArrow(t)},hideSiblings:function(e,t){var i=e.closest(".hierarchy").addClass("isSiblingsCollapsed"),n=(i.siblings().find(".spinner").length&&e.closest(".orgchart").data("inAjax",!1),t?"left"===t?i.addClass("left-sibs").prevAll(".isSiblingsCollapsed").removeClass("isSiblingsCollapsed left-sibs").end().prevAll().addClass("isCollapsedSibling isChildrenCollapsed").find(".node").filter(this.isVisibleNode.bind(this)).addClass("sliding slide-right"):i.addClass("right-sibs").nextAll(".isSiblingsCollapsed").removeClass("isSiblingsCollapsed right-sibs").end().nextAll().addClass("isCollapsedSibling isChildrenCollapsed").find(".node").filter(this.isVisibleNode.bind(this)).addClass("sliding slide-left"):(i.prevAll().find(".node").filter(this.isVisibleNode.bind(this)).addClass("sliding slide-right"),i.nextAll().find(".node").filter(this.isVisibleNode.bind(this)).addClass("sliding slide-left"),i.siblings().addClass("isCollapsedSibling isChildrenCollapsed")),i.siblings().find(".sliding"));n.eq(0).one("transitionend",{node:e,nodeContainer:i,direction:t,animatedNodes:n},this.hideSiblingsEnd.bind(this))},showSiblingsEnd:function(e){var t=e.data.node;e.data.visibleNodes.removeClass("sliding"),this.isInAction(t)&&(this.switchHorizontalArrow(t),t.children(".topEdge").removeClass(this.options.icons.expandToUp).addClass(this.options.icons.collapseToDown))},showRelatedParentEnd:function(e){l(e.target).removeClass("sliding")},showSiblings:function(e,t){var i=l(),n=e.closest(".hierarchy"),i=(t?"left"===t?n.prevAll():n.nextAll():e.closest(".hierarchy").siblings()).removeClass("hidden"),s=e.closest(".nodes").siblings(".node"),n=(t?(n.removeClass(t+"-sibs"),n.is("[class*=-sibs]")||n.removeClass("isSiblingsCollapsed"),i.removeClass("isCollapsedSibling "+t+"-sibs")):(e.closest(".hierarchy").removeClass("isSiblingsCollapsed"),i.removeClass("isCollapsedSibling")),this.getNodeState(e,"parent").visible||(e.closest(".hierarchy").removeClass("isAncestorsCollapsed"),s.removeClass("hidden"),this.repaint(s[0]),s.addClass("sliding").removeClass("slide-down").one("transitionend",this.showRelatedParentEnd)),i.find(".node").filter(this.isVisibleNode.bind(this)));this.repaint(n.get(0)),n.addClass("sliding").removeClass("slide-left slide-right"),n.eq(0).one("transitionend",{node:e,visibleNodes:n},this.showSiblingsEnd.bind(this))},startLoading:function(e){var t=this.$chart;return(void 0===t.data("inAjax")||!0!==t.data("inAjax"))&&(e.addClass("hidden"),e.parent().append(`<i class="${this.options.icons.theme} ${this.options.icons.spinner} spinner"></i>`).children().not(".spinner").css("opacity",.2),t.data("inAjax",!0),l(".oc-export-btn").prop("disabled",!0),!0)},endLoading:function(e){var t=e.parent();e.removeClass("hidden"),t.find(".spinner").remove(),t.children().removeAttr("style"),this.$chart.data("inAjax",!1),l(".oc-export-btn").prop("disabled",!1)},isInAction:function(t){return[this.options.icons.expandToUp,this.options.icons.collapseToDown,this.options.icons.collapseToLeft,this.options.icons.expandToRight].some(e=>-1<t.children(".edge").attr("class").indexOf(e))},switchVerticalArrow:function(e){e.toggleClass(this.options.icons.expandToUp+" "+this.options.icons.collapseToDown)},switchHorizontalArrow:function(e){var t,i=this.options;i.toggleSiblingsResp&&(void 0===i.ajaxURL||e.closest(".nodes").data("siblingsLoaded"))?((t=e.parent().prev()).length&&(t.is(".hidden")?e.children(".leftEdge").addClass(i.icons.collapseToLeft).removeClass(i.icons.expandToRight):e.children(".leftEdge").addClass(i.icons.expandToRight).removeClass(i.icons.collapseToLeft)),(t=e.parent().next()).length&&(t.is(".hidden")?e.children(".rightEdge").addClass(i.icons.expandToRight).removeClass(i.icons.collapseToLeft):e.children(".rightEdge").addClass(i.icons.collapseToLeft).removeClass(i.icons.expandToRight))):(t=!!(t=e.parent().siblings()).length&&!t.is(".hidden"),e.children(".leftEdge").toggleClass(i.icons.expandToRight,t).toggleClass(i.icons.collapseToLeft,!t),e.children(".rightEdge").toggleClass(i.icons.collapseToLeft,t).toggleClass(i.icons.expandToRight,!t))},repaint:function(e){e&&(e.style.offsetWidth=e.offsetWidth)},nodeEnterLeaveHandler:function(e){var t,i,n,s=l(e.delegateTarget),o=!1;s.closest(".nodes.vertical").length?(t=s.children(".toggleBtn"),"mouseenter"===e.type?s.children(".toggleBtn").length&&(o=this.getNodeState(s,"children").visible,t.toggleClass(this.options.icons.collapsed,!o).toggleClass(this.options.icons.expanded,o)):t.removeClass(this.options.icons.collapsed+" "+this.options.icons.expanded)):(t=s.children(".topEdge"),s.children(".rightEdge"),i=s.children(".bottomEdge"),n=s.children(".leftEdge"),"mouseenter"===e.type?(t.length&&(o=this.getNodeState(s,"parent").visible,t.toggleClass(this.options.icons.expandToUp,!o).toggleClass(this.options.icons.collapseToDown,o)),i.length&&(o=this.getNodeState(s,"children").visible,i.toggleClass(this.options.icons.collapseToDown,!o).toggleClass(this.options.icons.expandToUp,o)),n.length&&this.switchHorizontalArrow(s)):s.children(".edge").removeClass(`${this.options.icons.expandToUp} ${this.options.icons.collapseToDown} ${this.options.icons.collapseToLeft} `+this.options.icons.expandToRight))},nodeClickHandler:function(e){this.$chart.find(".focused").removeClass("focused"),l(e.delegateTarget).addClass("focused")},loadNodes:function(t,e,i){var n=this;this.options;l.ajax({url:e,dataType:"json"}).done(function(e){n.$chart.data("inAjax")&&("parent"===t?l.isEmptyObject(e)||n.addParent(i.parent(),e):"children"===t?e.children.length&&n.addChildren(i.parent(),e[t]):n.addSiblings(i.parent(),e.siblings||e),n.triggerLoadEvent(i.parent(),t))}).fail(function(){console.log("Failed to get "+t+" data")}).always(function(){n.endLoading(i)})},HideFirstParentEnd:function(e){var e=e.data.topEdge,t=e.parent();this.isInAction(t)&&(this.switchVerticalArrow(e),this.switchHorizontalArrow(t))},topEdgeClickHandler:function(e){e.stopPropagation();var t,i=l(e.target),e=l(e.delegateTarget),n=this.getNodeState(e,"parent");n.exist?(t=e.closest(".nodes").siblings(".node")).is(".sliding")||(n.visible?(this.hideParent(e),t.one("transitionend",{topEdge:i},this.HideFirstParentEnd.bind(this)),this.triggerHideEvent(e,"parent")):(this.showParent(e),this.triggerShowEvent(e,"parent"))):this.startLoading(i)&&(n=this.options,t=l.isFunction(n.ajaxURL.parent)?n.ajaxURL.parent(e.data("nodeData")):n.ajaxURL.parent+e[0].id,this.loadNodes("parent",t,i))},bottomEdgeClickHandler:function(e){e.stopPropagation();var t=l(e.target),e=l(e.delegateTarget),i=this.getNodeState(e,"children");i.exist?e.siblings(".nodes").children().children(".node").is(".sliding")||(i.visible?(this.hideChildren(e),this.triggerHideEvent(e,"children")):(this.showChildren(e),this.triggerShowEvent(e,"children"))):this.startLoading(t)&&(i=this.options,i=l.isFunction(i.ajaxURL.children)?i.ajaxURL.children(e.data("nodeData")):i.ajaxURL.children+e[0].id,this.loadNodes("children",i,t))},hEdgeClickHandler:function(e){e.stopPropagation();var t,i,n=l(e.target),e=l(e.delegateTarget),s=this.options,o=this.getNodeState(e,"siblings");o.exist?e.closest(".hierarchy").siblings().find(".sliding").length||(s.toggleSiblingsResp?(t=e.closest(".hierarchy").prev(),i=e.closest(".hierarchy").next(),n.is(".leftEdge")?t.is(".hidden")?(this.showSiblings(e,"left"),this.triggerShowEvent(e,"siblings")):(this.hideSiblings(e,"left"),this.triggerHideEvent(e,"siblings")):i.is(".hidden")?(this.showSiblings(e,"right"),this.triggerShowEvent(e,"siblings")):(this.hideSiblings(e,"right"),this.triggerHideEvent(e,"siblings"))):o.visible?(this.hideSiblings(e),this.triggerHideEvent(e,"siblings")):(this.showSiblings(e),this.triggerShowEvent(e,"siblings"))):this.startLoading(n)&&(t=e[0].id,i=this.getNodeState(e,"parent").exist?l.isFunction(s.ajaxURL.siblings)?s.ajaxURL.siblings(e.data("nodeData")):s.ajaxURL.siblings+t:l.isFunction(s.ajaxURL.families)?s.ajaxURL.families(e.data("nodeData")):s.ajaxURL.families+t,this.loadNodes("siblings",i,n))},expandVNodesEnd:function(e){e.data.vNodes.removeClass("sliding")},collapseVNodesEnd:function(e){e.data.vNodes.removeClass("sliding").closest("ul").addClass("hidden")},toggleVNodes:function(e){var e=l(e.target),t=e.parent().next(),i=t.find(".node"),n=t.children().children(".node");n.is(".sliding")||(e.toggleClass(this.options.icons.collapsed+" "+this.options.icons.expanded),i.eq(0).is(".slide-up")?(t.removeClass("hidden"),this.repaint(n.get(0)),n.addClass("sliding").removeClass("slide-up").eq(0).one("transitionend",{vNodes:n},this.expandVNodesEnd)):(i.addClass("sliding slide-up").eq(0).one("transitionend",{vNodes:i},this.collapseVNodesEnd),i.find(".toggleBtn").removeClass(this.options.icons.collapsed+" "+this.options.icons.expanded)))},createGhostNode:function(e){var t,i,n=l(e.target),s=this.options,e=e.originalEvent,o=/firefox/.test(h.navigator.userAgent.toLowerCase());if(c.querySelector(".ghost-node"))t=n.closest(".orgchart").children(".ghost-node").get(0),i=l(t).children().get(0);else{if(!(t=c.createElementNS("http://www.w3.org/2000/svg","svg")).classList)return;t.classList.add("ghost-node"),i=c.createElementNS("http://www.w3.org/2000/svg","rect"),t.appendChild(i),n.closest(".orgchart").append(t)}var a=n.closest(".orgchart").css("transform").split(","),d="t2b"===s.direction||"b2t"===s.direction,a=Math.abs(h.parseFloat(d?a[0].slice(a[0].indexOf("(")+1):a[1])),d=(t.setAttribute("width",d?n.outerWidth(!1):n.outerHeight(!1)),t.setAttribute("height",d?n.outerHeight(!1):n.outerWidth(!1)),i.setAttribute("x",5*a),i.setAttribute("y",5*a),i.setAttribute("width",120*a),i.setAttribute("height",40*a),i.setAttribute("rx",4*a),i.setAttribute("ry",4*a),i.setAttribute("stroke-width",+a),e.offsetX*a),r=e.offsetY*a;"l2r"===s.direction?(d=e.offsetY*a,r=e.offsetX*a):"r2l"===s.direction?(d=n.outerWidth(!1)-e.offsetY*a,r=e.offsetX*a):"b2t"===s.direction&&(d=n.outerWidth(!1)-e.offsetX*a,r=n.outerHeight(!1)-e.offsetY*a),o?(i.setAttribute("fill","rgb(255, 255, 255)"),i.setAttribute("stroke","rgb(191, 0, 0)"),(s=c.createElement("img")).src="data:image/svg+xml;utf8,"+(new XMLSerializer).serializeToString(t),e.dataTransfer.setDragImage(s,d,r)):e.dataTransfer.setDragImage&&e.dataTransfer.setDragImage(t,d,r)},getUpperLevel:function(e){return e.is(".node")?e.parents(".hierarchy").length:0},getLowerLevel:function(e){return e.is(".node")?e.closest(".hierarchy").find(".nodes").length+1:0},getLevelOrderNodes:function(e){if(!e)return[];var t=[],i=[];for(t.push(e);t.length;){for(var n=[],s=0;s<t.length;s++){var o=t.shift(),a=this.getChildren(o);a.length&&t.push(a.toArray().flat()),n.push(l(o))}i.push(n)}return i},filterAllowedDropNodes:function(i){var n=this.options,s=i.closest("[draggable]").hasClass("node"),o=i.closest(".nodes").siblings(".node"),a=i.closest(".hierarchy").find(".node");this.$chart.data("dragged",i).find(".node").each(function(e,t){s&&-1!==a.index(t)||n.dropCriteria&&!n.dropCriteria(i,o,l(t))||l(t).addClass("allowedDrop")})},dragstartHandler:function(e){e.originalEvent.dataTransfer.setData("text/html","hack for firefox"),"none"!==this.$chart.css("transform")&&this.createGhostNode(e),this.filterAllowedDropNodes(l(e.target))},dragoverHandler:function(e){l(e.delegateTarget).is(".allowedDrop")?e.preventDefault():e.originalEvent.dataTransfer.dropEffect="none"},dragendHandler:function(e){this.$chart.find(".allowedDrop").removeClass("allowedDrop")},dropHandler:async function(e){var t,i,n,s,o,e=l(e.delegateTarget),a=this.$chart.data("dragged");a.hasClass("node")?e.hasClass("allowedDrop")&&(t=a.closest(".nodes").siblings(".node"),i=l.Event("nodedrop.orgchart"),this.$chart.trigger(i,{draggedNode:a,dragZone:t,dropZone:e}),i.isDefaultPrevented()||(i=this.$chart.data("options").data,o=(s=new JSONDigger(i,this.$chart.data("options").nodeId,"children")).findOneNode({isHybrid:!0}),1<this.$chart.data("options").verticalLevel||o?(o=s.findNodeById(a.data("nodeData").id),n=Object.assign({},o),s.removeNode(o.id),(o=s.findNodeById(e.data("nodeData").id)).children?o.children.push(n):o.children=[n],this.init({data:i})):(e.siblings(".nodes").length?(s=`<i class="edge horizontalEdge rightEdge ${this.options.icons.theme}"></i><i class="edge horizontalEdge leftEdge ${this.options.icons.theme}"></i>`,a.find(".horizontalEdge").length||a.append(s),e.siblings(".nodes").append(a.closest(".hierarchy")),1===(o=a.closest(".hierarchy").siblings().find(".node:first")).length&&o.append(s)):(e.append(`<i class="edge verticalEdge bottomEdge ${this.options.icons.theme}"></i>`).after('<ul class="nodes"></ul>').siblings(".nodes").append(a.find(".horizontalEdge").remove().end().closest(".hierarchy")),e.children(".title").length&&e.children(".title").prepend(`<i class="${this.options.icons.theme} ${this.$chart.data("options").icons.parentNode} parentNodeSymbol"></i>`)),1===t.siblings(".nodes").children(".hierarchy").length?t.siblings(".nodes").children(".hierarchy").find(".node:first").find(".horizontalEdge").remove():0===t.siblings(".nodes").children(".hierarchy").length&&t.find(".bottomEdge, .parentNodeSymbol").remove().end().siblings(".nodes").remove()))):this.$chart.triggerHandler({type:"otherdropped.orgchart",draggedItem:a,dropZone:e})},touchstartHandler:function(e){this.touchHandled||e.touches&&1<e.touches.length||(this.touchHandled=!0,this.touchMoved=!1,e.preventDefault())},touchmoveHandler:function(e){var t;!this.touchHandled||e.touches&&1<e.touches.length||(e.preventDefault(),this.touchMoved||(this.filterAllowedDropNodes(l(e.currentTarget)),this.touchDragImage=this.createDragImage(e,this.$chart.data("dragged")[0])),this.touchMoved=!0,this.moveDragImage(e,this.touchDragImage),0<(e=l(c.elementFromPoint(e.touches[0].clientX,e.touches[0].clientY)).closest("div.node")).length&&(t=e[0],e.is(".allowedDrop"))?this.touchTargetNode=t:this.touchTargetNode=null)},touchendHandler:function(e){var t,i;this.touchHandled&&(this.destroyDragImage(),this.touchMoved?(this.touchTargetNode&&(t={delegateTarget:this.touchTargetNode},this.dropHandler(t),this.touchTargetNode=null),this.dragendHandler(e)):(t=e.changedTouches[0],(i=c.createEvent("MouseEvents")).initMouseEvent("click",!0,!0,h,1,t.screenX,t.screenY,t.clientX,t.clientY,e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,0,null),e.target.dispatchEvent(i)),this.touchHandled=!1)},createDragImage:function(e,t){var i=t.cloneNode(!0),t=(this.copyStyle(t,i),i.style.top=i.style.left="-9999px",t.getBoundingClientRect()),e=this.getTouchPoint(e);return this.touchDragImageOffset={x:e.x-t.left,y:e.y-t.top},i.style.opacity="0.5",c.body.appendChild(i),i},destroyDragImage:function(){this.touchDragImage&&this.touchDragImage.parentElement&&this.touchDragImage.parentElement.removeChild(this.touchDragImage),this.touchDragImageOffset=null,this.touchDragImage=null},copyStyle:function(e,t){["id","class","style","draggable"].forEach(function(e){t.removeAttribute(e)}),e instanceof HTMLCanvasElement&&((n=t).width=(i=e).width,n.height=i.height,n.getContext("2d").drawImage(i,0,0));for(var i,n,s=getComputedStyle(e),o=0;o<s.length;o++){var a=s[o];a.indexOf("transition")<0&&(t.style[a]=s[a])}t.style.pointerEvents="none";for(o=0;o<e.children.length;o++)this.copyStyle(e.children[o],t.children[o])},getTouchPoint:function(e){return{x:(e=e&&e.touches?e.touches[0]:e).clientX,y:e.clientY}},moveDragImage:function(i,n){var s;i&&n&&(s=this,requestAnimationFrame(function(){var e=s.getTouchPoint(i),t=n.style;t.position="absolute",t.pointerEvents="none",t.zIndex="999999",s.touchDragImageOffset&&(t.left=Math.round(e.x-s.touchDragImageOffset.x)+"px",t.top=Math.round(e.y-s.touchDragImageOffset.y)+"px")}))},bindDragDrop:function(e){e.on("dragstart",this.dragstartHandler.bind(this)).on("dragover",this.dragoverHandler.bind(this)).on("dragend",this.dragendHandler.bind(this)).on("drop",this.dropHandler.bind(this)).on("touchstart",this.touchstartHandler.bind(this)).on("touchmove",this.touchmoveHandler.bind(this)).on("touchend",this.touchendHandler.bind(this))},createNode:function(i){var n=this.options,e=i.level,t=(i.children&&i[n.nodeId]&&l.each(i.children,function(e,t){t.parentId=i[n.nodeId]}),l("<div"+(n.draggable?' draggable="true"':"")+(i[n.nodeId]?' id="'+i[n.nodeId]+'"':"")+(i.parentId?' data-parent="'+i.parentId+'"':"")+">").addClass("node "+(i.className||"")+(e>n.visibleLevel?" slide-up":""))),s=(n.nodeTemplate?t.append(n.nodeTemplate(i)):t.append('<div class="title">'+i[n.nodeTitle]+"</div>").append(void 0!==n.nodeContent?'<div class="content">'+(i[n.nodeContent]||"")+"</div>":""),l.extend({},i)),s=(delete s.children,t.data("nodeData",s),i.relationship||"");return n.verticalLevel&&e>=n.verticalLevel||i.isVertical?Number(s.substr(2,1))&&t.append(`<i class="toggleBtn ${n.icons.theme}"></i>`).children(".title").prepend(`<i class="${n.icons.theme} ${n.icons.parentNode} parentNodeSymbol"></i>`):(i.isHybrid||(Number(s.substr(0,1))&&t.append(`<i class="edge verticalEdge topEdge ${n.icons.theme}"></i>`),Number(s.substr(1,1))&&t.append(`<i class="edge horizontalEdge rightEdge ${n.icons.theme}"></i><i class="edge horizontalEdge leftEdge ${n.icons.theme}"></i>`)),Number(s.substr(2,1))&&t.append(`<i class="edge verticalEdge bottomEdge ${n.icons.theme}"></i>`).children(".title").prepend(`<i class="${n.icons.theme} ${n.icons.parentNode} parentNodeSymbol"></i>`)),t.on("mouseenter mouseleave",this.nodeEnterLeaveHandler.bind(this)),t.on("click",this.nodeClickHandler.bind(this)),t.on("click",".topEdge",this.topEdgeClickHandler.bind(this)),t.on("click",".bottomEdge",this.bottomEdgeClickHandler.bind(this)),t.on("click",".leftEdge, .rightEdge",this.hEdgeClickHandler.bind(this)),t.on("click",".toggleBtn",this.toggleVNodes.bind(this)),n.draggable&&(this.bindDragDrop(t),this.touchHandled=!1,this.touchMoved=!1,this.touchTargetNode=null),n.createNode&&n.createNode(t,i),t},buildHierarchy:function(e,t){var i,n,s=this,o=this.options,a=0,a=t.level||(t.level=e.parentsUntil(".orgchart",".nodes").length);2<Object.keys(t).length&&e.append(this.createNode(t)),t.children&&t.children.length&&(i=a+1>o.visibleLevel||t.collapsed!==d&&t.collapsed,o.verticalLevel&&a+1>=o.verticalLevel||t.isHybrid?(n=l('<ul class="nodes">'),i&&o.verticalLevel&&a+1>=o.verticalLevel&&n.addClass("hidden"),(o.verticalLevel&&a+1===o.verticalLevel||t.isHybrid)&&!e.closest(".vertical").length?e.append(n.addClass("vertical")):e.append(n)):(n=l('<ul class="nodes'+(i?" hidden":"")+'">'),2!==Object.keys(t).length&&i&&e.addClass("isChildrenCollapsed"),e.append(n)),l.each(t.children,function(){var e=l('<li class="hierarchy">');n.append(e),this.level=a+1,s.buildHierarchy(e,this)}))},buildChildNode:function(e,t){this.buildHierarchy(e,{children:t})},addChildren:function(e,t){this.buildChildNode(e.closest(".hierarchy"),t),e.find(".parentNodeSymbol").length||e.children(".title").prepend(`<i class="${this.options.icons.theme} ${this.options.icons.parentNode} parentNodeSymbol"></i>`),e.closest(".nodes.vertical").length?e.children(".toggleBtn").length||e.append(`<i class="toggleBtn ${this.options.icons.theme}"></i>`):e.children(".bottomEdge").length||e.append(`<i class="edge verticalEdge bottomEdge ${this.options.icons.theme}"></i>`),this.isInAction(e)&&this.switchVerticalArrow(e.children(".bottomEdge"))},buildParentNode:function(e,t){t.relationship=t.relationship||"001";t=l('<ul class="nodes"><li class="hierarchy"></li></ul>').find(".hierarchy").append(this.createNode(t)).end();this.$chart.prepend(t).find(".hierarchy:first").append(e.closest("ul").addClass("nodes"))},addParent:function(e,t){this.buildParentNode(e,t),e.children(".topEdge").length||e.children(".title").after(`<i class="edge verticalEdge topEdge ${this.options.icons.theme}"></i>`),this.isInAction(e)&&this.switchVerticalArrow(e.children(".topEdge"))},buildSiblingNode:function(e,t){var i,n=(l.isArray(t)?t:t.children).length,s=e.parent().is(".nodes")?e.siblings().length+1:1,n=s+n,n=1<n?Math.floor(n/2-1):0;e.closest(".nodes").parent().is(".hierarchy")?(this.buildChildNode(e.parent().closest(".hierarchy"),t),i=e.parent().closest(".hierarchy").children(".nodes:last").children(".hierarchy"),1<s?i.eq(0).before(e.siblings().addBack().unwrap()):i.eq(n).after(e.unwrap())):(this.buildHierarchy(e.parent().prepend(l('<li class="hierarchy">')).children(".hierarchy:first"),t),e.prevAll(".hierarchy").children(".nodes").children().eq(n).after(e))},addSiblings:function(e,t){this.buildSiblingNode(e.closest(".hierarchy"),t),e.closest(".nodes").data("siblingsLoaded",!0),e.children(".leftEdge").length||e.children(".topEdge").after(`<i class="edge horizontalEdge rightEdge ${this.options.icons.theme}"></i><i class="edge horizontalEdge leftEdge ${this.options.icons.theme}"></i>`),this.isInAction(e)&&(this.switchHorizontalArrow(e),e.children(".topEdge").removeClass(this.options.icons.expandToUp).addClass(this.options.icons.collapseToDown))},removeNodes:function(e){var t=e.closest(".hierarchy").parent();t.parent().is(".hierarchy")?this.getNodeState(e,"siblings").exist?(e.closest(".hierarchy").remove(),1===t.children().length&&t.find(".node:first .horizontalEdge").remove()):t.siblings(".node").find(".bottomEdge").remove().end().end().remove():t.closest(".orgchart").remove()},hideDropZones:function(){this.$chart.find(".allowedDrop").removeClass("allowedDrop")},showDropZones:function(e){this.$chart.find(".node").each(function(e,t){l(t).addClass("allowedDrop")}),this.$chart.data("dragged",l(e))},processExternalDrop:function(e,t){t&&this.$chart.data("dragged",l(t)),e.closest(".node").triggerHandler({type:"drop"})},exportPDF:function(e,t){var i={},n=Math.floor(e.width),s=Math.floor(e.height);h.jsPDF||(h.jsPDF=h.jspdf.jsPDF),(i=s<n?new jsPDF({orientation:"landscape",unit:"px",format:[n,s]}):new jsPDF({orientation:"portrait",unit:"px",format:[s,n]})).addImage(e.toDataURL(),"png",0,0),i.save(t+".pdf")},exportPNG:function(e,t){var i="WebkitAppearance"in c.documentElement.style,n=!!h.sidebar,s="Microsoft Internet Explorer"===navigator.appName||"Netscape"===navigator.appName&&-1<navigator.appVersion.indexOf("Edge"),o=this.$chartContainer;!i&&!n||s?h.navigator.msSaveBlob(e.msToBlob(),t+".png"):(i=".download-btn"+(""!==this.options.chartClass?"."+this.options.chartClass:""),o.find(i).length||o.append('<a class="download-btn'+(""!==this.options.chartClass?" "+this.options.chartClass:"")+'" download="'+t+'.png"></a>'),o.find(i).attr("href",e.toDataURL())[0].click())},export:function(t,i){var n=this;if(t=void 0!==t?t:this.options.exportFilename,i=void 0!==i?i:this.options.exportFileextension,l(this).children(".spinner").length)return!1;var s=this.$chartContainer,e=s.find(".mask"),e=(e.length?e.removeClass("hidden"):s.append(`<div class="mask"><i class="${this.options.icons.theme} ${this.options.icons.spinner} spinner"></i></div>`),s.addClass("canvasContainer").find('.orgchart:not(".hidden")').get(0)),o="l2r"===n.options.direction||"r2l"===n.options.direction;html2canvas(e,{width:o?e.clientHeight:e.clientWidth,height:o?e.clientWidth:e.clientHeight,onclone:function(e){l(e).find(".canvasContainer").css("overflow","visible").find('.orgchart:not(".hidden"):first').css("transform","")}}).then(function(e){s.find(".mask").addClass("hidden"),"pdf"===i.toLowerCase()?n.exportPDF(e,t):n.exportPNG(e,t),s.removeClass("canvasContainer")},function(){s.removeClass("canvasContainer")})}},l.fn.orgchart=function(e){return new t(this,e).init()}});
2
2
  //# sourceMappingURL=jquery.orgchart.min.js.map