orgchart 3.7.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 +39 -3
- package/demo/custom-icons.html +1 -1
- package/demo/data-prop-compact.html +82 -0
- package/demo/{isHybrid.html → data-prop-hybrid.html} +1 -1
- package/demo/index.html +2 -1
- package/dist/css/jquery.orgchart.css +189 -0
- package/dist/css/jquery.orgchart.min.css +1 -1
- package/dist/js/jquery.orgchart.js +71 -13
- 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 +189 -0
- package/src/js/jquery.orgchart.js +71 -13
- 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/gulpfile.js
CHANGED
|
@@ -71,7 +71,7 @@ gulp.task('e2e-tests', gulp.series('addAssets', function () {
|
|
|
71
71
|
});
|
|
72
72
|
}));
|
|
73
73
|
|
|
74
|
-
gulp.task('test', gulp.series('e2e-tests'
|
|
74
|
+
gulp.task('test', gulp.series('e2e-tests'));
|
|
75
75
|
|
|
76
76
|
gulp.task('cleanupJS', function() {
|
|
77
77
|
return del([paths.distJSFolder + '/**']);
|
package/package.json
CHANGED
|
@@ -273,6 +273,7 @@
|
|
|
273
273
|
|
|
274
274
|
.orgchart .node .content {
|
|
275
275
|
box-sizing: border-box;
|
|
276
|
+
width: 130px;
|
|
276
277
|
height: 20px;
|
|
277
278
|
line-height: 20px;
|
|
278
279
|
font-size: 10px;
|
|
@@ -533,6 +534,157 @@
|
|
|
533
534
|
border-width: 2px 0 0 0;
|
|
534
535
|
}
|
|
535
536
|
|
|
537
|
+
/* styles for compact nodes */
|
|
538
|
+
.orgchart .hierarchy > .node.compact {
|
|
539
|
+
position: static;
|
|
540
|
+
display: grid;
|
|
541
|
+
width: 140px;
|
|
542
|
+
height: 50px;
|
|
543
|
+
overflow: hidden;
|
|
544
|
+
background-color: #eee;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
.orgchart .node.compact.even,
|
|
548
|
+
.orgchart .node.compact.even:hover {
|
|
549
|
+
background-color: #eee;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
.orgchart .node.compact.odd,
|
|
553
|
+
.orgchart .node.compact.odd:hover {
|
|
554
|
+
background-color: #fff;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
.orgchart .node.compact.even > .node:hover,
|
|
558
|
+
.orgchart .node.compact.even > .node.focused,
|
|
559
|
+
.orgchart .node.compact.even > .node.selected {
|
|
560
|
+
background-color: #fff;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
.orgchart .node.compact.odd > .node:hover,
|
|
564
|
+
.orgchart .node.compact.odd > .node.focused,
|
|
565
|
+
.orgchart .node.compact.odd > .node.selected {
|
|
566
|
+
background-color: #eee;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
.orgchart .hierarchy > .node.compact.looseMode {
|
|
570
|
+
display: grid;
|
|
571
|
+
width: unset;
|
|
572
|
+
height: unset;
|
|
573
|
+
overflow: unset;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
.orgchart .hierarchy > .node.compact::before {
|
|
577
|
+
top: var(--top-cross-point, -10px);
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
.orgchart .node.compact > .node.compact {
|
|
581
|
+
position: relative;
|
|
582
|
+
display: grid;
|
|
583
|
+
width: 140px;
|
|
584
|
+
height: 50px;
|
|
585
|
+
overflow: hidden;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
.orgchart .node.compact .node.compact.looseMode {
|
|
589
|
+
width: unset;
|
|
590
|
+
height: unset;
|
|
591
|
+
overflow: unset;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
.orgchart .hierarchy > .node.compact > .content {
|
|
595
|
+
position: absolute;
|
|
596
|
+
top: 25px;
|
|
597
|
+
left: 5px;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
.orgchart .hierarchy > .node.compact.looseMode > .title {
|
|
601
|
+
margin-top: 5px;
|
|
602
|
+
margin-left: 5px;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
.orgchart .hierarchy > .node.compact.looseMode > .content {
|
|
606
|
+
top: 30px;
|
|
607
|
+
left: 10px;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
.orgchart .node.compact > .node.compact.looseMode > .title {
|
|
611
|
+
margin-top: 5px;
|
|
612
|
+
margin-left: 5px;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
.orgchart .node.compact > .node.compact > .content {
|
|
616
|
+
position: absolute;
|
|
617
|
+
top: 23px;
|
|
618
|
+
left: 3px;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
.orgchart .node.compact > .node.compact.looseMode > .content {
|
|
622
|
+
top: 28px;
|
|
623
|
+
left: 8px;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
.orgchart .node.compact .node {
|
|
627
|
+
margin-bottom: 0;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
.orgchart .node.compact .node:not(:only-child)::after {
|
|
631
|
+
content: unset;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
.orgchart .backToCompactSymbol, .orgchart .backToLooseSymbol {
|
|
635
|
+
cursor: pointer;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
.orgchart .hierarchy > .node.compact > .backToCompactSymbol {
|
|
639
|
+
position: absolute;
|
|
640
|
+
top: 5px;
|
|
641
|
+
left: 5px;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
.orgchart .hierarchy > .node.compact.looseMode > .backToCompactSymbol {
|
|
645
|
+
top: 10px;
|
|
646
|
+
left: 10px;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
.orgchart .node.compact > .node.compact.looseMode > .backToCompactSymbol {
|
|
650
|
+
top: 8px;
|
|
651
|
+
left: 8px;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
.orgchart .node.compact > .node.compact > .backToCompactSymbol {
|
|
655
|
+
position: absolute;
|
|
656
|
+
top: 3px;
|
|
657
|
+
left: 3px;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
.orgchart .hierarchy > .node.compact > .backToLooseSymbol {
|
|
661
|
+
position: absolute;
|
|
662
|
+
top: 25px;
|
|
663
|
+
right: 5px;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
.orgchart .node.compact > .node.compact > .backToLooseSymbol {
|
|
667
|
+
position: absolute;
|
|
668
|
+
top: 23px;
|
|
669
|
+
right: 3px;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
.orgchart .node.compact .backToCompactSymbol::before {
|
|
673
|
+
border-top-color: rgba(68, 157, 68, 0.6);
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
.orgchart .node.compact .backToLooseSymbol::before {
|
|
677
|
+
border-bottom-color: rgba(68, 157, 68, 0.6);
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
.orgchart .node.compact .backToCompactSymbol:hover::before {
|
|
681
|
+
border-top-color: #449d44;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
.orgchart .node.compact .backToLooseSymbol:hover::before {
|
|
685
|
+
border-bottom-color: #449d44;
|
|
686
|
+
}
|
|
687
|
+
|
|
536
688
|
/* custom icons for orgchart */
|
|
537
689
|
.oci {
|
|
538
690
|
display: inline-block;
|
|
@@ -600,6 +752,43 @@
|
|
|
600
752
|
border-bottom: unset;
|
|
601
753
|
}
|
|
602
754
|
|
|
755
|
+
.oci-corner-top-left::before {
|
|
756
|
+
content: "";
|
|
757
|
+
display: inline-block;
|
|
758
|
+
border-top: 20px solid #000;
|
|
759
|
+
border-right: 20px solid transparent;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
.oci-corner-top-right::before {
|
|
763
|
+
content: "";
|
|
764
|
+
display: inline-block;
|
|
765
|
+
box-sizing: border-box;
|
|
766
|
+
width: 0;
|
|
767
|
+
height: 0;
|
|
768
|
+
border-top: 20px solid #000;
|
|
769
|
+
border-left: 20px solid transparent;
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
.oci-corner-bottom-right::before {
|
|
773
|
+
content: "";
|
|
774
|
+
display: inline-block;
|
|
775
|
+
box-sizing: border-box;
|
|
776
|
+
width: 0;
|
|
777
|
+
height: 0;
|
|
778
|
+
border-bottom: 20px solid #000;
|
|
779
|
+
border-left: 20px solid transparent;
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
.oci-corner-bottom-left::before {
|
|
783
|
+
content: "";
|
|
784
|
+
display: inline-block;
|
|
785
|
+
box-sizing: border-box;
|
|
786
|
+
width: 0;
|
|
787
|
+
height: 0;
|
|
788
|
+
border-bottom: 20px solid #000;
|
|
789
|
+
border-right: 20px solid transparent;
|
|
790
|
+
}
|
|
791
|
+
|
|
603
792
|
.oci-plus-square::before {
|
|
604
793
|
content: "﹢";
|
|
605
794
|
display: inline-block;
|
|
@@ -28,6 +28,8 @@
|
|
|
28
28
|
'collapseToDown': 'oci-chevron-down',
|
|
29
29
|
'collapseToLeft': 'oci-chevron-left',
|
|
30
30
|
'expandToRight': 'oci-chevron-right',
|
|
31
|
+
'backToCompact': 'oci-corner-top-left',
|
|
32
|
+
'backToLoose': 'oci-corner-bottom-right',
|
|
31
33
|
'collapsed': 'oci-plus-square',
|
|
32
34
|
'expanded': 'oci-minus-square',
|
|
33
35
|
'spinner': 'oci-spinner'
|
|
@@ -113,6 +115,20 @@
|
|
|
113
115
|
|
|
114
116
|
return this;
|
|
115
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
|
+
},
|
|
116
132
|
//
|
|
117
133
|
triggerInitEvent: function () {
|
|
118
134
|
var that = this;
|
|
@@ -122,6 +138,7 @@
|
|
|
122
138
|
for (var i = 0; i < mutations.length; i++) {
|
|
123
139
|
for (var j = 0; j < mutations[i].addedNodes.length; j++) {
|
|
124
140
|
if (mutations[i].addedNodes[j].classList.contains('orgchart')) {
|
|
141
|
+
that.handleCompactNodes();
|
|
125
142
|
if (that.options.initCompleted && typeof that.options.initCompleted === 'function') {
|
|
126
143
|
that.options.initCompleted(that.$chart);
|
|
127
144
|
}
|
|
@@ -377,14 +394,21 @@
|
|
|
377
394
|
});
|
|
378
395
|
return subObj;
|
|
379
396
|
},
|
|
380
|
-
//
|
|
397
|
+
// process datasource and add necessary information
|
|
381
398
|
attachRel: function (data, flags) {
|
|
382
399
|
var that = this;
|
|
383
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
|
+
}
|
|
384
404
|
if (data.children) {
|
|
385
405
|
data.children.forEach(function(item) {
|
|
386
|
-
if (data.
|
|
387
|
-
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;
|
|
388
412
|
}
|
|
389
413
|
that.attachRel(item, '1' + (data.children.length > 1 ? 1 : 0));
|
|
390
414
|
});
|
|
@@ -954,6 +978,19 @@
|
|
|
954
978
|
}
|
|
955
979
|
}
|
|
956
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
|
+
},
|
|
957
994
|
//
|
|
958
995
|
expandVNodesEnd: function (event) {
|
|
959
996
|
event.data.vNodes.removeClass('sliding');
|
|
@@ -1137,7 +1174,7 @@
|
|
|
1137
1174
|
// special process for hybrid chart
|
|
1138
1175
|
var datasource = this.$chart.data('options').data;
|
|
1139
1176
|
var digger = new JSONDigger(datasource, this.$chart.data('options').nodeId, 'children');
|
|
1140
|
-
const hybridNode = digger.findOneNode({ '
|
|
1177
|
+
const hybridNode = digger.findOneNode({ 'hybrid': true });
|
|
1141
1178
|
if (this.$chart.data('options').verticalLevel > 1 || hybridNode) {
|
|
1142
1179
|
var draggedNode = digger.findNodeById($dragged.data('nodeData').id);
|
|
1143
1180
|
var copy = Object.assign({}, draggedNode);
|
|
@@ -1359,18 +1396,29 @@
|
|
|
1359
1396
|
var nodeData = $.extend({}, data);
|
|
1360
1397
|
delete nodeData.children;
|
|
1361
1398
|
$nodeDiv.data('nodeData', nodeData);
|
|
1362
|
-
// append 4 direction arrows or expand/collapse buttons
|
|
1399
|
+
// append 4 direction arrows or expand/collapse buttons or reset buttons
|
|
1363
1400
|
var flags = data.relationship || '';
|
|
1364
|
-
if ((opts.verticalLevel && level >= opts.verticalLevel) || data.
|
|
1401
|
+
if ((opts.verticalLevel && level >= opts.verticalLevel) || data.vertical) {
|
|
1365
1402
|
if (Number(flags.substr(2,1))) {
|
|
1366
1403
|
$nodeDiv.append(`<i class="toggleBtn ${opts.icons.theme}"></i>`)
|
|
1367
1404
|
.children('.title').prepend(`<i class="${opts.icons.theme} ${opts.icons.parentNode} parentNodeSymbol"></i>`);
|
|
1368
1405
|
}
|
|
1369
|
-
} else if (data.
|
|
1406
|
+
} else if (data.hybrid) {
|
|
1370
1407
|
if (Number(flags.substr(2,1))) {
|
|
1371
1408
|
$nodeDiv.append(`<i class="edge verticalEdge bottomEdge ${opts.icons.theme}"></i>`)
|
|
1372
1409
|
.children('.title').prepend(`<i class="${opts.icons.theme} ${opts.icons.parentNode} parentNodeSymbol"></i>`);
|
|
1373
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
|
+
|
|
1374
1422
|
} else {
|
|
1375
1423
|
if (Number(flags.substr(0,1))) {
|
|
1376
1424
|
$nodeDiv.append(`<i class="edge verticalEdge topEdge ${opts.icons.theme}"></i>`);
|
|
@@ -1390,6 +1438,8 @@
|
|
|
1390
1438
|
$nodeDiv.on('click', '.bottomEdge', this.bottomEdgeClickHandler.bind(this));
|
|
1391
1439
|
$nodeDiv.on('click', '.leftEdge, .rightEdge', this.hEdgeClickHandler.bind(this));
|
|
1392
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));
|
|
1393
1443
|
|
|
1394
1444
|
if (opts.draggable) {
|
|
1395
1445
|
this.bindDragDrop($nodeDiv);
|
|
@@ -1409,6 +1459,7 @@
|
|
|
1409
1459
|
var that = this;
|
|
1410
1460
|
var opts = this.options;
|
|
1411
1461
|
var level = 0;
|
|
1462
|
+
var $nodeDiv;
|
|
1412
1463
|
if (data.level) {
|
|
1413
1464
|
level = data.level;
|
|
1414
1465
|
} else {
|
|
@@ -1416,23 +1467,26 @@
|
|
|
1416
1467
|
}
|
|
1417
1468
|
// Construct the node
|
|
1418
1469
|
if (Object.keys(data).length > 2) {
|
|
1419
|
-
$
|
|
1470
|
+
$nodeDiv = this.createNode(data);
|
|
1471
|
+
$appendTo.append($nodeDiv);
|
|
1420
1472
|
}
|
|
1421
1473
|
// Construct the "inferior nodes"
|
|
1422
1474
|
if (data.children && data.children.length) {
|
|
1423
1475
|
var isHidden = level + 1 > opts.visibleLevel || (data.collapsed !== undefined && data.collapsed);
|
|
1424
1476
|
var $nodesLayer;
|
|
1425
|
-
if ((opts.verticalLevel && (level + 1) >= opts.verticalLevel) || data.
|
|
1477
|
+
if ((opts.verticalLevel && (level + 1) >= opts.verticalLevel) || data.hybrid) {
|
|
1426
1478
|
$nodesLayer = $('<ul class="nodes">');
|
|
1427
1479
|
if (isHidden && (opts.verticalLevel && (level + 1) >= opts.verticalLevel)) {
|
|
1428
1480
|
$nodesLayer.addClass('hidden');
|
|
1429
1481
|
}
|
|
1430
|
-
if (((opts.verticalLevel && level + 1 === opts.verticalLevel) || data.
|
|
1482
|
+
if (((opts.verticalLevel && level + 1 === opts.verticalLevel) || data.hybrid)
|
|
1431
1483
|
&& !$appendTo.closest('.vertical').length) {
|
|
1432
1484
|
$appendTo.append($nodesLayer.addClass('vertical'));
|
|
1433
1485
|
} else {
|
|
1434
1486
|
$appendTo.append($nodesLayer);
|
|
1435
1487
|
}
|
|
1488
|
+
} else if (data.compact) {
|
|
1489
|
+
$nodeDiv.addClass('compact');
|
|
1436
1490
|
} else {
|
|
1437
1491
|
$nodesLayer = $('<ul class="nodes' + (isHidden ? ' hidden' : '') + '">');
|
|
1438
1492
|
if (Object.keys(data).length === 2) {
|
|
@@ -1446,10 +1500,14 @@
|
|
|
1446
1500
|
}
|
|
1447
1501
|
// recurse through children nodes
|
|
1448
1502
|
$.each(data.children, function () {
|
|
1449
|
-
var $nodeCell = $('<li class="hierarchy">');
|
|
1450
|
-
$nodesLayer.append($nodeCell);
|
|
1451
1503
|
this.level = level + 1;
|
|
1452
|
-
|
|
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
|
+
}
|
|
1453
1511
|
});
|
|
1454
1512
|
}
|
|
1455
1513
|
},
|
|
Binary file
|