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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +41 -0
- data/README.md +745 -82
- data/VERSION +1 -1
- data/lib/glimmer-dsl-opal.rb +14 -1
- data/lib/glimmer-dsl-opal/ext/class.rb +10 -0
- data/lib/{file.rb → glimmer-dsl-opal/ext/file.rb} +0 -0
- data/lib/glimmer-dsl-opal/ext/glimmer/dsl/engine.rb +30 -0
- data/lib/glimmer-dsl-opal/samples/elaborate/contact_manager.rb +50 -23
- data/lib/glimmer-dsl-opal/samples/elaborate/login.rb +22 -5
- data/lib/glimmer-dsl-opal/samples/hello/hello_browser.rb +24 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_button.rb +46 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_computed.rb +27 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_custom_shell.rb +7 -7
- data/lib/glimmer-dsl-opal/samples/hello/hello_list_multi_selection.rb +62 -32
- data/lib/glimmer-dsl-opal/samples/hello/hello_list_single_selection.rb +47 -22
- data/lib/glimmer-dsl-opal/samples/hello/hello_menu_bar.rb +241 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_message_box.rb +37 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_pop_up_context_menu.rb +84 -0
- data/lib/glimmer/data_binding/observable_element.rb +1 -1
- data/lib/glimmer/dsl/opal/custom_widget_expression.rb +6 -0
- data/lib/glimmer/dsl/opal/dsl.rb +2 -0
- data/lib/glimmer/dsl/opal/menu_bar_expression.rb +54 -0
- data/lib/glimmer/dsl/opal/menu_expression.rb +61 -0
- data/lib/glimmer/dsl/opal/shell_expression.rb +0 -4
- data/lib/glimmer/dsl/opal/widget_expression.rb +3 -2
- data/lib/glimmer/dsl/opal/widget_listener_expression.rb +2 -2
- data/lib/glimmer/swt/custom/checkbox_group.rb +2 -2
- data/lib/glimmer/swt/custom/radio_group.rb +2 -2
- data/lib/glimmer/swt/date_time_proxy.rb +5 -4
- data/lib/glimmer/swt/display_proxy.rb +4 -4
- data/lib/glimmer/swt/event_listener_proxy.rb +14 -4
- data/lib/glimmer/swt/font_proxy.rb +4 -4
- data/lib/glimmer/swt/grid_layout_proxy.rb +21 -12
- data/lib/glimmer/swt/label_proxy.rb +17 -6
- data/lib/glimmer/swt/latest_message_box_proxy.rb +20 -0
- data/lib/glimmer/swt/layout_data_proxy.rb +6 -6
- data/lib/glimmer/swt/list_proxy.rb +15 -0
- data/lib/glimmer/swt/menu_item_proxy.rb +174 -0
- data/lib/glimmer/swt/menu_proxy.rb +273 -0
- data/lib/glimmer/swt/message_box_proxy.rb +57 -72
- data/lib/glimmer/swt/property_owner.rb +2 -0
- data/lib/glimmer/swt/radio_proxy.rb +1 -1
- data/lib/glimmer/swt/shell_proxy.rb +34 -189
- data/lib/glimmer/swt/tab_folder_proxy.rb +43 -0
- data/lib/glimmer/swt/table_column_proxy.rb +3 -2
- data/lib/glimmer/swt/table_editor.rb +1 -1
- data/lib/glimmer/swt/table_item_proxy.rb +7 -5
- data/lib/glimmer/swt/table_proxy.rb +14 -10
- data/lib/glimmer/swt/widget_proxy.rb +327 -33
- data/lib/glimmer/ui/custom_shell.rb +9 -7
- data/lib/glimmer/ui/custom_widget.rb +3 -3
- metadata +36 -4
@@ -0,0 +1,84 @@
|
|
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
|
+
include Glimmer
|
23
|
+
|
24
|
+
shell {
|
25
|
+
grid_layout {
|
26
|
+
margin_width 0
|
27
|
+
margin_height 0
|
28
|
+
}
|
29
|
+
|
30
|
+
text 'Hello, Pop Up Context Menu!'
|
31
|
+
|
32
|
+
label {
|
33
|
+
text "Right-Click on the Text to\nPop Up a Context Menu"
|
34
|
+
font height: 50
|
35
|
+
|
36
|
+
menu {
|
37
|
+
menu {
|
38
|
+
text '&History'
|
39
|
+
menu {
|
40
|
+
text '&Recent'
|
41
|
+
menu_item {
|
42
|
+
text 'File 1'
|
43
|
+
on_widget_selected {
|
44
|
+
message_box {
|
45
|
+
text 'File 1'
|
46
|
+
message 'File 1 Contents'
|
47
|
+
}.open
|
48
|
+
}
|
49
|
+
}
|
50
|
+
menu_item {
|
51
|
+
text 'File 2'
|
52
|
+
on_widget_selected {
|
53
|
+
message_box {
|
54
|
+
text 'File 2'
|
55
|
+
message 'File 2 Contents'
|
56
|
+
}.open
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}
|
60
|
+
menu {
|
61
|
+
text '&Archived'
|
62
|
+
menu_item {
|
63
|
+
text 'File 3'
|
64
|
+
on_widget_selected {
|
65
|
+
message_box {
|
66
|
+
text 'File 3'
|
67
|
+
message 'File 3 Contents'
|
68
|
+
}.open
|
69
|
+
}
|
70
|
+
}
|
71
|
+
menu_item {
|
72
|
+
text 'File 4'
|
73
|
+
on_widget_selected {
|
74
|
+
message_box {
|
75
|
+
text 'File 4'
|
76
|
+
message 'File 4 Contents'
|
77
|
+
}.open
|
78
|
+
}
|
79
|
+
}
|
80
|
+
}
|
81
|
+
}
|
82
|
+
}
|
83
|
+
}
|
84
|
+
}.open
|
@@ -42,6 +42,12 @@ module Glimmer
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def interpret(parent, keyword, *args, &block)
|
45
|
+
begin
|
46
|
+
require_path = LocalStorage[keyword]
|
47
|
+
require(require_path) if require_path
|
48
|
+
rescue => e
|
49
|
+
Glimmer::Config.logger.debug e.message
|
50
|
+
end
|
45
51
|
custom_widget_class = UI::CustomWidget.for(keyword)
|
46
52
|
# TODO clean code by extracting methods into CustomShell
|
47
53
|
if !Glimmer::UI::CustomShell.requested? && custom_widget_class&.ancestors&.to_a.include?(Glimmer::UI::CustomShell)
|
data/lib/glimmer/dsl/opal/dsl.rb
CHANGED
@@ -26,6 +26,8 @@ require 'glimmer/dsl/opal/swt_expression'
|
|
26
26
|
require 'glimmer/dsl/opal/radio_group_selection_data_binding_expression'
|
27
27
|
require 'glimmer/dsl/opal/checkbox_group_selection_data_binding_expression'
|
28
28
|
require 'glimmer/dsl/opal/block_property_expression'
|
29
|
+
require 'glimmer/dsl/opal/menu_expression'
|
30
|
+
# require 'glimmer/dsl/opal/menu_bar_expression'
|
29
31
|
|
30
32
|
module Glimmer
|
31
33
|
module DSL
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# Copyright (c) 2007-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'
|
23
|
+
require 'glimmer/dsl/static_expression'
|
24
|
+
require 'glimmer/dsl/parent_expression'
|
25
|
+
require 'glimmer/swt/menu_proxy'
|
26
|
+
|
27
|
+
# TODO implement for Opal
|
28
|
+
|
29
|
+
module Glimmer
|
30
|
+
module DSL
|
31
|
+
module SWT
|
32
|
+
class MenuBarExpression < StaticExpression
|
33
|
+
include ParentExpression
|
34
|
+
|
35
|
+
def can_interpret?(parent, keyword, *args, &block)
|
36
|
+
initial_condition = (keyword == 'menu_bar')
|
37
|
+
if initial_condition
|
38
|
+
if parent.swt_widget.is_a?(Shell)
|
39
|
+
return true
|
40
|
+
else
|
41
|
+
raise Glimmer::Error, "menu_bar may only be nested under a shell!"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
false
|
45
|
+
end
|
46
|
+
|
47
|
+
def interpret(parent, keyword, *args, &block)
|
48
|
+
args = args.unshift(:bar)
|
49
|
+
Glimmer::SWT::MenuProxy.new(parent, args)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,61 @@
|
|
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'
|
23
|
+
require 'glimmer/dsl/static_expression'
|
24
|
+
require 'glimmer/dsl/parent_expression'
|
25
|
+
require 'glimmer/swt/widget_proxy'
|
26
|
+
require 'glimmer/swt/menu_proxy'
|
27
|
+
|
28
|
+
module Glimmer
|
29
|
+
module DSL
|
30
|
+
module Opal
|
31
|
+
class MenuExpression < StaticExpression
|
32
|
+
include ParentExpression
|
33
|
+
|
34
|
+
def can_interpret?(parent, keyword, *args, &block)
|
35
|
+
initial_condition = (keyword == 'menu')
|
36
|
+
if initial_condition
|
37
|
+
if parent.is_a?(Glimmer::SWT::WidgetProxy)
|
38
|
+
return true
|
39
|
+
else
|
40
|
+
raise Glimmer::Error, "menu may only be nested under a widget (like shell or another menu)!"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
false
|
44
|
+
end
|
45
|
+
|
46
|
+
def interpret(parent, keyword, *args, &block)
|
47
|
+
Glimmer::SWT::MenuProxy.new(parent, args)
|
48
|
+
end
|
49
|
+
|
50
|
+
def add_content(parent, &block)
|
51
|
+
super(parent, &block)
|
52
|
+
parent.post_add_content
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
@@ -7,6 +7,7 @@ module Glimmer
|
|
7
7
|
module Opal
|
8
8
|
class WidgetExpression < Expression
|
9
9
|
include ParentExpression
|
10
|
+
|
10
11
|
EXCLUDED_KEYWORDS = %w[shell display]
|
11
12
|
|
12
13
|
def can_interpret?(parent, keyword, *args, &block)
|
@@ -18,9 +19,9 @@ module Glimmer
|
|
18
19
|
def interpret(parent, keyword, *args, &block)
|
19
20
|
Glimmer::SWT::WidgetProxy.for(keyword, parent, args, block)
|
20
21
|
end
|
21
|
-
|
22
|
+
|
22
23
|
def add_content(parent, &block)
|
23
|
-
if parent.rendered?
|
24
|
+
if parent.rendered? || parent.skip_content_on_render_blocks?
|
24
25
|
super(parent, &block)
|
25
26
|
parent.post_add_content
|
26
27
|
else
|
@@ -20,10 +20,10 @@ module Glimmer
|
|
20
20
|
# Glimmer::Config.logger.debug {"can add listener? #{result}"}
|
21
21
|
# raise Glimmer::Error, "Invalid listener keyword: #{keyword}" unless result
|
22
22
|
true
|
23
|
-
end
|
23
|
+
end
|
24
24
|
|
25
25
|
def interpret(parent, keyword, *args, &block)
|
26
|
-
parent.handle_observation_request(keyword,
|
26
|
+
parent.handle_observation_request(keyword, block)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -78,7 +78,7 @@ module Glimmer
|
|
78
78
|
checkboxes.first&.can_handle_observation_request?(observation_request) || super(observation_request)
|
79
79
|
end
|
80
80
|
|
81
|
-
def handle_observation_request(observation_request,
|
81
|
+
def handle_observation_request(observation_request, block)
|
82
82
|
observation_requests << [observation_request, block]
|
83
83
|
delegate_observation_request_to_checkboxes(observation_request, &block)
|
84
84
|
super
|
@@ -88,7 +88,7 @@ module Glimmer
|
|
88
88
|
if observation_request != 'on_widget_disposed'
|
89
89
|
checkboxes.count.times do |index|
|
90
90
|
checkbox = checkboxes[index]
|
91
|
-
checkbox.handle_observation_request(observation_request,
|
91
|
+
checkbox.handle_observation_request(observation_request, block) if checkbox.can_handle_observation_request?(observation_request)
|
92
92
|
end
|
93
93
|
end
|
94
94
|
end
|
@@ -81,7 +81,7 @@ module Glimmer
|
|
81
81
|
radios.first&.can_handle_observation_request?(observation_request) || super(observation_request)
|
82
82
|
end
|
83
83
|
|
84
|
-
def handle_observation_request(observation_request,
|
84
|
+
def handle_observation_request(observation_request, block)
|
85
85
|
observation_requests << [observation_request, block]
|
86
86
|
delegate_observation_request_to_radios(observation_request, &block)
|
87
87
|
super
|
@@ -91,7 +91,7 @@ module Glimmer
|
|
91
91
|
if observation_request != 'on_widget_disposed'
|
92
92
|
radios.count.times do |index|
|
93
93
|
radio = radios[index]
|
94
|
-
radio.handle_observation_request(observation_request,
|
94
|
+
radio.handle_observation_request(observation_request, block) if radio.can_handle_observation_request?(observation_request)
|
95
95
|
end
|
96
96
|
end
|
97
97
|
end
|
@@ -114,8 +114,8 @@ module Glimmer
|
|
114
114
|
event: 'change',
|
115
115
|
event_handler: -> (event_listener) {
|
116
116
|
-> (event) {
|
117
|
-
if @timepicker_done
|
118
|
-
@timepicker_done = false
|
117
|
+
if calendar? || date? || (time? && @timepicker_done)
|
118
|
+
@timepicker_done = false if time?
|
119
119
|
event_listener.call(event)
|
120
120
|
end
|
121
121
|
}
|
@@ -127,8 +127,9 @@ module Glimmer
|
|
127
127
|
event: 'blur',
|
128
128
|
event_handler: -> (event_listener) {
|
129
129
|
-> (event) {
|
130
|
-
|
131
|
-
|
130
|
+
# TODO support blur event for date?
|
131
|
+
if time? && @timepicker_done
|
132
|
+
@timepicker_done = false if time?
|
132
133
|
event_listener.call(event)
|
133
134
|
end
|
134
135
|
}
|
@@ -28,6 +28,10 @@ module Glimmer
|
|
28
28
|
@shells ||= []
|
29
29
|
end
|
30
30
|
|
31
|
+
def message_boxes
|
32
|
+
@message_boxes ||= []
|
33
|
+
end
|
34
|
+
|
31
35
|
def render
|
32
36
|
# No rendering as body is rendered as part of ShellProxy.. this class only serves as an SWT Display utility
|
33
37
|
end
|
@@ -74,10 +78,6 @@ module Glimmer
|
|
74
78
|
]
|
75
79
|
}
|
76
80
|
end
|
77
|
-
|
78
|
-
def shells
|
79
|
-
@shells ||= []
|
80
|
-
end
|
81
81
|
end
|
82
82
|
end
|
83
83
|
end
|
@@ -1,18 +1,28 @@
|
|
1
1
|
module Glimmer
|
2
2
|
module SWT
|
3
3
|
class EventListenerProxy
|
4
|
-
attr_reader :element_proxy, :event, :selector, :
|
4
|
+
attr_reader :element_proxy, :event, :dom_element, :selector, :listener, :original_event_listener
|
5
5
|
|
6
|
-
def initialize(element_proxy:, event:, selector:,
|
6
|
+
def initialize(element_proxy:, event:, dom_element:, selector:, listener:)
|
7
7
|
@element_proxy = element_proxy
|
8
8
|
@event = event
|
9
|
+
@dom_element = dom_element
|
9
10
|
@selector = selector
|
10
|
-
@
|
11
|
+
@listener = listener
|
12
|
+
@original_event_listener = original_event_listener
|
11
13
|
end
|
12
14
|
|
15
|
+
def register
|
16
|
+
@dom_element.on(@event, @delegate)
|
17
|
+
end
|
18
|
+
alias observe register
|
19
|
+
alias reregister register
|
20
|
+
|
13
21
|
def unregister
|
14
|
-
|
22
|
+
@dom_element.off(@event, @delegate)
|
15
23
|
end
|
24
|
+
alias unobserve unregister
|
25
|
+
alias deregister unregister
|
16
26
|
end
|
17
27
|
end
|
18
28
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (c) 2020 Andy Maleh
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
# a copy of this software and associated documentation files (the
|
5
5
|
# "Software"), to deal in the Software without restriction, including
|
@@ -7,10 +7,10 @@
|
|
7
7
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
8
|
# permit persons to whom the Software is furnished to do so, subject to
|
9
9
|
# the following conditions:
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# The above copyright notice and this permission notice shall be
|
12
12
|
# included in all copies or substantial portions of the Software.
|
13
|
-
#
|
13
|
+
#
|
14
14
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
15
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
16
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
@@ -68,7 +68,7 @@ module Glimmer
|
|
68
68
|
private
|
69
69
|
|
70
70
|
def detect_invalid_font_property(font_properties)
|
71
|
-
|
71
|
+
font_properties[:style].to_collection(false).select do |style|
|
72
72
|
style.is_a?(Symbol) || style.is_a?(String)
|
73
73
|
end.each do |style|
|
74
74
|
raise Error, style.to_s + ERROR_INVALID_FONT_STYLE if !FONT_STYLES.include?(style.to_sym)
|
@@ -7,18 +7,20 @@ module Glimmer
|
|
7
7
|
.grid-layout {
|
8
8
|
display: grid;
|
9
9
|
grid-template-rows: min-content;
|
10
|
-
justify-content: start;
|
11
10
|
place-content: start;
|
12
|
-
align-items: stretch;
|
11
|
+
align-items: stretch;
|
13
12
|
}
|
14
13
|
CSS
|
14
|
+
|
15
15
|
attr_reader :num_columns, :make_columns_equal_width, :horizontal_spacing, :vertical_spacing, :margin_width, :margin_height
|
16
16
|
|
17
17
|
def initialize(parent, args)
|
18
18
|
super(parent, args)
|
19
19
|
self.horizontal_spacing = 10
|
20
20
|
self.vertical_spacing = 10
|
21
|
-
self.
|
21
|
+
self.margin_width = 15
|
22
|
+
self.margin_height = 15
|
23
|
+
self.num_columns = @args.first || 1
|
22
24
|
reapply
|
23
25
|
end
|
24
26
|
|
@@ -30,7 +32,7 @@ module Glimmer
|
|
30
32
|
end
|
31
33
|
|
32
34
|
def make_columns_equal_width=(equal_width)
|
33
|
-
@make_columns_equal_width = equal_width
|
35
|
+
@make_columns_equal_width = equal_width
|
34
36
|
# @parent.add_css_class('make_columns_equal_width') if @make_columns_equal_width
|
35
37
|
reapply
|
36
38
|
end
|
@@ -50,14 +52,18 @@ module Glimmer
|
|
50
52
|
def margin_width=(pixels)
|
51
53
|
@margin_width = pixels
|
52
54
|
# Using padding for width since margin-right isn't getting respected with width 100%
|
53
|
-
|
54
|
-
@parent.
|
55
|
+
effective_margin_width = @margin_width
|
56
|
+
effective_margin_width += 6 if @parent.is_a?(GroupProxy)
|
57
|
+
@parent.dom_element.css('padding-left', effective_margin_width)
|
58
|
+
@parent.dom_element.css('padding-right', effective_margin_width)
|
55
59
|
end
|
56
60
|
|
57
61
|
def margin_height=(pixels)
|
58
62
|
@margin_height = pixels
|
59
|
-
|
60
|
-
@parent.
|
63
|
+
effective_margin_height = @margin_height
|
64
|
+
effective_margin_height += 9 if @parent.is_a?(GroupProxy)
|
65
|
+
@parent.dom_element.css('padding-top', effective_margin_height)
|
66
|
+
@parent.dom_element.css('padding-bottom', effective_margin_height)
|
61
67
|
end
|
62
68
|
|
63
69
|
def reapply
|
@@ -68,15 +74,18 @@ module Glimmer
|
|
68
74
|
grid-column-gap: #{@horizontal_spacing}px;
|
69
75
|
CSS
|
70
76
|
if @parent.css_classes.include?('grid-layout')
|
71
|
-
layout_css.split(";").map(&:strip).map {|l| l.split(':').map(&:strip)}.each do |key, value|
|
77
|
+
layout_css.split(";").map(&:strip).map {|l| l.split(':').map(&:strip)}.each do |key, value|
|
72
78
|
@parent.dom_element.css(key, value) unless key.nil?
|
73
79
|
end
|
80
|
+
if @parent.is_a?(GroupProxy)
|
81
|
+
@parent.dom_element.find('legend').css('grid-column-start', "span #{@num_columns.to_i}")
|
82
|
+
end
|
74
83
|
else
|
75
|
-
layout_css.split(";").map(&:strip).map {|l| l.split(':').map(&:strip)}.each do |key, value|
|
84
|
+
layout_css.split(";").map(&:strip).map {|l| l.split(':').map(&:strip)}.each do |key, value|
|
76
85
|
@parent.dom_element.css(key, 'initial') unless key.nil?
|
77
|
-
end
|
86
|
+
end
|
78
87
|
end
|
79
|
-
end
|
88
|
+
end
|
80
89
|
end
|
81
90
|
end
|
82
91
|
end
|