Modal.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
  7. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  8. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  10. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11. var Modal =
  12. /*#__PURE__*/
  13. function () {
  14. function Modal(time) {
  15. _classCallCheck(this, Modal);
  16. this.time = time;
  17. }
  18. _createClass(Modal, [{
  19. key: "setDuration",
  20. value: function setDuration(d) {
  21. this.time = d;
  22. }
  23. }, {
  24. key: "create",
  25. value: function create(html, options) {
  26. window.Materialize ? window.Materialize.toast(html, this.time) : window.M && window.M.toast(_objectSpread({
  27. html: html,
  28. displayLength: this.time
  29. }, options));
  30. }
  31. }, {
  32. key: "success",
  33. value: function success(html) {
  34. this.create(html, {
  35. classes: " green darken-3"
  36. });
  37. }
  38. }, {
  39. key: "notify",
  40. value: function notify(html) {
  41. this.create(html, {
  42. classes: "blue lighten-2"
  43. });
  44. }
  45. }, {
  46. key: "warning",
  47. value: function warning(html) {
  48. this.create(html, {
  49. classes: "orange lighten-2"
  50. });
  51. }
  52. }, {
  53. key: "error",
  54. value: function error(html) {
  55. this.create(html, {
  56. classes: "red lighten-2"
  57. });
  58. }
  59. }, {
  60. key: "clear",
  61. value: function clear() {}
  62. }]);
  63. return Modal;
  64. }();
  65. var _default = new Modal(5000);
  66. exports.default = _default;