ladda.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. (function (global, factory) {
  2. if (typeof define === "function" && define.amd) {
  3. define("/Plugin/ladda", ["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.PluginLadda = 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 = 'ladda';
  21. var LaddaPlugin =
  22. /*#__PURE__*/
  23. function (_Plugin) {
  24. babelHelpers.inherits(LaddaPlugin, _Plugin);
  25. function LaddaPlugin() {
  26. babelHelpers.classCallCheck(this, LaddaPlugin);
  27. return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(LaddaPlugin).apply(this, arguments));
  28. }
  29. babelHelpers.createClass(LaddaPlugin, [{
  30. key: "getName",
  31. value: function getName() {
  32. return NAME;
  33. }
  34. }, {
  35. key: "render",
  36. value: function render() {
  37. if (typeof Ladda === 'undefined') {
  38. return;
  39. }
  40. if (this.options.type === 'progress') {
  41. this.options.callback = function (instance) {
  42. var progress = 0;
  43. var interval = setInterval(function () {
  44. progress = Math.min(progress + Math.random() * 0.1, 1);
  45. instance.setProgress(progress);
  46. if (progress === 1) {
  47. instance.stop();
  48. clearInterval(interval);
  49. }
  50. }, 200);
  51. };
  52. }
  53. Ladda.bind(this.$el[0], this.options);
  54. }
  55. }], [{
  56. key: "getDefaults",
  57. value: function getDefaults() {
  58. return {
  59. type: 'normal',
  60. timeout: 2000
  61. };
  62. }
  63. }]);
  64. return LaddaPlugin;
  65. }(_Plugin2.default);
  66. _Plugin2.default.register(NAME, LaddaPlugin);
  67. var _default = LaddaPlugin;
  68. _exports.default = _default;
  69. });