Source

libs/alerts.js

  1. /**
  2. * @category Libs
  3. * @module alerts */
  4. import dependencies from '../data/dependencies';
  5. const NotiPop = dependencies.require('NotiPop');
  6. /**
  7. * Show error message
  8. * @param {string} params - Object.
  9. */
  10. export function error(params) {
  11. let msg, title, timer;
  12. if (params instanceof Object) {
  13. msg = params.msg;
  14. title = params.title;
  15. timer = params.timer;
  16. } else if (typeof params === 'string') {
  17. msg = params;
  18. }
  19. new NotiPop({ text: msg, type: NotiPop.ERROR, title: title, timer: timer });
  20. }
  21. /**
  22. * Show info message
  23. * @param {string} params - Object.
  24. */
  25. export function info(params) {
  26. let msg, title, timer;
  27. if (params instanceof Object) {
  28. msg = params.msg;
  29. title = params.title;
  30. timer = params.timer;
  31. } else if (typeof params === 'string') {
  32. msg = params;
  33. }
  34. new NotiPop({ text: msg, type: NotiPop.INFO, title: title, timer: timer });
  35. }
  36. /**
  37. * Show success message
  38. * @param {string} params - Object.
  39. */
  40. export function success(params) {
  41. let msg, title, timer;
  42. if (params instanceof Object) {
  43. msg = params.msg;
  44. title = params.title;
  45. timer = params.timer;
  46. } else if (typeof params === 'string') {
  47. msg = params;
  48. }
  49. new NotiPop({ text: msg, type: NotiPop.SUCCESS, title: title, timer: timer });
  50. }
  51. /**
  52. * Show warning message
  53. * @param {string} params - Object.
  54. */
  55. export function warning(params) {
  56. let msg, title, timer;
  57. if (params instanceof Object) {
  58. msg = params.msg;
  59. title = params.title;
  60. timer = params.timer;
  61. } else if (typeof params === 'string') {
  62. msg = params;
  63. }
  64. new NotiPop({ text: msg, type: NotiPop.WARNING, title: title, timer: timer });
  65. }
  66. export default {
  67. error,
  68. info,
  69. success,
  70. warning,
  71. };