glimmer-dsl-opal 0.7.2 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +41 -0
  3. data/README.md +745 -82
  4. data/VERSION +1 -1
  5. data/lib/glimmer-dsl-opal.rb +14 -1
  6. data/lib/glimmer-dsl-opal/ext/class.rb +10 -0
  7. data/lib/{file.rb → glimmer-dsl-opal/ext/file.rb} +0 -0
  8. data/lib/glimmer-dsl-opal/ext/glimmer/dsl/engine.rb +30 -0
  9. data/lib/glimmer-dsl-opal/samples/elaborate/contact_manager.rb +50 -23
  10. data/lib/glimmer-dsl-opal/samples/elaborate/login.rb +22 -5
  11. data/lib/glimmer-dsl-opal/samples/hello/hello_browser.rb +24 -1
  12. data/lib/glimmer-dsl-opal/samples/hello/hello_button.rb +46 -0
  13. data/lib/glimmer-dsl-opal/samples/hello/hello_computed.rb +27 -0
  14. data/lib/glimmer-dsl-opal/samples/hello/hello_custom_shell.rb +7 -7
  15. data/lib/glimmer-dsl-opal/samples/hello/hello_list_multi_selection.rb +62 -32
  16. data/lib/glimmer-dsl-opal/samples/hello/hello_list_single_selection.rb +47 -22
  17. data/lib/glimmer-dsl-opal/samples/hello/hello_menu_bar.rb +241 -0
  18. data/lib/glimmer-dsl-opal/samples/hello/hello_message_box.rb +37 -0
  19. data/lib/glimmer-dsl-opal/samples/hello/hello_pop_up_context_menu.rb +84 -0
  20. data/lib/glimmer/data_binding/observable_element.rb +1 -1
  21. data/lib/glimmer/dsl/opal/custom_widget_expression.rb +6 -0
  22. data/lib/glimmer/dsl/opal/dsl.rb +2 -0
  23. data/lib/glimmer/dsl/opal/menu_bar_expression.rb +54 -0
  24. data/lib/glimmer/dsl/opal/menu_expression.rb +61 -0
  25. data/lib/glimmer/dsl/opal/shell_expression.rb +0 -4
  26. data/lib/glimmer/dsl/opal/widget_expression.rb +3 -2
  27. data/lib/glimmer/dsl/opal/widget_listener_expression.rb +2 -2
  28. data/lib/glimmer/swt/custom/checkbox_group.rb +2 -2
  29. data/lib/glimmer/swt/custom/radio_group.rb +2 -2
  30. data/lib/glimmer/swt/date_time_proxy.rb +5 -4
  31. data/lib/glimmer/swt/display_proxy.rb +4 -4
  32. data/lib/glimmer/swt/event_listener_proxy.rb +14 -4
  33. data/lib/glimmer/swt/font_proxy.rb +4 -4
  34. data/lib/glimmer/swt/grid_layout_proxy.rb +21 -12
  35. data/lib/glimmer/swt/label_proxy.rb +17 -6
  36. data/lib/glimmer/swt/latest_message_box_proxy.rb +20 -0
  37. data/lib/glimmer/swt/layout_data_proxy.rb +6 -6
  38. data/lib/glimmer/swt/list_proxy.rb +15 -0
  39. data/lib/glimmer/swt/menu_item_proxy.rb +174 -0
  40. data/lib/glimmer/swt/menu_proxy.rb +273 -0
  41. data/lib/glimmer/swt/message_box_proxy.rb +57 -72
  42. data/lib/glimmer/swt/property_owner.rb +2 -0
  43. data/lib/glimmer/swt/radio_proxy.rb +1 -1
  44. data/lib/glimmer/swt/shell_proxy.rb +34 -189
  45. data/lib/glimmer/swt/tab_folder_proxy.rb +43 -0
  46. data/lib/glimmer/swt/table_column_proxy.rb +3 -2
  47. data/lib/glimmer/swt/table_editor.rb +1 -1
  48. data/lib/glimmer/swt/table_item_proxy.rb +7 -5
  49. data/lib/glimmer/swt/table_proxy.rb +14 -10
  50. data/lib/glimmer/swt/widget_proxy.rb +327 -33
  51. data/lib/glimmer/ui/custom_shell.rb +9 -7
  52. data/lib/glimmer/ui/custom_widget.rb +3 -3
  53. metadata +36 -4
