您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

47 行
1.4KB

  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. SovNotification.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. }