Skip to content

Commit a81ec0f

Browse files
committed
Add support to show tooltips in orgchart nodes (fixes #9)
1 parent 54b10e9 commit a81ec0f

File tree

2 files changed

+14
-4
lines changed
  • orgchart-addon/src/main/resources/com/flowingcode/vaadin/addons/orgchart
  • orgchart-addon-demo/src/main/java/com/flowingcode/vaadin/addons/orgchart/demo

2 files changed

+14
-4
lines changed

orgchart-addon-demo/src/main/java/com/flowingcode/vaadin/addons/orgchart/demo/DemoUI.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ public OrgChart getExample1() {
8383
OrgChartItem item2 = new OrgChartItem(2, "Anna Thompson", "Administration");
8484
item2.setData("mail", "[email protected]");
8585
item2.setClassName("blue-node");
86-
OrgChartItem item3 = new OrgChartItem(3, "Timothy Jones", "Sub-Director");
87-
item3.setData("mail", "tjonees@example.com");
86+
OrgChartItem item3 = new OrgChartItem(3, "Timothy Albert Henry Jones ", "Sub-Director of Administration Department");
87+
item3.setData("mail", "timothy.albert.jones@example.com");
8888
item1.setChildren(Arrays.asList(item2, item3));
8989
OrgChartItem item4 = new OrgChartItem(4, "Louise Night", "Department 1");
9090
item4.setData("mail", "[email protected]");
@@ -106,8 +106,8 @@ public OrgChart getExample2() {
106106
OrgChartItem item2 = new OrgChartItem(2, "Anna Thompson", "Administration");
107107
OrgChartItem item3 = new OrgChartItem(3, "Timothy Jones", "Sub-Director");
108108
item1.setChildren(Arrays.asList(item2, item3));
109-
OrgChartItem item4 = new OrgChartItem(4, "Louise Night", "Department 1");
110-
OrgChartItem item5 = new OrgChartItem(5, "John Porter", "Department 2");
109+
OrgChartItem item4 = new OrgChartItem(4, "Louise Night, Louise Night, Louise Night", "Department 1");
110+
OrgChartItem item5 = new OrgChartItem(5, "John Porter", "Department 2, Department 2, Department 2, Department 2, Department 2");
111111
item2.setChildren(Arrays.asList(item4, item5));
112112
OrgChartItem item6 = new OrgChartItem(6, "Charles Thomas", "Department 3");
113113
item5.setChildren(Arrays.asList(item6));

orgchart-addon/src/main/resources/com/flowingcode/vaadin/addons/orgchart/orgchart-connector.js

+10
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@ function() {
6666
$node.on('click', function() {
6767
rpcProxy.onNodeClick(data.id);
6868
});
69+
70+
$node.on('mouseover', function(event) {
71+
var target = event.target;
72+
if (!$(target).attr('title')) {
73+
if ($(target).prop('scrollWidth') > $(target).prop('clientWidth')) {
74+
$(target).attr('title', target.innerText);
75+
}
76+
}
77+
});
78+
6979
}
7080
});
7181

0 commit comments

Comments
 (0)