Requires

Provides

Menu.js

Dropdowns should be easy to use.

License:
Public domain (http://unlicense.org).
Authors:
Yaroslaff Fedin
  1. 23
  2. 24
  3. 25
  4. 26
  5. 27
  6. 28
  7. 29
  8. 30
  9. 31
  10. 32
  11. 33
  12. 34
  13. 35
  14. 36
  15. 37
  16. 38
  17. 39
  18. 40
  19. 41
  20. 42
  21. 43
  22. 44
  23. 45
  24. 46
  25. 47
  26. 48
  27. 49
  28. 50
  29. 51
  30. 52
  31. 53
  32. 54
  33. 55
  34. 56
  35. 57
  36. 58
  37. 59
  38. 60
  39. 61
  40. 62
  41. 63
  42. 64
  43. 65
  44. 66
  45. 67
  46. 68
  47. 69
  48. 70
  49. 71
  50. 72
  51. 73
  52. 74
  53. 75
  54. 76
  55. 77
  56. 78
  57. 79
  58. 80
  59. 81
  60. 82
  61. 83
  62. 84
  63. 85
  64. 86
  65. 87
  66. 88
  67. 89
  68. 90
  69. 91
  70. 92
  71. 93
  72. 94
  73. 95
  74. 96
  75. 97
  76. 98
  77. 99
  78. 100
  79. 101
  80. 102
  81. 103
  82. 104
  83. 105
  84. 106
  85. 107
  86. 108
  87. 109
  88. 110
  89. 111
  90. 112
  91. 113
  92. 114
  93. 115
  94. 116
LSD.Trait.Menu = new Class({ options: { shortcuts: { ok: 'set', cancel: 'cancel' }, events: { _menu: { self: { expand: 'makeItems', redraw: 'repositionMenu', focus: 'repositionMenu', blur: 'collapse', next: 'expand', previous: 'expand', cancel: 'collapse' } } }, menu: { position: 'top', width: 'auto', origin: null }, has: { one: { menu: { selector: 'menu[type=context]', proxy: function(widget) { return widget.pseudos.item; }, states: { set: { expanded: 'hidden' } } } } }, states: Array.fast('expanded') }, cancel: function() { this.collapse(); }, set: function() { this.collapse(); }, repositionMenu: function() { if (!this.menu || this.collapsed) return; var top = 0; var origin = (this.options.menu.origin == 'document') ? this.document : this; if (!origin.size) origin.setSize(true); if (!this.menu.size) this.menu.setSize(true); var position = LSD.position(origin.size, this.menu.size) if (position.x != null) { position.x += (this.offset.padding.left || 0) - (this.offset.inside.left || 0) + (this.offset.outside.left || 0); this.menu.setStyle('left', position.x); } if (position.y != null) { position.y += (this.offset.padding.top || 0) - (this.offset.inside.top || 0) + (this.offset.outside.top || 0); this.menu.setStyle('top', position.y); } switch (this.options.menu.width) { case "adapt": this.menu.setWidth(this.getStyle('width')); break; case "auto": break; } }, buildMenu: function() { return this.buildLayout(this.options.layout.menu); }, expand: function() { if (!this.menu) { this.menu = this.buildMenu(); this.repositionMenu(); if (this.hasItems()) this.refresh(); } else { this.repositionMenu(); } if (this.hasItems()) this.menu.show(); else this.menu.hide(); }, getSelectedOptionPosition: function() { return 0 } });