bootstrap3_helper 2.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +125 -40
- data/lib/bootstrap3_helper/accordion.rb +44 -41
- data/lib/bootstrap3_helper/accordion_group.rb +6 -6
- data/lib/bootstrap3_helper/alert.rb +13 -19
- data/lib/bootstrap3_helper/callout.rb +3 -3
- data/lib/bootstrap3_helper/component.rb +57 -5
- data/lib/bootstrap3_helper/configuration.rb +28 -9
- data/lib/bootstrap3_helper/initialize.rb +19 -0
- data/lib/bootstrap3_helper/panel.rb +103 -43
- data/lib/bootstrap3_helper/railtie.rb +4 -2
- data/lib/bootstrap3_helper/tabs/content.rb +1 -1
- data/lib/bootstrap3_helper/tabs/dropdown.rb +2 -2
- data/lib/bootstrap3_helper/tabs/menu.rb +6 -6
- data/lib/bootstrap3_helper/version.rb +1 -1
- data/lib/bootstrap3_helper.rb +147 -94
- metadata +32 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4bf8c7130e4ef285f58ed677735798e7095891782e0fcc4b9b8cc0be5e5ffeb
|
4
|
+
data.tar.gz: 4de1b4d4797e2af870b9dbcfb3a59448b0ad94fef36e616ec54de6aa1bf0f78d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93fc72762c550db6deb1864bbb678275da47192b9a9429d54d26de7dc3eab93f15301e481849d4beedfd1f199656f4a9fc4ddd507445f363866653652f80f47e
|
7
|
+
data.tar.gz: 3b627ae82825902360e04fcd3e8ab6a79a4ede3492dd37cd62aca54801e788c3336b3ed4ad4603de6699c18b117e89de8c22ea93f46e1766e750b0ea28982903
|
data/README.md
CHANGED
@@ -18,14 +18,42 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
$ gem install bootstrap3_helper
|
20
20
|
|
21
|
-
##
|
21
|
+
## Panel Helper
|
22
22
|
|
23
|
-
|
23
|
+
Panels supper the following methods:
|
24
|
+
|
25
|
+
- body
|
26
|
+
- heaader
|
27
|
+
- footer
|
28
|
+
- title
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
# @overload panel_helper(context, opts)
|
32
|
+
# @param [String|Symbol] context - :primary, :danger etc
|
33
|
+
# @param [Hash] opts
|
34
|
+
# @option opts [String] :id
|
35
|
+
# @option opts [String] :class
|
36
|
+
# @option opts [Hash] :data
|
37
|
+
# @option opts [Hash] :aria
|
38
|
+
#
|
39
|
+
# @overload panel_helper(opts)
|
40
|
+
# @param [Hash] opts
|
41
|
+
# @option opts [String] :id
|
42
|
+
# @option opts [String] :class
|
43
|
+
# @option opts [Hash] :data
|
44
|
+
# @option opts [Hash] :aria
|
45
|
+
#
|
46
|
+
# @yieldparam [Panel] panel
|
47
|
+
# @return [String]
|
48
|
+
```
|
49
|
+
|
50
|
+
#### Example
|
24
51
|
|
25
52
|
```erb
|
26
53
|
<%= panel_helper :primary do |p| %>
|
27
54
|
<%= p.header id: 'optional-id', class: 'any-optional-extra-classes' do %>
|
28
|
-
|
55
|
+
<%= p.header { 'Optional header title' } %>
|
56
|
+
<p>Non styled content for header...</p>
|
29
57
|
<% end %>
|
30
58
|
<%= p.body id: 'optional-id', class: 'any-optional-extra-classes' do %>
|
31
59
|
All your custom HTML or Ruby. You can render blocks here, whatever
|
@@ -37,9 +65,25 @@ Or install it yourself as:
|
|
37
65
|
end
|
38
66
|
```
|
39
67
|
|
40
|
-
|
68
|
+
## Alert Helper
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
# @overload alert_helper(context, opts)
|
72
|
+
# @param [Symbol|String] context - :primary, :danger etc
|
73
|
+
# @param [Hash] opts
|
74
|
+
# @option opts [String] :id
|
75
|
+
# @option opts [String] :class
|
76
|
+
# @option opts [Boolean] :dismissible
|
77
|
+
#
|
78
|
+
# @overload alert_helper(opts)
|
79
|
+
# @param [Hash] opts
|
80
|
+
# @option opts [String] :id
|
81
|
+
# @option opts [String] :class
|
82
|
+
#
|
83
|
+
# @return [String]
|
84
|
+
```
|
41
85
|
|
42
|
-
|
86
|
+
### Example
|
43
87
|
|
44
88
|
```erb
|
45
89
|
<%= alert_helper :success { 'Some success message' } %>
|
@@ -51,12 +95,28 @@ end
|
|
51
95
|
<% end %>
|
52
96
|
```
|
53
97
|
|
54
|
-
|
98
|
+
## Acordion Helper
|
55
99
|
|
56
|
-
|
100
|
+
```ruby
|
101
|
+
# @overload accordion_helper(context, opts)
|
102
|
+
# @param [Symbol|String] context - :primary, :danger etc
|
103
|
+
# @param [Hash] opts
|
104
|
+
# @option opts [String] :id
|
105
|
+
# @option opts [String] :class
|
106
|
+
#
|
107
|
+
# @overload accordion_helper(opts)
|
108
|
+
# @param [Hash] opts
|
109
|
+
# @option opts [String] :id
|
110
|
+
# @option opts [String] :class
|
111
|
+
#
|
112
|
+
# @yieldparam [Accordion] accordion
|
113
|
+
# @return [String]
|
114
|
+
```
|
115
|
+
|
116
|
+
### Example
|
57
117
|
|
58
118
|
```erb
|
59
|
-
<%= accordion_helper :primary,
|
119
|
+
<%= accordion_helper :primary, id: 'optional_id', expanded: true do |accordion| %>
|
60
120
|
<%= accordion.header do %>
|
61
121
|
<span class="something">This is the heading....</span>
|
62
122
|
<% end %>
|
@@ -66,11 +126,19 @@ end
|
|
66
126
|
<% end %>
|
67
127
|
```
|
68
128
|
|
69
|
-
**Note:** the accordion helper handles all the attributes and data attributes needed to sync up the javascript in order to give the component its functionality. You just worry about about the class or state of the component. The helper does the rest. But if you do want to control the collapse ID and syncing, `collapse_id` is the
|
129
|
+
**Note:** the accordion helper handles all the attributes and data attributes needed to sync up the javascript in order to give the component its functionality. You just worry about about the class or state of the component. The helper does the rest. But if you do want to control the collapse ID and syncing, `collapse_id` is the parameter you are looking for.
|
70
130
|
|
71
|
-
|
131
|
+
## Accordion Group
|
72
132
|
|
73
|
-
|
133
|
+
```ruby
|
134
|
+
# @param [Hash] opts
|
135
|
+
# @option opts [String] :id
|
136
|
+
# @option opts [String] :class
|
137
|
+
# @yieldparam [AccordionGroup] group
|
138
|
+
# @return [String]
|
139
|
+
```
|
140
|
+
|
141
|
+
### Example
|
74
142
|
|
75
143
|
```erb
|
76
144
|
<%= accordion_group_helper do |g| %>
|
@@ -95,41 +163,58 @@ end
|
|
95
163
|
<% end %>
|
96
164
|
```
|
97
165
|
|
98
|
-
|
166
|
+
## Tab Helper
|
99
167
|
|
100
|
-
|
168
|
+
Tabs respond to the following methods:
|
101
169
|
|
102
|
-
|
170
|
+
- menu
|
171
|
+
- item (Used for linking to tab content)
|
172
|
+
- dropdown (Used for making dropdown menus)
|
173
|
+
- content
|
103
174
|
|
104
|
-
```
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
<%= dropdown.item(:testing7 ) { 'Testing 7' } %>
|
113
|
-
<% end %>
|
175
|
+
```ruby
|
176
|
+
# @param [Hash] opts
|
177
|
+
# @option args [String|Symbol] :type - :tabs, :pills
|
178
|
+
# @option args [String] :id
|
179
|
+
# @option args [String] :class
|
180
|
+
# @yieldparam [Tabs] tabs
|
181
|
+
# @return [String]
|
182
|
+
```
|
114
183
|
|
184
|
+
### Example
|
115
185
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
<% end %>
|
128
|
-
<% content.item :testing6 do %>
|
129
|
-
Testing 6 content
|
186
|
+
```erb
|
187
|
+
<%= tabs_helper type: :pills do |tabs| %>
|
188
|
+
<%= tabs.menu do |menu| %>
|
189
|
+
<%= menu.item(:testing1, class: 'active') { ' Testing 1' } %>
|
190
|
+
<%= menu.item :testing2 %>
|
191
|
+
<%= menu.item(:testing3) { ' Testing 3' } %>
|
192
|
+
<%= menu.dropdown 'Testing Dropdown' do |dropdown| %>
|
193
|
+
<%= dropdown.item(:testing5 ) { 'Testing 5' } %>
|
194
|
+
<%= dropdown.item(:testing6 ) { 'Testing 6' } %>
|
195
|
+
<%= dropdown.item(:testing7 ) { 'Testing 7' } %>
|
196
|
+
<% end %>
|
130
197
|
<% end %>
|
131
|
-
|
132
|
-
|
198
|
+
|
199
|
+
<%= tabs.content do |content| %>
|
200
|
+
<% content.pane :testing1, class: 'active' do %>
|
201
|
+
Testing 1 content
|
202
|
+
<% end %>
|
203
|
+
<% content.pane :testing2 do %>
|
204
|
+
Testing 2 content
|
205
|
+
<% end %>
|
206
|
+
<% content.pane :testing3 do %>
|
207
|
+
Testing 3 content
|
208
|
+
<% end %>
|
209
|
+
<% content.pane :testing5 do %>
|
210
|
+
Testing 5 content
|
211
|
+
<% end %>
|
212
|
+
<% content.pane :testing6 do %>
|
213
|
+
Testing 6 content
|
214
|
+
<% end %>
|
215
|
+
<% content.pane :testing7 do %>
|
216
|
+
Testing 7 content
|
217
|
+
<% end %>
|
133
218
|
<% end %>
|
134
219
|
<% end %>
|
135
220
|
```
|
@@ -1,17 +1,6 @@
|
|
1
1
|
module Bootstrap3Helper # :nodoc:
|
2
2
|
# Used to generate Bootstrap Accordion objects.
|
3
3
|
#
|
4
|
-
# @example Render out an Accordion component in a template:
|
5
|
-
# <code>
|
6
|
-
# <%= accordion_helper :primary do |accordion| %>
|
7
|
-
# <%= accordion.header do %>
|
8
|
-
# <span class="something">This is the heading....</span>
|
9
|
-
# <% end %>
|
10
|
-
# <%= accordion.body do %>
|
11
|
-
# <p>This is the body of the accordion....</p>
|
12
|
-
# <% end %>
|
13
|
-
# <% end %>
|
14
|
-
# </code>
|
15
4
|
#
|
16
5
|
class Accordion < Component
|
17
6
|
# Initlize a new accordion object. If this part of a parent element, i.e
|
@@ -19,7 +8,7 @@ module Bootstrap3Helper # :nodoc:
|
|
19
8
|
# pass it down to the other components.
|
20
9
|
#
|
21
10
|
# @param [Class] template - Template in which your are binding too.
|
22
|
-
# @param [NilClass|String|Symbol|Hash]
|
11
|
+
# @param [NilClass|String|Symbol|Hash] context_or_options Bootstrap class context, or options hash.
|
23
12
|
# @param [Hash] opts
|
24
13
|
# @option opts [String] :parent_id The parent element ID if this accordion is part of a group.
|
25
14
|
# @option opts [String] :id The ID of the element
|
@@ -30,7 +19,7 @@ module Bootstrap3Helper # :nodoc:
|
|
30
19
|
#
|
31
20
|
def initialize(template, context_or_options = nil, opts = {}, &block)
|
32
21
|
super(template)
|
33
|
-
@context, args =
|
22
|
+
@context, args = parse_context_or_options(context_or_options, opts)
|
34
23
|
|
35
24
|
@parent_id = args.fetch(:parent_id, nil)
|
36
25
|
@id = args.fetch(:id, nil)
|
@@ -41,27 +30,27 @@ module Bootstrap3Helper # :nodoc:
|
|
41
30
|
@panel = Panel.new(@template, context_or_options, opts)
|
42
31
|
end
|
43
32
|
|
44
|
-
# rubocop:disable Metrics/MethodLength
|
45
|
-
|
46
33
|
# Creates the header element for the accordion
|
47
34
|
#
|
48
|
-
# @
|
49
|
-
#
|
50
|
-
# @params [Hash] args
|
35
|
+
# @param [Symbol|String|Hash|NilClass] tag_or_options
|
36
|
+
# @param [Hash] opts
|
51
37
|
# @option opts [String] :id
|
52
38
|
# @option opts [String] :class
|
53
39
|
# @option opts [Hash] :data
|
54
|
-
# @
|
40
|
+
# @option opts [Hash] :aria
|
41
|
+
# @return [String]
|
55
42
|
#
|
56
|
-
def header(
|
57
|
-
|
43
|
+
def header(tag_or_options = nil, opts = {}, &block)
|
44
|
+
tag, args = parse_tag_or_options(tag_or_options, opts)
|
45
|
+
|
46
|
+
data = {}
|
58
47
|
data[:toggle] = 'collapse'
|
59
48
|
data[:parent] = "##{@parent_id}" if @parent_id.present?
|
49
|
+
data[:target] = "##{@collapse_id}"
|
60
50
|
|
61
|
-
@panel.header(args) do
|
51
|
+
@panel.header(tag, args.merge!(config_for: :accordions)) do
|
62
52
|
content_tag(
|
63
|
-
:
|
64
|
-
href: "##{@collapse_id}",
|
53
|
+
:span,
|
65
54
|
role: 'button',
|
66
55
|
data: data,
|
67
56
|
aria: { expanded: @expanded, controls: "##{@collapse_id}" },
|
@@ -69,21 +58,35 @@ module Bootstrap3Helper # :nodoc:
|
|
69
58
|
)
|
70
59
|
end
|
71
60
|
end
|
72
|
-
# rubocop:enable Metrics/MethodLength
|
73
61
|
|
74
|
-
#
|
62
|
+
# Builds a title component for the accordion header.
|
63
|
+
#
|
64
|
+
# @param [Symbol|String|Hash|NilClass] tag_or_options
|
65
|
+
# @param [Hash] opts
|
66
|
+
# @option opts [String] :id
|
67
|
+
# @option opts [String] :class
|
68
|
+
# @option opts [Hash] :data
|
69
|
+
# @option opts [Hash] :aria
|
70
|
+
# @return [String]
|
71
|
+
#
|
72
|
+
def title(tag_or_options = nil, opts = {}, &block)
|
73
|
+
tag, args = parse_tag_or_options(tag_or_options, opts)
|
74
|
+
@panel.title(tag, args.merge!(config_for: :accordions), &block)
|
75
|
+
end
|
75
76
|
|
76
77
|
# Creates the body element for the accordion.
|
77
78
|
#
|
78
79
|
# @note NilClass :to_s returns an empty String
|
79
80
|
#
|
80
|
-
# @
|
81
|
-
# @option
|
82
|
-
# @option
|
83
|
-
# @option
|
81
|
+
# @param [Hash] args
|
82
|
+
# @option args [String] :id
|
83
|
+
# @option args [String] :class
|
84
|
+
# @option args [Hash] :data
|
84
85
|
# @yieldreturn [String]
|
85
86
|
#
|
86
|
-
def body(
|
87
|
+
def body(tag_or_options = nil, opts = {}, &block)
|
88
|
+
tag, args = parse_tag_or_options(tag_or_options, opts)
|
89
|
+
|
87
90
|
klass = 'panel-collapse collapse '
|
88
91
|
klass += ' in' if @expanded
|
89
92
|
|
@@ -94,21 +97,21 @@ module Bootstrap3Helper # :nodoc:
|
|
94
97
|
class: klass,
|
95
98
|
aria: { labelledby: "##{@collapse_id}" }
|
96
99
|
) do
|
97
|
-
@panel.body(args, &block)
|
100
|
+
@panel.body(tag, args.merge!(config_for: :accordions), &block)
|
98
101
|
end
|
99
102
|
end
|
100
|
-
# rubocop:enable Metrics/MethodLength
|
101
103
|
|
102
104
|
# Creates the footer element for the accordion
|
103
105
|
#
|
104
|
-
# @
|
105
|
-
# @option
|
106
|
-
# @option
|
107
|
-
# @option
|
108
|
-
# @
|
106
|
+
# @param [Hash] args
|
107
|
+
# @option args [String] :id
|
108
|
+
# @option args [String] :class
|
109
|
+
# @option args [Hash] :data
|
110
|
+
# @return [String]
|
109
111
|
#
|
110
|
-
def footer(
|
111
|
-
|
112
|
+
def footer(tag_or_options = nil, opts = {}, &block)
|
113
|
+
tag, args = parse_tag_or_options(tag_or_options, opts)
|
114
|
+
@panel.footer(tag, args.merge!(config_for: :accordions), &block)
|
112
115
|
end
|
113
116
|
|
114
117
|
# The to string method here is what is responsible for rendering out the
|
@@ -118,7 +121,7 @@ module Bootstrap3Helper # :nodoc:
|
|
118
121
|
# @return [String]
|
119
122
|
#
|
120
123
|
def to_s
|
121
|
-
|
124
|
+
content_tag :div, id: @id, class: container_classes do
|
122
125
|
@content.call(self)
|
123
126
|
end
|
124
127
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Bootstrap3Helper # :nodoc:
|
2
2
|
# This class is used to general groups of accordions.
|
3
3
|
#
|
4
|
-
# @
|
4
|
+
# @example Rendering out an Accordion Group in template:
|
5
5
|
# <code>
|
6
6
|
# <%= accordion_group_helper do |group| %>
|
7
7
|
# <%= group.accordion :primary do |accordion| %>
|
@@ -48,11 +48,11 @@ module Bootstrap3Helper # :nodoc:
|
|
48
48
|
# This method is the main method for generating individual accordions.
|
49
49
|
# This is where you would pass in the html attributes.
|
50
50
|
#
|
51
|
-
# @param [NilClass|String|Symbol|Hash]
|
51
|
+
# @param [NilClass|String|Symbol|Hash] context_or_options
|
52
52
|
# @param [Hash] opts
|
53
|
-
# @option
|
54
|
-
# @option
|
55
|
-
# @
|
53
|
+
# @option opts [String] :id
|
54
|
+
# @option opts [String] :class
|
55
|
+
# @yieldreturn [Accordion] accordion
|
56
56
|
#
|
57
57
|
def accordion(context_or_options = nil, opts = {}, &block)
|
58
58
|
if context_or_options.is_a?(Hash)
|
@@ -71,7 +71,7 @@ module Bootstrap3Helper # :nodoc:
|
|
71
71
|
# @return [String]
|
72
72
|
#
|
73
73
|
def to_s
|
74
|
-
|
74
|
+
content_tag :div, id: @id, class: "panel-group #{@class}" do
|
75
75
|
@content.call(self)
|
76
76
|
end
|
77
77
|
end
|
@@ -2,22 +2,11 @@ module Bootstrap3Helper # :nodoc:
|
|
2
2
|
# The Alert helper is meant to help you rapidly build Bootstrap Alert
|
3
3
|
# components quickly and easily. The dissmiss button is optional.
|
4
4
|
#
|
5
|
-
# @example Rendering a Bootstrap Alert Component in a view:
|
6
|
-
# <code>
|
7
|
-
# <%= alert_helper :warning, dismissable: true do %>
|
8
|
-
# <% if @model.errors.present? %>
|
9
|
-
# <p>Some kind of error</p>
|
10
|
-
# <% end %>
|
11
|
-
# <% end %>
|
12
|
-
#
|
13
|
-
# <%= alert_helper(:success, dismissible: true) { "Successful save"}
|
14
|
-
# </code>
|
15
|
-
#
|
16
5
|
class Alert < Component
|
17
6
|
# Used to generate Bootstrap alert components quickly.
|
18
7
|
#
|
19
|
-
# @param [
|
20
|
-
# @param [NilClass|String|Symbol|Hash] Bootstrap class context, or options hash.
|
8
|
+
# @param [ActionView] template Template in which your are binding too.
|
9
|
+
# @param [NilClass|String|Symbol|Hash] context_or_options Bootstrap class context, or options hash.
|
21
10
|
# @param [Hash] opts
|
22
11
|
# @option opts [String] :id The ID of the element
|
23
12
|
# @option opts [String] :class Custom class for the component.
|
@@ -25,12 +14,12 @@ module Bootstrap3Helper # :nodoc:
|
|
25
14
|
#
|
26
15
|
def initialize(template, context_or_options = nil, opts = {}, &block)
|
27
16
|
super(template)
|
28
|
-
@context, args = parse_arguments(context_or_options, opts)
|
29
17
|
|
30
|
-
@
|
31
|
-
@
|
32
|
-
@
|
33
|
-
@
|
18
|
+
@context, args = parse_context_or_options(context_or_options, opts)
|
19
|
+
@id = args.fetch(:id, nil)
|
20
|
+
@class = args.fetch(:class, '')
|
21
|
+
@dismissible = args.fetch(:dismissible, false)
|
22
|
+
@content = block || proc { '' }
|
34
23
|
end
|
35
24
|
|
36
25
|
# The dissmiss button, if the element has one.
|
@@ -38,7 +27,12 @@ module Bootstrap3Helper # :nodoc:
|
|
38
27
|
# @return [String]
|
39
28
|
#
|
40
29
|
def close_button
|
41
|
-
content_tag(
|
30
|
+
content_tag(
|
31
|
+
:button,
|
32
|
+
class: 'close',
|
33
|
+
data: { dismiss: 'alert' },
|
34
|
+
aria: { label: 'Close' }
|
35
|
+
) do
|
42
36
|
content_tag(:span, aria: { hidden: true }) { '×'.html_safe }
|
43
37
|
end
|
44
38
|
end
|
@@ -3,8 +3,8 @@ module Bootstrap3Helper # :nodoc:
|
|
3
3
|
#
|
4
4
|
#
|
5
5
|
class Callout < Component
|
6
|
-
# @param [
|
7
|
-
# @param [NilClass|String|Symbol|Hash]
|
6
|
+
# @param [ActionView] template Template in which your are binding too.
|
7
|
+
# @param [NilClass|String|Symbol|Hash] context_or_options Bootstrap class context, or options hash.
|
8
8
|
# @param [Hash] opts
|
9
9
|
# @option opts [String] :id The ID of the element
|
10
10
|
# @option opts [String] :class Custom class for the component.
|
@@ -12,7 +12,7 @@ module Bootstrap3Helper # :nodoc:
|
|
12
12
|
#
|
13
13
|
def initialize(template, context_or_options = nil, opts = {}, &block)
|
14
14
|
super(template)
|
15
|
-
@context, args =
|
15
|
+
@context, args = parse_context_or_options(context_or_options, opts)
|
16
16
|
|
17
17
|
@id = args.fetch(:id, nil)
|
18
18
|
@class = args.fetch(:class, '')
|
@@ -15,7 +15,7 @@ module Bootstrap3Helper # :nodoc
|
|
15
15
|
# Used to ensure that the helpers always have the propert context for
|
16
16
|
# rendering and bindings.
|
17
17
|
#
|
18
|
-
# @param [
|
18
|
+
# @param [ActionView] template the context of the bindings
|
19
19
|
#
|
20
20
|
def initialize(template)
|
21
21
|
@template = template
|
@@ -46,7 +46,7 @@ module Bootstrap3Helper # :nodoc
|
|
46
46
|
# binding. Concat adds a String to the template Output buffer. Useful when
|
47
47
|
# trying to add a String with no block.
|
48
48
|
#
|
49
|
-
# @
|
49
|
+
# @param [String] text
|
50
50
|
#
|
51
51
|
def concat(text)
|
52
52
|
@template.concat(text)
|
@@ -57,14 +57,46 @@ module Bootstrap3Helper # :nodoc
|
|
57
57
|
# contectual class. So we will assign it to `default` and
|
58
58
|
# return the Hash to be used as options.
|
59
59
|
#
|
60
|
-
# @
|
60
|
+
# @param [Hash|NilClass|String|Symbol] args
|
61
61
|
# @return [Array]
|
62
62
|
#
|
63
|
-
def
|
63
|
+
def parse_context_or_options(*args)
|
64
|
+
parse_arguments(*args, 'default')
|
65
|
+
end
|
66
|
+
|
67
|
+
# Used to parse method arguments. If the first argument is
|
68
|
+
# a Hash, then it is assumed that the user left off the tag
|
69
|
+
# element. So we will assign it to <tt>NilClass</tt> and
|
70
|
+
# return the Hash to be used as options.
|
71
|
+
#
|
72
|
+
# @param [Hash|NilClass|String|Symbol] args
|
73
|
+
# @return [Array]
|
74
|
+
#
|
75
|
+
def parse_tag_or_options(*args)
|
76
|
+
parse_arguments(*args, nil)
|
77
|
+
end
|
78
|
+
|
79
|
+
# Used to parse method arguments. If the first argument is
|
80
|
+
# a Hash, then it is assumed that the user left off the bootstrap
|
81
|
+
# contectual class. So we will assign it to `default` and
|
82
|
+
# return the Hash to be used as options.
|
83
|
+
#
|
84
|
+
# @overload parse_arguments(param_or_options, options, default)
|
85
|
+
# @param [NilClass|Hash|Symbol|String] param_or_options
|
86
|
+
# @param [Hash] options
|
87
|
+
# @param [NilClass|String|Symbol] default
|
88
|
+
#
|
89
|
+
# @overload parse_arguments(options, default)
|
90
|
+
# @param [Hash] options
|
91
|
+
# @param [NilClass|String|Symbol] default
|
92
|
+
#
|
93
|
+
# @return [Array]
|
94
|
+
#
|
95
|
+
def parse_arguments(*args, default)
|
64
96
|
first, second = *args
|
65
97
|
case first
|
66
98
|
when Hash, NilClass
|
67
|
-
[
|
99
|
+
[default, first || second]
|
68
100
|
when Symbol, String
|
69
101
|
[first, second]
|
70
102
|
end
|
@@ -78,5 +110,25 @@ module Bootstrap3Helper # :nodoc
|
|
78
110
|
def uuid
|
79
111
|
(0...10).map { rand(65..90).chr }.join
|
80
112
|
end
|
113
|
+
|
114
|
+
# Used to get config settings inside of components quicker.
|
115
|
+
#
|
116
|
+
# @param [Symbol|String|Hash] setting
|
117
|
+
# @return [Mixed]
|
118
|
+
#
|
119
|
+
def config(setting, fallback)
|
120
|
+
object = Bootstrap3Helper.config
|
121
|
+
|
122
|
+
value = (
|
123
|
+
case setting
|
124
|
+
when Hash
|
125
|
+
object.send(setting.keys[0])[setting.values[0]] if object.send(setting.keys[0])
|
126
|
+
when Symbol, String
|
127
|
+
object.send(setting) if object.respond_to?(setting)
|
128
|
+
end
|
129
|
+
)
|
130
|
+
|
131
|
+
value || fallback
|
132
|
+
end
|
81
133
|
end
|
82
134
|
end
|
@@ -6,20 +6,39 @@ module Bootstrap3Helper
|
|
6
6
|
#
|
7
7
|
#
|
8
8
|
class Configuration
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
DEFAULT_SETTINGS = {
|
10
|
+
autoload_in_views: true,
|
11
|
+
accodions: {
|
12
|
+
header: :div,
|
13
|
+
body: :div,
|
14
|
+
footer: :div,
|
15
|
+
title: :h4
|
16
|
+
},
|
17
|
+
panels: {
|
18
|
+
header: :div,
|
19
|
+
body: :div,
|
20
|
+
footer: :div,
|
21
|
+
title: :h3
|
22
|
+
}
|
23
|
+
}.freeze
|
12
24
|
|
13
|
-
attr_accessor(*
|
25
|
+
attr_accessor(*DEFAULT_SETTINGS.keys)
|
14
26
|
|
15
|
-
#
|
16
|
-
# -
|
27
|
+
# Class constructor
|
17
28
|
#
|
18
|
-
# @
|
29
|
+
# @param [Hash] _args
|
19
30
|
# @return [ClassName]
|
20
31
|
#
|
21
|
-
def initialize(
|
22
|
-
|
32
|
+
def initialize(_args = {})
|
33
|
+
DEFAULT_SETTINGS.each { |key, value| instance_variable_set("@#{key}", value) }
|
34
|
+
end
|
35
|
+
|
36
|
+
# Simple predicate method
|
37
|
+
#
|
38
|
+
# @return [Boolean]
|
39
|
+
#
|
40
|
+
def autoload_in_views?
|
41
|
+
@autoload_in_views
|
23
42
|
end
|
24
43
|
end
|
25
44
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Bootstrap3Helper # :nodoc:
|
2
|
+
# Naming convention used as to not pollute views where the module is
|
3
|
+
# included. @config is a common instance variable name. We don't want
|
4
|
+
# to risk overriding another developers variable.
|
5
|
+
#
|
6
|
+
@_bs3h_config = Configuration.new
|
7
|
+
|
8
|
+
class << self
|
9
|
+
# Simple interface for exposing the configuration object.
|
10
|
+
#
|
11
|
+
# @return [Bootstrap5Helper::Configuration]
|
12
|
+
#
|
13
|
+
def config
|
14
|
+
yield @_bs3h_config if block_given?
|
15
|
+
|
16
|
+
@_bs3h_config
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,80 +1,140 @@
|
|
1
1
|
module Bootstrap3Helper # :nodoc:
|
2
2
|
# Used to rapidly build Bootstrap Panel Components.
|
3
3
|
#
|
4
|
-
# @example Rendering a Bootstrap Panel Component in a view:
|
5
|
-
# <%= panel_helper class: 'panel-primary' do |p| %>
|
6
|
-
# <%= p.header { "Some Title" }
|
7
|
-
# <%= p.body class: 'custom-class', id: 'custom-id' do %>
|
8
|
-
# //HTML or Ruby code here...
|
9
|
-
# <% end %>
|
10
|
-
# <%= p.footer do %>
|
11
|
-
# //HTML or Ruby
|
12
|
-
# <% end %>
|
13
|
-
# <% end %>
|
14
4
|
#
|
15
5
|
class Panel < Component
|
16
6
|
# Creates a new Panel object.
|
17
7
|
#
|
18
|
-
# @param [
|
19
|
-
# @param [NilClass|String|Symbol|Hash] - Bootstrap class context, or options hash.
|
8
|
+
# @param [ActionView] template - Template in which your are binding too.
|
9
|
+
# @param [NilClass|String|Symbol|Hash] context_or_options - Bootstrap class context, or options hash.
|
20
10
|
# @param [Hash] opts
|
21
|
-
# @option opts [String] :id The ID of the element
|
22
|
-
# @option opts [String] :class Custom class for the component.
|
23
|
-
# @option opts [Hash] :data Any data attributes for the element.
|
11
|
+
# @option opts [String] :id - The ID of the element
|
12
|
+
# @option opts [String] :class - Custom class for the component.
|
13
|
+
# @option opts [Hash] :data - Any data attributes for the element.
|
14
|
+
# @option opts [Symbol] :config_type - Used to change config from Panel to Accordion.
|
24
15
|
# @return [Panel]
|
25
16
|
#
|
26
17
|
def initialize(template, context_or_options = nil, opts = {}, &block)
|
27
18
|
super(template)
|
28
|
-
@context, args =
|
19
|
+
@context, args = parse_context_or_options(context_or_options, opts)
|
29
20
|
|
30
|
-
@id
|
31
|
-
@class
|
32
|
-
@data
|
33
|
-
@
|
21
|
+
@id = args.fetch(:id, '')
|
22
|
+
@class = args.fetch(:class, '')
|
23
|
+
@data = args.fetch(:data, nil)
|
24
|
+
@config_type = args.fetch(:config_type, :panels)
|
25
|
+
@content = block || proc { '' }
|
34
26
|
end
|
35
27
|
|
36
28
|
# Used to generate the header component for the panel.
|
37
29
|
#
|
38
|
-
# @param
|
39
|
-
# @
|
40
|
-
# @option
|
41
|
-
# @
|
30
|
+
# @param [Symbol|String|Hash|NilClass] tag_or_options
|
31
|
+
# @param [Hash] opts
|
32
|
+
# @option opts [String] :id
|
33
|
+
# @option opts [String] :class
|
34
|
+
# @option opts [Hash] :data
|
35
|
+
# @option opts [Hash] :aria
|
36
|
+
# @return [String]
|
42
37
|
#
|
43
|
-
def header(
|
44
|
-
|
38
|
+
def header(tag_or_options = nil, opts = {}, &block)
|
39
|
+
tag, args = parse_tag_or_options(tag_or_options, opts)
|
40
|
+
|
41
|
+
id = args.fetch(:id, nil)
|
45
42
|
klass = args.fetch(:class, '')
|
43
|
+
data = args.fetch(:data, {})
|
44
|
+
aria = args.fetch(:aria, {})
|
46
45
|
|
47
|
-
content_tag(
|
48
|
-
|
49
|
-
|
46
|
+
content_tag(
|
47
|
+
tag || config({ @config_type => :header }, :div),
|
48
|
+
id: id,
|
49
|
+
class: "panel-heading #{klass}",
|
50
|
+
data: data,
|
51
|
+
aria: aria,
|
52
|
+
&block
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
# Builds a title component for the panel.
|
57
|
+
#
|
58
|
+
# @param [Symbol|String|Hash|NilClass] tag_or_options
|
59
|
+
# @param [Hash] opts
|
60
|
+
# @option opts [String] :id
|
61
|
+
# @option opts [String] :class
|
62
|
+
# @option opts [Hash] :data
|
63
|
+
# @option opts [Hash] :aria
|
64
|
+
# @return [String]
|
65
|
+
#
|
66
|
+
def title(tag_or_options = nil, opts = {}, &block)
|
67
|
+
tag, args = parse_tag_or_options(tag_or_options, opts)
|
68
|
+
|
69
|
+
id = args.fetch(:id, nil)
|
70
|
+
klass = args.fetch(:class, '')
|
71
|
+
data = args.fetch(:data, {})
|
72
|
+
aria = args.fetch(:aria, {})
|
73
|
+
|
74
|
+
content_tag(
|
75
|
+
tag || config({ @config_type => :title }, :h3),
|
76
|
+
id: id,
|
77
|
+
class: "panel-title #{klass}",
|
78
|
+
data: data,
|
79
|
+
aria: aria,
|
80
|
+
&block
|
81
|
+
)
|
50
82
|
end
|
51
83
|
|
52
84
|
# Used to generate the body component for the panel.
|
53
85
|
#
|
54
|
-
# @param
|
55
|
-
# @
|
56
|
-
# @option
|
57
|
-
# @
|
86
|
+
# @param [Symbol|String|Hash|NilClass] tag_or_options
|
87
|
+
# @param [Hash] opts
|
88
|
+
# @option opts [String] :id
|
89
|
+
# @option opts [String] :class
|
90
|
+
# @option opts [Hash] :data
|
91
|
+
# @option opts [Hash] :aria
|
92
|
+
# @return [String]
|
58
93
|
#
|
59
|
-
def body(
|
60
|
-
|
94
|
+
def body(tag_or_options = nil, opts = {}, &block)
|
95
|
+
tag, args = parse_tag_or_options(tag_or_options, opts)
|
96
|
+
|
97
|
+
id = args.fetch(:id, nil)
|
61
98
|
klass = args.fetch(:class, '')
|
99
|
+
data = args.fetch(:data, {})
|
100
|
+
aria = args.fetch(:aria, {})
|
62
101
|
|
63
|
-
content_tag(
|
102
|
+
content_tag(
|
103
|
+
tag || config({ @config_type => :body }, :div),
|
104
|
+
id: id,
|
105
|
+
class: "panel-body #{klass}",
|
106
|
+
data: data,
|
107
|
+
aria: aria,
|
108
|
+
&block
|
109
|
+
)
|
64
110
|
end
|
65
111
|
|
66
112
|
# Used to generate the footer component for the panel.
|
67
113
|
#
|
68
|
-
# @param
|
69
|
-
# @
|
70
|
-
# @option
|
71
|
-
# @
|
114
|
+
# @param [Symbol|String|Hash|NilClass] tag_or_options
|
115
|
+
# @param [Hash] opts
|
116
|
+
# @option opts [String] :id
|
117
|
+
# @option opts [String] :class
|
118
|
+
# @option opts [Hash] :data
|
119
|
+
# @option opts [Hash] :aria
|
120
|
+
# @return [String]
|
72
121
|
#
|
73
|
-
def footer(
|
74
|
-
|
122
|
+
def footer(tag_or_options = nil, opts = {}, &block)
|
123
|
+
tag, args = parse_tag_or_options(tag_or_options, opts)
|
124
|
+
|
125
|
+
id = args.fetch(:id, nil)
|
75
126
|
klass = args.fetch(:class, '')
|
127
|
+
data = args.fetch(:data, {})
|
128
|
+
aria = args.fetch(:aria, {})
|
76
129
|
|
77
|
-
content_tag(
|
130
|
+
content_tag(
|
131
|
+
tag || config({ @config_type => :footer }, :div),
|
132
|
+
id: id,
|
133
|
+
class: "panel-footer #{klass}",
|
134
|
+
data: data,
|
135
|
+
aria: aria,
|
136
|
+
&block
|
137
|
+
)
|
78
138
|
end
|
79
139
|
|
80
140
|
# Used to render the html for the entire panel object.
|
@@ -3,8 +3,10 @@ module Bootstrap3Helper
|
|
3
3
|
# - Used to tie into the ActionView
|
4
4
|
#
|
5
5
|
class Railtie < Rails::Railtie
|
6
|
-
|
7
|
-
ActiveSupport.on_load(:action_view)
|
6
|
+
config.after_initialize do
|
7
|
+
ActiveSupport.on_load(:action_view) do
|
8
|
+
include Bootstrap3Helper if Bootstrap3Helper.config.autoload_in_views?
|
9
|
+
end
|
8
10
|
end
|
9
11
|
end
|
10
12
|
end
|
@@ -21,7 +21,7 @@ module Bootstrap3Helper # :nodoc:
|
|
21
21
|
super(template)
|
22
22
|
|
23
23
|
@name = name
|
24
|
-
@content = block || proc { '' }
|
24
|
+
@content = block || proc { '' }
|
25
25
|
end
|
26
26
|
|
27
27
|
# rubocop:disable Metrics/MethodLength
|
@@ -76,7 +76,7 @@ module Bootstrap3Helper # :nodoc:
|
|
76
76
|
data: { toggle: 'dropdown' }, aria: { expanded: false }
|
77
77
|
)
|
78
78
|
|
79
|
-
content
|
79
|
+
content + content_tag(:ul, id: @id, class: 'dropdown-menu ') do
|
80
80
|
@content.call(self)
|
81
81
|
end
|
82
82
|
end
|
@@ -19,9 +19,9 @@ module Bootstrap3Helper # :nodoc:
|
|
19
19
|
def initialize(template, args = {}, &block)
|
20
20
|
super(template)
|
21
21
|
|
22
|
-
@id = args.fetch(:id,
|
22
|
+
@id = args.fetch(:id, nil)
|
23
23
|
@class = args.fetch(:class, '')
|
24
|
-
@type = args.fetch(:type,
|
24
|
+
@type = args.fetch(:type, :tabs)
|
25
25
|
@content = block || proc { '' }
|
26
26
|
end
|
27
27
|
|
@@ -40,12 +40,12 @@ module Bootstrap3Helper # :nodoc:
|
|
40
40
|
# @yieldreturn [String]
|
41
41
|
#
|
42
42
|
def item(name, args = {})
|
43
|
-
id = args.fetch(:id,
|
44
|
-
data = args.fetch(:data,
|
43
|
+
id = args.fetch(:id, nil)
|
44
|
+
data = args.fetch(:data, nil)
|
45
45
|
klass = args.fetch(:class, '')
|
46
46
|
active = klass.include? 'active'
|
47
47
|
|
48
|
-
|
48
|
+
content_tag(
|
49
49
|
:li,
|
50
50
|
id: id,
|
51
51
|
class: klass,
|
@@ -81,7 +81,7 @@ module Bootstrap3Helper # :nodoc:
|
|
81
81
|
klass = args.fetch(:class, '')
|
82
82
|
dropdown = Tabs::Dropdown.new(@template, name, &block)
|
83
83
|
|
84
|
-
|
84
|
+
content_tag :li, id: id, class: 'dropdown' + klass, data: data do
|
85
85
|
dropdown.to_s.html_safe
|
86
86
|
end
|
87
87
|
end
|
data/lib/bootstrap3_helper.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'bootstrap3_helper/version'
|
2
|
+
require 'bootstrap3_helper/configuration'
|
3
|
+
require 'bootstrap3_helper/initialize'
|
2
4
|
|
3
5
|
# Implementation files
|
4
6
|
require 'bootstrap3_helper/component'
|
@@ -17,66 +19,6 @@ require 'bootstrap3_helper/railtie'
|
|
17
19
|
# common Bootstrap components.
|
18
20
|
#
|
19
21
|
module Bootstrap3Helper
|
20
|
-
# Allows you to rapidly build Panel components.
|
21
|
-
#
|
22
|
-
# @example Bootstrap Panel Component:
|
23
|
-
# <%= panel_helper :primary do |p| %>
|
24
|
-
# <%= p.header { "Some Title" }
|
25
|
-
# <%= p.body class: 'custom-class', id: 'custom-id' do %>
|
26
|
-
# //HTML or Ruby code here...
|
27
|
-
# <% end %>
|
28
|
-
# <%= p.footer do %>
|
29
|
-
# //HTML or Ruby
|
30
|
-
# <% end %>
|
31
|
-
# <% end %>
|
32
|
-
#
|
33
|
-
# @param [Symbol|String|Hash|NilClass] args
|
34
|
-
# @yieldparam [Panel] panel
|
35
|
-
# @return [String]
|
36
|
-
#
|
37
|
-
def panel_helper(*args, &block)
|
38
|
-
Panel.new(self, *args, &block)
|
39
|
-
end
|
40
|
-
|
41
|
-
# Creates an Alert component.
|
42
|
-
#
|
43
|
-
# @example Bootstrap Alert Component:
|
44
|
-
# <%= alert_helper :danger, dismissble: true do %>
|
45
|
-
# Something went wrong with your model data...
|
46
|
-
# <% end %>
|
47
|
-
#
|
48
|
-
# @param [Symbol|String|Hash|NilClass] args
|
49
|
-
# @yieldreturn [String]
|
50
|
-
# @return [String]
|
51
|
-
#
|
52
|
-
def alert_helper(*args, &block)
|
53
|
-
Alert.new(self, *args, &block)
|
54
|
-
end
|
55
|
-
|
56
|
-
# Creates an Callout component.
|
57
|
-
#
|
58
|
-
# @example Bootstrap Callout Component:
|
59
|
-
# <%= callout_helper :danger %>
|
60
|
-
# Some information that needs your attention...
|
61
|
-
# <% end %>
|
62
|
-
#
|
63
|
-
# @param [Symbol|String|Hash|NilClass] args
|
64
|
-
# @yieldreturn [String]
|
65
|
-
# @return [String]
|
66
|
-
#
|
67
|
-
def callout_helper(*args, &block)
|
68
|
-
Callout.new(self, *args, &block)
|
69
|
-
end
|
70
|
-
|
71
|
-
# Just a easy way of checking if the environment is a devbox
|
72
|
-
# or a server.
|
73
|
-
#
|
74
|
-
# @return [Boolean]
|
75
|
-
#
|
76
|
-
def host_is_dev_pc?
|
77
|
-
Rails.root.to_s.include?('home')
|
78
|
-
end
|
79
|
-
|
80
22
|
# Easily build a bootstrap accordion group component.
|
81
23
|
#
|
82
24
|
# @note All the element ids and data attributes needed to make the javascript
|
@@ -84,6 +26,7 @@ module Bootstrap3Helper
|
|
84
26
|
# You don't need to worry about them.
|
85
27
|
#
|
86
28
|
# @example Bootstrap Accordion Group Component:
|
29
|
+
# ```erb
|
87
30
|
# <%= accordion_group_helper do |group| %>
|
88
31
|
# <% group.accordion class: 'primary' do |accordion| %>
|
89
32
|
# <%= accordion.header { "accordion 1" } %>
|
@@ -104,18 +47,22 @@ module Bootstrap3Helper
|
|
104
47
|
# <% end %>
|
105
48
|
# <% end %>
|
106
49
|
# <% end %>
|
50
|
+
# ```
|
107
51
|
#
|
108
|
-
# @param [
|
52
|
+
# @param [Hash] opts
|
53
|
+
# @option opts [String] :id
|
54
|
+
# @option opts [String] :class
|
109
55
|
# @yieldparam [AccordionGroup] group
|
110
56
|
# @return [String]
|
111
57
|
#
|
112
|
-
def accordion_group_helper(
|
113
|
-
AccordionGroup.new(self,
|
58
|
+
def accordion_group_helper(opts = {}, &block)
|
59
|
+
AccordionGroup.new(self, opts, &block)
|
114
60
|
end
|
115
61
|
|
116
62
|
# Easily build a bootstrap accordion component
|
117
63
|
#
|
118
64
|
# @example Bootstrap Panel Component:
|
65
|
+
# ```erb
|
119
66
|
# <%= accordion_helper class: 'primary' do |accordion| %>
|
120
67
|
# <%= accordion.header do %>
|
121
68
|
# <span class="something">This is the heading....</span>
|
@@ -124,8 +71,19 @@ module Bootstrap3Helper
|
|
124
71
|
# <p>This is the body of the accordion....</p>
|
125
72
|
# <% end %>
|
126
73
|
# <% end %>
|
74
|
+
# ```
|
75
|
+
#
|
76
|
+
# @overload accordion_helper(context, opts)
|
77
|
+
# @param [Symbol|String] context - :primary, :danger etc
|
78
|
+
# @param [Hash] opts
|
79
|
+
# @option opts [String] :id
|
80
|
+
# @option opts [String] :class
|
81
|
+
#
|
82
|
+
# @overload accordion_helper(opts)
|
83
|
+
# @param [Hash] opts
|
84
|
+
# @option opts [String] :id
|
85
|
+
# @option opts [String] :class
|
127
86
|
#
|
128
|
-
# @param [Symbol|String|Hash|NilClass] args
|
129
87
|
# @yieldparam [Accordion] accordion
|
130
88
|
# @return [String]
|
131
89
|
#
|
@@ -133,6 +91,59 @@ module Bootstrap3Helper
|
|
133
91
|
Accordion.new(self, *args, &block)
|
134
92
|
end
|
135
93
|
|
94
|
+
# Creates an Alert component.
|
95
|
+
#
|
96
|
+
# @example Bootstrap Alert Component:
|
97
|
+
# ```erb
|
98
|
+
# <%= alert_helper :danger, dismissble: true do %>
|
99
|
+
# Something went wrong with your model data...
|
100
|
+
# <% end %>
|
101
|
+
# ```
|
102
|
+
#
|
103
|
+
# @overload alert_helper(context, opts)
|
104
|
+
# @param [Symbol|String] context - :primary, :danger etc
|
105
|
+
# @param [Hash] opts
|
106
|
+
# @option opts [String] :id
|
107
|
+
# @option opts [String] :class
|
108
|
+
# @option opts [Boolean] :dismissible
|
109
|
+
#
|
110
|
+
# @overload alert_helper(opts)
|
111
|
+
# @param [Hash] opts
|
112
|
+
# @option opts [String] :id
|
113
|
+
# @option opts [String] :class
|
114
|
+
#
|
115
|
+
# @return [String]
|
116
|
+
#
|
117
|
+
def alert_helper(*args, &block)
|
118
|
+
Alert.new(self, *args, &block)
|
119
|
+
end
|
120
|
+
|
121
|
+
# Creates an Callout component.
|
122
|
+
#
|
123
|
+
# @example Bootstrap Callout Component:
|
124
|
+
# ```erb
|
125
|
+
# <%= callout_helper :danger %>
|
126
|
+
# Some information that needs your attention...
|
127
|
+
# <% end %>
|
128
|
+
# ```
|
129
|
+
#
|
130
|
+
# @overload callout_helper(context, opts)
|
131
|
+
# @param [Symbol|String] context - :primary, :danger etc
|
132
|
+
# @param [Hash] opts
|
133
|
+
# @option opts [String] :id
|
134
|
+
# @option opts [String] :class
|
135
|
+
#
|
136
|
+
# @overload callout_helper(opts)
|
137
|
+
# @param [Hash] opts
|
138
|
+
# @option opts [String] :id
|
139
|
+
# @option opts [String] :class
|
140
|
+
#
|
141
|
+
# @return [String]
|
142
|
+
#
|
143
|
+
def callout_helper(*args, &block)
|
144
|
+
Callout.new(self, *args, &block)
|
145
|
+
end
|
146
|
+
|
136
147
|
# Allows you to rapidly build bootstrap glyphs.
|
137
148
|
#
|
138
149
|
# @note Only supply the last part of the glyph makrup.
|
@@ -146,6 +157,42 @@ module Bootstrap3Helper
|
|
146
157
|
content_tag :span, '', class: "glyphicon glyphicon-#{name}"
|
147
158
|
end
|
148
159
|
|
160
|
+
# Allows you to rapidly build Panel components.
|
161
|
+
#
|
162
|
+
# @example Bootstrap Panel Component:
|
163
|
+
# ```erb
|
164
|
+
# <%= panel_helper :default do |p| %>
|
165
|
+
# <%= p.header do %>
|
166
|
+
# <%= p.title { 'Some random text here' } %>
|
167
|
+
# <% end %>
|
168
|
+
# <%= p.body do %>
|
169
|
+
# //HTML & Ruby
|
170
|
+
# <% end %>
|
171
|
+
# <% end %>
|
172
|
+
# ```
|
173
|
+
#
|
174
|
+
# @overload panel_helper(context, opts)
|
175
|
+
# @param [String|Symbol] context - :primary, :danger etc
|
176
|
+
# @param [Hash] opts
|
177
|
+
# @option opts [String] :id
|
178
|
+
# @option opts [String] :class
|
179
|
+
# @option opts [Hash] :data
|
180
|
+
# @option opts [Hash] :aria
|
181
|
+
#
|
182
|
+
# @overload panel_helper(opts)
|
183
|
+
# @param [Hash] opts
|
184
|
+
# @option opts [String] :id
|
185
|
+
# @option opts [String] :class
|
186
|
+
# @option opts [Hash] :data
|
187
|
+
# @option opts [Hash] :aria
|
188
|
+
#
|
189
|
+
# @yieldparam [Panel] panel
|
190
|
+
# @return [String]
|
191
|
+
#
|
192
|
+
def panel_helper(*args, &block)
|
193
|
+
Panel.new(self, *args, &block)
|
194
|
+
end
|
195
|
+
|
149
196
|
# Used to rapidly build Tabs.
|
150
197
|
#
|
151
198
|
# @note On menu items - you can pass in either symbol or string for the link. If
|
@@ -156,42 +203,48 @@ module Bootstrap3Helper
|
|
156
203
|
# or a Tabs::Dropdown.
|
157
204
|
#
|
158
205
|
# @example Bootstrap Tabs Component:
|
159
|
-
# <%= tabs_helper type: :pills do |
|
160
|
-
# <%= menu
|
161
|
-
#
|
162
|
-
#
|
163
|
-
#
|
164
|
-
#
|
165
|
-
#
|
166
|
-
#
|
167
|
-
#
|
168
|
-
#
|
169
|
-
#
|
170
|
-
# <%= content.item :testing1, class: 'active' do %>
|
171
|
-
# Testing 1 content
|
172
|
-
# <% end %>
|
173
|
-
# <%= content.item :testing2 do %>
|
174
|
-
# Testing 2 content
|
175
|
-
# <% end %>
|
176
|
-
# <%= content.item :testing3 do %>
|
177
|
-
# Testing 3 content
|
178
|
-
# <% end %>
|
179
|
-
# <%= content.item :testing5 do %>
|
180
|
-
# Testing 5 content
|
181
|
-
# <% end %>
|
182
|
-
# <%= content.item :testing6 do %>
|
183
|
-
# Testing 6 content
|
206
|
+
# <%= tabs_helper type: :pills do |tabs| %>
|
207
|
+
# <%= tabs.menu do |menu| %>
|
208
|
+
# <%= menu.item(:testing1, class: 'active') { ' Testing 1' } %>
|
209
|
+
# <%= menu.item :testing2 %>
|
210
|
+
# <%= menu.item(:testing3) { ' Testing 3' } %>
|
211
|
+
# <%= menu.dropdown 'Testing Dropdown' do |dropdown| %>
|
212
|
+
# <%= dropdown.item(:testing5 ) { 'Testing 5' } %>
|
213
|
+
# <%= dropdown.item(:testing6 ) { 'Testing 6' } %>
|
214
|
+
# <%= dropdown.item(:testing7 ) { 'Testing 7' } %>
|
215
|
+
# <% end %>
|
184
216
|
# <% end %>
|
185
|
-
#
|
186
|
-
#
|
217
|
+
#
|
218
|
+
# <%= tabs.content do |content| %>
|
219
|
+
# <%= content.pane :testing1, class: 'active' do %>
|
220
|
+
# Testing 1 content
|
221
|
+
# <% end %>
|
222
|
+
# <%= content.pane :testing2 do %>
|
223
|
+
# Testing 2 content
|
224
|
+
# <% end %>
|
225
|
+
# <%= content.pane :testing3 do %>
|
226
|
+
# Testing 3 content
|
227
|
+
# <% end %>
|
228
|
+
# <%= content.pane :testing5 do %>
|
229
|
+
# Testing 5 content
|
230
|
+
# <% end %>
|
231
|
+
# <%= content.pane :testing6 do %>
|
232
|
+
# Testing 6 content
|
233
|
+
# <% end %>
|
234
|
+
# <%= content.pane :testing7 do %>
|
235
|
+
# Testing 7 content
|
236
|
+
# <% end %>
|
187
237
|
# <% end %>
|
188
238
|
# <% end %>
|
189
239
|
#
|
190
|
-
# @param [
|
240
|
+
# @param [Hash] opts
|
241
|
+
# @option args [String|Symbol] :type
|
242
|
+
# @option args [String] :id
|
243
|
+
# @option args [String] :class
|
191
244
|
# @yieldparam [Tabs] tabs
|
192
245
|
# @return [String]
|
193
246
|
#
|
194
|
-
def tabs_helper(
|
195
|
-
Tabs.new(self,
|
247
|
+
def tabs_helper(opts = {}, &block)
|
248
|
+
Tabs.new(self, opts, &block)
|
196
249
|
end
|
197
250
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootstrap3_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert David
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -66,6 +66,34 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 5.2.4
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: redcarpet
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: solargraph
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
98
|
name: sassc-rails
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -111,6 +139,7 @@ files:
|
|
111
139
|
- lib/bootstrap3_helper/callout.rb
|
112
140
|
- lib/bootstrap3_helper/component.rb
|
113
141
|
- lib/bootstrap3_helper/configuration.rb
|
142
|
+
- lib/bootstrap3_helper/initialize.rb
|
114
143
|
- lib/bootstrap3_helper/panel.rb
|
115
144
|
- lib/bootstrap3_helper/railtie.rb
|
116
145
|
- lib/bootstrap3_helper/tabs.rb
|
@@ -138,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
167
|
- !ruby/object:Gem::Version
|
139
168
|
version: '0'
|
140
169
|
requirements: []
|
141
|
-
rubygems_version: 3.1.
|
170
|
+
rubygems_version: 3.1.6
|
142
171
|
signing_key:
|
143
172
|
specification_version: 4
|
144
173
|
summary: Simple gem for rapidly building bootstrap 3 components
|