Class: Glimmer::SWT::CheckboxProxy
Constant Summary
collapse
- STYLE =
TODO add a create method that ensures passing :check style in if not there
<<~CSS
.checkbox {
display: inline;
}
.checkbox-label {
display: inline;
}
CSS
Constants inherited
from WidgetProxy
WidgetProxy::DEFAULT_INITIALIZERS
Instance Attribute Summary collapse
Attributes inherited from WidgetProxy
#args, #background, #children, #enabled, #focus, #font, #foreground, #parent, #path
Instance Method Summary
collapse
Methods inherited from WidgetProxy
#add_css_class, #add_css_classes, #add_observer, #apply_property_type_converters, #build_dom, #can_handle_observation_request?, #clear_css_classes, #content, #css_classes, #dispose, #dom_element, for, #handle_observation_request, #has_style?, #id, #id=, #initialize, #listener_dom_element, #listener_path, max_id_number_for, max_id_numbers, #name, next_id_number_for, #parent_dom_element, #parent_path, #post_add_content, #post_initialize_child, #property_type_converters, #remove_css_class, #remove_css_classes, #render, reset_max_id_numbers!, #selector, #set_attribute, #set_focus, #style_element, underscored_widget_name, widget_class, widget_exists?, #widget_property_listener_installers
#attribute_getter, #attribute_setter, #get_attribute, #set_attribute
Instance Attribute Details
#text ⇒ Object
TODO consider reuse of logic in Radioproxy
16
17
18
|
# File 'lib/glimmer/swt/checkbox_proxy.rb', line 16
def text
@text
end
|
Instance Method Details
#dom ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/glimmer/swt/checkbox_proxy.rb', line 57
def dom
check_text = @text
check_id = id
check_style = css
check_class = name
check_selection = @selection
options = {type: 'checkbox', id: check_id, name: parent.id, style: check_style, class: check_class, value: check_text, style: 'min-width: 27px;'}
options[checked: 'checked'] if check_selection
@dom ||= html {
span {
input(options) {
}
label(id: label_id, class: label_class, for: check_id) {
check_text
}
}
}.to_s
end
|
#element ⇒ Object
33
34
35
|
# File 'lib/glimmer/swt/checkbox_proxy.rb', line 33
def element
'input'
end
|
#label_class ⇒ Object
49
50
51
|
# File 'lib/glimmer/swt/checkbox_proxy.rb', line 49
def label_class
"#{name}-label"
end
|
#label_dom_element ⇒ Object
53
54
55
|
# File 'lib/glimmer/swt/checkbox_proxy.rb', line 53
def label_dom_element
Element.find("##{label_id}")
end
|
#label_id ⇒ Object
45
46
47
|
# File 'lib/glimmer/swt/checkbox_proxy.rb', line 45
def label_id
"#{id}-label"
end
|
#observation_request_to_event_mapping ⇒ Object
37
38
39
40
41
42
43
|
# File 'lib/glimmer/swt/checkbox_proxy.rb', line 37
def observation_request_to_event_mapping
{
'on_widget_selected' => {
event: 'change'
},
}
end
|
#selection ⇒ Object
24
25
26
|
# File 'lib/glimmer/swt/checkbox_proxy.rb', line 24
def selection
dom_element.prop('checked')
end
|
#selection=(value) ⇒ Object
28
29
30
31
|
# File 'lib/glimmer/swt/checkbox_proxy.rb', line 28
def selection=(value)
@selection = value
dom_element.prop('checked', @selection)
end
|