|
|
@ -1,28 +1,35 @@ |
|
|
|
<%= turbo_frame_tag 'notification' do %> |
|
|
|
<% if flash.count.positive? %> |
|
|
|
<script data-turbo-temporary> |
|
|
|
document.addEventListener('turbo:load',(e)=>{ |
|
|
|
|
|
|
|
const common={ |
|
|
|
<script> |
|
|
|
var commonOptions |
|
|
|
var noticeOptions |
|
|
|
var alertOptions |
|
|
|
if (typeof commonOptions === 'undefined'){ |
|
|
|
commonOptions={ |
|
|
|
gravity: 'top', |
|
|
|
position: 'center', |
|
|
|
duration: 4000, |
|
|
|
offset: { y: '1em' }, |
|
|
|
close: true |
|
|
|
} |
|
|
|
const notice={ className: 'toastify-notice', ...common } |
|
|
|
const alert={ className: 'toastify-alert', ...common } |
|
|
|
|
|
|
|
<% if flash.notice%> |
|
|
|
Toastify({ text: '<%=flash.notice%>', ...notice}).showToast(); |
|
|
|
<%end%> |
|
|
|
|
|
|
|
<% if flash.alert%> |
|
|
|
Toastify({ text: '<%=flash.alert%>', ...alert}).showToast(); |
|
|
|
<%end%> |
|
|
|
noticeOptions={ className: 'toastify-notice', ...commonOptions } |
|
|
|
alertOptions={ className: 'toastify-alert', ...commonOptions } |
|
|
|
} |
|
|
|
|
|
|
|
// useful to prevent flickering from turbo preview |
|
|
|
Turbo.cache.exemptPageFromPreview() |
|
|
|
var notice='<%= flash.notice %>' |
|
|
|
var alert='<%= flash.alert %>' |
|
|
|
<% flash.clear %> |
|
|
|
|
|
|
|
}, {once: true}) |
|
|
|
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 %> |