toastr.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. (function (global, factory) {
  2. if (typeof define === "function" && define.amd) {
  3. define("/Plugin/toastr", ["exports", "Plugin"], factory);
  4. } else if (typeof exports !== "undefined") {
  5. factory(exports, require("Plugin"));
  6. } else {
  7. var mod = {
  8. exports: {}
  9. };
  10. factory(mod.exports, global.Plugin);
  11. global.PluginToastr = mod.exports;
  12. }
  13. })(this, function (_exports, _Plugin2) {
  14. "use strict";
  15. Object.defineProperty(_exports, "__esModule", {
  16. value: true
  17. });
  18. _exports.default = void 0;
  19. _Plugin2 = babelHelpers.interopRequireDefault(_Plugin2);
  20. var NAME = 'toastr';
  21. var Toastr =
  22. /*#__PURE__*/
  23. function (_Plugin) {
  24. babelHelpers.inherits(Toastr, _Plugin);
  25. function Toastr() {
  26. babelHelpers.classCallCheck(this, Toastr);
  27. return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Toastr).apply(this, arguments));
  28. }
  29. babelHelpers.createClass(Toastr, [{
  30. key: "getName",
  31. value: function getName() {
  32. return NAME;
  33. }
  34. }, {
  35. key: "render",
  36. value: function render() {
  37. this.$el.data('toastrWrapApi', this);
  38. }
  39. }, {
  40. key: "show",
  41. value: function show(e) {
  42. if (typeof toastr === 'undefined') {
  43. return;
  44. }
  45. e.preventDefault();
  46. var options = this.options;
  47. var message = options.message || '';
  48. var type = options.type || 'info';
  49. var title = options.title || undefined;
  50. switch (type) {
  51. case 'success':
  52. toastr.success(message, title, options);
  53. break;
  54. case 'warning':
  55. toastr.warning(message, title, options);
  56. break;
  57. case 'error':
  58. toastr.error(message, title, options);
  59. break;
  60. case 'info':
  61. toastr.info(message, title, options);
  62. break;
  63. default:
  64. toastr.info(message, title, options);
  65. }
  66. }
  67. }], [{
  68. key: "api",
  69. value: function api() {
  70. return 'click|show';
  71. }
  72. }]);
  73. return Toastr;
  74. }(_Plugin2.default);
  75. _Plugin2.default.register(NAME, Toastr);
  76. var _default = Toastr;
  77. _exports.default = _default;
  78. });