@@ -4,16 +4,19 @@ require 'glimmer/swt/widget_proxy'
4
4
  module Glimmer
5
5
  module SWT
6
6
  class LabelProxy < WidgetProxy
7
- attr_reader :text, :background_image, :image, :alignment
7
+ attr_reader :text, :background_image, :image
8
8
 
9
9
  def initialize(parent, args, block)
10
10
  super(parent, args, block)
11
- self.alignment = [:left, :center, :right].detect {|align| args.detect { |arg| SWTProxy[align] == arg } }
12
11
  end
13
12
 
14
13
  def text=(value)
15
14
  @text = value
16
- dom_element.html(value)
15
+ dom_element.html(html_text)
16
+ end
17
+
18
+ def html_text
19
+ text.gsub("\n", '<br />')
17
20
  end
18
21
 
19
22
  def background_image=(*image_options)
@@ -32,6 +35,15 @@ module Glimmer
32
35
  def element
33
36
  'label'
34
37
  end
38
+
39
+ def alignment
40
+ if @alignment.nil?
41
+ found_arg = nil
42
+ @alignment = [:left, :center, :right].detect {|align| found_arg = args.detect { |arg| SWTProxy[align] == SWTProxy[arg] } }
43
+ args.delete(found_arg)
44
+ end
45
+ @alignment
46
+ end
35
47
 
36
48
  def alignment=(value)
37
49
  # TODO consider storing swt value in the future instead
@@ -40,12 +52,11 @@ module Glimmer
40
52
  end
41
53
 
42
54
  def dom
43
- label_text = @text
44
55
  label_id = id
45
56
  label_class = name
