This repository was archived by the owner on Jul 30, 2025. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathpositions.js
More file actions
222 lines (222 loc) · 13.3 KB
/
Copy pathpositions.js
File metadata and controls
222 lines (222 loc) · 13.3 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
"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_base_1 = require("@syncfusion/ej2-base");
var ej2_react_buttons_1 = require("@syncfusion/ej2-react-buttons");
var ej2_react_dropdowns_1 = require("@syncfusion/ej2-react-dropdowns");
var ej2_react_notifications_1 = require("@syncfusion/ej2-react-notifications");
require("./positions.css");
var Positions = (function (_super) {
__extends(Positions, _super);
function Positions() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.position = { X: 'Right', Y: 'Bottom' };
_this.target = document.body;
_this.initialWid = '';
_this.customFlag = false;
_this.dropData = [
{ Id: 'topleft', Text: 'Top Left' },
{ Id: 'topright', Text: 'Top Right' },
{ Id: 'topcenter', Text: 'Top Center' },
{ Id: 'topfullwidth', Text: 'Top Full Width' },
{ Id: 'bottomleft', Text: 'Bottom Left' },
{ Id: 'bottomright', Text: 'Bottom Right' },
{ Id: 'bottomcenter', Text: 'Bottom Center' },
{ Id: 'bottomfullwidth', Text: 'Bottom Full Width' },
];
_this.dropFields = { text: 'Text', value: 'Id' };
_this.value = 'bottomright';
return _this;
}
Positions.prototype.checkboxChange = function (e) {
if (this.radio1.checked) {
this.toastObj.hide('All');
this.toastObj.target = '#toast_pos_target';
this.toastShow(1000);
}
};
Positions.prototype.toastShow = function (timeOutDelay) {
setTimeout(function () {
this.toastObj.show();
}.bind(this), timeOutDelay);
};
Positions.prototype.checkboxChange1 = function (e) {
if (this.radio2.checked) {
this.toastObj.hide('All');
this.toastObj.target = document.body;
this.toastShow(1000);
}
};
Positions.prototype.checkboxChange2 = function (e) {
if (this.dropRadioObj.checked) {
this.toastObj.hide('All');
document.getElementById('dropdown').style.display = 'table-cell';
document.getElementById('customChoose').style.display = 'none';
this.setToastPosValue(this.dropDownObj.value.toString());
this.customFlag = false;
this.toastShow(1000);
}
};
Positions.prototype.checkboxChange3 = function (e) {
if (this.customRadioObj.checked) {
this.toastObj.hide('All');
document.getElementById('dropdown').style.display = 'none';
document.getElementById('customChoose').style.display = 'table-cell';
this.setcustomPosValue();
this.customFlag = true;
this.toastShow(1000);
}
};
Positions.prototype.valueChange = function (e) {
this.toastObj.hide('All');
this.setToastPosValue(e.value.toString());
this.toastShow(1000);
};
Positions.prototype.setcustomPosValue = function () {
this.toastObj.width = this.initialWid;
this.toastObj.position.X = parseInt(document.getElementById('xPos').value, 10);
this.toastObj.position.Y = parseInt(document.getElementById('yPos').value, 10);
};
Positions.prototype.showBtnClick = function () {
if (this.customFlag) {
this.setcustomPosValue();
}
this.toastObj.show();
};
Positions.prototype.setToastPosValue = function (value) {
this.toastObj.width = this.initialWid;
switch (value) {
case 'topleft':
this.toastObj.position.X = 'Left';
this.toastObj.position.Y = 'Top';
break;
case 'topright':
this.toastObj.position.X = 'Right';
this.toastObj.position.Y = 'Top';
break;
case 'topcenter':
this.toastObj.position.X = 'Center';
this.toastObj.position.Y = 'Top';
break;
case 'topfullwidth':
this.toastObj.width = '100%';
this.toastObj.position.X = 'Center';
this.toastObj.position.Y = 'Top';
break;
case 'bottomleft':
this.toastObj.position.X = 'Left';
this.toastObj.position.Y = 'Bottom';
break;
case 'bottomright':
this.toastObj.position.X = 'Right';
this.toastObj.position.Y = 'Bottom';
break;
case 'bottomcenter':
this.toastObj.position.X = 'Center';
this.toastObj.position.Y = 'Bottom';
break;
case 'bottomfullwidth':
this.toastObj.width = '100%';
this.toastObj.position.X = 'Center';
this.toastObj.position.Y = 'Bottom';
break;
}
};
Positions.prototype.hideBtnClick = function () {
this.toastObj.hide('All');
};
Positions.prototype.created = function () {
setTimeout(function () {
this.toastShow(200);
this.initialWid = this.toastObj.width.toString();
}.bind(this), 200);
};
Positions.prototype.onclose = function (e) {
var btnEleHide = document.getElementById('hideTosat');
if (e.toastContainer.childElementCount === 0) {
btnEleHide.style.display = 'none';
}
};
Positions.prototype.onbeforeOpen = function () {
var btnEleHide = document.getElementById('hideTosat');
btnEleHide.style.display = 'inline-block';
};
Positions.prototype.render = function () {
var _this = this;
document.addEventListener('click', function (e) {
var btnEle = document.getElementById('show_Toast');
if (!ej2_base_1.isNullOrUndefined(this.toastObj) && e.target !== btnEle && this.toastObj.target === document.body) {
this.toastObj.hide('All');
}
}.bind(this));
return (React.createElement("div", { className: 'control-pane' },
React.createElement("div", { className: 'col-lg-12 control-section toast-pos-section' },
React.createElement("div", { className: "e-sample-resize-container", id: "toast_pos_target" },
React.createElement(ej2_react_notifications_1.ToastComponent, { ref: function (toast) { _this.toastObj = toast; }, id: 'toast_pos', title: 'Matt sent you a friend request', content: 'You have a friend request yet to accept.', icon: 'e-laura', position: this.position, target: this.target, created: this.created.bind(this), close: this.onclose.bind(this), beforeOpen: this.onbeforeOpen.bind(this) }),
React.createElement("div", { id: "toast_pos_property" },
React.createElement("table", { style: { 'width': '100%' } },
React.createElement("tbody", null,
React.createElement("tr", null,
React.createElement("td", null,
React.createElement("div", { style: { 'padding': '25px 0 0 0' } },
React.createElement(ej2_react_buttons_1.RadioButtonComponent, { ref: function (scope) { _this.dropRadioObj = scope; }, id: 'dropdownRadio', checked: true, label: 'Position', name: 'toastPos', value: "Position", change: this.checkboxChange2.bind(this) }))),
React.createElement("td", null,
React.createElement("div", { style: { 'padding': '25px 0 0 0' } },
React.createElement(ej2_react_buttons_1.RadioButtonComponent, { ref: function (scope) { _this.customRadioObj = scope; }, id: 'customRedio', label: 'Custom', name: 'toastPos', value: "Custom", change: this.checkboxChange3.bind(this) })))))),
React.createElement("div", { id: "dropdownChoose" },
React.createElement("div", { id: "dropdown", style: { 'padding-top': '25px' } },
React.createElement(ej2_react_dropdowns_1.DropDownListComponent, { ref: function (dropdownlist) { _this.dropDownObj = dropdownlist; }, id: "position", dataSource: this.dropData, fields: this.dropFields, placeholder: "Select a position", change: this.valueChange.bind(this), value: this.value, index: 5, popupHeight: '200px' }))),
React.createElement("table", { style: { 'width': '100%' } },
React.createElement("tbody", null,
React.createElement("tr", null,
React.createElement("td", { id: "customChoose", style: { 'display': 'none' } },
React.createElement("form", { id: "formId", className: "form-horizontal" },
React.createElement("div", { className: "e-row" },
React.createElement("div", { className: "e-float-input" },
React.createElement("input", { className: "e-input", id: "xPos", name: "Digits", defaultValue: "50", required: true }),
React.createElement("span", { className: "e-float-line" }),
React.createElement("label", { className: "e-float-text" }, "X Position"))),
React.createElement("div", { className: "e-row" },
React.createElement("div", { className: "e-float-input" },
React.createElement("input", { className: "e-input", id: "yPos", name: "Digits", defaultValue: "50", required: true }),
React.createElement("span", { className: "e-float-line" }),
React.createElement("label", { className: "e-float-text" }, "Y Position")))))),
React.createElement("tr", null,
React.createElement("td", null,
React.createElement("div", { style: { 'padding': '25px 0 0 0' } },
React.createElement(ej2_react_buttons_1.RadioButtonComponent, { ref: function (scope) { _this.radio1 = scope; }, id: 'radio1', label: 'Target', name: 'toast', value: 'Target', change: this.checkboxChange.bind(this) }))),
React.createElement("td", null,
React.createElement("div", { style: { 'padding': '25px 0 0 0' } },
React.createElement(ej2_react_buttons_1.RadioButtonComponent, { ref: function (scope) { _this.radio2 = scope; }, id: 'radio2', checked: true, label: 'Global', name: 'toast', value: 'Global', change: this.checkboxChange1.bind(this) })))))),
React.createElement("div", { id: "toast_btn", style: { 'padding-top': '25px' } },
React.createElement(ej2_react_buttons_1.ButtonComponent, { className: "e-btn e-control", id: 'show_Toast', style: { 'margin-right': '15px' }, onClick: this.showBtnClick.bind(this) }, "Show Toasts"),
React.createElement(ej2_react_buttons_1.ButtonComponent, { className: "e-btn e-control", id: 'hideTosat', onClick: this.hideBtnClick.bind(this) }, "Hide All"))))),
React.createElement("div", { id: "action-description" },
React.createElement("p", null,
"This sample demonstrates the different positioning of the ",
React.createElement("code", null, "Toast"),
" based on the target given.")),
React.createElement("div", { id: "description" },
React.createElement("p", null, "Based on the use case toast can take the body element or any specific element as target. In this sample, with help of custom inputs toast can be positioned based on the target."),
React.createElement("ul", null,
React.createElement("li", null, "Toast can be positioned in the 8 pre-defined places."),
React.createElement("li", null, "Custom option will enable to give X and Y values to align the toast based on the given inputs.")),
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 Positions;
}(sample_base_1.SampleBase));
exports.Positions = Positions;