/* Template Name: Grenviro Monitoring Author: Themesbrand Website: https://Themesbrand.com/ Contact: Themesbrand@gmail.com File: Sweatalerts init js */ //Basic if (document.getElementById("sa-basic")) document.getElementById("sa-basic").addEventListener("click", function () { Swal.fire({ title: 'Any fool can use a computer', confirmButtonClass: 'btn btn-primary w-xs mt-2', buttonsStyling: false, showCloseButton: true }) }); //A title with a text under if (document.getElementById("sa-title")) document.getElementById("sa-title").addEventListener("click", function () { Swal.fire({ title: "The Internet?", text: 'That thing is still around?', icon: 'question', confirmButtonClass: 'btn btn-primary w-xs mt-2', buttonsStyling: false, showCloseButton: true }) }); //Success Message if (document.getElementById("sa-success")) document.getElementById("sa-success").addEventListener("click", function () { Swal.fire({ title: 'Good job!', text: 'You clicked the button!', icon: 'success', showCancelButton: true, confirmButtonClass: 'btn btn-primary w-xs me-2 mt-2', cancelButtonClass: 'btn btn-danger w-xs mt-2', buttonsStyling: false, showCloseButton: true }) }); //error Message if (document.getElementById("sa-error")) document.getElementById("sa-error").addEventListener("click", function () { Swal.fire({ title: 'Oops...', text: 'Something went wrong!', icon: 'error', confirmButtonClass: 'btn btn-primary w-xs mt-2', buttonsStyling: false, footer: 'Why do I have this issue?', showCloseButton: true }) }); // long content if (document.getElementById("sa-longcontent")) document.getElementById("sa-longcontent").addEventListener("click", function () { Swal.fire({ imageUrl: 'https://placeholder.pics/svg/300x1500', imageHeight: 1500, imageAlt: 'A tall image', confirmButtonClass: 'btn btn-primary w-xs mt-2', buttonsStyling: false, showCloseButton: true }) }); //Warning Message if (document.getElementById("sa-warning")) document.getElementById("sa-warning").addEventListener("click", function () { Swal.fire({ title: "Are you sure?", text: "You won't be able to revert this!", icon: "warning", showCancelButton: true, confirmButtonClass: 'btn btn-primary w-xs me-2 mt-2', cancelButtonClass: 'btn btn-danger w-xs mt-2', confirmButtonText: "Yes, delete it!", buttonsStyling: false, showCloseButton: true }).then(function (result) { if (result.value) { Swal.fire({ title: 'Deleted!', text: 'Your file has been deleted.', icon: 'success', confirmButtonClass: 'btn btn-primary w-xs mt-2', buttonsStyling: false }) } }); }); //Parameter if (document.getElementById("sa-params")) document.getElementById("sa-params").addEventListener("click", function () { Swal.fire({ title: 'Are you sure?', text: "You won't be able to revert this!", icon: 'warning', showCancelButton: true, confirmButtonText: 'Yes, delete it!', cancelButtonText: 'No, cancel!', confirmButtonClass: 'btn btn-primary w-xs me-2 mt-2', cancelButtonClass: 'btn btn-danger w-xs mt-2', buttonsStyling: false, showCloseButton: true }).then(function (result) { if (result.value) { Swal.fire({ title: 'Deleted!', text: 'Your file has been deleted.', icon: 'success', confirmButtonClass: 'btn btn-primary w-xs mt-2', buttonsStyling: false }) } else if ( // Read more about handling dismissals result.dismiss === Swal.DismissReason.cancel ) { Swal.fire({ title: 'Cancelled', text: 'Your imaginary file is safe :)', icon: 'error', confirmButtonClass: 'btn btn-primary mt-2', buttonsStyling: false }) } }); }); //Custom Image if (document.getElementById("sa-image")) document.getElementById("sa-image").addEventListener("click", function () { Swal.fire({ title: 'Sweet!', text: 'Modal with a custom image.', imageUrl: 'build/images/logo-sm.png', imageHeight: 40, confirmButtonClass: 'btn btn-primary w-xs mt-2', buttonsStyling: false, animation: false, showCloseButton: true }) }); //Auto Close Timer if (document.getElementById("sa-close")) document.getElementById("sa-close").addEventListener("click", function () { var timerInterval; Swal.fire({ title: 'Auto close alert!', html: 'I will close in seconds.', timer: 2000, timerProgressBar: true, showCloseButton: true, didOpen: function () { Swal.showLoading() timerInterval = setInterval(function () { var content = Swal.getHtmlContainer() if (content) { var b = content.querySelector('b') if (b) { b.textContent = Swal.getTimerLeft() } } }, 100) }, onClose: function () { clearInterval(timerInterval) } }).then(function (result) { /* Read more about handling dismissals below */ if (result.dismiss === Swal.DismissReason.timer) { console.log('I was closed by the timer') } }) }); //custom html alert if (document.getElementById("custom-html-alert")) document.getElementById("custom-html-alert").addEventListener("click", function () { Swal.fire({ title: 'HTML example', icon: 'info', html: 'You can use bold text, ' + 'links ' + 'and other HTML tags', showCloseButton: true, showCancelButton: true, confirmButtonClass: 'btn btn-success me-2', cancelButtonClass: 'btn btn-danger', buttonsStyling: false, confirmButtonText: ' Great!', cancelButtonText: '', showCloseButton: true }) }); //dialog three buttons if (document.getElementById("sa-dialog-three-btn")) document.getElementById("sa-dialog-three-btn").addEventListener("click", function () { Swal.fire({ title: 'Do you want to save the changes?', showDenyButton: true, showCancelButton: true, confirmButtonText: 'Save', confirmButtonClass: 'btn btn-success w-xs me-2', cancelButtonClass: 'btn btn-danger w-xs', denyButtonClass: 'btn btn-info w-xs me-2', buttonsStyling: false, denyButtonText: 'Don\'t save', showCloseButton: true }).then(function (result) { /* Read more about isConfirmed, isDenied below */ if (result.isConfirmed) { Swal.fire({ title: 'Saved!', icon: 'success', confirmButtonClass: 'btn btn-primary w-xs', buttonsStyling: false, }) } else if (result.isDenied) { Swal.fire({ title: 'Changes are not saved', icon: 'info', confirmButtonClass: 'btn btn-primary w-xs', buttonsStyling: false, }) } }) }); //position if (document.getElementById("sa-position")) document.getElementById("sa-position").addEventListener("click", function () { Swal.fire({ position: 'top-end', icon: 'success', title: 'Your work has been saved', showConfirmButton: false, timer: 1500, showCloseButton: true }) }); //Custom width padding if (document.getElementById("custom-padding-width-alert")) document.getElementById("custom-padding-width-alert").addEventListener("click", function () { Swal.fire({ title: 'Custom width, padding, background.', width: 600, padding: 100, confirmButtonClass: 'btn btn-primary w-xs', buttonsStyling: false, background: '#fff url(build/images/chat-bg-pattern.png)' }) }); //Ajax if (document.getElementById("ajax-alert")) document.getElementById("ajax-alert").addEventListener("click", function () { Swal.fire({ title: 'Submit email to run ajax request', input: 'email', showCancelButton: true, confirmButtonText: 'Submit', showLoaderOnConfirm: true, confirmButtonClass: 'btn btn-primary w-xs me-2', cancelButtonClass: 'btn btn-danger w-xs', buttonsStyling: false, showCloseButton: true, preConfirm: function (email) { return new Promise(function (resolve, reject) { setTimeout(function () { if (email === 'taken@example.com') { reject('This email is already taken.') } else { resolve() } }, 2000) }) }, allowOutsideClick: false }).then(function (email) { Swal.fire({ icon: 'success', title: 'Ajax request finished!', confirmButtonClass: 'btn btn-primary w-xs', buttonsStyling: false, html: 'Submitted email: ' + email }) }) }); // Custom SweatAlerts //Custom success Message if (document.getElementById("custom-sa-success")) document.getElementById("custom-sa-success").addEventListener("click", function () { Swal.fire({ html: '
Aww yeah, you successfully read this important message.
' + 'Your email Address is invalid
' + 'Are you Sure You want to Delete this Account ?
' + 'Already have an account ? Signin
', imageHeight: 40, confirmButtonClass: 'btn btn-primary w-xs mb-2', confirmButtonText: 'Register ', buttonsStyling: false, showCloseButton: true }) }); //Custom Email varification if (document.getElementById("custom-sa-email-verify")) document.getElementById("custom-sa-email-verify").addEventListener("click", function () { Swal.fire({ html: 'We have sent you verification email example@abc.com,
Please check it.
Didn\'t receive an email ? Resend
', showCloseButton: true }) }); //Custom notification Message if (document.getElementById("custom-sa-notification")) document.getElementById("custom-sa-notification").addEventListener("click", function () { Swal.fire({ html: 'You have 2 Notifications
' + '