You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.0 KiB
35 lines
1.0 KiB
<%= 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 %>
|