46
57
  @dom ||= html {
47
- label(id: label_id, class: label_class) {
48
- label_text
58
+ label(id: label_id, class: label_class, style: "text-align: #{alignment};") {
59
+ html_text
49
60
  }
50
61
  }.to_s
51
62
  end
@@ -0,0 +1,20 @@
1
+ module Glimmer
2
+ module SWT
3
+ class LatestMessageBoxProxy #< MessageBoxProxy
4
+ # TODO consider overriding all methods from MessageBoxProxy and proxying to them
5
+
6
+ def initialize(parent, args, block)
7
+ # No Op
8
+ end
9
+
10
+ def open
11
+ Document.ready? do
12
+ DisplayProxy.instance.message_boxes.last&.open
13
+ end
14
+ end
15
+
16
+ end
17
+
18
+ end
19
+
20
+ end
@@ -45,10 +45,9 @@ module Glimmer
45
45
  def horizontal_alignment=(horizontal_alignment)
46
46
  @horizontal_alignment = horizontal_alignment
47
47
  return if @horizontal_alignment.nil?
48
- if @horizontal_alignment == 'fill'
49
- @parent.dom_element.css('width', '100%') if width_hint.nil?
50
- else
51
- @parent.dom_element.css('text-align', @horizontal_alignment)
48
+ if @horizontal_alignment != 'fill'
49
+ @parent.dom_element.css('text-align', @horizontal_alignment.to_s)
50
+ @parent.dom_element.css('place-self', @horizontal_alignment.to_s)
52
51
  @parent.dom_element.css('margin-left', 'auto') if ['right', 'center'].include?(@horizontal_alignment.to_s)
53
52
  @parent.dom_element.css('margin-right', 'auto') if ['left', 'center'].include?(@horizontal_alignment.to_s)
54
53
  end
@@ -88,18 +87,19 @@ module Glimmer
88
87
 
89
88
  def grab_excess_horizontal_space=(grab_excess_horizontal_space)
90
89
  @grab_excess_horizontal_space = grab_excess_horizontal_space
91
- @parent.dom_element.css('width', "100%") if @grab_excess_horizontal_space && @horizontal_alignment == 'fill' && width_hint.nil?
90
+ @parent.dom_element.css('justify-self', @horizontal_alignment) if @grab_excess_horizontal_space && @horizontal_alignment != 'fill' && width_hint.nil?
91
+ @parent.parent.dom_element.css('justify-content', "normal") if @grab_excess_horizontal_space
92
92
  # reapply
93
93
  end
94
94
 
95
95
  def grab_excess_vertical_space=(grab_excess_vertical_space)
96
96
  @grab_excess_vertical_space = grab_excess_vertical_space
97
97
  @parent.dom_element.css('height', "100%") if @grab_excess_vertical_space && @vertical_alignment == 'fill' && height_hint.nil?
98
- # TODO
99
98
  # reapply
100
99
  end
101
100
 
102
101
  def reapply
102
+ # TODO remove reapply method
103
103
  # @parent.css = <<~CSS
104
104
  # CSS
105
105
  end
@@ -3,6 +3,21 @@ require 'glimmer/swt/widget_proxy'
3
3
  module Glimmer
4
4
  module SWT
5
5
  class ListProxy < WidgetProxy
6
+ STYLE = <<~CSS
7
+ ul {
8
+ list-style: none;
9
+ padding: 0;
10
+ }
11
+ li {
12
+ cursor: default;
13
+ padding-left: 10px;
14
+ padding-right: 10px;
15
+ }
16
+ li.empty-list-item {
17
+ color: transparent;
18
+ }
19
+ CSS
20
+
6
21
  ITEM_EMPTY = '_____'
7
22
  attr_reader :items, :selection
8
23
 
@@ -0,0 +1,174 @@
1
+ # Copyright (c) 2020 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ # TODO implement set_menu or self.menu=
23
+
24
+ require 'glimmer/swt/widget_proxy'
25
+
26
+ module Glimmer
27
+ module SWT
28
+ # Proxy for org.eclipse.swt.widgets.MenuItem
29
+ #
30
+ # Follows the Proxy Design Pattern since it's a proxy for an HTML based menu
31
+ # Follows the Adapter Design Pattern since it's adapting a Glimmer DSL for SWT widget
32
+ class MenuItemProxy < WidgetProxy
33
+ STYLE = <<~CSS
34
+ .menu-item.disabled {
35
+ background-color: lightgrey;
36
+ color: grey;
37
+ }
38
+ .menu-item.disabled .menu, .menu-item.disabled .menu * {
39
+ display: none;
40
+ opacity: 0;
41
+ }
42
+ CSS
43
+
44
+ attr_accessor :accelerator # TODO consider doing something with it
45
+
46
+ def initialize(parent, args)
47
+ args.push(:push) if args.empty?
48
+ super(parent, args)
49
+ # TODO do not add the following event till post_add_content to avoid adding if already one on_widget_selected event existed
50
+ on_widget_selected {
51
+ # No Op, just trigger selection
52
+ }
53
+ end
54
+
55
+ def post_initialize_child(child)
56
+ @children << child
57
+ end
58
+
59
+ def cascade?
60
+ args.include?(:cascade)
61
+ end
62
+
63
+ def push?
64
+ args.include?(:push)
65
+ end
66
+
67
+ def radio?
68
+ args.include?(:radio)
69
+ end
70
+
71
+ def check?
72
+ args.include?(:check)
73
+ end
74
+
75
+ def separator?
76
+ args.include?(:separator)
77
+ end
78
+
79
+ def text
80
+ @text
81
+ end
82
+
83
+ def text=(value)
84
+ @text = value
85
+ dom_element.find('.menu-item-text').html(@text)
86
+ @text
87
+ end
88
+
89
+ def selection
90
+ @selection
91
+ end
92
+
93
+ def selection=(value)
94
+ @selection = value
95
+ icon_suffix = check? ? 'check' : 'bullet'
96
+ dom_element.find('.menu-item-selection').toggle_class("ui-icon ui-icon-#{icon_suffix}", @selection)
97
+ @selection
98
+ end
99
+
100
+ def toggle_selection!
101
+ self.selection = !selection
102
+ end
103
+
104
+ def enabled=(value)
105
+ @enabled = value
106
+ dom_element.toggle_class('disabled', !@enabled)
107
+ @enabled
108
+ end
109
+
110
+ def div_content
111
+ div_attributes = {}
112
+ icon_suffix = check? ? 'check' : 'bullet'
113
+ div(div_attributes) {
114
+ unless separator? # empty content automatically gets a separator style in jQuery-UI
115
+ span(class: "menu-item-selection #{"ui-icon ui-icon-#{icon_suffix}" if selection}") {}
116
+ span(class: 'ui-menu-icon ui-icon ui-icon-caret-1-e') {} if cascade? && !parent.bar?
117
+ span(class: 'menu-item-text') {
118
+ @text
119
+ }
120
+ ''
121
+ end
122
+ }
123
+ end
124
+
125
+ def root_menu
126
+ the_menu = parent
127
+ the_menu = the_menu.parent_menu until the_menu.root_menu?
128
+ the_menu
129
+ end
130
+
131
+ def skip_content_on_render_blocks?
132
+ true
133
+ end
134
+
135
+ def observation_request_to_event_mapping
136
+ {
137
+ 'on_widget_selected' => {
138
+ event: 'mouseup',
139
+ event_handler: -> (event_listener) {
140
+ -> (event) {
141
+ if enabled && (push? || radio? || check?)
142
+ if check?
143
+ self.toggle_selection!
144
+ elsif radio? && !selection
145
+ parent.children.detect(&:selection)&.selection = false
146
+ self.selection = true
147
+ end
148
+ if !root_menu.bar?
149
+ remove_event_listener_proxies
150
+ root_menu.close
151
+ end
152
+ event_listener.call(event)
153
+ end
154
+ }
155
+ },
156
+ },
157
+ }
158
+ end
159
+
160
+ def element
161
+ 'li'
162
+ end
163
+
164
+ def dom
165
+ # TODO support rendering image
166
+ @dom ||= html {
167
+ li(id: id, class: "#{name} #{'disabled' unless enabled}") {
168
+ div_content
169
+ }
170
+ }.to_s
171
+ end
172
+ end
173
+ end
174
+ end
@@ -0,0 +1,273 @@
1
+ # Copyright (c) 2020 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require 'glimmer/swt/widget_proxy'
23
+ require 'glimmer/swt/menu_item_proxy'
24
+
25
+ module Glimmer
26
+ module SWT
27
+ # Proxy for org.eclipse.swt.widgets.Menu
28
+ #
29
+ # Functions differently from other widget proxies.
30
+ #
31
+ # Glimmer automatically detects if this is a drop down menu
32
+ # or pop up menu from its parent if no SWT style is passed in.
33
+ #
34
+ # There are 3 possibilities:
35
+ # - SWT :bar style is passed in: Menu Bar
36
+ # - Parent is ShellProxy: Pop Up Menu (having style :pop_up)
37
+ # - Parent is another Menu: Drop Down Menu (having style :drop_down)
38
+ #
39
+ # In order to get the SWT Menu object, one must call `#swt_widget`.
40
+ #
41
+ # In the case of a Drop Down menu, this automatically creates an
42
+ # SWT MenuItem object with style :cascade
43
+ #
44
+ # In order to retrieve the menu item widget proxy, one must call `#menu_item_proxy`
45
+ #
46
+ # Follows the Proxy Design Pattern
47
+ class MenuProxy < WidgetProxy
48
+ STYLE = <<~CSS
49
+ .menu.menu-bar {
50
+ position: absolute;
51
+ top: -30px;
52
+ border-radius: 0;
53
+ width: 100%;
54
+ }
55
+ .menu.menu-bar .menu {
56
+ border-radius: 0;
57
+ }
58
+ .menu-bar .menu-item {
59
+ width: 180px;
60
+ }
61
+ .menu-bar > .menu-item {
62
+ display: inline-block;
63
+ width: 150px;
64
+ }
65
+ li.menu-item {
66
+ padding-left: initial;
67
+ padding-right: initial;
68
+ }
69
+ .menu {
70
+ /* TODO consider auto-sizing in the future */
71
+ font-size: initial;
72
+ border-radius: 5px;
73
+ }
74
+ .menu:not(.menu-bar) {
75
+ width: 150px;
76
+ }
77
+ .menu-bar .ui-menu:not(.menu-bar) {
78
+ width: 180px;
79
+ }
80
+ .ui-menu-item:first-child > .ui-menu-item-wrapper {
81
+ border-top-left-radius: 5px;
82
+ border-top-right-radius: 5px;
83
+ }
84
+ .ui-menu-item:last-child > .ui-menu-item-wrapper {
85
+ border-bottom-left-radius: 5px;
86
+ border-bottom-right-radius: 5px;
87
+ }
88
+ .menu-bar .ui-menu-item:first-child > .ui-menu-item-wrapper {
89
+ border-top-left-radius: 0;
90
+ border-top-right-radius: 0;
91
+ }
92
+ .menu-bar .ui-menu-item:last-child > .ui-menu-item-wrapper {
93
+ border-bottom-left-radius: 0;
94
+ border-bottom-right-radius: 0;
95
+ }
96
+
97
+ CSS
98
+
99
+ attr_reader :menu_item_proxy, :menu_parent
100
+
101
+ def initialize(parent, args)
102
+ # TODO refactor/simplify code below
103
+ @children = []
104
+ index = args.delete(args.last) if args.last.is_a?(Numeric)
105
+ args = args.map {|arg| arg.is_a?(String) ? arg.to_sym : arg}
106
+ if parent.is_a?(ShellProxy)
107
+ args = args.unshift(:bar)
108
+ elsif parent.is_a?(MenuProxy)
109
+ args = args.unshift(:drop_down)
110
+ else
111
+ args = args.unshift(:pop_up)
112
+ end
113
+ if parent.is_a?(MenuProxy)
114
+ @menu_item_proxy = SWT::WidgetProxy.for('menu_item', parent, [:cascade] + [index].compact)
115
+ super(@menu_item_proxy, args)
116
+ @menu_item_proxy.menu = self
117
+ elsif parent.is_a?(ShellProxy)
118
+ super(parent, args)
119
+ else # widget pop up
120
+ super(parent, args)
121
+ end
122
+
123
+ if bar?
124
+ # Assumes a parent shell
125
+ parent.menu_bar = self
126
+ elsif pop_up?
127
+ parent.menu = self
128
+ end
129
+ # TODO IMPLEMENT PROPERLY
130
+ # on_focus_lost {
131
+ # dispose
132
+ # }
133
+ end
134
+
135
+ def bar?
136
+ args.include?(:bar)
137
+ end
138
+
139
+ def pop_up?
140
+ args.include?(:pop_up)
141
+ end
142
+
143
+ def drop_down?
144
+ args.include?(:drop_down)
145
+ end
146
+
147
+ def text
148
+ @menu_item_proxy&.text
149
+ end
150
+
151
+ def text=(text_value)
152
+ @menu_item_proxy&.text = text_value
153
+ end
154
+
155
+ def enabled
156
+ if drop_down?
157
+ menu_item_proxy.enabled
158
+ else
159
+ true
160
+ end
161
+ end
162
+
163
+ def enabled=(value)
164
+ if drop_down?
165
+ menu_item_proxy.enabled = value
166
+ end
167
+ end
168
+
169
+ def can_handle_observation_request?(observation_request, super_only: false)
170
+ super_result = super(observation_request)
171
+ if observation_request.start_with?('on_') && !super_result && !super_only
172
+ return menu_item_proxy.can_handle_observation_request?(observation_request)
173
+ else
174
+ super_result
175
+ end
176
+ end
177
+
178
+ def handle_observation_request(observation_request, block)
179
+ if can_handle_observation_request?(observation_request, super_only: true)
180
+ super
181
+ else
182
+ menu_item_proxy.handle_observation_request(observation_request, block)
183
+ end
184
+ end
185
+
186
+ def post_initialize_child(child)
187
+ if child && !@children.include?(child)
188
+ if child.is_a?(MenuItemProxy)
189
+ @children << child
190
+ else
191
+ @children << child.menu_item_proxy
192
+ end
193
+ end
194
+ end
195
+
196
+ def post_add_content
197
+ if bar?
198
+ # delay this till all children rendered (perhaps post_add_content block)
199
+ parent_dom_element.css('position', 'relative')
200
+ parent_dom_element.css('margin-top', '30px')
201
+ redraw
202
+ `$(#{path}).menu({
203
+ position: { my: "top", at: "bottom" },
204
+ icons: { submenu: "ui-icon-blank" }
205
+ });`
206
+ the_element = dom_element
207
+ the_element.on('mouseover') { |event|
208
+ if event.page_x.between?(the_element.offset.left, the_element.offset.left + the_element.width) and
209
+ event.page_y.between?(the_element.offset.top, the_element.offset.top + the_element.height)
210
+ `$(#{path}).menu('option', 'position', { my: 'left top', at: 'left bottom' });`
211
+ end
212
+ }
213
+ the_element.on('menublur') {
214
+ `$(#{path}).menu('option', 'position', { my: 'left top', at: 'right top' });`
215
+ }
216
+ minimum_width = children.to_a.map(&:dom_element).map(&:width).reduce(:+)
217
+ the_element.css('min-width', minimum_width)
218
+ end
219
+ end
220
+
221
+ def render(custom_parent_dom_element: nil, brand_new: false)
222
+ # TODO attach to top nav bar if parent is shell
223
+ # TODO attach listener to parent to display on right click
224
+ if parent.is_a?(MenuProxy) || parent.is_a?(MenuItemProxy) || parent.menu_requested? || parent.is_a?(ShellProxy)
225
+ super(custom_parent_dom_element: custom_parent_dom_element, brand_new: brand_new)
226
+ if root_menu? && !bar?
227
+ `$(#{path}).menu();`
228
+ @close_event_handler = lambda do |event|
229
+ close if event.target.parents('.ui-menu').empty?
230
+ end
231
+ Element['body'].on('click', &@close_event_handler)
232
+ end
233
+ end
234
+ end
235
+
236
+ def close
237
+ dom_element.remove
238
+ Element['body'].off('click', &@close_event_handler)
239
+ end
240
+
241
+ def root_menu?
242
+ !parent.is_a?(MenuProxy) && !parent.is_a?(MenuItemProxy)
243
+ end
244
+
245
+ def root_menu
246
+ the_menu = self
247
+ the_menu = the_menu.parent_menu until the_menu.root_menu?
248
+ the_menu
249
+ end
250
+
251
+ def parent_menu
252
+ parent.parent unless root_menu?
253
+ end
254
+
255
+ def element
256
+ 'ul'
257
+ end
258
+
259
+ def dom
260
+ css_class = name
261
+ css_class += ' menu-bar' if bar?
262
+ css_class += ' menu-drop-down' if drop_down?
263
+ css_class += ' menu-pop-up' if pop_up?
264
+ @dom ||= html {
265
+ ul(id: id, class: css_class) {
266
+ }
267
+ }.to_s
268
+ end
269
+ end
270
+
271
+ MenuBarProxy = MenuProxy
272
+ end
273
+ end