Repository navigation
Expand file tree
/
Copy pathmenu.js
More file actions
117 lines (109 loc) · 3.17 KB
/
Copy pathmenu.js
File metadata and controls
117 lines (109 loc) · 3.17 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
/**
* menu sample
*/
this.default = function () {
//Initialize Toolbar component
var toolbarObj = new ej.navigations.Toolbar({
items: [
{
prefixIcon: 'e-copy-icon tb-icons',
text: 'Wireless & networks',
overflow: 'Hide',
tooltipText: 'Wireless'
},
{
prefixIcon: 'e-copy-icon tb-icons',
text: 'Device',
overflow: 'Hide',
tooltipText: 'Device'
},
{
prefixIcon: 'e-copy-icon tb-icons',
text: 'Personal',
overflow: 'Hide',
tooltipText: 'Personal'
}
],
width: 390
});
//Render initialized Toolbar component
toolbarObj.appendTo('#toolbar-menu');
//Initialize Tooltip component
var tip = new ej.popups.Tooltip({
//Set tooltip target
target: '#toolbar-menu button',
//Raise beforeRender event
beforeRender: onBeforeRender,
//Set tooltip width
width: 170,
//Set tooltip cssClass
cssClass: 'e-tooltip-menu-settings',
//Set tooltip open mode
opensOn: 'Click'
});
//Render initialized Tooltip component
tip.appendTo('#tooltip-menu');
//Define an array of JSON data
var data1 = [
{ Name: 'WI-FI', id: '1', icon: 'wifi' },
{ Name: 'Bluetooth', id: '2', icon: 'bluetooth' },
{ Name: 'SIM cards', id: '3', icon: 'sim' }
];
var data2 = [
{ Name: 'Display', icon: 'display' },
{ Name: 'Sound', icon: 'sound' },
{ Name: 'Battery', icon: 'battery' },
{ Name: 'Users', icon: 'user' }
];
var data3 = [
{ Name: 'Location', icon: 'location' },
{ Name: 'Security', icon: 'security' },
{ Name: 'Language', icon: 'language' }
];
//Initialize ListView component
var listObj = new ej.lists.ListView({
//Map appropriate columns to fields property
fields: { text: 'Name', iconCss: 'icon' },
//Set true to show icons
showIcon: true
});
var listObjects = [data1, data2, data3];
//beforRender event handler for Tooltip
function onBeforeRender(args) {
var data = [
{ title: 'Wireless' },
{ title: 'Device' },
{ title: 'Personal' }
];
for (var i = 0; i < data.length; i++) {
if (data[i].title === args.target.parentElement.getAttribute('title')) {
var list = document.createElement('div');
list.id = 'tooltipMenu-list';
listObj.dataSource = listObjects[i];
listObj.appendTo(list);
tip.content = list;
}
}
}
//Attached scroll and click event listners in right pane
if (document.getElementById('right-pane')) {
document.getElementById('right-pane').addEventListener('click', onClick);
document.getElementById('right-pane').addEventListener('scroll', onScroll);
}
//click event handler to close Tooltip while navigating to other tabs in right pane
function onClick(args) {
if (
!args.target.parentNode.parentNode.classList.contains('e-toolbar-item')
) {
if (document.getElementsByClassName('e-tooltip-wrap').length > 0) {
tip.close();
}
}
}
//scroll event handler to close Tooltip while perfomring page scroll
function onScroll() {
if (document.getElementsByClassName('e-tooltip-wrap').length > 0) {
tip.close();
}
}
};