openclassify/addons/default/visiosoft/base-theme/resources/views/partials/messages.twig
2021-08-17 12:33:42 +03:00

54 lines
1.5 KiB
Twig

<script>
const Toast = Swal.mixin({
toast: true,
position: 'top-end',
showConfirmButton: false,
timer: 3000,
timerProgressBar: true,
didOpen: (toast) => {
toast.addEventListener('mouseenter', Swal.stopTimer)
toast.addEventListener('mouseleave', Swal.resumeTimer)
}
})
// Success Messages
{% if message_exists('success') %}
{% for message in message_pull('success') %}
Toast.fire({
icon: 'success',
title: `{{ trans(message)|markdown }}`,
})
{% endfor %}
{% endif %}
// Informational Messages
{% if message_exists('info') %}
{% for message in message_pull('info') %}
Toast.fire({
icon: 'info',
title: `{{ trans(message)|markdown }}`,
})
{% endfor %}
{% endif %}
// Warning Messages
{% if message_exists('warning') %}
{% for message in message_pull('warning') %}
Toast.fire({
icon: 'warning',
title: `{{ trans(message)|markdown }}`,
})
{% endfor %}
{% endif %}
// Error Messages
{% if message_exists('error') %}
{% for message in message_pull('error') %}
Toast.fire({
icon: 'error',
title: `{{ trans(message)|markdown }}`,
})
{% endfor %}
{% endif %}
</script>