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

4 months ago
10 months ago
10 months ago
4 months ago
10 months ago
4 months ago
  1. <%= turbo_frame_tag 'notification' do %>
  2. <% if flash.count.positive? %>
  3. <script>
  4. var commonOptions
  5. var noticeOptions
  6. var alertOptions
  7. if (typeof commonOptions === 'undefined'){
  8. commonOptions={
  9. gravity: 'top',
  10. position: 'center',
  11. duration: 4000,
  12. offset: { y: '1em' },
  13. close: true
  14. }
  15. noticeOptions={ className: 'toastify-notice', ...commonOptions }
  16. alertOptions={ className: 'toastify-alert', ...commonOptions }
  17. }
  18. var notice='<%= flash.notice %>'
  19. var alert='<%= flash.alert %>'
  20. <% flash.clear %>
  21. if (notice.length>0){
  22. console.info(`TOAST notice: ${notice}`)
  23. Toastify({ text: notice, ...noticeOptions }).showToast();
  24. notice=''
  25. }
  26. if (alert.length>0){
  27. console.warn(`TOAST alert: ${alert}`)
  28. Toastify({ text: alert, ...alertOptions }).showToast();
  29. alert=''
  30. }
  31. </script>
  32. <% end %>
  33. <% end %>