not really known
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.7 KiB

  1. /**
  2. A control designed to display a group of stacked items, typically used in
  3. lists. Items are displayed with small guide lines between them; by default,
  4. they are highlighted when tapped. Set *tapHighlight* to false to prevent the
  5. highlighting.
  6. {kind: "onyx.Item", tapHighlight: false}
  7. */
  8. enyo.kind({
  9. name: "onyx.Item",
  10. classes: "onyx-item",
  11. tapHighlight: true,
  12. handlers: {
  13. onhold: "hold",
  14. onrelease: "release"
  15. },
  16. //* @public
  17. hold: function(inSender, inEvent) {
  18. if (this.tapHighlight) {
  19. onyx.Item.addFlyweightClass(this.controlParent || this, "onyx-highlight", inEvent);
  20. }
  21. },
  22. //* @public
  23. release: function(inSender, inEvent) {
  24. if (this.tapHighlight) {
  25. onyx.Item.removeFlyweightClass(this.controlParent || this, "onyx-highlight", inEvent);
  26. }
  27. },
  28. //* @protected
  29. statics: {
  30. addFlyweightClass: function(inControl, inClass, inEvent, inIndex) {
  31. var flyweight = inEvent.flyweight;
  32. if (flyweight) {
  33. var index = inIndex != undefined ? inIndex : inEvent.index;
  34. flyweight.performOnRow(index, function() {
  35. if (!inControl.hasClass(inClass)) {
  36. inControl.addClass(inClass);
  37. } else {
  38. inControl.setClassAttribute(inControl.getClassAttribute());
  39. }
  40. });
  41. inControl.removeClass(inClass);
  42. }
  43. },
  44. // FIXME: dry
  45. removeFlyweightClass: function(inControl, inClass, inEvent, inIndex) {
  46. var flyweight = inEvent.flyweight;
  47. if (flyweight) {
  48. var index = inIndex != undefined ? inIndex : inEvent.index;
  49. flyweight.performOnRow(index, function() {
  50. if (!inControl.hasClass(inClass)) {
  51. inControl.setClassAttribute(inControl.getClassAttribute());
  52. } else {
  53. inControl.removeClass(inClass);
  54. }
  55. });
  56. }
  57. }
  58. }
  59. });