admin
2020-12-08 7f2d1daf6af6ecebad84d80de46a0e5024bbf5da
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Component({
  props: {
    alphabet: []
  },
  data: {
    current: -1
  },
  didMount: function didMount() {
    this._updateDataSet();
  },
  didUpdate: function didUpdate() {
    this._updateDataSet();
  },
  methods: {
    _updateDataSet: function _updateDataSet() {
      this.dataset = {};
 
      for (var key in this.props) {
        if (/data-/gi.test(key)) {
          this.dataset[key.replace(/data-/gi, '')] = this.props[key];
        }
      }
    },
    onItemTap: function onItemTap(ev) {
      var _this$props = this.props,
          onClick = _this$props.onClick,
          disabled = _this$props.disabled;
 
      if (onClick && !disabled) {
        onClick({
          data: ev.target.dataset,
          target: {
            dataset: this.dataset
          }
        });
      }
    },
    onTouchStart: function onTouchStart(ev) {
      var disabled = this.props.disabled;
 
      if (!disabled) {
        this.setData({
          current: ev.target.dataset.index
        });
      }
    },
    onTouchEnd: function onTouchEnd() {
      this.setData({
        current: -1
      });
    }
  }
});