abp.toastr.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. (function (define) {
  2. define(['toastr', 'abp-web-resources'], function (toastr, abp) {
  3. return (function () {
  4. if (!toastr) {
  5. return;
  6. }
  7. if (!abp) {
  8. return;
  9. }
  10. /* DEFAULTS *************************************************/
  11. toastr.options.positionClass = 'toast-bottom-right';
  12. /* NOTIFICATION *********************************************/
  13. var showNotification = function (type, message, title, options) {
  14. toastr[type](message, title, options);
  15. };
  16. abp.notify.success = function (message, title, options) {
  17. showNotification('success', message, title, options);
  18. };
  19. abp.notify.info = function (message, title, options) {
  20. showNotification('info', message, title, options);
  21. };
  22. abp.notify.warn = function (message, title, options) {
  23. showNotification('warning', message, title, options);
  24. };
  25. abp.notify.error = function (message, title, options) {
  26. showNotification('error', message, title, options);
  27. };
  28. return abp;
  29. })();
  30. });
  31. }(typeof define === 'function' && define.amd
  32. ? define
  33. : function (deps, factory) {
  34. if (typeof module !== 'undefined' && module.exports) {
  35. module.exports = factory(require('toastr'), require('abp-web-resources'));
  36. } else {
  37. window.abp = factory(window.toastr, window.abp);
  38. }
  39. }));