Requires

Provides

Select.js

Basic selectbox

License:
Public domain (http://unlicense.org).
Authors:
Yaroslaff Fedin
  1. 31
  2. 32
  3. 33
  4. 34
  5. 35
  6. 36
  7. 37
  8. 38
  9. 39
  10. 40
  11. 41
  12. 42
  13. 43
  14. 44
  15. 45
  16. 46
  17. 47
  18. 48
  19. 49
  20. 50
  21. 51
  22. 52
  23. 53
  24. 54
  25. 55
  26. 56
  27. 57
  28. 58
  29. 59
  30. 60
  31. 61
  32. 62
  33. 63
  34. 64
  35. 65
  36. 66
  37. 67
  38. 68
  39. 69
  40. 70
  41. 71
  42. 72
  43. 73
  44. 74
  45. 75
  46. 76
  47. 77
  48. 78
  49. 79
  50. 80
  51. 81
  52. 82
  53. 83
  54. 84
  55. 85
  56. 86
  57. 87
  58. 88
  59. 89
  60. 90
  61. 91
  62. 92
  63. 93
  64. 94
  65. 95
  66. 96
  67. 97
  68. 98
  69. 99
  70. 100
  71. 101
  72. 102
  73. 103
  74. 104
  75. 105
  76. 106
  77. 107
  78. 108
  79. 109
  80. 110
  81. 111
  82. 112
  83. 113
  84. 114
  85. 115
LSD.Widget.Select = new Class({ Includes: [ LSD.Widget.Paint, LSD.Trait.Menu.Stateful, LSD.Trait.List, LSD.Trait.Choice, LSD.Trait.Value, LSD.Trait.Accessibility, LSD.Trait.Proxies ], options: { tag: 'select', layout: { item: '^option', children: { '^button': {} } }, events: { element: { click: 'expand' }, self: { set: function(item) { this.setValue(item.getValue()); this.collapse(); }, collapse: 'forgetChosenItem' }, _items: { element: { 'mouseover:on(option)': function() { if (!this.chosen) this.listWidget.selectItem(this, true) }, 'click:on(option)': function(e) { if (!this.selected) { this.listWidget.selectItem(this); e.stop() } else this.listWidget.collapse(); this.forget() } } } }, shortcuts: { 'ok': 'selectChosenItem' }, menu: { position: 'focus', width: 'adapt' }, writable: true } }); LSD.Widget.Select.Button = new Class({ Extends: LSD.Widget.Button }); LSD.Widget.Select.Option = new Class({ Includes: [ LSD.Widget.Paint, LSD.Trait.Value, LSD.Trait.Item.Stateful ], States: { chosen: ['choose', 'forget'] }, options: { tag: 'option' }, getValue: function() { if (this.attributes && this.attributes.value) this.value = this.attributes.value; return this.parent.apply(this, arguments); }, setContent: function() { return (this.value = this.parent.apply(this, arguments)); } });