Module: JqmHelper
- Includes:
- ActionView::Helpers::OutputSafetyHelper, ActionView::Helpers::TagHelper
- Included in:
- NavBuilder
- Defined in:
- lib/jqm_helper.rb,
lib/jqm_helper/railtie.rb,
lib/jqm_helper/nav_builder.rb,
lib/jqm_helper/tag_helpers.rb
Defined Under Namespace
Classes: NavBuilder, Railtie
Instance Method Summary
collapse
-
#back_button(options = {}) ⇒ Object
-
#backward_button(text, href, options = {}) ⇒ Object
(also: #backwards_button)
-
#dialog_button(text, href, options = {}) ⇒ Object
-
#forward_button(text, href, options = {}) ⇒ Object
(also: #forwards_button)
-
#jqm_button(text, href_or_options, options = {}) ⇒ Object
-
#jqm_page(title, options = {}, &block) ⇒ Object
-
#make_options(defaults, custom) ⇒ Object
-
#nav_for(page, &block) ⇒ Object
-
#slider_tag(name, label) ⇒ Object
Instance Method Details
102
103
104
105
106
107
108
109
|
# File 'lib/jqm_helper/tag_helpers.rb', line 102
def back_button(options = {})
defaults = {
data: {
rel: :back
}
}
backwards_button('Back', '#', make_options(defaults, options))
end
|
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/jqm_helper/tag_helpers.rb', line 88
def backward_button(text, href, options = {})
defaults = {
:href => href,
:data => {
:role => :button,
:icon => 'arrow-l',
:direction => 'reverse'
}
}
content_tag(:a, raw(text), make_options(defaults, options))
end
|
64
65
66
67
68
69
70
71
72
|
# File 'lib/jqm_helper/tag_helpers.rb', line 64
def dialog_button(text, href, options = {})
defaults = {
data: {
rel: :dialog,
transition: :slidedown,
}
}
jqm_button(text, href, make_options(defaults, options))
end
|
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/jqm_helper/tag_helpers.rb', line 74
def forward_button(text, href, options = {})
defaults = {
:href => href,
:data => {
:role => :button,
:icon => 'arrow-r',
:iconpos => 'right'
}
}
content_tag(:a, raw(text), make_options(defaults, options))
end
|
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/jqm_helper/tag_helpers.rb', line 45
def jqm_button(text, href_or_options, options = {})
defaults = {
data: {
role: :button,
prefetch: :true
}
}
if href_or_options.is_a? Hash
options = href_of_options
else
defaults[:href] = href_or_options
end
defaults[:class] = 'notext' if text.blank? || text==' '
content_tag(:a, raw(text), make_options(defaults, options))
end
|
#jqm_page(title, options = {}, &block) ⇒ Object
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
|
# File 'lib/jqm_helper/tag_helpers.rb', line 3
def jqm_page(title, options = {}, &block)
defaults = {
:class => "#{title.downcase}_page",
:id => "#{title.downcase}_page",
:data => {
:role => 'page',
:title => title.capitalize,
}
}
script = ''
content_tag(:div, raw(%Q{
<meta name="assets_version" content="#{1 || Brickbook::Application.config.assets.version}"/>
#{csrf_meta_tags}
<!--<script type='text/javascript'>#{script}</script>-->
#{capture(&block)}
}), make_options(defaults, options))
end
|
#make_options(defaults, custom) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/jqm_helper.rb', line 16
def make_options(defaults, custom)
[defaults, custom].each do |options|
if data = options.delete(:data)
data.each do |k, v|
options[:"data-#{k}"] = v
end
end
end
options = defaults.merge(custom)
options.delete(:'data-prefetch') if options[:'data-prefetch'] == false
options
end
|
#nav_for(page, &block) ⇒ Object
3
4
5
6
|
# File 'lib/jqm_helper/nav_builder.rb', line 3
def nav_for(page, &block) builder = NavBuilder.new(page)
content_tag :div, capture(builder, &block), make_options({data: {role: 'controlgroup', type: 'horizontal'}}, {})
end
|
#slider_tag(name, label) ⇒ Object
111
112
113
114
115
116
117
118
119
120
121
|
# File 'lib/jqm_helper/tag_helpers.rb', line 111
def slider_tag(name, label)
raw %Q{
<div data-role="fieldcontain" style="border: 0; margin: 0; padding: 1em 0 0 0;">
<label style="" for="#{name}">#{label}</label>
<select name="#{name}" id="#{name}" data-role="slider">
<option value="no">Off</option>
<option value="yes">On</option>
</select>
</div>
}
end
|