forked from syncfusion/ej2-aspnetcore-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApi.cshtml
168 lines (153 loc) · 5.65 KB
/
Api.cshtml
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
@using Syncfusion.EJ2
@section ControlsSection{
<div class="col-lg-8 control-section">
<!-- Tooltip element -->
<ejs-tooltip id="tooltip" target="#default" content="Tooltip content" opensOn="Click" created="onCreated">
<e-content-template>
<ejs-button id="default" content="Show Tooltip"></ejs-button>
</e-content-template>
</ejs-tooltip>
</div>
<div class="col-lg-4 property-section">
<table id="property" title="Properties">
<tbody>
<tr>
<td style="width: 50%">
<div class="userselect">Content</div>
</td>
<td style="width: 50%;padding-right: 10px">
<div>
<input id="value" type="text" placeholder="Tooltip content">
</div>
</td>
</tr>
<tr>
<td style="width: 50%">
<div class="userselect">Height</div>
</td>
<td style="width: 50%;padding-right: 10px">
<div>
<ejs-numerictextbox id="height" value="45" change="onHeightChange" type="text"></ejs-numerictextbox>
</div>
</td>
</tr>
<tr>
<td style="width: 50%">
<div class="userselect">Width</div>
</td>
<td style="width: 50%;padding-right: 10px">
<div>
<ejs-numerictextbox id="width" value="100" change="onWidthChange" class="e-input" type="text"></ejs-numerictextbox>
</div>
</td>
</tr>
<tr>
<td style="width: 50%">
<div class="userselect">Open Mode</div>
</td>
<td style="width: 50%;padding-right: 10px">
<div>
<ejs-dropdownlist type="text" tabindex="1" placeholder="Select mode" dataSource="ViewBag.ddlData" change="onModeChange" id='ddlelement'></ejs-dropdownlist>
</div>
</td>
</tr>
<tr>
<td style="width: 50%">
<div class="userselect">Sticky Mode</div>
</td>
<td style="width: 50%;padding-right: 10px">
<div>
<ejs-checkbox id="sticky" type="checkbox" checked="false" change="stickyChange"></ejs-checkbox>
</div>
</td>
</tr>
</tbody>
</table>
</div>
}
<style>
.userselect {
-webkit-user-select: none;
/* Safari 3.1+ */
-moz-user-select: none;
/* Firefox 2+ */
-ms-user-select: none;
/* IE 10+ */
user-select: none;
/* Standard syntax */
}
#property {
padding-top: 200px;
}
#default {
position: absolute;
left: calc( 50% - 60px);
top: 35%;
}
#value {
height: 34px;
width: 136px;
padding-left: 10px;
}
.highcontrast #value {
border: 1px solid;
border-width: 1px;
color: #fff;
background: #000;
}
</style>
<script type="text/javascript">
var tooltipObj;
var buttonElement
function onCreated() {
tooltipObj = document.getElementById("tooltip").ej2_instances[0];
buttonElement = document.getElementById("default");
//change event handler for content change
document.querySelector('#value').addEventListener('change', function () {
tooltipObj.content = this.value;
tooltipObj.refresh(buttonElement);
});
//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);
}
}
//change event handler for height change in Tooltip
function onHeightChange(args) {
tooltipObj.height = args.value;
tooltipObj.refresh(buttonElement);
}
//change event handler for width change in Tooltip
function onWidthChange(args) {
tooltipObj.width = args.value;
tooltipObj.refresh(buttonElement);
}
//change event handler for mode change in Tooltip
function onModeChange(args) {
tooltipObj.opensOn = args.value;
tooltipObj.close();
}
//change event handler for sticky mode in Tooltip
function stickyChange(args) {
tooltipObj.isSticky = args.checked;
tooltipObj.close();
}
//scroll event handler to close Tooltip while perfomring page scroll
function onScroll(args) {
if (document.getElementsByClassName('e-tooltip-wrap').length > 0) {
tooltipObj.close();
}
}
//click event handler to close Tooltip while navigating to other tabs in right pane
function onClick(args) {
if (args.target.parentNode.className === 'e-tab-text') {
if (document.getElementsByClassName('e-tooltip-wrap').length > 0) {
tooltipObj.close();
}
}
}
</script>
@section Meta{
<meta name="description" content="Essential JS 2 Tooltip control demo showcasing the most frequently used API combinations, like content, height, width, open, sticky mode, and more." />
}