Files
easy-going-rails/app/views/layouts/_notification.html.erb
T
2024-07-03 15:17:26 +04:00

36 lines
1.0 KiB
ERB

<%= turbo_frame_tag 'notification' do %>
<% if flash.count.positive? %>
<script>
var commonOptions
var noticeOptions
var alertOptions
if (typeof commonOptions === 'undefined'){
commonOptions={
gravity: 'top',
position: 'center',
duration: 4000,
offset: { y: '1em' },
close: true
}
noticeOptions={ className: 'toastify-notice', ...commonOptions }
alertOptions={ className: 'toastify-alert', ...commonOptions }
}
var notice='<%= flash.notice %>'
var alert='<%= flash.alert %>'
<% flash.clear %>
if (notice.length>0){
console.info(`TOAST notice: ${notice}`)
Toastify({ text: notice, ...noticeOptions }).showToast();
notice=''
}
if (alert.length>0){
console.warn(`TOAST alert: ${alert}`)
Toastify({ text: alert, ...alertOptions }).showToast();
alert=''
}
</script>
<% end %>
<% end %>