This repository was archived by the owner on Jul 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapi.js
More file actions
269 lines (269 loc) · 17.6 KB
/
api.js
File metadata and controls
269 lines (269 loc) · 17.6 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
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var sample_base_1 = require("../common/sample-base");
var ej2_react_notifications_1 = require("@syncfusion/ej2-react-notifications");
var ej2_base_1 = require("@syncfusion/ej2-base");
var ej2_react_dropdowns_1 = require("@syncfusion/ej2-react-dropdowns");
var ej2_react_buttons_1 = require("@syncfusion/ej2-react-buttons");
require("./api.css");
var Api = (function (_super) {
__extends(Api, _super);
function Api() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.position = { X: 'Right', Y: 'Bottom' };
_this.prevDuplicates = false;
_this.showData = [
{ Id: 'ease', Text: 'Ease' },
{ Id: 'linear', Text: 'Linear' }
];
_this.animationData = [
{ Id: 'SlideBottomIn', Effect: 'Slide Bottom In' },
{ Id: 'FadeIn', Effect: 'Fade In' },
{ Id: 'FadeZoomIn', Effect: 'Fade Zoom In' },
{ Id: 'FadeZoomOut', Effect: 'Fade Zoom Out' },
{ Id: 'FlipLeftDownIn', Effect: 'Flip Left Down In' },
{ Id: 'FlipLeftDownOut', Effect: 'Flip Left Down Out' },
{ Id: 'FlipLeftUpIn', Effect: 'Flip Left Up In' },
{ Id: 'FlipLeftUpOut', Effect: 'Flip Left Up Out' },
{ Id: 'FlipRightDownIn', Effect: 'Flip Right Down In' },
{ Id: 'FlipRightDownOut', Effect: 'Flip Right Down Out' },
{ Id: 'FlipRightUpIn', Effect: 'Flip Right Up In' },
{ Id: 'FlipRightUpOut', Effect: 'Flip Right Up Out' },
{ Id: 'SlideBottomOut', Effect: 'Slide Bottom Out' },
{ Id: 'SlideLeftIn', Effect: 'Slide Left In' },
{ Id: 'SlideLeftOut', Effect: 'Slide Left Out' },
{ Id: 'SlideRightIn', Effect: 'Slide Right In' },
{ Id: 'SlideRightOut', Effect: 'Slide Right Out' },
{ Id: 'SlideTopIn', Effect: 'Slide Top In' },
{ Id: 'SlideTopOut', Effect: 'Slide Top Out' },
{ Id: 'ZoomIn', Effect: 'Zoom In' },
{ Id: 'ZoomOut', Effect: 'Zoom Out' }
];
_this.animationData1 = [
{ Id: 'SlideBottomOut', Effect: 'Slide Bottom Out' },
{ Id: 'FadeIn', Effect: 'Fade In' },
{ Id: 'FadeZoomIn', Effect: 'Fade Zoom In' },
{ Id: 'FadeZoomOut', Effect: 'Fade Zoom Out' },
{ Id: 'FlipLeftDownIn', Effect: 'Flip Left Down In' },
{ Id: 'FlipLeftDownOut', Effect: 'Flip Left Down Out' },
{ Id: 'FlipLeftUpIn', Effect: 'Flip Left Up In' },
{ Id: 'FlipLeftUpOut', Effect: 'Flip Left Up Out' },
{ Id: 'FlipRightDownIn', Effect: 'Flip Right Down In' },
{ Id: 'FlipRightDownOut', Effect: 'Flip Right Down Out' },
{ Id: 'FlipRightUpIn', Effect: 'Flip Right Up In' },
{ Id: 'FlipRightUpOut', Effect: 'Flip Right Up Out' },
{ Id: 'SlideBottomIn', Effect: 'Slide Bottom In' },
{ Id: 'SlideLeftIn', Effect: 'Slide Left In' },
{ Id: 'SlideLeftOut', Effect: 'Slide Left Out' },
{ Id: 'SlideRightIn', Effect: 'Slide Right In' },
{ Id: 'SlideRightOut', Effect: 'Slide Right Out' },
{ Id: 'SlideTopIn', Effect: 'Slide Top In' },
{ Id: 'SlideTopOut', Effect: 'Slide Top Out' },
{ Id: 'ZoomIn', Effect: 'Zoom In' },
{ Id: 'ZoomOut', Effect: 'Zoom Out' }
];
_this.showFields = { text: 'Text', value: 'Id' };
_this.animationFields = { text: 'Effect', value: 'Id' };
_this.easeValue = 'ease';
_this.animationValue = 'SlideBottomIn';
_this.animationHideValue = 'SlideBottomOut';
return _this;
}
Api.prototype.closeOnChange = function (e) {
e.checked ? this.toastObj.showCloseButton = true : this.toastObj.showCloseButton = false;
};
Api.prototype.OnProgressChange = function (e) {
e.checked ? this.toastObj.showProgressBar = true : this.toastObj.showProgressBar = false;
};
Api.prototype.closeNewestOnChange = function (e) {
e.checked ? this.toastObj.newestOnTop = true : this.toastObj.newestOnTop = false;
};
Api.prototype.OnPrevDubChange = function (e) {
this.prevDuplicates = e.checked;
};
Api.prototype.OnactionBtnChange = function (e) {
if (e.checked) {
this.toastObj.buttons = [{ model: { content: '<div class="e-toast-btn"> Click Here </div>' }, click: this.onActionBtnClick }];
}
else {
this.toastObj.buttons = [];
}
};
Api.prototype.onActionBtnClick = function (e) {
alert('Action button is clicked');
};
Api.prototype.showToast = function () {
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);
this.toastObj.show({
title: title, content: content, timeOut: timeOut,
animation: {
show: { duration: showDuration },
hide: { duration: hideDuration }
}
});
};
Api.prototype.onShowEase = function () {
this.toastObj.animation.show.easing = this.dropDownListShowEase.value.toString();
};
Api.prototype.showChange = function () {
this.toastObj.animation.show.effect = this.dropDownListShow.value;
};
Api.prototype.hideChange = function () {
this.toastObj.animation.hide.effect = this.dropDownListHide.value;
};
Api.prototype.onHideEase = function () {
this.toastObj.animation.hide.easing = this.dropDownListHideEase.value.toString();
};
Api.prototype.showBtnClick = function () {
this.showToast();
};
Api.prototype.hideBtnClick = function () {
this.toastObj.hide('All');
};
Api.prototype.onbeforeOpen = function (e) {
var btnEleHide = document.getElementById('toastBtnHide');
btnEleHide.style.display = 'inline-block';
if (this.prevDuplicates) {
e.cancel = this.preventDuplicate(e);
}
};
Api.prototype.onclose = function (e) {
var btnEleHide = document.getElementById('toastBtnHide');
if (e.toastContainer.childElementCount === 0) {
btnEleHide.style.display = 'none';
}
};
Api.prototype.preventDuplicate = function (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;
};
Api.prototype.render = function () {
var _this = this;
document.addEventListener('click', function (e) {
var btnEleShow = document.getElementById('toastBtnShow');
if (!ej2_base_1.isNullOrUndefined(this.toastObj) && e.target !== btnEleShow) {
this.toastObj.hide('All');
}
}.bind(this));
return (React.createElement("div", { className: 'control-pane' },
React.createElement("div", { className: "col-lg-12 control-section toast-api-section" },
React.createElement("div", { className: "e-sample-resize-container" },
React.createElement(ej2_react_notifications_1.ToastComponent, { ref: function (toast) { _this.toastObj = toast; }, id: 'toastApi', position: this.position, close: this.onclose.bind(this), beforeOpen: this.onbeforeOpen.bind(this), newestOnTop: true }),
React.createElement("div", { className: "row" },
React.createElement("div", { className: "col-lg-6 padding" },
React.createElement("div", { className: "input-form" },
React.createElement("div", { className: "e-float-input" },
React.createElement("input", { id: "toast_input_title", className: 'e-input', required: true }),
React.createElement("span", { className: "e-float-line" }),
React.createElement("label", { className: "e-float-text" }, "Enter the title"))),
React.createElement("div", { className: "input-form" },
React.createElement("div", { className: "e-float-input" },
React.createElement("textarea", { className: 'e-input', id: 'toast_input_content', rows: 3, required: true }),
React.createElement("label", { className: "e-float-text" }, "Enter the content"))),
React.createElement("div", { className: "group-form e-group" },
React.createElement(ej2_react_buttons_1.CheckBoxComponent, { id: 'closeButton', label: 'Show Close Button', change: this.closeOnChange.bind(this) })),
React.createElement("div", { className: "group-form e-group" },
React.createElement(ej2_react_buttons_1.CheckBoxComponent, { id: 'progressBar', label: 'Show Progress Bar', change: this.OnProgressChange.bind(this) })),
React.createElement("div", { className: "group-form e-group" },
React.createElement(ej2_react_buttons_1.CheckBoxComponent, { id: 'newestOnTop', checked: true, label: 'Newest On Top', change: this.closeNewestOnChange.bind(this) })),
React.createElement("div", { className: "group-form e-group" },
React.createElement(ej2_react_buttons_1.CheckBoxComponent, { id: 'prevDuplicates', label: 'Prevent Duplicates', change: this.OnPrevDubChange.bind(this) })),
React.createElement("div", { className: "group-form e-group" },
React.createElement(ej2_react_buttons_1.CheckBoxComponent, { id: 'actionButtons', label: 'Action Buttons', change: this.OnactionBtnChange.bind(this) })),
React.createElement("div", { className: "input-form" },
React.createElement("div", { className: "e-float-input e-input-group" },
React.createElement("input", { className: "e-input", id: "timeOut", name: "Digits", value: "5000", required: true }),
React.createElement("span", { className: "e-float-line" }),
React.createElement("label", { className: "e-float-text" }, "TimeOut")))),
React.createElement("div", { className: "col-lg-6 padding" },
React.createElement("div", { className: "input-form" },
React.createElement("h4", null, " Show Animation"),
React.createElement("div", { className: "e-float-input" },
React.createElement("input", { className: "e-input", id: "showDuration", defaultValue: "400", required: true }),
React.createElement("span", { className: "e-float-line" }),
React.createElement("label", { className: "e-float-text" }, "Duration"))),
React.createElement("div", { className: "input-form" },
React.createElement(ej2_react_dropdowns_1.DropDownListComponent, { ref: function (dropdownlist) { _this.dropDownListShowEase = dropdownlist; }, id: "ShowEasing", dataSource: this.showData, fields: this.showFields, placeholder: "Select an Easing", change: this.onShowEase.bind(this), value: this.easeValue })),
React.createElement("div", { className: "input-form" },
React.createElement(ej2_react_dropdowns_1.DropDownListComponent, { ref: function (dropdownlist) { _this.dropDownListShow = dropdownlist; }, id: "ShowAnimation", dataSource: this.animationData, fields: this.animationFields, placeholder: "Select an Animation", change: this.showChange.bind(this), value: this.animationValue })),
React.createElement("div", { className: "input-form e-group" },
React.createElement("h4", null, " Hide Animation"),
React.createElement("div", { className: "e-float-input" },
React.createElement("input", { className: "e-input", id: "hideDuration", defaultValue: "400", required: true }),
React.createElement("span", { className: "e-float-line" }),
React.createElement("label", { className: "e-float-text" }, "Duration"))),
React.createElement("div", { className: "input-form" },
React.createElement(ej2_react_dropdowns_1.DropDownListComponent, { ref: function (dropdownlist) { _this.dropDownListHideEase = dropdownlist; }, id: "HideEasing", dataSource: this.showData, fields: this.showFields, placeholder: "Select an Easing", change: this.onHideEase.bind(this), value: this.easeValue })),
React.createElement("div", { className: "input-form" },
React.createElement(ej2_react_dropdowns_1.DropDownListComponent, { ref: function (dropdownlist) { _this.dropDownListHide = dropdownlist; }, id: "HideAnimation", dataSource: this.animationData1, fields: this.animationFields, placeholder: "Select an Animation", change: this.hideChange.bind(this), value: this.animationHideValue })))),
React.createElement("div", { className: "row center" },
React.createElement(ej2_react_buttons_1.ButtonComponent, { id: 'toastBtnShow', className: 'e-btn e-primary', onClick: this.showBtnClick.bind(this), style: { 'margin-right': '15px' } }, "Show Toasts"),
React.createElement(ej2_react_buttons_1.ButtonComponent, { id: 'toastBtnHide', className: 'e-btn e-primary', onClick: this.hideBtnClick.bind(this), style: { 'display': 'none' } }, " Hide All")))),
React.createElement("br", null),
React.createElement("div", { id: "action-description" },
React.createElement("p", null,
"This sample demonstrates all the API functionalities available in ",
React.createElement("code", null, "Toast."))),
React.createElement("div", { id: "description" },
React.createElement("p", null,
"In this sample, with help of text inputs toast header ",
React.createElement("code", null, "title"),
" and ",
React.createElement("code", null, "content"),
" text can be provided."),
React.createElement("ul", null,
React.createElement("li", null,
React.createElement("code", null, "Action Buttons"),
" \u2013 Provide support to add a button inside toast to interact with it."),
React.createElement("li", null,
React.createElement("code", null, "Prevent Duplicates"),
" \u2013 Disable the user to create same toast message multiple times."),
React.createElement("li", null,
React.createElement("code", null, "TimeOut"),
" \u2013 Allows to set time in millisecond to close toast."),
React.createElement("li", null,
React.createElement("code", null, "Progress Bar"),
" \u2013 Visualizes the time out of toast as an indicator."),
React.createElement("li", null,
React.createElement("code", null, "Animation"),
" \u2013 Enables to define the toast show and hide animation."),
React.createElement("li", null,
React.createElement("code", null, "Close button"),
" \u2013 Show close button to hide toast irrespective of time out.")),
React.createElement("p", null,
"More information about Toast can be found in this ",
React.createElement("a", { target: "_blank", href: "http://ej2.syncfusion.com/react/documentation/toast/getting-started.html" }, "documentation section"),
"."))));
};
return Api;
}(sample_base_1.SampleBase));
exports.Api = Api;