Source: toast_module.js

  1. /*
  2. * Módulo para el despliegue de mensajes en la plataforma
  3. *
  4. * @module module_toast
  5. *
  6. */
  7. var toast_module = (function(verbose){
  8. var _toastr;
  9. var _VERBOSE = verbose;
  10. var _type_info = "info",
  11. _type_error = "error",
  12. _type_warning = "warning",
  13. _type_success = "success";
  14. /**
  15. * Método setter para el objeto que controla el despliegue de mensajes.
  16. *
  17. * @function _toastConfigure
  18. * @public
  19. *
  20. */
  21. function _toastConfigure(){
  22. _VERBOSE ? console.log("_toastConfigure") : _VERBOSE;
  23. _toastr = toastr;
  24. }
  25. function _displayMessage(message, type){
  26. if(type == _type_info){
  27. _toastr.info(message);
  28. }
  29. else if(type == _type_error){
  30. _toastr.error(message);
  31. }
  32. else if(type == _type_warning){
  33. _toastr.warning(message);
  34. }
  35. else if(type == _type_success){
  36. _toastr.success(message);
  37. }
  38. }
  39. function showToast_CenterCenter(message, type){
  40. _toastr.options = {
  41. "debug": false,
  42. "onclick": null,
  43. "fadeIn": 300,
  44. "fadeOut": 1000,
  45. "timeOut": 2000,
  46. "extendedTimeOut": 2000,
  47. "positionClass": "toast-center-center",
  48. "preventDuplicates": true,
  49. "progressBar": true
  50. };
  51. _displayMessage(message, type);
  52. }
  53. function showToast_BottomCenter(message, type){
  54. _toastr.options = {
  55. "debug": false,
  56. "onclick": null,
  57. "fadeIn": 300,
  58. "fadeOut": 1000,
  59. "timeOut": 2000,
  60. "extendedTimeOut": 2000,
  61. "positionClass": "toast-bottom-center",
  62. "preventDuplicates": true,
  63. "progressBar": true
  64. };
  65. _displayMessage(message, type);
  66. }
  67. // funcion pública que inicializa la configuración del mapa
  68. function startToast(){
  69. _VERBOSE ? console.log("startToast") : _VERBOSE;
  70. _toastConfigure();
  71. }
  72. return{
  73. showToast_CenterCenter: showToast_CenterCenter,
  74. showToast_BottomCenter: showToast_BottomCenter,
  75. startToast: startToast
  76. }
  77. });