ItemRenderer.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. var t = require;
  2. var e = module;
  3. var i = exports;
  4. var o,
  5. e =
  6. (this && this.__decorate) ||
  7. function(t, e, i, s) {
  8. var o,
  9. a = arguments.length,
  10. n = a < 3 ? e : null === s ? (s = Object.getOwnPropertyDescriptor(e, i)) : s;
  11. if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(t, e, i, s);
  12. else
  13. for (var r = t.length - 1; 0 <= r; r--)
  14. (o = t[r]) && (n = (a < 3 ? o(n) : 3 < a ? o(e, i, n) : o(e, i)) || n);
  15. return 3 < a && n && Object.defineProperty(e, i, n), n;
  16. };
  17. Object.defineProperty(i, "__esModule", { value: !0 });
  18. const a = t("ListView"),
  19. { ccclass: s, property: n, menu: r } = cc._decorator;
  20. t = o = class extends cc.Component {
  21. constructor() {
  22. super(...arguments),
  23. (this.data = null),
  24. (this.recycled = !1),
  25. (this.nodeSelected = null),
  26. (this.nodeUnselected = null),
  27. (this.nodeDisableSelected = null);
  28. }
  29. onSelected() {
  30. this.nodeSelected && (this.nodeSelected.active = !0), this.nodeUnselected && (this.nodeUnselected.active = !1);
  31. }
  32. isSelected() {
  33. return this.listView.selectedItems.include(this.data);
  34. }
  35. onClickSelected() {
  36. this.onSelected();
  37. }
  38. onCancelSelected() {
  39. this.onUnselected();
  40. }
  41. onUnselected() {
  42. this.nodeSelected && (this.nodeSelected.active = !1), this.nodeUnselected && (this.nodeUnselected.active = !0);
  43. }
  44. onEnableSelect() {
  45. this.nodeDisableSelected && (this.nodeDisableSelected.active = !1);
  46. }
  47. onDisableSelect() {
  48. this.nodeDisableSelected && (this.nodeDisableSelected.active = !0);
  49. }
  50. onDestroy() {}
  51. dataChanged(t) {}
  52. setData(e, t = !1) {
  53. var i,
  54. s = this;
  55. (this.data && this.data === e && !t && !this.recycled) ||
  56. ((i = this.data),
  57. (this.data = e),
  58. this.dataChanged(i),
  59. 1 < (t = this.getComponents(o)).length &&
  60. t.forEach(function(t) {
  61. t != s && ((t.data = e), t.dataChanged(i));
  62. })),
  63. this.listView && this.listView.node.emit(a.ListViewEvent.ITEM_DATA_CHANGED, this);
  64. }
  65. reportItemTapped() {
  66. this.listView ? this.listView.onItemTap(this) : this.node.emit(a.ListViewEvent.ITEM_TAP, this.data);
  67. }
  68. checkSelect(t) {
  69. return !0;
  70. }
  71. };
  72. e([n(cc.Node)], t.prototype, "nodeSelected", void 0),
  73. e([n(cc.Node)], t.prototype, "nodeUnselected", void 0),
  74. e([n(cc.Node)], t.prototype, "nodeDisableSelected", void 0),
  75. (t = o = e([s], t)),
  76. (i.default = t = o);