orgchart 3.6.0 → 3.8.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.
- package/README.md +64 -4
- package/demo/css/fontawesome.min.css +9 -0
- package/demo/custom-icons.html +146 -0
- package/demo/data-prop-compact.html +82 -0
- package/demo/{isHybrid.html → data-prop-hybrid.html} +1 -1
- package/demo/index.html +3 -1
- package/demo/multiple-layers.html +4 -4
- package/demo/option-createNode.html +2 -2
- package/demo/pan-zoom.html +3 -0
- package/demo/vertical-level.html +17 -17
- package/demo/webfonts/fa-brands-400.ttf +0 -0
- package/demo/webfonts/fa-brands-400.woff2 +0 -0
- package/demo/webfonts/fa-regular-400.ttf +0 -0
- package/demo/webfonts/fa-regular-400.woff2 +0 -0
- package/demo/webfonts/fa-solid-900.ttf +0 -0
- package/demo/webfonts/fa-solid-900.woff2 +0 -0
- package/demo/webfonts/fa-v4compatibility.ttf +0 -0
- package/demo/webfonts/fa-v4compatibility.woff2 +0 -0
- package/dist/css/jquery.orgchart.css +311 -156
- package/dist/css/jquery.orgchart.min.css +1 -1
- package/dist/js/jquery.orgchart.js +128 -56
- package/dist/js/jquery.orgchart.min.js +4 -1
- package/dist/js/jquery.orgchart.min.js.map +1 -1
- package/gulpfile.js +1 -1
- package/package.json +1 -1
- package/src/css/jquery.orgchart.css +311 -156
- package/src/js/jquery.orgchart.js +128 -56
- package/test/integration/init-tests.js +8 -8
- package/test/visual-regression/zoom/__image_snapshots__/__diff_output__/test-js-orgchart-visual-regression-tests-zoomin-correctly-1-snap-diff.png +0 -0
- package/test/visual-regression/zoom/__image_snapshots__/__diff_output__/test-js-orgchart-visual-regression-tests-zoomout-correctly-1-snap-diff.png +0 -0
- package/test/visual-regression/zoom/__image_snapshots__/test-js-orgchart-visual-regression-tests-zoomin-correctly-1-snap.png +0 -0
- package/test/visual-regression/zoom/__image_snapshots__/test-js-orgchart-visual-regression-tests-zoomout-correctly-1-snap.png +0 -0
|
@@ -21,6 +21,19 @@
|
|
|
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
|
+
'backToCompact': 'oci-corner-top-left',
|
|
32
|
+
'backToLoose': 'oci-corner-bottom-right',
|
|
33
|
+
'collapsed': 'oci-plus-square',
|
|
34
|
+
'expanded': 'oci-minus-square',
|
|
35
|
+
'spinner': 'oci-spinner'
|
|
36
|
+
},
|
|
24
37
|
'nodeTitle': 'name',
|
|
25
38
|
'nodeId': 'id',
|
|
26
39
|
'toggleSiblingsResp': false,
|
|
@@ -30,7 +43,6 @@
|
|
|
30
43
|
'exportButtonName': 'Export',
|
|
31
44
|
'exportFilename': 'OrgChart',
|
|
32
45
|
'exportFileextension': 'png',
|
|
33
|
-
'parentNodeSymbol': 'oci-leader',
|
|
34
46
|
'draggable': false,
|
|
35
47
|
'direction': 't2b',
|
|
36
48
|
'pan': false,
|
|
@@ -71,7 +83,7 @@
|
|
|
71
83
|
this.buildHierarchy($root, this.options.ajaxURL ? data : this.attachRel(data, '00'));
|
|
72
84
|
}
|
|
73
85
|
} else {
|
|
74
|
-
$chart.append(
|
|
86
|
+
$chart.append(`<i class="${this.options.icons.theme} ${this.options.icons.spinner} spinner"></i>`);
|
|
75
87
|
$.ajax({
|
|
76
88
|
'url': data,
|
|
77
89
|
'dataType': 'json'
|
|
@@ -103,6 +115,20 @@
|
|
|
103
115
|
|
|
104
116
|
return this;
|
|
105
117
|
},
|
|
118
|
+
handleCompactNodes: function () {
|
|
119
|
+
// caculate the compact nodes' level which is used to add different styles
|
|
120
|
+
this.$chart.find('.node.compact')
|
|
121
|
+
.each((index, node) => {
|
|
122
|
+
$(node).addClass($(node).parents('.compact').length % 2 === 0 ? 'even' : 'odd');
|
|
123
|
+
}); // the following code snippets is used to add direction arrows for the most top compact node, however the styles is not adjusted correctly
|
|
124
|
+
// .filter((index, node) => !$(node).parent().is('.compact'))
|
|
125
|
+
// .each((index, node) => {
|
|
126
|
+
// $(node).append(`<i class="edge verticalEdge topEdge ${this.options.icons.theme}"></i>`);
|
|
127
|
+
// if (this.getSiblings($(node)).length) {
|
|
128
|
+
// $(node).append(`<i class="edge horizontalEdge rightEdge ${this.options.icons.theme}"></i><i class="edge horizontalEdge leftEdge ${this.options.icons.theme}"></i>`);
|
|
129
|
+
// }
|
|
130
|
+
// });
|
|
131
|
+
},
|
|
106
132
|
//
|
|
107
133
|
triggerInitEvent: function () {
|
|
108
134
|
var that = this;
|
|
@@ -112,6 +138,7 @@
|
|
|
112
138
|
for (var i = 0; i < mutations.length; i++) {
|
|
113
139
|
for (var j = 0; j < mutations[i].addedNodes.length; j++) {
|
|
114
140
|
if (mutations[i].addedNodes[j].classList.contains('orgchart')) {
|
|
141
|
+
that.handleCompactNodes();
|
|
115
142
|
if (that.options.initCompleted && typeof that.options.initCompleted === 'function') {
|
|
116
143
|
that.options.initCompleted(that.$chart);
|
|
117
144
|
}
|
|
@@ -367,14 +394,21 @@
|
|
|
367
394
|
});
|
|
368
395
|
return subObj;
|
|
369
396
|
},
|
|
370
|
-
//
|
|
397
|
+
// process datasource and add necessary information
|
|
371
398
|
attachRel: function (data, flags) {
|
|
372
399
|
var that = this;
|
|
373
400
|
data.relationship = flags + (data.children && data.children.length > 0 ? 1 : 0);
|
|
401
|
+
if (this.options?.compact?.constructor === Function && this.options.compact(data)) {
|
|
402
|
+
data.compact = true;
|
|
403
|
+
}
|
|
374
404
|
if (data.children) {
|
|
375
405
|
data.children.forEach(function(item) {
|
|
376
|
-
if (data.
|
|
377
|
-
item.
|
|
406
|
+
if (data.hybrid || data.vertical) { // identify all the descendant nodes except the root node of hybrid structure
|
|
407
|
+
item.vertical = true;
|
|
408
|
+
} else if (data.compact && item.children) { // identify all the compact ancestor nodes
|
|
409
|
+
item.compact = true;
|
|
410
|
+
} else if (data.compact && !item.children) { // identify all the compact descendant nodes
|
|
411
|
+
item.associatedCompact = true;
|
|
378
412
|
}
|
|
379
413
|
that.attachRel(item, '1' + (data.children.length > 1 ? 1 : 0));
|
|
380
414
|
});
|
|
@@ -568,7 +602,7 @@
|
|
|
568
602
|
$animatedNodes.closest('.hierarchy').addClass('isCollapsedDescendant');
|
|
569
603
|
}
|
|
570
604
|
if ($lowerLevel.is('.vertical') || $lowerLevel.find('.vertical').length) {
|
|
571
|
-
$animatedNodes.find(
|
|
605
|
+
$animatedNodes.find(this.options.icons.expanded).removeClass(this.options.icons.expanded).addClass(this.options.icons.collapsed);
|
|
572
606
|
}
|
|
573
607
|
this.repaint($animatedNodes.get(0));
|
|
574
608
|
$animatedNodes.addClass('sliding slide-up').eq(0).one('transitionend', { 'animatedNodes': $animatedNodes, 'lowerLevel': $lowerLevel, 'node': $node }, this.hideChildrenEnd.bind(this));
|
|
@@ -647,7 +681,7 @@
|
|
|
647
681
|
event.data.visibleNodes.removeClass('sliding');
|
|
648
682
|
if (this.isInAction($node)) {
|
|
649
683
|
this.switchHorizontalArrow($node);
|
|
650
|
-
$node.children('.topEdge').removeClass(
|
|
684
|
+
$node.children('.topEdge').removeClass(this.options.icons.expandToUp).addClass(this.options.icons.collapseToDown);
|
|
651
685
|
}
|
|
652
686
|
},
|
|
653
687
|
//
|
|
@@ -702,7 +736,7 @@
|
|
|
702
736
|
}
|
|
703
737
|
|
|
704
738
|
$edge.addClass('hidden');
|
|
705
|
-
$edge.parent().append(
|
|
739
|
+
$edge.parent().append(`<i class="${this.options.icons.theme} ${this.options.icons.spinner} spinner"></i>`)
|
|
706
740
|
.children().not('.spinner').css('opacity', 0.2);
|
|
707
741
|
$chart.data('inAjax', true);
|
|
708
742
|
$('.oc-export-btn').prop('disabled', true);
|
|
@@ -719,11 +753,16 @@
|
|
|
719
753
|
},
|
|
720
754
|
// whether the cursor is hovering over the node
|
|
721
755
|
isInAction: function ($node) {
|
|
722
|
-
return
|
|
756
|
+
return [
|
|
757
|
+
this.options.icons.expandToUp,
|
|
758
|
+
this.options.icons.collapseToDown,
|
|
759
|
+
this.options.icons.collapseToLeft,
|
|
760
|
+
this.options.icons.expandToRight
|
|
761
|
+
].some((icon) => $node.children('.edge').attr('class').indexOf(icon) > -1);
|
|
723
762
|
},
|
|
724
763
|
//
|
|
725
764
|
switchVerticalArrow: function ($arrow) {
|
|
726
|
-
$arrow.toggleClass(
|
|
765
|
+
$arrow.toggleClass(`${this.options.icons.expandToUp} ${this.options.icons.collapseToDown}`);
|
|
727
766
|
},
|
|
728
767
|
//
|
|
729
768
|
switchHorizontalArrow: function ($node) {
|
|
@@ -732,24 +771,24 @@
|
|
|
732
771
|
var $prevSib = $node.parent().prev();
|
|
733
772
|
if ($prevSib.length) {
|
|
734
773
|
if ($prevSib.is('.hidden')) {
|
|
735
|
-
$node.children('.leftEdge').addClass(
|
|
774
|
+
$node.children('.leftEdge').addClass(opts.icons.collapseToLeft).removeClass(opts.icons.expandToRight);
|
|
736
775
|
} else {
|
|
737
|
-
$node.children('.leftEdge').addClass(
|
|
776
|
+
$node.children('.leftEdge').addClass(opts.icons.expandToRight).removeClass(opts.icons.collapseToLeft);
|
|
738
777
|
}
|
|
739
778
|
}
|
|
740
779
|
var $nextSib = $node.parent().next();
|
|
741
780
|
if ($nextSib.length) {
|
|
742
781
|
if ($nextSib.is('.hidden')) {
|
|
743
|
-
$node.children('.rightEdge').addClass(
|
|
782
|
+
$node.children('.rightEdge').addClass(opts.icons.expandToRight).removeClass(opts.icons.collapseToLeft);
|
|
744
783
|
} else {
|
|
745
|
-
$node.children('.rightEdge').addClass(
|
|
784
|
+
$node.children('.rightEdge').addClass(opts.icons.collapseToLeft).removeClass(opts.icons.expandToRight);
|
|
746
785
|
}
|
|
747
786
|
}
|
|
748
787
|
} else {
|
|
749
788
|
var $sibs = $node.parent().siblings();
|
|
750
789
|
var sibsVisible = $sibs.length ? !$sibs.is('.hidden') : false;
|
|
751
|
-
$node.children('.leftEdge').toggleClass(
|
|
752
|
-
$node.children('.rightEdge').toggleClass(
|
|
790
|
+
$node.children('.leftEdge').toggleClass(opts.icons.expandToRight, sibsVisible).toggleClass(opts.icons.collapseToLeft, !sibsVisible);
|
|
791
|
+
$node.children('.rightEdge').toggleClass(opts.icons.collapseToLeft, sibsVisible).toggleClass(opts.icons.expandToRight, !sibsVisible);
|
|
753
792
|
}
|
|
754
793
|
},
|
|
755
794
|
//
|
|
@@ -767,10 +806,10 @@
|
|
|
767
806
|
if (event.type === 'mouseenter') {
|
|
768
807
|
if ($node.children('.toggleBtn').length) {
|
|
769
808
|
flag = this.getNodeState($node, 'children').visible;
|
|
770
|
-
$toggleBtn.toggleClass(
|
|
809
|
+
$toggleBtn.toggleClass(this.options.icons.collapsed, !flag).toggleClass(this.options.icons.expanded, flag);
|
|
771
810
|
}
|
|
772
811
|
} else {
|
|
773
|
-
$toggleBtn.removeClass(
|
|
812
|
+
$toggleBtn.removeClass(`${this.options.icons.collapsed} ${this.options.icons.expanded}`);
|
|
774
813
|
}
|
|
775
814
|
} else {
|
|
776
815
|
var $topEdge = $node.children('.topEdge');
|
|
@@ -780,17 +819,17 @@
|
|
|
780
819
|
if (event.type === 'mouseenter') {
|
|
781
820
|
if ($topEdge.length) {
|
|
782
821
|
flag = this.getNodeState($node, 'parent').visible;
|
|
783
|
-
$topEdge.toggleClass(
|
|
822
|
+
$topEdge.toggleClass(this.options.icons.expandToUp, !flag).toggleClass(this.options.icons.collapseToDown, flag);
|
|
784
823
|
}
|
|
785
824
|
if ($bottomEdge.length) {
|
|
786
825
|
flag = this.getNodeState($node, 'children').visible;
|
|
787
|
-
$bottomEdge.toggleClass(
|
|
826
|
+
$bottomEdge.toggleClass(this.options.icons.collapseToDown, !flag).toggleClass(this.options.icons.expandToUp, flag);
|
|
788
827
|
}
|
|
789
828
|
if ($leftEdge.length) {
|
|
790
829
|
this.switchHorizontalArrow($node);
|
|
791
830
|
}
|
|
792
831
|
} else {
|
|
793
|
-
$node.children('.edge').removeClass(
|
|
832
|
+
$node.children('.edge').removeClass(`${this.options.icons.expandToUp} ${this.options.icons.collapseToDown} ${this.options.icons.collapseToLeft} ${this.options.icons.expandToRight}`);
|
|
794
833
|
}
|
|
795
834
|
}
|
|
796
835
|
},
|
|
@@ -939,6 +978,19 @@
|
|
|
939
978
|
}
|
|
940
979
|
}
|
|
941
980
|
},
|
|
981
|
+
// show the compact node's children in the compact mode
|
|
982
|
+
backToCompactHandler: function (event) {
|
|
983
|
+
$(event.delegateTarget).removeClass('looseMode')
|
|
984
|
+
.children('.backToCompactSymbol').addClass('hidden').end()
|
|
985
|
+
.children('.backToLooseSymbol').removeClass('hidden');
|
|
986
|
+
},
|
|
987
|
+
// show the compact node's children in the loose mode
|
|
988
|
+
backToLooseHandler: function (event) {
|
|
989
|
+
$(event.delegateTarget)
|
|
990
|
+
.addClass('looseMode')
|
|
991
|
+
.children('.backToLooseSymbol').addClass('hidden').end()
|
|
992
|
+
.children('.backToCompactSymbol').removeClass('hidden');
|
|
993
|
+
},
|
|
942
994
|
//
|
|
943
995
|
expandVNodesEnd: function (event) {
|
|
944
996
|
event.data.vNodes.removeClass('sliding');
|
|
@@ -954,14 +1006,14 @@
|
|
|
954
1006
|
var $descendants = $descWrapper.find('.node');
|
|
955
1007
|
var $children = $descWrapper.children().children('.node');
|
|
956
1008
|
if ($children.is('.sliding')) { return; }
|
|
957
|
-
$toggleBtn.toggleClass(
|
|
1009
|
+
$toggleBtn.toggleClass(`${this.options.icons.collapsed} ${this.options.icons.expanded}`);
|
|
958
1010
|
if ($descendants.eq(0).is('.slide-up')) {
|
|
959
1011
|
$descWrapper.removeClass('hidden');
|
|
960
1012
|
this.repaint($children.get(0));
|
|
961
1013
|
$children.addClass('sliding').removeClass('slide-up').eq(0).one('transitionend', { 'vNodes': $children }, this.expandVNodesEnd);
|
|
962
1014
|
} else {
|
|
963
1015
|
$descendants.addClass('sliding slide-up').eq(0).one('transitionend', { 'vNodes': $descendants }, this.collapseVNodesEnd);
|
|
964
|
-
$descendants.find('.toggleBtn').removeClass(
|
|
1016
|
+
$descendants.find('.toggleBtn').removeClass(`${this.options.icons.collapsed} ${this.options.icons.expanded}`);
|
|
965
1017
|
}
|
|
966
1018
|
},
|
|
967
1019
|
//
|
|
@@ -1122,7 +1174,7 @@
|
|
|
1122
1174
|
// special process for hybrid chart
|
|
1123
1175
|
var datasource = this.$chart.data('options').data;
|
|
1124
1176
|
var digger = new JSONDigger(datasource, this.$chart.data('options').nodeId, 'children');
|
|
1125
|
-
const hybridNode = digger.findOneNode({ '
|
|
1177
|
+
const hybridNode = digger.findOneNode({ 'hybrid': true });
|
|
1126
1178
|
if (this.$chart.data('options').verticalLevel > 1 || hybridNode) {
|
|
1127
1179
|
var draggedNode = digger.findNodeById($dragged.data('nodeData').id);
|
|
1128
1180
|
var copy = Object.assign({}, draggedNode);
|
|
@@ -1138,14 +1190,14 @@
|
|
|
1138
1190
|
// The folowing code snippets are used to process horizontal chart
|
|
1139
1191
|
// firstly, deal with the hierarchy of drop zone
|
|
1140
1192
|
if (!$dropZone.siblings('.nodes').length) { // if the drop zone is a leaf node
|
|
1141
|
-
$dropZone.append(
|
|
1193
|
+
$dropZone.append(`<i class="edge verticalEdge bottomEdge ${this.options.icons.theme}"></i>`)
|
|
1142
1194
|
.after('<ul class="nodes"></ul>')
|
|
1143
1195
|
.siblings('.nodes').append($dragged.find('.horizontalEdge').remove().end().closest('.hierarchy'));
|
|
1144
1196
|
if ($dropZone.children('.title').length) {
|
|
1145
|
-
$dropZone.children('.title').prepend(
|
|
1197
|
+
$dropZone.children('.title').prepend(`<i class="${this.options.icons.theme} ${this.$chart.data('options').icons.parentNode} parentNodeSymbol"></i>`);
|
|
1146
1198
|
}
|
|
1147
1199
|
} else {
|
|
1148
|
-
var horizontalEdges =
|
|
1200
|
+
var horizontalEdges = `<i class="edge horizontalEdge rightEdge ${this.options.icons.theme}"></i><i class="edge horizontalEdge leftEdge ${this.options.icons.theme}"></i>`;
|
|
1149
1201
|
if (!$dragged.find('.horizontalEdge').length) {
|
|
1150
1202
|
$dragged.append(horizontalEdges);
|
|
1151
1203
|
}
|
|
@@ -1160,7 +1212,7 @@
|
|
|
1160
1212
|
$dragZone.siblings('.nodes').children('.hierarchy').find('.node:first')
|
|
1161
1213
|
.find('.horizontalEdge').remove();
|
|
1162
1214
|
} else if ($dragZone.siblings('.nodes').children('.hierarchy').length === 0) {
|
|
1163
|
-
$dragZone.find('.bottomEdge, .
|
|
1215
|
+
$dragZone.find('.bottomEdge, .parentNodeSymbol').remove()
|
|
1164
1216
|
.end().siblings('.nodes').remove();
|
|
1165
1217
|
}
|
|
1166
1218
|
}
|
|
@@ -1344,29 +1396,39 @@
|
|
|
1344
1396
|
var nodeData = $.extend({}, data);
|
|
1345
1397
|
delete nodeData.children;
|
|
1346
1398
|
$nodeDiv.data('nodeData', nodeData);
|
|
1347
|
-
// append 4 direction arrows or expand/collapse buttons
|
|
1399
|
+
// append 4 direction arrows or expand/collapse buttons or reset buttons
|
|
1348
1400
|
var flags = data.relationship || '';
|
|
1349
|
-
if ((opts.verticalLevel && level >= opts.verticalLevel) || data.
|
|
1401
|
+
if ((opts.verticalLevel && level >= opts.verticalLevel) || data.vertical) {
|
|
1350
1402
|
if (Number(flags.substr(2,1))) {
|
|
1351
|
-
$nodeDiv.append(
|
|
1352
|
-
.children('.title').prepend(
|
|
1403
|
+
$nodeDiv.append(`<i class="toggleBtn ${opts.icons.theme}"></i>`)
|
|
1404
|
+
.children('.title').prepend(`<i class="${opts.icons.theme} ${opts.icons.parentNode} parentNodeSymbol"></i>`);
|
|
1353
1405
|
}
|
|
1354
|
-
} else if (data.
|
|
1406
|
+
} else if (data.hybrid) {
|
|
1355
1407
|
if (Number(flags.substr(2,1))) {
|
|
1356
|
-
$nodeDiv.append(
|
|
1357
|
-
.children('.title').prepend(
|
|
1408
|
+
$nodeDiv.append(`<i class="edge verticalEdge bottomEdge ${opts.icons.theme}"></i>`)
|
|
1409
|
+
.children('.title').prepend(`<i class="${opts.icons.theme} ${opts.icons.parentNode} parentNodeSymbol"></i>`);
|
|
1358
1410
|
}
|
|
1411
|
+
} else if (data.compact) {
|
|
1412
|
+
$nodeDiv.css('grid-template-columns', `repeat(${Math.floor(Math.sqrt(data.children.length + 1))}, auto)`);
|
|
1413
|
+
if (Number(flags.substr(2,1))) {
|
|
1414
|
+
$nodeDiv.append(`
|
|
1415
|
+
<i class="${opts.icons.theme} ${opts.icons.backToCompact} backToCompactSymbol hidden"></i>
|
|
1416
|
+
<i class="${opts.icons.theme} ${opts.icons.backToLoose} backToLooseSymbol"></i>
|
|
1417
|
+
`)
|
|
1418
|
+
.children('.title').prepend(`<i class="${opts.icons.theme} ${opts.icons.parentNode} parentNodeSymbol"></i>`);
|
|
1419
|
+
}
|
|
1420
|
+
} else if (data.associatedCompact) {
|
|
1421
|
+
|
|
1359
1422
|
} else {
|
|
1360
1423
|
if (Number(flags.substr(0,1))) {
|
|
1361
|
-
$nodeDiv.append(
|
|
1424
|
+
$nodeDiv.append(`<i class="edge verticalEdge topEdge ${opts.icons.theme}"></i>`);
|
|
1362
1425
|
}
|
|
1363
1426
|
if(Number(flags.substr(1,1))) {
|
|
1364
|
-
$nodeDiv.append(
|
|
1365
|
-
'<i class="edge horizontalEdge leftEdge oci"></i>');
|
|
1427
|
+
$nodeDiv.append(`<i class="edge horizontalEdge rightEdge ${opts.icons.theme}"></i><i class="edge horizontalEdge leftEdge ${opts.icons.theme}"></i>`);
|
|
1366
1428
|
}
|
|
1367
1429
|
if(Number(flags.substr(2,1))) {
|
|
1368
|
-
$nodeDiv.append(
|
|
1369
|
-
.children('.title').prepend(
|
|
1430
|
+
$nodeDiv.append(`<i class="edge verticalEdge bottomEdge ${opts.icons.theme}"></i>`)
|
|
1431
|
+
.children('.title').prepend(`<i class="${opts.icons.theme} ${opts.icons.parentNode} parentNodeSymbol"></i>`);
|
|
1370
1432
|
}
|
|
1371
1433
|
}
|
|
1372
1434
|
|
|
@@ -1376,6 +1438,8 @@
|
|
|
1376
1438
|
$nodeDiv.on('click', '.bottomEdge', this.bottomEdgeClickHandler.bind(this));
|
|
1377
1439
|
$nodeDiv.on('click', '.leftEdge, .rightEdge', this.hEdgeClickHandler.bind(this));
|
|
1378
1440
|
$nodeDiv.on('click', '.toggleBtn', this.toggleVNodes.bind(this));
|
|
1441
|
+
$nodeDiv.on('click', '> .backToCompactSymbol',this.backToCompactHandler.bind(this));
|
|
1442
|
+
$nodeDiv.on('click', '> .backToLooseSymbol',this.backToLooseHandler.bind(this));
|
|
1379
1443
|
|
|
1380
1444
|
if (opts.draggable) {
|
|
1381
1445
|
this.bindDragDrop($nodeDiv);
|
|
@@ -1395,6 +1459,7 @@
|
|
|
1395
1459
|
var that = this;
|
|
1396
1460
|
var opts = this.options;
|
|
1397
1461
|
var level = 0;
|
|
1462
|
+
var $nodeDiv;
|
|
1398
1463
|
if (data.level) {
|
|
1399
1464
|
level = data.level;
|
|
1400
1465
|
} else {
|
|
@@ -1402,23 +1467,26 @@
|
|
|
1402
1467
|
}
|
|
1403
1468
|
// Construct the node
|
|
1404
1469
|
if (Object.keys(data).length > 2) {
|
|
1405
|
-
$
|
|
1470
|
+
$nodeDiv = this.createNode(data);
|
|
1471
|
+
$appendTo.append($nodeDiv);
|
|
1406
1472
|
}
|
|
1407
1473
|
// Construct the "inferior nodes"
|
|
1408
1474
|
if (data.children && data.children.length) {
|
|
1409
1475
|
var isHidden = level + 1 > opts.visibleLevel || (data.collapsed !== undefined && data.collapsed);
|
|
1410
1476
|
var $nodesLayer;
|
|
1411
|
-
if ((opts.verticalLevel && (level + 1) >= opts.verticalLevel) || data.
|
|
1477
|
+
if ((opts.verticalLevel && (level + 1) >= opts.verticalLevel) || data.hybrid) {
|
|
1412
1478
|
$nodesLayer = $('<ul class="nodes">');
|
|
1413
1479
|
if (isHidden && (opts.verticalLevel && (level + 1) >= opts.verticalLevel)) {
|
|
1414
1480
|
$nodesLayer.addClass('hidden');
|
|
1415
1481
|
}
|
|
1416
|
-
if (((opts.verticalLevel && level + 1 === opts.verticalLevel) || data.
|
|
1482
|
+
if (((opts.verticalLevel && level + 1 === opts.verticalLevel) || data.hybrid)
|
|
1417
1483
|
&& !$appendTo.closest('.vertical').length) {
|
|
1418
1484
|
$appendTo.append($nodesLayer.addClass('vertical'));
|
|
1419
1485
|
} else {
|
|
1420
1486
|
$appendTo.append($nodesLayer);
|
|
1421
1487
|
}
|
|
1488
|
+
} else if (data.compact) {
|
|
1489
|
+
$nodeDiv.addClass('compact');
|
|
1422
1490
|
} else {
|
|
1423
1491
|
$nodesLayer = $('<ul class="nodes' + (isHidden ? ' hidden' : '') + '">');
|
|
1424
1492
|
if (Object.keys(data).length === 2) {
|
|
@@ -1432,10 +1500,14 @@
|
|
|
1432
1500
|
}
|
|
1433
1501
|
// recurse through children nodes
|
|
1434
1502
|
$.each(data.children, function () {
|
|
1435
|
-
var $nodeCell = $('<li class="hierarchy">');
|
|
1436
|
-
$nodesLayer.append($nodeCell);
|
|
1437
1503
|
this.level = level + 1;
|
|
1438
|
-
|
|
1504
|
+
if (data.compact) {
|
|
1505
|
+
that.buildHierarchy($nodeDiv, this);
|
|
1506
|
+
} else {
|
|
1507
|
+
var $nodeCell = $('<li class="hierarchy">');
|
|
1508
|
+
$nodesLayer.append($nodeCell);
|
|
1509
|
+
that.buildHierarchy($nodeCell, this);
|
|
1510
|
+
}
|
|
1439
1511
|
});
|
|
1440
1512
|
}
|
|
1441
1513
|
},
|
|
@@ -1446,16 +1518,16 @@
|
|
|
1446
1518
|
// exposed method
|
|
1447
1519
|
addChildren: function ($node, data) {
|
|
1448
1520
|
this.buildChildNode($node.closest('.hierarchy'), data);
|
|
1449
|
-
if (!$node.find('.
|
|
1450
|
-
$node.children('.title').prepend(
|
|
1521
|
+
if (!$node.find('.parentNodeSymbol').length) {
|
|
1522
|
+
$node.children('.title').prepend(`<i class="${this.options.icons.theme} ${this.options.icons.parentNode} parentNodeSymbol"></i>`);
|
|
1451
1523
|
}
|
|
1452
1524
|
if ($node.closest('.nodes.vertical').length) {
|
|
1453
1525
|
if (!$node.children('.toggleBtn').length) {
|
|
1454
|
-
$node.append(
|
|
1526
|
+
$node.append(`<i class="toggleBtn ${this.options.icons.theme}"></i>`);
|
|
1455
1527
|
}
|
|
1456
1528
|
} else {
|
|
1457
1529
|
if (!$node.children('.bottomEdge').length) {
|
|
1458
|
-
$node.append(
|
|
1530
|
+
$node.append(`<i class="edge verticalEdge bottomEdge ${this.options.icons.theme}"></i>`);
|
|
1459
1531
|
}
|
|
1460
1532
|
}
|
|
1461
1533
|
if (this.isInAction($node)) {
|
|
@@ -1474,7 +1546,7 @@
|
|
|
1474
1546
|
addParent: function ($currentRoot, data) {
|
|
1475
1547
|
this.buildParentNode($currentRoot, data);
|
|
1476
1548
|
if (!$currentRoot.children('.topEdge').length) {
|
|
1477
|
-
$currentRoot.children('.title').after(
|
|
1549
|
+
$currentRoot.children('.title').after(`<i class="edge verticalEdge topEdge ${this.options.icons.theme}"></i>`);
|
|
1478
1550
|
}
|
|
1479
1551
|
if (this.isInAction($currentRoot)) {
|
|
1480
1552
|
this.switchVerticalArrow($currentRoot.children('.topEdge'));
|
|
@@ -1505,11 +1577,11 @@
|
|
|
1505
1577
|
this.buildSiblingNode($node.closest('.hierarchy'), data);
|
|
1506
1578
|
$node.closest('.nodes').data('siblingsLoaded', true);
|
|
1507
1579
|
if (!$node.children('.leftEdge').length) {
|
|
1508
|
-
$node.children('.topEdge').after(
|
|
1580
|
+
$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
1581
|
}
|
|
1510
1582
|
if (this.isInAction($node)) {
|
|
1511
1583
|
this.switchHorizontalArrow($node);
|
|
1512
|
-
$node.children('.topEdge').removeClass(
|
|
1584
|
+
$node.children('.topEdge').removeClass(this.options.icons.expandToUp).addClass(this.options.icons.collapseToDown);
|
|
1513
1585
|
}
|
|
1514
1586
|
},
|
|
1515
1587
|
// remove node and its descendent nodes
|
|
@@ -1594,10 +1666,10 @@
|
|
|
1594
1666
|
if ((!isWebkit && !isFf) || isEdge) {
|
|
1595
1667
|
window.navigator.msSaveBlob(canvas.msToBlob(), exportFilename + '.png');
|
|
1596
1668
|
} else {
|
|
1597
|
-
var selector = '.
|
|
1669
|
+
var selector = '.download-btn' + (that.options.chartClass !== '' ? '.' + that.options.chartClass : '');
|
|
1598
1670
|
|
|
1599
1671
|
if (!$chartContainer.find(selector).length) {
|
|
1600
|
-
$chartContainer.append('<a class="
|
|
1672
|
+
$chartContainer.append('<a class="download-btn' + (that.options.chartClass !== '' ? ' ' + that.options.chartClass : '') + '"'
|
|
1601
1673
|
+ ' download="' + exportFilename + '.png"></a>');
|
|
1602
1674
|
}
|
|
1603
1675
|
|
|
@@ -1615,7 +1687,7 @@
|
|
|
1615
1687
|
var $chartContainer = this.$chartContainer;
|
|
1616
1688
|
var $mask = $chartContainer.find('.mask');
|
|
1617
1689
|
if (!$mask.length) {
|
|
1618
|
-
$chartContainer.append(
|
|
1690
|
+
$chartContainer.append(`<div class="mask"><i class="${this.options.icons.theme} ${this.options.icons.spinner} spinner"></i></div>`);
|
|
1619
1691
|
} else {
|
|
1620
1692
|
$mask.removeClass('hidden');
|
|
1621
1693
|
}
|
|
@@ -19,7 +19,7 @@ describe('orgchart -- integration tests', function () {
|
|
|
19
19
|
]
|
|
20
20
|
},
|
|
21
21
|
fragment = '<div class="orgchart"><ul class="nodes"><li class="hierarchy">' +
|
|
22
|
-
'<div id="n1" class="node"><div class="title"><i class="oci oci-
|
|
22
|
+
'<div id="n1" class="node"><div class="title"><i class="oci oci-menu parentNodeSymbol">' +
|
|
23
23
|
'</i>Lao Lao</div><i class="edge verticalEdge bottomEdge oci"></i></div><ul class="nodes">' +
|
|
24
24
|
'<li class="hierarchy"><div id="n2" data-parent="n1" class="node">' +
|
|
25
25
|
'<div class="title">Bo Miao</div><i class="edge verticalEdge topEdge oci"></i>' +
|
|
@@ -73,7 +73,7 @@ describe('orgchart -- integration tests', function () {
|
|
|
73
73
|
|
|
74
74
|
it('initialize chart with the given vertical level', function () {
|
|
75
75
|
var fragment = '<li class="hierarchy"><div id="n1" class="node"><div class="title">' +
|
|
76
|
-
'<i class="oci oci-
|
|
76
|
+
'<i class="oci oci-menu parentNodeSymbol"></i>Lao Lao</div><i class="edge verticalEdge bottomEdge oci">' +
|
|
77
77
|
'</i></div><ul class="nodes vertical"><li class="hierarchy"><div id="n2" data-parent="n1" class="node">' +
|
|
78
78
|
'<div class="title">Bo Miao</div></div></li><li class="hierarchy"><div id="n3" data-parent="n1" class="node">' +
|
|
79
79
|
'<div class="title">Su Miao</div></div></li></ul></li>';
|
|
@@ -101,11 +101,11 @@ describe('orgchart -- integration tests', function () {
|
|
|
101
101
|
|
|
102
102
|
it('verticalLevel=2 and visibleLevel=1', function () {
|
|
103
103
|
var fragment = '<div class="orgchart"><ul class="nodes"><li class="hierarchy">' +
|
|
104
|
-
'<div class="node"><div class="title"><i class="oci oci-
|
|
104
|
+
'<div class="node"><div class="title"><i class="oci oci-menu parentNodeSymbol">' +
|
|
105
105
|
'</i>Lao Lao</div><i class="edge verticalEdge bottomEdge oci"></i></div>' +
|
|
106
106
|
'<ul class="nodes hidden vertical"><li class="hierarchy"><div class="node slide-up">' +
|
|
107
107
|
'<div class="title">Bo Miao</div></div></li><li class="hierarchy">' +
|
|
108
|
-
'<div class="node slide-up"><div class="title"><i class="oci oci-
|
|
108
|
+
'<div class="node slide-up"><div class="title"><i class="oci oci-menu parentNodeSymbol"></i>Su Miao</div>' +
|
|
109
109
|
'<i class="toggleBtn oci"></i></div><ul class="nodes hidden">' +
|
|
110
110
|
'<li class="hierarchy"><div class="node slide-up"><div class="title">Tie Hua</div>' +
|
|
111
111
|
'</div></li><li class="hierarchy"><div class="node slide-up">' +
|
|
@@ -120,10 +120,10 @@ describe('orgchart -- integration tests', function () {
|
|
|
120
120
|
|
|
121
121
|
it('verticalLevel=2 and visibleLevel=2', function () {
|
|
122
122
|
var fragment = '<div class="orgchart"><ul class="nodes"><li class="hierarchy">' +
|
|
123
|
-
'<div class="node"><div class="title"><i class="oci oci-
|
|
123
|
+
'<div class="node"><div class="title"><i class="oci oci-menu parentNodeSymbol"></i>Lao Lao</div>' +
|
|
124
124
|
'<i class="edge verticalEdge bottomEdge oci"></i></div><ul class="nodes vertical">' +
|
|
125
125
|
'<li class="hierarchy"><div class="node"><div class="title">Bo Miao</div></div></li>' +
|
|
126
|
-
'<li class="hierarchy"><div class="node"><div class="title"><i class="oci oci-
|
|
126
|
+
'<li class="hierarchy"><div class="node"><div class="title"><i class="oci oci-menu parentNodeSymbol"></i>Su Miao</div>' +
|
|
127
127
|
'<i class="toggleBtn oci"></i></div><ul class="nodes hidden">' +
|
|
128
128
|
'<li class="hierarchy"><div class="node slide-up"><div class="title">Tie Hua</div></div>' +
|
|
129
129
|
'</li><li class="hierarchy"><div class="node slide-up"><div class="title">Hei Hei</div>' +
|
|
@@ -138,10 +138,10 @@ describe('orgchart -- integration tests', function () {
|
|
|
138
138
|
|
|
139
139
|
it('verticalLevel=2 and visibleLevel=3', function () {
|
|
140
140
|
var fragment = '<div class="orgchart"><ul class="nodes"><li class="hierarchy">' +
|
|
141
|
-
'<div class="node"><div class="title"><i class="oci oci-
|
|
141
|
+
'<div class="node"><div class="title"><i class="oci oci-menu parentNodeSymbol"></i>Lao Lao</div>' +
|
|
142
142
|
'<i class="edge verticalEdge bottomEdge oci"></i></div><ul class="nodes vertical">' +
|
|
143
143
|
'<li class="hierarchy"><div class="node"><div class="title">Bo Miao</div></div></li>' +
|
|
144
|
-
'<li class="hierarchy"><div class="node"><div class="title"><i class="oci oci-
|
|
144
|
+
'<li class="hierarchy"><div class="node"><div class="title"><i class="oci oci-menu parentNodeSymbol"></i>Su Miao</div>' +
|
|
145
145
|
'<i class="toggleBtn oci"></i></div><ul class="nodes">' +
|
|
146
146
|
'<li class="hierarchy"><div class="node"><div class="title">Tie Hua</div></div>' +
|
|
147
147
|
'</li><li class="hierarchy"><div class="node"><div class="title">Hei Hei</div></div>' +
|
|
Binary file
|
|
Binary file
|
|
Binary file
|