forked from BasicPrimitives/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDemoPartners.html
More file actions
804 lines (743 loc) · 29.3 KB
/
DemoPartners.html
File metadata and controls
804 lines (743 loc) · 29.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
<!DOCTYPE html>
<html>
<head>
<title>JavaScript Organizational Chart Control General & Limited Partners Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" type='text/css'>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.css" rel="stylesheet" type='text/css'>
<link href="../../css/primitives.css" media="screen" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../primitives.js"></script>
<script type="text/javascript" src="../../javascriptsamples.js"></script>
<link href="./css/styles.css" media="screen" rel="stylesheet" type="text/css" />
<script type="text/javascript">
var control;
var timer = null;
var treeItems = {};
var /* Layout */
optionsRender = javascriptsamples.getOrgDiagramOptionsRender({
pageFitMode: primitives.PageFitMode.FitToPage,
alignBranches: false,
orientationType: primitives.OrientationType.Top,
verticalAlignment: primitives.VerticalAlignmentType.Middle,
horizontalAlignment: primitives.HorizontalAlignmentType.Center,
childrenPlacementType: primitives.ChildrenPlacementType.Horizontal,
leavesPlacementType: primitives.ChildrenPlacementType.Horizontal,
placeAdvisersAboveChildren: true,
placeAssistantsAboveChildren: true,
maximumColumnsInMatrix: 6,
minimalVisibility: primitives.Visibility.Dot,
minimumVisibleLevels: 0,
selectionPathMode: primitives.SelectionPathMode.FullStack,
hasButtons: primitives.Enabled.Auto,
hasSelectorCheckbox: primitives.Enabled.True,
selectCheckBoxLabel: "Selected",
itemTitleFirstFontColor: primitives.Colors.White,
itemTitleSecondFontColor: primitives.Colors.White,
buttonsPanelSize: 32,
groupTitlePanelSize: 24,
checkBoxPanelSize: 24,
/* group title options */
groupTitlePlacementType: primitives.AdviserPlacementType.Left,
groupTitleOrientation: primitives.TextOrientationType.RotateRight,
groupTitleVerticalAlignment: primitives.VerticalAlignmentType.Middle,
groupTitleHorizontalAlignment: primitives.HorizontalAlignmentType.Center,
groupTitleFontSize: "12px",
groupTitleFontFamily: "Arial",
groupTitleColor: primitives.Colors.RoyalBlue,
groupTitleFontWeight: "normal",
groupTitleFontStyle: "normal",
/* level title options */
levelTitlePlacementType: primitives.AdviserPlacementType.Left,
levelTitlePanelSize: 24,
levelTitlePlaceInside: false,
levelTitleOrientation: primitives.TextOrientationType.Auto,
levelTitleVerticalAlignment: primitives.VerticalAlignmentType.Middle,
levelTitleHorizontalAlignment: primitives.HorizontalAlignmentType.Center,
levelTitleFontSize: "12px",
levelTitleFontFamily: "Arial",
levelTitleFontColor: primitives.Colors.White,
levelTitleColor: primitives.Colors.RoyalBlue,
levelTitleFontWeight: "normal",
levelTitleFontStyle: "normal",
/* Template */
DefaultTemplateOptions: {
minimizedItemCornerRadius: 19,
minimizedItemSize: new primitives.Size(16, 16),
highlightPadding: 6,
minimizedItemShapeType: primitives.ShapeType.Rhombus,
minimizedItemLineWidth: 0,
minimizedItemLineType: primitives.LineType.Solid,
minimizedItemBorderColor: null,
minimizedItemFillColor: null,
minimizedItemOpacity: 1
},
/* Intervals */
normalLevelShift: 30,
dotLevelShift: 24,
lineLevelShift: 24,
normalItemsInterval: 20,
dotItemsInterval: 10,
lineItemsInterval: 5,
cousinsIntervalMultiplier: 0,
/* Connectors */
arrowsDirection: primitives.GroupByType.None,
showExtraArrows: true,
extraArrowsMinimumSpace: 30,
connectorType: primitives.ConnectorType.Squared,
elbowType: primitives.ElbowType.None,
bevelSize: 4,
elbowDotSize: 4,
linesType: primitives.LineType.Solid,
linesColor: primitives.Colors.Silver,
linesWidth: 1,
/* Labels */
showLabels: primitives.Enabled.Auto,
labelSize: new primitives.Size(10, 14),
labelOrientation: primitives.TextOrientationType.Horizontal,
labelPlacement: primitives.PlacementType.Bottom,
labelOffset: 3,
labelFontSize: "10px",
labelFontFamily: "Arial",
labelColor: primitives.Colors.Black,
labelFontWeight: "normal",
labelFontStyle: "normal",
/* Callout */
calloutMaximumVisibility: primitives.Visibility.Dot,
showCallout: true,
calloutPlacementOffset: 100,
calloutfillColor: "#000000",
calloutBorderColor: null,
calloutOffset: 4,
calloutCornerRadius: 4,
calloutPointerWidth: "10%",
calloutLineWidth: 1,
calloutOpacity: 0.2,
/* Interactivity */
navigationMode: primitives.NavigationMode.Default,
highlightGravityRadius: 40,
enablePanning: true,
scale: 1.0,
/* Frame */
showFrame: false,
frameInnerPadding: 2,
frameOuterPadding: 2,
padding: new primitives.Thickness(10, 10, 10, 10)
},
/* On property change event handler */
function () {
var options = getOptions();
control.setOptions(options);
control.update(primitives.UpdateMode.Recreate);
});
document.addEventListener('DOMContentLoaded', function () {
optionsRender.render(document.getElementById("westpanel"));
control = primitives.OrgDiagram(document.getElementById("centerpanel"),
primitives.mergeObjects(getOptions(), getUserData())
);
window.addEventListener('resize', function (event) {
onWindowResize();
});
});
function getOptions() {
options = optionsRender.getValues();
// User Event Handlers
primitives.mergeObjects(options, {
onCursorChanging: onCursorChanging,
onCursorChanged: onCursorChanged,
onMouseClick: onMouseClick,
onMouseDblClick: onMouseDblClick,
onHighlightChanging: onHighlightChanging,
onHighlightChanged: onHighlightChanged,
onSelectionChanged: onSelectionChanged
});
// Templates, User Buttons & related Event Handlers
primitives.mergeObjects(options, {
onButtonClick: onButtonClick,
onButtonsRender: onButtonsRender,
templates: [getDefaultTemplate(options)],
defaultTemplateName: "defaultTemplate",
highlightLinesColor: primitives.Colors.Navy,
highlightLinesWidth: 2,
highlightLinesType: primitives.LineType.Dashed
})
var annotations = [];
if(options.addLevelAnnotations) {
annotations = [
{
annotationType: primitives.AnnotationType.Level,
levels: [0],
title: "CEO",
titleColor: primitives.Colors.RoyalBlue,
offset: new primitives.Thickness(0, 0, 0, -5),
lineWidth: new primitives.Thickness(0, 0, 0, 0),
opacity: 0,
borderColor: primitives.Colors.Gray,
fillColor: primitives.Colors.Gray,
lineType: primitives.LineType.Dotted
},
{
annotationType: primitives.AnnotationType.Level,
levels: [1],
title: "Management",
titleColor: primitives.Colors.RoyalBlue,
offset: new primitives.Thickness(0, 4, 0, -15),
lineWidth: new primitives.Thickness(0, 0, 0, 0),
opacity: 0.08,
borderColor: primitives.Colors.Gray,
fillColor: primitives.Colors.Gray,
lineType: primitives.LineType.Dotted
},
{
annotationType: primitives.AnnotationType.Level,
levels: [2],
title: "Members",
titleColor: primitives.Colors.RoyalBlue,
offset: new primitives.Thickness(0, 14, 0, -5),
lineWidth: new primitives.Thickness(0, 0, 0, 0),
opacity: 0,
borderColor: primitives.Colors.Gray,
fillColor: primitives.Colors.Gray,
lineType: primitives.LineType.Dotted
}
];
}
connectorAnnotation = new primitives.ConnectorAnnotationConfig(31, 7);
connectorAnnotation.label = "<span class=\"badge bg-danger\">1</span> Parent";
connectorAnnotation.labelSize = new primitives.Size(70, 30);
connectorAnnotation.connectorShapeType = primitives.ConnectorShapeType.OneWay;
connectorAnnotation.color = primitives.Colors.Red;
connectorAnnotation.offset = 0;
connectorAnnotation.lineWidth = 2;
connectorAnnotation.lineType = primitives.LineType.Dashed;
connectorAnnotation.selectItems = false;
annotations.push(connectorAnnotation);
var backgroundAnnotation = new primitives.BackgroundAnnotationConfig([30, 31, 32, 33, 34, 37, 38, 39, 40, 41, 42, 18, 19]);
backgroundAnnotation.borderColor = "#f8e5f9";
backgroundAnnotation.fillColor = "#e5f9f8";
backgroundAnnotation.lineWidth = 2;
backgroundAnnotation.selectItems = true;
backgroundAnnotation.lineType = primitives.LineType.Solid;
annotations.push(backgroundAnnotation);
backgroundAnnotation = new primitives.BackgroundAnnotationConfig([21, 22, 23, 24, 25]);
backgroundAnnotation.borderColor = "#ccffb3";
backgroundAnnotation.fillColor = "#effda4";
backgroundAnnotation.lineWidth = 2;
backgroundAnnotation.selectItems = false;
backgroundAnnotation.lineType = primitives.LineType.Solid;
annotations.push(backgroundAnnotation);
backgroundAnnotation = new primitives.BackgroundAnnotationConfig([13, 14]);
backgroundAnnotation.borderColor = "#e3c5ad";
backgroundAnnotation.fillColor = "#f6eeeb";
backgroundAnnotation.lineWidth = 2;
backgroundAnnotation.selectItems = true;
backgroundAnnotation.includeChildren = true;
backgroundAnnotation.lineType = primitives.LineType.Solid;
annotations.push(backgroundAnnotation);
pathAnnotation2 = new primitives.HighlightPathAnnotationConfig([41, 3]);
pathAnnotation2.selectItems = true;
pathAnnotation2.color = primitives.Colors.Black;
pathAnnotation2.lineWidth = 2;
pathAnnotation2.lineType = primitives.LineType.Solid;
annotations.push(pathAnnotation2);
pathAnnotation = new primitives.HighlightPathAnnotationConfig([35, 1]);
pathAnnotation.selectItems = true;
pathAnnotation.color = primitives.Colors.Red;
pathAnnotation.lineWidth = 2;
pathAnnotation.lineType = primitives.LineType.Solid;
annotations.push(pathAnnotation);
options.annotations = annotations;
return options;
}
function getUserData() {
var index, len;
var items = [];
/* Create chart item as instance of ItemConfig options class and set its properties */
items.push(new primitives.OrgItemConfig({
id: 0,
parent: null, /* if parent set to null, it is shown at the root of hierarchy */
title: "Root",
description: "Regular root item",
image: "../images/photos/r.png",
groupTitle: "Has Partners",
groupTitleColor: primitives.Colors.Red
}));
/* create chart items as instance of ItemConfig options class and pass options as regular noname JavaScript object */
items.push(new primitives.OrgItemConfig({
id: 1,
parent: 0,
title: "GP 1",
description: "General Partner on right",
image: "../images/photos/g.png",
itemType: primitives.ItemType.GeneralPartner,
adviserPlacementType: primitives.AdviserPlacementType.Right,
groupTitleColor: primitives.Colors.Green,
groupTitle: "Partner"
}));
items.push(new primitives.OrgItemConfig({
id: 2,
parent: 0,
title: "LP 2",
description: "Limited Partner on right",
image: "../images/photos/l.png",
itemType: primitives.ItemType.LimitedPartner,
adviserPlacementType: primitives.AdviserPlacementType.Right,
groupTitle: "Partner"
}));
items.push(new primitives.OrgItemConfig({
id: 3,
parent: 0,
title: "LP 3",
description: "Limited Partner on left",
image: "../images/photos/l.png",
itemType: primitives.ItemType.LimitedPartner,
adviserPlacementType: primitives.AdviserPlacementType.Left,
groupTitle: "Partner"
}));
/* create array of ItemConfig option classes and merge them to final collections of items */
items = items.concat([
new primitives.OrgItemConfig({
id: 4,
parent: 0,
title: "Regular 1",
description: "Regular",
image: "../images/photos/r.png"
}),
new primitives.OrgItemConfig({
id: 5,
parent: 4,
title: "Adviser 5",
description: "Adviser on right",
image: "../images/photos/a.png",
itemType: primitives.ItemType.Adviser,
adviserPlacementType: primitives.AdviserPlacementType.Right,
groupTitleColor: primitives.Colors.Red,
groupTitle: "Has Partners"
}),
new primitives.OrgItemConfig({
id: 6,
parent: 5,
title: "GP 6",
description: "General Partner on right",
image: "../images/photos/g.png",
itemType: primitives.ItemType.GeneralPartner,
adviserPlacementType: primitives.AdviserPlacementType.Right,
groupTitleColor: primitives.Colors.Green,
groupTitle: "Partner"
})
]);
/* create array of ItemConfig option classes and merge them to final collections of items */
items = items.concat([
{
id: 7,
parent: 0,
title: "Regular 7",
description: "Regular",
image: "../images/photos/r.png",
childrenPlacementType: primitives.ChildrenPlacementType.Matrix,
groupTitle: "Has Partners",
groupTitleColor: primitives.Colors.Red
}, {
id: 8,
parent: 7,
title: "LP 8",
description: "Limited Partner on the right",
image: "../images/photos/l.png",
itemType: primitives.ItemType.LimitedPartner,
adviserPlacementType: primitives.AdviserPlacementType.Right,
groupTitle: "Partner"
}, {
id: 9,
parent: 8,
title: "Assistant 9",
description: "Assistant having its own partner node",
image: "../images/photos/r.png",
itemType: primitives.ItemType.Assistant,
adviserPlacementType: primitives.AdviserPlacementType.Left
}, {
id: 10,
parent: 9,
title: "Adviser 10",
description: "Adviser on the left",
image: "../images/photos/a.png",
itemType: primitives.ItemType.Adviser,
adviserPlacementType: primitives.AdviserPlacementType.Left,
groupTitleColor: primitives.Colors.Red,
groupTitle: "Has Partners"
}, {
id: 11,
parent: 10,
title: "GP 11",
description: "General Partner on right",
image: "../images/photos/g.png",
itemType: primitives.ItemType.GeneralPartner,
adviserPlacementType: primitives.AdviserPlacementType.Right,
groupTitleColor: primitives.Colors.Green,
groupTitle: "Partner"
}
]);
/* create array of ItemConfig option classes and merge them to final collections of items */
items = items.concat([
new primitives.OrgItemConfig({
id: 12,
parent: 7,
title: "GP 12",
description: "General Partner on right",
image: "../images/photos/g.png",
itemType: primitives.ItemType.GeneralPartner,
adviserPlacementType: primitives.AdviserPlacementType.Right,
groupTitleColor: primitives.Colors.Green,
groupTitle: "Partner"
}),
new primitives.OrgItemConfig({
id: 13,
parent: 12,
title: "Adviser 13",
description: "Adviser",
image: "../images/photos/a.png",
itemType: primitives.ItemType.Adviser,
adviserPlacementType: primitives.AdviserPlacementType.Right,
groupTitle: "Has Partners",
groupTitleColor: primitives.Colors.Red
}),
new primitives.OrgItemConfig({
id: 14,
parent: 13,
title: "GP 14",
description: "General Partner on right",
image: "../images/photos/g.png",
itemType: primitives.ItemType.GeneralPartner,
adviserPlacementType: primitives.AdviserPlacementType.Right,
groupTitleColor: primitives.Colors.Green,
groupTitle: "Partner"
}),
new primitives.OrgItemConfig({
id: 1400,
parent: 14,
title: "GP 14 Assistant",
description: "Assistant on right",
image: "../images/photos/g.png",
itemType: primitives.ItemType.Assistant,
adviserPlacementType: primitives.AdviserPlacementType.Right,
groupTitleColor: primitives.Colors.Green,
levelOffset: 2
}),
new primitives.OrgItemConfig({
id: 15,
parent: 13,
title: "Adviser 15",
description: "Adviser",
image: "../images/photos/a.png",
itemType: primitives.ItemType.Adviser,
adviserPlacementType: primitives.AdviserPlacementType.Right
})
, new primitives.OrgItemConfig({
id: 16,
parent: 13,
title: "Regular 16",
description: "Regular",
image: "../images/photos/r.png",
childrenPlacementType: primitives.ChildrenPlacementType.Matrix
})
, new primitives.OrgItemConfig({
id: 17,
parent: 16,
title: "Regular 17",
description: "Regular",
image: "../images/photos/r.png",
itemType: primitives.ItemType.Regular /* We explicitly set itemType of the regular item here */
})
,
new primitives.OrgItemConfig({
id: 18,
parent: 12,
title: "Assistant 18",
description: "Assistant item on right",
image: "../images/photos/s.png",
itemType: primitives.ItemType.Assistant,
adviserPlacementType: primitives.AdviserPlacementType.Right
}),
new primitives.OrgItemConfig({
id: 19,
parent: 12,
title: "Assistant 19",
description: "Assistant item on right",
image: "../images/photos/s.png",
itemType: primitives.ItemType.Regular,
adviserPlacementType: primitives.AdviserPlacementType.Right
})
]);
/* create array of items and merge them to final collections of items */
items = items.concat([
{
id: 20,
parent: 7,
title: "GP 20",
description: "General Partner on right",
image: "../images/photos/g.png",
itemType: primitives.ItemType.GeneralPartner,
adviserPlacementType: primitives.AdviserPlacementType.Right,
groupTitleColor: primitives.Colors.Green,
groupTitle: "Partner"
}, {
id: 21,
parent: 20,
title: "Assistant 21",
description: "Assistant item on right",
image: "../images/photos/s.png",
itemType: primitives.ItemType.Assistant,
adviserPlacementType: primitives.AdviserPlacementType.Right
}, {
id: 22,
parent: 20,
title: "Regular 22",
description: "Regular item assigned to Partner is shown as its Assistant.",
image: "../images/photos/r.png",
itemType: primitives.ItemType.Regular
}, {
id: 23,
parent: 21,
title: "Regular 23",
description: "Regular item assigned to assistant.",
image: "../images/photos/r.png",
itemType: primitives.ItemType.Regular
}, {
id: 24,
parent: 21,
title: "Regular 24",
description: "Regular item assigned to assistant.",
image: "../images/photos/r.png",
itemType: primitives.ItemType.Regular
}, {
id: 25,
parent: 21,
title: "Regular 25",
description: "Regular item assigned to assistant.",
image: "../images/photos/r.png",
itemType: primitives.ItemType.Regular
}
]);
/* Add assistants and adviser to item which has Partners attached */
/* create array of items and merge them to final collections of items */
items = items.concat([
{
id: 26,
parent: 7,
title: "Adviser 26",
description: "Adviser on left",
image: "../images/photos/a.png",
itemType: primitives.ItemType.Adviser,
adviserPlacementType: primitives.AdviserPlacementType.Left
}, {
id: 27,
parent: 7,
title: "Adviser 27",
description: "Adviser on right",
image: "../images/photos/a.png",
itemType: primitives.ItemType.Adviser,
adviserPlacementType: primitives.AdviserPlacementType.Right
}, {
id: 127,
parent: 27,
title: "Child of Adviser 27",
description: "Extra Child",
image: "../images/photos/a.png",
itemType: primitives.ItemType.Regular,
adviserPlacementType: primitives.AdviserPlacementType.Right
}, {
id: 28,
parent: 7,
title: "Assistant 28",
description: "Assistant on right",
image: "../images/photos/s.png",
itemType: primitives.ItemType.Assistant,
adviserPlacementType: primitives.AdviserPlacementType.Right
}, {
id: 29,
parent: 7,
title: "Assistant 29",
description: "Assistant on left",
image: "../images/photos/s.png",
itemType: primitives.ItemType.Assistant,
adviserPlacementType: primitives.AdviserPlacementType.Left
}, {
id: 280,
parent: 7,
title: "Assistant 280",
description: "Assistant on right",
image: "../images/photos/s.png",
itemType: primitives.ItemType.Assistant,
adviserPlacementType: primitives.AdviserPlacementType.Right,
levelOffset: 1
}, {
id: 290,
parent: 7,
title: "Assistant 290",
description: "Assistant on left",
image: "../images/photos/s.png",
itemType: primitives.ItemType.Assistant,
adviserPlacementType: primitives.AdviserPlacementType.Left,
levelOffset: 1
}, {
id: 291,
parent: 7,
title: "Assistant 291",
description: "Assistant on left",
image: "../images/photos/s.png",
itemType: primitives.ItemType.Assistant,
adviserPlacementType: primitives.AdviserPlacementType.Left,
levelOffset: 3
}, {
id: 292,
parent: 7,
title: "Assistant 292",
description: "Assistant on left",
image: "../images/photos/s.png",
itemType: primitives.ItemType.Assistant,
adviserPlacementType: primitives.AdviserPlacementType.Left,
levelOffset: 4
}
]);
/* Add some regular children to item having Partners attached
These children are shared by their parent and parents partner items. */
var commonChildren = [];
for (var index = 30; index <= 42; index += 1) {
commonChildren.push(index);
items.push({
id: index,
parent: 7,
title: "Regular " + index,
description: "Regular item assigned to regular item having partners",
image: "../images/photos/r.png"
});
}
/* create hash of items */
var index, len;
for (index = 0, len = items.length; index < len; index += 1) {
treeItems[items[index].id] = items[index];
}
return {
items: items,
cursorItem: 0
};
}
function getDefaultTemplate(options) {
var result = new primitives.TemplateConfig();
result.name = "defaultTemplate";
// If we don't change anything in template then all its properties stays default
// So we change only minimized item properties
primitives.mergeObjects(result, options.DefaultTemplateOptions);
return result;
}
function onSelectionChanged(e, data) {
var selectedItems = control.getOption("selectedItems");
var message = "";
for (var index = 0; index < selectedItems.length; index += 1) {
var itemConfig = selectedItems[index];
if (message != "") {
message += ", ";
}
message += "<b>'" + itemConfig.title + "'</b>";
}
message += (data.parentItem != null ? " Parent item <b>'" + data.parentItem.title + "'" : "");
document.getElementById("southpanel").innerHTML = "User selected following items: " + message;
}
function onHighlightChanging(e, data) {
var message = (data.context != null) ? "User is hovering mouse over item <b>'" + data.context.title + "'</b>." : "";
message += (data.parentItem != null ? " Parent item <b>'" + data.parentItem.title + "'" : "");
document.getElementById("southpanel").innerHTML = message;
}
function onHighlightChanged(e, data) {
var message = (data.context != null) ? "User hovers mouse over item <b>'" + data.context.title + "'</b>." : "";
message += (data.parentItem != null ? " Parent item <b>'" + data.parentItem.title + "'" : "");
document.getElementById("southpanel").innerHTML = message;
}
function onCursorChanging(e, data) {
var message = "User is clicking on item '" + data.context.title + "'.";
message += (data.parentItem != null ? " Parent item <b>'" + data.parentItem.title + "'" : "");
document.getElementById("southpanel").innerHTML = message;
}
function onCursorChanged(e, data) {
var message = "User clicked on item '" + data.context.title + "'.";
message += (data.parentItem != null ? " Parent item <b>'" + data.parentItem.title + "'" : "");
document.getElementById("southpanel").innerHTML = message;
}
function onButtonsRender(data) {
var itemConfig = data.context;
var element = data.element;
element.innerHTML = "";
element.appendChild(primitives.JsonML.toHTML(["div",
{
class: "btn-group-vertical btn-group-sm"
},
["button",
{
"type": "button",
"data-buttonname": "user",
"class": "btn btn-light"
},
["i", { "class": "fa fa-user" }]
],
["button",
{
"type": "button",
"data-buttonname": "remove",
"class": "btn btn-light"
},
["i", { "class": "fa fa-minus-circle" }]
],
["button",
{
"type": "button",
"data-buttonname": "properties",
"class": "btn btn-light"
},
["i", { "class": "fa fa-cog" }]
]
]));
}
function onButtonClick(e, data) {
var message = "User clicked <b>'" + data.name + "'</b> button for item <b>'" + data.context.title + "'</b>.";
message += (data.parentItem != null ? " Parent item <b>'" + data.parentItem.title + "'" : "");
document.getElementById("southpanel").innerHTML = message;
}
function onMouseClick(e, data) {
var message = "User clicked item <b>'" + data.context.title + "'</b>.";
message += (data.parentItem != null ? " Parent item <b>'" + data.parentItem.title + "'" : "");
document.getElementById("southpanel").innerHTML = message;
}
function onMouseDblClick(e, data) {
var message = "User double clicked item <b>'" + data.context.title + "'</b>.";
message += (data.parentItem != null ? " Parent item <b>'" + data.parentItem.title + "'" : "");
document.getElementById("southpanel").innerHTML = message;
}
function onWindowResize() {
if (timer == null) {
timer = window.setTimeout(function () {
control.update(primitives.UpdateMode.Refresh);
window.clearTimeout(timer);
timer = null;
}, 300);
}
}
</script>
</head>
<body>
<div class="container-fluid">
<div class="row">
<nav id="sidebarMenu" class="col-md-4 col-lg-2 d-md-block bg-light sidebar collapse" style="position: fixed; top: 0; bottom: 0px; overflow-y: auto; float: none;">
<div class="position-sticky pt-3">
<div id="westpanel" class="flex-column"></div>
</div>
</nav>
<main class="col-md-8 ms-sm-auto col-lg-10 px-md-4">
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
<h1 class="h2">Organizational Chart, General & Limited Partner item types demo</h1>
</div>
<div id="centerpanel" class="mediaPlaceholder my-2 w-100"></div>
<div id="southpanel" class="alert alert-primary" style="min-height: 60px;" role="alert">
</div>
</main>
</div>
</div>
</body>
</html>