custom-input.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. "use strict";
  2. var processDataSet = require('../utils/processDataSet');
  3. Component({
  4. props: {
  5. value: '',
  6. type: '',
  7. password: false,
  8. placeholder: '',
  9. placeholderStyle: '',
  10. placeholderClass: '',
  11. disabled: false,
  12. maxlength: 140,
  13. focus: false,
  14. confirmType: 'done',
  15. confirmHold: false,
  16. cursor: 0,
  17. selectionStart: -1,
  18. selectionEnd: -1,
  19. name: '',
  20. onInput: function onInput() {},
  21. onFocus: function onFocus() {},
  22. onBlur: function onBlur() {},
  23. onConfirm: function onConfirm() {},
  24. onTap: function onTap() {},
  25. catchTap: function catchTap() {}
  26. },
  27. methods: {
  28. inputHandler: function inputHandler(e) {
  29. if (this.props.onInput) {
  30. var tapEvent = processDataSet(e, this.props);
  31. this.props.onInput(tapEvent);
  32. }
  33. },
  34. focusHandler: function focusHandler(e) {
  35. if (this.props.onFocus) {
  36. var tapEvent = processDataSet(e, this.props);
  37. this.props.onFocus(tapEvent);
  38. }
  39. },
  40. blurHandler: function blurHandler(e) {
  41. if (this.props.onBlur) {
  42. var tapEvent = processDataSet(e, this.props);
  43. this.props.onBlur(tapEvent);
  44. }
  45. },
  46. bindconfirmHandler: function bindconfirmHandler(e) {
  47. if (this.props.onConfirm) {
  48. var tapEvent = processDataSet(e, this.props);
  49. this.props.onConfirm(tapEvent);
  50. }
  51. },
  52. tapHandler: function tapHandler(e) {
  53. var tapEvent = processDataSet(e, this.props);
  54. this.props.onTap && this.props.onTap(tapEvent);
  55. },
  56. catchtapHandler: function catchtapHandler(e) {
  57. var tapEvent = processDataSet(e, this.props);
  58. this.props.catchTap && this.props.catchTap(tapEvent);
  59. }
  60. }
  61. });