function alertaSwitch(tipoAlert, titulo, mensaje){ Swal.fire({ icon: tipoAlert, title: titulo, text: mensaje, showConfirmButton: true, timer: 20000, timerProgressBar: true }) } function alertaSwitchRedirection(tipoAlert, titulo, mensaje, url){ Swal.fire({ icon: tipoAlert, title: titulo, text: mensaje, timer: 5000, timerProgressBar: true, showConfirmButton: false }).then(function(){ if(window.location.href == url){ location.reload(); } else { window.location.href = url; } }); } function alertaSwitchRedirectionTiming(tipoAlert, titulo, mensaje, url, timer){ Swal.fire({ icon: tipoAlert, title: titulo, text: mensaje, showConfirmButton: true, timer: timer, timerProgressBar: true }).then(function(){ if(window.location.href == url){ location.reload(); } else { window.location.href = url; } }); } function alertaSwitchRedirectionPermanent(tipoAlert, titulo, mensaje, url, imagen){ var opciones = { icon: tipoAlert, title: titulo, text: mensaje, showConfirmButton: true, timerProgressBar: false }; if (imagen) { opciones.imageUrl = imagen; opciones.imageAlt = titulo; } var coloresBarra = { info: '#1b6ec2', error: '#c0392b', success: '#1e824c', warning: '#b9770e', question: '#6c3fc0' }; var colorBarra = coloresBarra[tipoAlert] || '#1b6ec2'; opciones.didOpen = function (popup) { popup.style.borderTop = '6px solid ' + colorBarra; }; Swal.fire(opciones).then(function(){ if(window.location.href == url){ location.reload(); } else { window.location.href = url; } }); } function alertaSwitchUserChoiceRedirection(tipoAlert, titulo, mensaje, url, mensajeUrl) { Swal.fire({ icon: tipoAlert, title: titulo, text: mensaje, timer: 5000, timerProgressBar: true, showConfirmButton: true, confirmButtonText: mensajeUrl, showCancelButton: true, cancelButtonText: 'Hacerlo mas tarde', allowOutsideClick: false }).then(function (result) { if (result.isConfirmed) { window.open(url, '_blank'); } }); }