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