input-group-file.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. (function (global, factory) {
  2. if (typeof define === "function" && define.amd) {
  3. define("/Plugin/input-group-file", ["exports", "jquery", "Plugin"], factory);
  4. } else if (typeof exports !== "undefined") {
  5. factory(exports, require("jquery"), require("Plugin"));
  6. } else {
  7. var mod = {
  8. exports: {}
  9. };
  10. factory(mod.exports, global.jQuery, global.Plugin);
  11. global.PluginInputGroupFile = mod.exports;
  12. }
  13. })(this, function (_exports, _jquery, _Plugin2) {
  14. "use strict";
  15. Object.defineProperty(_exports, "__esModule", {
  16. value: true
  17. });
  18. _exports.default = void 0;
  19. _jquery = babelHelpers.interopRequireDefault(_jquery);
  20. _Plugin2 = babelHelpers.interopRequireDefault(_Plugin2);
  21. var NAME = 'inputGroupFile';
  22. var InputGroupFile =
  23. /*#__PURE__*/
  24. function (_Plugin) {
  25. babelHelpers.inherits(InputGroupFile, _Plugin);
  26. function InputGroupFile() {
  27. babelHelpers.classCallCheck(this, InputGroupFile);
  28. return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(InputGroupFile).apply(this, arguments));
  29. }
  30. babelHelpers.createClass(InputGroupFile, [{
  31. key: "getName",
  32. value: function getName() {
  33. return NAME;
  34. }
  35. }, {
  36. key: "render",
  37. value: function render() {
  38. this.$file = this.$el.find('[type=file]');
  39. this.$text = this.$el.find('.form-control');
  40. }
  41. }, {
  42. key: "change",
  43. value: function change() {
  44. var value = '';
  45. _jquery.default.each(this.$file[0].files, function (i, file) {
  46. value += "".concat(file.name, ", ");
  47. });
  48. value = value.substring(0, value.length - 2);
  49. this.$text.val(value);
  50. }
  51. }], [{
  52. key: "api",
  53. value: function api() {
  54. return 'change|change';
  55. }
  56. }]);
  57. return InputGroupFile;
  58. }(_Plugin2.default);
  59. _Plugin2.default.register(NAME, InputGroupFile);
  60. var _default = InputGroupFile;
  61. _exports.default = _default;
  62. });