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 pathcustom-dialog.js
More file actions
145 lines (145 loc) · 8.72 KB
/
custom-dialog.js
File metadata and controls
145 lines (145 loc) · 8.72 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
"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 ej2_react_popups_1 = require("@syncfusion/ej2-react-popups");
var sample_base_1 = require("../common/sample-base");
require("./custom-dialog.css");
var Basic = (function (_super) {
__extends(Basic, _super);
function Basic(props) {
var _this = _super.call(this, props) || this;
_this.state = {
hideAlertDialog: false,
hideConfirmDialog: false,
hidePromptDialog: false
};
_this.alertButtonElement = null;
_this.confirmButtonElement = null;
_this.promptButtonElement = null;
_this.spanElement = null;
_this.alertButtonRef = function (element) {
_this.alertButtonElement = element;
};
_this.confirmButtonRef = function (element) {
_this.confirmButtonElement = element;
};
_this.promptButtonRef = function (element) {
_this.promptButtonElement = element;
};
_this.spanRef = function (element) {
_this.spanElement = element;
};
_this.alertButtons = [{
// Click the footer buttons to hide the Dialog
click: function () {
_this.setState({ hideAlertDialog: false });
},
buttonModel: { content: 'Dismiss', isPrimary: true }
}];
_this.confirmButton = [{
click: function () {
_this.setState({ hideConfirmDialog: false });
},
buttonModel: { content: 'Yes', isPrimary: true }
},
{
click: function () {
_this.setState({ hideConfirmDialog: false });
},
buttonModel: { content: 'No' }
}];
_this.promptButtons = [{
click: function () {
_this.setState({ hidePromptDialog: false });
},
buttonModel: { content: 'Connect', isPrimary: true }
},
{
click: function () {
_this.setState({ hidePromptDialog: false });
},
buttonModel: { content: 'Cancel' }
}];
_this.animationSettings = { effect: 'None' };
return _this;
}
Basic.prototype.buttonClick = function (args) {
if (args.target.innerHTML.toLowerCase() == 'alert') {
this.setState({ hideAlertDialog: true });
}
else if (args.target.innerHTML.toLowerCase() == 'confirm') {
this.setState({ hideConfirmDialog: true });
}
else if (args.target.innerHTML.toLowerCase() == 'prompt')
this.setState({ hidePromptDialog: true });
};
Basic.prototype.dialogClose = function () {
this.setState({
hideAlertDialog: false,
hideConfirmDialog: false,
hidePromptDialog: false
});
this.alertButtonElement.style.display = 'inline-block';
this.confirmButtonElement.style.display = 'inline-block';
this.promptButtonElement.style.display = 'inline-block';
};
Basic.prototype.dialogOpen = function () {
this.alertButtonElement.style.display = 'none';
this.confirmButtonElement.style.display = 'none';
this.promptButtonElement.style.display = 'none';
};
Basic.prototype.onFocus = function (args) {
this.spanElement.classList.add('e-input-focus');
};
Basic.prototype.onBlur = function (args) {
this.spanElement.classList.remove('e-input-focus');
};
Basic.prototype.render = function () {
var _this = this;
return (React.createElement("div", { className: 'control-pane' },
React.createElement("div", { id: 'target', className: 'col-lg-12 control-section dialog-target' },
React.createElement("button", { className: "e-control e-btn dlgbtn", ref: this.alertButtonRef, onClick: this.buttonClick.bind(this), id: "alertBtn" }, "Alert"),
React.createElement("button", { className: "e-control e-btn dlgbtn", ref: this.confirmButtonRef, onClick: this.buttonClick.bind(this), id: "confirmBtn" }, "Confirm"),
React.createElement("button", { className: "e-control e-btn dlgbtn", ref: this.promptButtonRef, onClick: this.buttonClick.bind(this), id: "promptBtn" }, "Prompt"),
React.createElement(ej2_react_popups_1.DialogComponent, { id: "alertDialog", header: 'Low Battery', visible: this.state.hideAlertDialog, animationSettings: this.animationSettings, width: '250px', content: '10% of battery remaining', ref: function (alertdialog) { return _this.alertDialogInstance = alertdialog; }, target: '#target', buttons: this.alertButtons, open: this.dialogOpen.bind(this), close: this.dialogClose.bind(this) }),
React.createElement(ej2_react_popups_1.DialogComponent, { id: "confirmDialog", header: 'Delete Multiple Items', visible: this.state.hideConfirmDialog, showCloseIcon: true, animationSettings: this.animationSettings, width: '400px', content: 'Are you sure you want to permanently delete these items ?', ref: function (dialog) { return _this.confirmDialogInstance = dialog; }, target: '#target', buttons: this.confirmButton, open: this.dialogOpen.bind(this), close: this.dialogClose.bind(this) }),
React.createElement(ej2_react_popups_1.DialogComponent, { id: "promptDialog", header: 'Join Wi-Fi network', visible: this.state.hidePromptDialog, showCloseIcon: true, animationSettings: this.animationSettings, width: '330px', ref: function (dialog) { return _this.promptDialogInstance = dialog; }, target: '#target', buttons: this.promptButtons, open: this.dialogOpen.bind(this), close: this.dialogClose.bind(this) },
React.createElement("table", null,
React.createElement("tbody", null,
React.createElement("tr", null,
React.createElement("td", null, "SSID:")),
React.createElement("tr", null,
React.createElement("td", null,
React.createElement("b", null, "AndroidAP"))),
React.createElement("tr", null,
React.createElement("td", null, "Password:")),
React.createElement("tr", null,
React.createElement("td", null,
React.createElement("span", { id: 'password', ref: this.spanRef, className: "e-input-group" },
React.createElement("input", { type: "password", onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this), name: "Required", className: "e-input" })))))))),
React.createElement("div", { id: "action-description" },
React.createElement("p", null, "This sample demonstrates that you can create different types of custom dialogs such as alert, confirm, and prompt dialogs. The buttons \u201Calert\u201D, \u201Cconfirm\u201D, and \u201Cprompt\u201D are used to open the corresponding dialogs.")),
React.createElement("div", { id: "description" },
React.createElement("p", null, "The dialog control is used to create alert, prompt, and confirmation dialogs using content, and buttons property. The content property accepts both string and HTML element as content."),
React.createElement("ul", null,
React.createElement("li", null, "Alert - Used to show errors, warnings, and information that needs user awareness."),
React.createElement("li", null, "Prompt - Used to get input from the user."),
React.createElement("li", null, "Confirmation - Used to get approval from user that appears before any critical action.")),
React.createElement("p", null,
"More information on the Dialog instantiation can be found in the ",
React.createElement("a", { target: "_blank", href: "http://ej2.syncfusion.com/react/documentation/dialog/getting-started.html" }, "documentation section"),
"."))));
};
return Basic;
}(sample_base_1.SampleBase));
exports.Basic = Basic;