forked from syncfusion/ej2-aspnetcore-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
API.cshtml
315 lines (279 loc) · 12.2 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
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
@using Syncfusion.EJ2
@using Syncfusion.EJ2.Notifications;
@using Syncfusion.EJ2.DropDowns;
@using Syncfusion.EJ2.Buttons;
@section ControlsSection{
<div class="col-lg-12 control-section toast-api-section">
<div class="control_wrapper">
<ejs-toast id="toastApi" close="onclose" beforeOpen="onBeforeOpen" created="created">
<e-toast-position X="Right" Y="Bottom"></e-toast-position>
</ejs-toast>
<div class="row">
<div class="col-lg-6 padding">
<div class="input-form">
<div class="e-float-input">
<input class="e-input" id="toast_input_title" required="">
<span class="e-float-line"></span>
<label class="e-float-text">Enter the title</label>
</div>
</div>
<div class="input-form">
<div class="e-float-input">
<textarea class="e-input" id="toast_input_content" rows="3" required=""></textarea>
<label class="e-float-text">Enter the content</label>
</div>
</div>
<div class="group-form e-group">
<ejs-checkbox id="closeButton" label="Show Close Button" change="closeOnChange"></ejs-checkbox>
</div>
<div class="group-form">
<ejs-checkbox id="progressBar" label="Show Progress Bar" change="OnProgressChange"></ejs-checkbox>
</div>
<div class="group-form">
<ejs-checkbox id="newestOnTop" label="Newest On Top" change="closeNewestOnChange" checked="true"></ejs-checkbox>
</div>
<div class="group-form">
<ejs-checkbox id="prevDuplicates" label="Prevent Duplicates" change="OnPrevDubChange"></ejs-checkbox>
</div>
<div class="group-form">
<ejs-checkbox id="actionButtons" label="Action Buttons" change="OnactionBtnChange"></ejs-checkbox>
</div>
<div class="input-form">
<div class="e-float-input e-input-group">
<input class="e-input" id="timeOut" name="Digits" value="5000" digits="true" data-digits-message="Please enter digits only." required="">
<span class="e-float-line"></span>
<label class="e-float-text" for="Digits">TimeOut</label>
</div>
</div>
</div>
<div class="col-lg-6 padding">
<div class="input-form">
<h4> Show Animation</h4>
<div class="e-float-input">
<input class="e-input" id="showDuration" value="400" required="">
<span class="e-float-line"></span>
<label class="e-float-text">Duration</label>
</div>
</div>
<div class="input-form">
<ejs-dropdownlist id="ShowEasing" dataSource="ViewBag.easingData" change="onShowEase" placeholder="Select an Easing" created="showEasingCreated" index="0">
<e-dropdownlist-fields text="Value" value="Id"></e-dropdownlist-fields>
</ejs-dropdownlist>
</div>
<div class="input-form">
<ejs-dropdownlist id="ShowAnimation" dataSource="ViewBag.animationData" change="showChange" placeholder="Select an Animation" created="showAnimationCreated" index="0">
<e-dropdownlist-fields text="Value" value="Id"></e-dropdownlist-fields>
</ejs-dropdownlist>
</div>
<div class="input-form e-group">
<h4> Hide Animation</h4>
<div class="e-float-input">
<ejs-textbox id="hideDuration" cssClass="e-input" value="400" placeholder="Duration"></ejs-textbox>
</div>
</div>
<div class="input-form">
<ejs-dropdownlist id="HideEasing" dataSource="ViewBag.easingData" change="onHideEase" placeholder="Select an Easing" created="hideEasingCreated" index="0">
<e-dropdownlist-fields text="Value" value="Id"></e-dropdownlist-fields>
</ejs-dropdownlist>
</div>
<div class="input-form">
<ejs-dropdownlist id="HideAnimation" dataSource="ViewBag.animationData" change="hideChange" placeholder="Select an Animation" created="hideAnimationCreated" index="1">
<e-dropdownlist-fields text="Value" value="Id"></e-dropdownlist-fields>
</ejs-dropdownlist>
</div>
</div>
</div>
<div class="row center">
<ejs-button id="toastBtnShow" cssClass="e-btn e-primary" content="Show Toasts"></ejs-button>
<ejs-button id="toastBtnHide" cssClass="e-btn e-primary e-hide-toast" content="Hide all"></ejs-button>
</div>
</div>
</div>
<script type="text/javascript">
var btnEleShow = document.getElementById('toastBtnShow');
var btnEleHide = document.getElementById('toastBtnHide');
var prevDuplicates = false;
var toastObj, showEasingObj, showAnimationObj, hideEasingObj, hideAnimationObj;
btnEleShow.onclick = function () { showToast(); };
btnEleHide.onclick = function () {
toastObj.hide('All');
};
document.onclick = function (e){
if (e.target !== btnEleShow) {
toastObj.hide('All');
}
};
function created() {
toastObj = this;
}
function showEasingCreated() {
showEasingObj = this;
}
function showAnimationCreated() {
showAnimationObj = this;
}
function hideEasingCreated() {
hideEasingObj = this;
}
function hideAnimationCreated() {
hideAnimationObj = this;
}
function showToast() {
var title = (document.getElementById('toast_input_title')).value;
var content = (document.getElementById('toast_input_content')).value;
if (title === '' && content === '') {
content = 'You have created a Toast message';
}
var showDuration = parseInt((document.getElementById('showDuration')).value, 10);
var hideDuration = parseInt((document.getElementById('hideDuration')).value, 10);
var timeOut = parseInt((document.getElementById('timeOut')).value, 10);
toastObj.show(
{
title: title, content: content, timeOut: timeOut,
animation: {
show: { duration: showDuration },
hide: { duration: hideDuration }
}, target: document.body
});
}
setTimeout(
() => {
showChange();
}, 500);
setTimeout(
() => {
hideChange();
}, 500);
function onShowEase(e) {
toastObj.animation.show.easing = showEasingObj.value;
}
function onHideEase(e) {
toastObj.animation.hide.easing = hideEasingObj.value;
}
function showChange() {
toastObj.animation.show.effect = showAnimationObj.value;
}
function hideChange() {
toastObj.animation.hide.effect = hideAnimationObj.value;
}
function onclose(e) {
if (e.toastContainer.childElementCount === 0) {
btnEleHide.style.display = 'none';
}
}
// Toast beforeOpen Event Function
function onBeforeOpen(e)
{
btnEleHide.style.display = 'inline-block';
if (prevDuplicates) {
e.cancel = preventDuplicate(e);
}
}
// Toast preventDuplicate Function for toast title
function preventDuplicate(e) {
var toastEle = e.element;
var toasts = e.toastObj.element.children;
for (var i = 0; i < toasts.length; i++) {
var toastTitle = (toasts[i]).querySelector('.e-toast-title');
var toastMessage = (toasts[i]).querySelector('.e-toast-message');
if (toastTitle && toastTitle.isEqualNode(toastEle.querySelector('.e-toast-title'))) {
return true;
}
if (!toastTitle && toastMessage && toastMessage.isEqualNode(toastEle.querySelector('.e-toast-message'))) {
return true;
}
}
return false;
}
function closeOnChange(e) {
e.checked ? toastObj.showCloseButton = true : toastObj.showCloseButton = false;
}
function OnProgressChange(e) {
e.checked ? toastObj.showProgressBar = true : toastObj.showProgressBar = false;
}
function closeNewestOnChange(e) {
e.checked ? toastObj.newestOnTop = true : toastObj.newestOnTop = false;
}
function OnPrevDubChange(e) {
prevDuplicates = e.checked;
}
function onActionBtnClick(e) {
alert('Action button is clicked');
}
function OnactionBtnChange(e) {
if (e.checked) {
toastObj.buttons = [{ model: { content: '<div class="e-toast-btn"> Click Here </div>' }, click: onActionBtnClick }];
} else { toastObj.buttons = []; }
}
</script>
<style>
/* custom code start */
.toast-api-section .input-form {
margin: 33px 0;
}
.toast-api-section .group-form {
margin: 25px 0;
}
.toast-api-section .group-form.e-group {
margin-top: 35px;
}
.toast-api-section .row .padding {
padding: 15px;
}
.toast-api-section .row.center {
text-align: center;
}
.toast-api-section .row {
padding: 0 15px;
}
/* custom code end */
.e-btn.e-hide-toast{
display: none
}
</style>
}
@section ActionDescription{
<div id="action-description">
<p>This sample demonstrates all the API functionalities available in Toast.</p>
</div>
}
@section Description{
<div id="description">
<p>In this sample, with help of text inputs toast header title and content text can be provided.</p>
<ul>
<li>
<code>Action Buttons</code> – Provide support to add a button inside toast to interact with it.
</li>
<li>
<code>Prevent Duplicates</code> – Disable the user to create same toast message multiple times.
</li>
<li>
<code> TimeOut</code> – Allows to set time in millisecond to close toast.
</li>
<li>
<code> Progress Bar</code> – Visualizes the time out of toast as an indicator.
</li>
<li>
<code> Animation</code> – Enables to define the toast show and hide animation.
</li>
<li>
<code>Close button</code> – Show close button to hide toast irrespective of time out.
</li>
</ul>
<p>
More information about Toast can be found in this
<a href="https://ej2.syncfusion.com/aspnetcore/documentation/toast/getting-started/" target="_blank"> documentation section</a>.
</p>
</div>
}
@*custom code start*@
@section Meta{
<meta name="description" content="This example demonstrates the API in ASP.NET Core Toast control. Explore here for more details."/>
}
@*custom code end*@
@section Title{
<title>ASP.NET Core Toast API Example - Syncfusion Demos </title>
}
@section Header{
<h1 class='sb-sample-text'>Example for API in ASP.NET Core Toast Control</h1>
}