templates/partials/_flashes.html.twig line 1

Open in your IDE?
  1. {% for label, messages in app.flashes %}
  2.     {% for message in messages %}
  3.         <script>
  4.             (function() {
  5.                 function showFlash() {
  6.                     if (window.Swal && window.Swal.fire) {
  7.                         const icons = { 
  8.                             success: 'success', 
  9.                             danger: 'error', 
  10.                             warning: 'warning', 
  11.                             info: 'info' 
  12.                         };
  13.                         
  14.                         Swal.fire({
  15.                             toast: true,
  16.                             position: 'bottom-end',
  17.                             icon: icons['{{ label }}'] || 'info',
  18.                             title: "{{ message|e('js') }}",
  19.                             showConfirmButton: false,
  20.                             timer: 2000,
  21.                             width: '430px',
  22.                             customClass: {
  23.                                 popup: 'toast-slide toast-offset'
  24.                             },
  25.                             showClass: {
  26.                                 popup: 'animate__animated animate__slideInUp'
  27.                             },
  28.                             hideClass: {
  29.                                 popup: 'animate__animated animate__slideOutDown'
  30.                             }
  31.                         });
  32.                     } else {
  33.                         // Reintentar después de 100ms
  34.                         setTimeout(showFlash, 100);
  35.                     }
  36.                 }
  37.                 
  38.                 // Iniciar cuando el DOM esté listo
  39.                 if (document.readyState === 'loading') {
  40.                     document.addEventListener('DOMContentLoaded', showFlash);
  41.                 } else {
  42.                     showFlash();
  43.                 }
  44.             })();
  45.         </script>
  46.     {% endfor %}
  47. {% endfor %}