Class: Wee::FormDialog
Overview
Constant Summary
Constants inherited
from Component
Component::NO_CHILDREN
Instance Method Summary
collapse
Methods inherited from Component
#add_decoration, #children, #choose_from, #confirm, #decoration, #decoration=, depends, #each_decoration, #find_decoration, #inform, instanciate, #process_callbacks, #remove_decoration, #remove_decoration_if, #state
Methods inherited from Presenter
#process_callbacks, #render!, #renderer_class, #state
Constructor Details
#initialize(caption) ⇒ FormDialog
Returns a new instance of FormDialog.
10
11
12
|
# File 'lib/wee/dialog.rb', line 10
def initialize(caption)
@caption = caption
end
|
Instance Method Details
51
52
53
|
# File 'lib/wee/dialog.rb', line 51
def buttons
[]
end
|
#render(r) ⇒ Object
14
15
16
17
18
19
|
# File 'lib/wee/dialog.rb', line 14
def render(r)
r.div.css_class('wee').with {
render_caption(r)
render_form(r)
}
end
|
#render_body(r) ⇒ Object
32
33
|
# File 'lib/wee/dialog.rb', line 32
def render_body(r)
end
|
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/wee/dialog.rb', line 35
def render_buttons(r)
return if buttons.empty?
r.div.css_class('dialog-buttons').with {
buttons.each do |title, return_value, sym, method|
sym ||= title.downcase
r.span.css_class("dialog-button-#{sym}").with {
if method
r.submit_button.callback_method(method).value(title)
else
r.submit_button.callback_method(:answer, return_value).value(title)
end
}
end
}
end
|
#render_caption(r) ⇒ Object
21
22
23
|
# File 'lib/wee/dialog.rb', line 21
def render_caption(r)
r.h3 @caption if @caption
end
|
25
26
27
28
29
30
|
# File 'lib/wee/dialog.rb', line 25
def render_form(r)
r.form.with {
render_body(r)
render_buttons(r)
}
end
|