toastr-config.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // ===== GLOBAL TOASTR CONFIGURATION =====
  2. // This file configures the behavior of toastr notifications throughout the application
  3. // Configure toastr as soon as jQuery is available
  4. (function() {
  5. function initToastr() {
  6. // Check that jQuery and toastr are available
  7. if (typeof $ === 'undefined' || typeof toastr === 'undefined') {
  8. console.warn('jQuery or toastr are not available yet');
  9. return false;
  10. }
  11. // Toastr configuration
  12. toastr.options = {
  13. closeButton: true,
  14. debug: false,
  15. newestOnTop: false, // false = new notifications appear BELOW
  16. progressBar: true,
  17. positionClass: "toast-top-right",
  18. preventDuplicates: false,
  19. onclick: null,
  20. showDuration: 300,
  21. hideDuration: 1000,
  22. timeOut: 10000, // 10 seconds
  23. extendedTimeOut: 2000,
  24. showEasing: "swing",
  25. hideEasing: "linear",
  26. showMethod: "fadeIn",
  27. hideMethod: "fadeOut",
  28. tapToDismiss: true
  29. };
  30. return true;
  31. }
  32. // Try to configure immediately
  33. if (initToastr()) {
  34. return; // Already configured
  35. }
  36. // If it doesn't work, wait for DOMContentLoaded
  37. if (document.readyState === 'loading') {
  38. document.addEventListener('DOMContentLoaded', function() {
  39. setTimeout(initToastr, 100);
  40. });
  41. } else {
  42. setTimeout(initToastr, 100);
  43. }
  44. // Also try on window.load just in case
  45. window.addEventListener('load', function() {
  46. setTimeout(initToastr, 100);
  47. });
  48. })();