4
var SweetAlert = function () {};
7
(SweetAlert.prototype.init = function () {
9
$("#sa-basic").click(function () {
10
Swal.fire("Here's a message!");
14
$("#sa-title").click(function () {
17
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed lorem erat eleifend ex semper, lobortis purus sed."
22
$("#sa-success").click(function () {
25
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed lorem erat eleifend ex semper, lobortis purus sed.",
31
$("#sa-warning").click(function () {
34
title: "Are you sure?",
35
text: "You will not be able to recover this imaginary file!",
37
showCancelButton: true,
38
confirmButtonColor: "#DD6B55",
39
confirmButtonText: "Yes, delete it!",
40
closeOnConfirm: false,
43
swal("Deleted!", "Your imaginary file has been deleted.", "success");
49
$("#sa-image").click(function () {
52
text: "Recently joined twitter",
53
imageUrl: "../assets/images/profile/user-2.jpg",
58
$("#sa-close").click(function () {
60
title: "Auto close alert!",
61
text: "I will close in 2 seconds.",
63
showConfirmButton: false,
67
$("#model-error-icon").click(function () {
71
text: "Something went wrong!",
72
footer: "<a href>Why do I have this issue?</a>",
76
$("#sa-html").click(function () {
78
title: "<strong>HTML <u>example</u></strong>",
81
"You can use <b>bold text</b>, " +
82
'<a href="//github.com">links</a> ' +
83
"and other HTML tags",
84
showCloseButton: true,
85
showCancelButton: true,
87
confirmButtonText: '<i class="ti ti-thumb-up"></i> Great!',
88
confirmButtonAriaLabel: "Thumbs up, great!",
89
cancelButtonText: '<i class="ti ti-thumb-down"></i>',
90
cancelButtonAriaLabel: "Thumbs down",
94
$("#sa-position").click(function () {
98
title: "Your work has been saved",
99
showConfirmButton: false,
104
$("#sa-animation").click(function () {
106
title: "Custom animation with Animate.css",
109
popup: "animated tada",
114
$("#sa-confirm").click(function () {
116
title: "Are you sure?",
117
text: "You won't be able to revert this!",
119
showCancelButton: true,
120
confirmButtonColor: "#3085d6",
121
cancelButtonColor: "#d33",
122
confirmButtonText: "Yes, delete it!",
123
}).then((result) => {
125
Swal.fire("Deleted!", "Your file has been deleted.", "success");
130
$("#sa-passparameter").click(function () {
131
const swalWithBootstrapButtons = Swal.mixin({
133
confirmButton: "btn btn-success",
134
cancelButton: "me-6 btn btn-danger",
136
buttonsStyling: false,
139
swalWithBootstrapButtons
141
title: "Are you sure?",
142
text: "You won't be able to revert this!",
144
showCancelButton: true,
145
confirmButtonText: "Yes, delete it!",
146
cancelButtonText: "No, cancel!",
147
reverseButtons: true,
151
swalWithBootstrapButtons.fire(
153
"Your file has been deleted.",
158
result.dismiss === Swal.DismissReason.cancel
160
swalWithBootstrapButtons.fire(
162
"Your imaginary file is safe :)",
169
$("#sa-bg").click(function () {
171
title: "Custom width, padding, background.",
175
"var(--bs-body-bg) url(../assets/images/backgrounds/active-bg.png)",
178
url("../assets/images/backgrounds/nyan-cat.gif")
185
$("#sa-autoclose").click(function () {
188
title: "Auto close alert!",
189
html: "I will close in <strong></strong> seconds.",
191
onBeforeOpen: () => {
193
timerInterval = setInterval(() => {
194
Swal.getContent().querySelector("strong").textContent =
199
clearInterval(timerInterval);
201
}).then((result) => {
204
result.dismiss === Swal.DismissReason.timer
206
console.log("I was closed by the timer");
211
$("#sa-rtl").click(function () {
213
title: "هل تريد الاستمرار؟",
216
icon: "swal2-arabic-question-mark",
218
confirmButtonText: "نعم",
219
cancelButtonText: "لا",
220
showCancelButton: true,
221
showCloseButton: true,
225
$("#sa-ajax").click(function () {
227
title: "Submit your Github username",
230
autocapitalize: "off",
232
showCancelButton: true,
233
confirmButtonText: "Look up",
234
showLoaderOnConfirm: true,
235
preConfirm: (login) => {
236
return fetch(`//api.github.com/users/${login}`)
237
.then((response) => {
239
throw new Error(response.statusText);
241
return response.json();
244
Swal.showValidationMessage(`Request failed: ${error}`);
247
allowOutsideClick: () => !Swal.isLoading(),
248
}).then((result) => {
251
title: `${result.value.login}'s avatar`,
252
imageUrl: result.value.avatar_url,
258
$("#sa-chain").click(function () {
261
confirmButtonText: "Next →",
262
showCancelButton: true,
263
progressSteps: ["1", "2", "3"],
268
text: "Chaining swal2 modals is easy",
278
"Your answers: <pre><code>" +
279
JSON.stringify(result.value) +
281
confirmButtonText: "Lovely!",
287
$("#sa-queue").click(function () {
288
const ipAPI = "https://api.ipify.org?format=json";
292
title: "Your public IP",
293
confirmButtonText: "Show my public IP",
294
text: "Your public IP will be received " + "via AJAX request",
295
showLoaderOnConfirm: true,
298
.then((response) => response.json())
299
.then((data) => Swal.insertQueueStep(data.ip))
301
Swal.insertQueueStep({
303
title: "Unable to get your public IP",
311
$("#sa-timerfun").click(function () {
314
title: "Auto close alert!",
316
"I will close in <strong></strong> seconds.<br/><br/>" +
317
'<button id="increase" class="btn bg-warning-subtle text-warning px-4">' +
318
"I need 5 more seconds!" +
320
'<button id="stop" class="btn bg-danger-subtle text-danger px-4 mt-1">' +
321
"Please stop the timer!!" +
323
'<button id="resume" class="btn bg-success-subtle text-success px-4 mt-1" disabled>' +
324
"Phew... you can restart now!" +
326
'<button id="toggle" class="btn bg-primary-subtle text-primary px-4 mt-1">' +
330
onBeforeOpen: () => {
331
const content = Swal.getContent();
332
const $ = content.querySelector.bind(content);
334
const stop = $("#stop");
335
const resume = $("#resume");
336
const toggle = $("#toggle");
337
const increase = $("#increase");
341
function toggleButtons() {
342
stop.disabled = !Swal.isTimerRunning();
343
resume.disabled = Swal.isTimerRunning();
346
stop.addEventListener("click", () => {
351
resume.addEventListener("click", () => {
356
toggle.addEventListener("click", () => {
361
increase.addEventListener("click", () => {
362
Swal.increaseTimer(5000);
365
timerInterval = setInterval(() => {
366
Swal.getContent().querySelector("strong").textContent = (
367
Swal.getTimerLeft() / 1000
372
clearInterval(timerInterval);
378
($.SweetAlert = new SweetAlert()),
379
($.SweetAlert.Constructor = SweetAlert);