Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

notification.js 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. export class SovNotification {
  2. static init() {
  3. toastr.options.timeOut = 3000;
  4. toastr.options.positionClass = 'toast-bottom-right';
  5. toastr.options.onHidden = function () {
  6. if ($('#toast-container .toast').length == 1) {
  7. $('#toast-close-all').remove();
  8. }
  9. };
  10. }
  11. static set(notifications) {
  12. var currentNotifications = new Array();
  13. for (var type in notifications) {
  14. for (var key in notifications[type]) {
  15. if (!currentNotifications.includes(notifications[type][key])) {
  16. currentNotifications.push(notifications[type][key]);
  17. self.add(type, notifications[type][key]);
  18. }
  19. }
  20. }
  21. }
  22. static add(type, text) {
  23. toastr[type](text);
  24. let $container = $('#toast-container') ;
  25. let selectorButtonCloseAll = '#toast-close-all' ;
  26. let countMessages = $container.find('.toast').length ;
  27. if ($(selectorButtonCloseAll).length == 0 && countMessages > 2) {
  28. $container.prepend('<button id="toast-close-all"><i class="fa fa-times"></i></button>');
  29. }
  30. $(selectorButtonCloseAll).off('click').on('click', function () {
  31. toastr.remove();
  32. if (countMessages == 0) {
  33. $('#toast-close-all').remove();
  34. }
  35. });
  36. }
  37. }