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.1KB

  1. export class Notification {
  2. static setNotifications(notifications) {
  3. var currentNotifications = new Array();
  4. for (var type in notifications) {
  5. for (var key in notifications[type]) {
  6. if (!currentNotifications.includes(notifications[type][key])) {
  7. currentNotifications.push(notifications[type][key]);
  8. self.addNotification(type, notifications[type][key]);
  9. }
  10. }
  11. }
  12. }
  13. static addNotification(type, text) {
  14. toastr.options.timeOut = 3000;
  15. toastr.options.onHidden = function () {
  16. if ($('#toast-container .toast').length == 0) $('#toast-close-all').remove();
  17. };
  18. toastr[type](text);
  19. if ($('#toast-close-all').length == 0) {
  20. $('#toast-container').prepend('<button id="toast-close-all"><i class="fa fa-times"></i></button>');
  21. }
  22. $('#toast-close-all').off('click');
  23. $('#toast-close-all').on('click', function () {
  24. toastr.remove();
  25. if ($('#toast-container .toast').length == 0) $('#toast-close-all').remove();
  26. });
  27. }
  28. }