institution_modal_helper.rb
1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
class InstitutionModalHelper
extend(
ActionView::Helpers::FormOptionsHelper, # content_tag
ActionView::Helpers::FormTagHelper, # button_tag
ActionView::Helpers::UrlHelper, # link_to
ActionView::Context # content_tag do end
)
def self.modal_button link_text=_("Create new institution"), display="block"
# HTML Sample in: http://getbootstrap.com/javascript/#modals-examples
content_tag :div, :id=>"institution_modal_container", :style=>"display: #{display}" do
link = link_to(
link_text,
"javascript: void(0)",
{:class=>"button with-text", :data=>{:toggle=>"modal", :target=>"#institution_modal"}, :id=>"create_institution_link"}
)
link.concat modal
end
end
private
def self.modal
options = {
:id=>"institution_modal",
:role=>"dialog",
:class=>"modal fade"
}
content_tag :div, options do
modal_dialog
end
end
def self.modal_dialog
content_tag :div, :class=>"modal-dialog", :role=>"document" do
modal_content
end
end
def self.modal_content
content_tag :div, :class=>"modal-content" do
#modal_header.concat(modal_body.concat(modal_footer))
modal_header.concat(modal_body)
end
end
def self.modal_header
content_tag :div, :class=>"modal-header" do
button = button_tag :type=>"button", :data=>{:dismiss=>"modal"}, :class=>"close" do
content_tag :span, "×"
end
h4 = content_tag :h4, _("New Institution"), :class=>"modal-title"
button.concat h4
end
end
def self.modal_body
content_tag :div, "", :id=>"institution_modal_body", :class=>"modal-body"
end
#def self.modal_footer
# content_tag :div, {:class=>"modal-footer"} do
# close = button_tag _("Close"), :type=>"button", :class=>"button with-text"
# save = button_tag _("Save changes"), :type=>"button", :class=>"button with-text"
#
# close.concat save
# end
#end
end