notie-js.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. (function (global, factory) {
  2. if (typeof define === "function" && define.amd) {
  3. define("/Plugin/notie-js", ["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.PluginNotieJs = 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 = 'notie';
  21. var Notie =
  22. /*#__PURE__*/
  23. function (_Plugin) {
  24. babelHelpers.inherits(Notie, _Plugin);
  25. function Notie() {
  26. babelHelpers.classCallCheck(this, Notie);
  27. return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Notie).apply(this, arguments));
  28. }
  29. babelHelpers.createClass(Notie, [{
  30. key: "getName",
  31. value: function getName() {
  32. return NAME;
  33. }
  34. }, {
  35. key: "render",
  36. value: function render() {
  37. this.$el.data('notieApi', this);
  38. }
  39. }, {
  40. key: "show",
  41. value: function show() {
  42. var options = this.options;
  43. if (options.type !== undefined) {
  44. switch (options.type) {
  45. case 'confirm':
  46. notie.confirm(Object.assign(options, {
  47. submitCallback: function submitCallback() {
  48. if (options.submitCallback && typeof window[options.submitCallback] === 'function') {
  49. window[options.submitCallback]();
  50. } else {
  51. notie.alert({
  52. type: 1,
  53. text: options.submitMsg,
  54. time: 1.5
  55. });
  56. }
  57. },
  58. cancelCallback: function cancelCallback() {
  59. if (options.cancelCallback && typeof window[options.cancelCallback] === 'function') {
  60. window[options.cancelCallback]();
  61. } else {
  62. notie.alert({
  63. type: 3,
  64. text: options.cancelMsg,
  65. time: 1.5
  66. });
  67. }
  68. }
  69. }));
  70. break;
  71. case 'input':
  72. notie.input(Object.assign(options, {
  73. submitCallback: function submitCallback(value) {
  74. if (options.submitCallback && typeof window[options.submitCallback] === 'function') {
  75. window[options.submitCallback](value);
  76. } else {
  77. notie.alert({
  78. type: 1,
  79. text: "you entered: ".concat(value),
  80. time: 1.5
  81. });
  82. }
  83. },
  84. cancelCallback: function cancelCallback(value) {
  85. if (options.cancelCallback && typeof window[options.cancelCallback] === 'function') {
  86. window[options.cancelCallback](value);
  87. } else {
  88. notie.alert({
  89. type: 1,
  90. text: "You cancelled with this value: ".concat(value),
  91. time: 1.5
  92. });
  93. }
  94. }
  95. }));
  96. break;
  97. case 'select':
  98. notie.select(options);
  99. break;
  100. case 'date':
  101. notie.date(options);
  102. break;
  103. default:
  104. notie.alert(options);
  105. }
  106. }
  107. }
  108. }], [{
  109. key: "api",
  110. value: function api() {
  111. return 'click|show';
  112. }
  113. }]);
  114. return Notie;
  115. }(_Plugin2.default);
  116. _Plugin2.default.register(NAME, Notie);
  117. var _default = Notie;
  118. _exports.default = _default;
  119. });