-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalerted.js
119 lines (91 loc) · 3.28 KB
/
alerted.js
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
/*!
* Name: Alerted.js
* Description: Sweetalert2 depended semi customizable alert and confirmation dialogs.
* Github: https://github.com/eIektro/Alerted.js
* License: MIT License
* (c) 2020-2021 M. Emre Koral
*/
/**
* Usage: FOR CONFIRMATION ALERT.
* @param {any} description Displays on the body of alert dialog
* @param {any} title Alert dialog title
* @param {any} handleResponse function to be run when you click Yes
*/
var confirmationAlert = (description, title, handleResponse) => {
title = (title === undefined) ? "Emin misiniz?" : title;
handleResponse = (handleResponse === undefined || handleResponse === null) ? () => { } : handleResponse;
Swal.fire({
title: title,
html: `<span style="color:#214B6A">${description}</span>`,
showCloseButton: false,
showCancelButton: true,
showConfirmButton: true,
confirmButtonColor: "#00D373",
confirmButtonText: "Evet",
cancelButtonText: "Vazgeç",
}).then(result => {
handleResponse(result.value)
});
}
/**
* Usage: BEFORE DELETE REQUEST.
* @param {any} description Displays on the body of alert dialog
* @param {any} title Alert dialog title
* @param {any} handleResponse function to be run when you click Yes
*/
var deleteRequestAlert = (description, title, handleResponse) => {
title = (title === undefined) ? "Silmeye emin misiniz!" : title;
handleResponse = (handleResponse === undefined || handleResponse === null) ? () => { } : handleResponse;
Swal.fire({
title: title,
html: `<span style="color:red">${description}</span>`,
showCloseButton: false,
showCancelButton: true,
showConfirmButton: true,
confirmButtonColor: "#d33",
confirmButtonText: "Sil",
cancelButtonText: "Vazgeç",
}).then(result => {
handleResponse(result.value)
});
}
/**
* Usage: AFTER FAIL RESPONSE.
* @param {any} description Displays on the body of alert dialog
* @param {any} title Alert dialog title
* @param {any} handleResponse function to be when dialog closing
*/
var failResponseAlert = (description, title, afterClosing) => {
title = (title === undefined) ? "İşlem başarısız!" : title;
afterClosing = (afterClosing === undefined || afterClosing === null) ? () => { } : afterClosing;
Swal.fire({
title: title,
html: `<span style="color:red">${description}</span>`,
showCloseButton: false,
showCancelButton: false,
showConfirmButton: true,
confirmButtonText: "Tamam",
}).then(() => {
afterClosing()
});
}
/**
* Usage: AFTER SUCCESS RESPONSE.
* @param {any} description Displays on the body of alert dialog
* @param {any} title Alert dialog title
* @param {any} handleResponse function to be when dialog closing
*/
var successResponseAlert = (description, title, afterClosing) => {
title = (title === undefined) ? "İşlem başarılı!" : title;
afterClosing = (afterClosing === undefined || afterClosing === null) ? () => { } : afterClosing;
Swal.fire({
title: title,
html: `<span style="color:green">${description}</span>`,
showCloseButton: false,
showCancelButton: false,
showConfirmButton: true,
confirmButtonText: "Tamam",
}).then(() => {
afterClosing();
});
}