andy_rails_toolbox 1.2.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 31b8a7518aee9bf4c54c09b73d02b3fbe89d0706
4
- data.tar.gz: 20241958a1185c837802e22afb0cd0d345ddf5b7
3
+ metadata.gz: f46f72b368a653fefb51ac5a69c2156ddeef548f
4
+ data.tar.gz: 2454ca2b96aed234829f6f7c5451571d99fd0f6e
5
5
  SHA512:
6
- metadata.gz: 41071a296569363077121accbe9b4b174e28073f91bf0be26f71cc67e77d872d0f405f8d172adf83f9494e1aebcb9cdd30f73bbed30954b95eca81323d329c3f
7
- data.tar.gz: 13eb21c616bbd1dc29776578c41e40ca32ae5f4c3e55093436d91d656fca8a140b1fc18a36a6cbd319111067d0c642b38cc03651cd6b55e873237412a6e70f70
6
+ metadata.gz: 3179d44c5464a4278e37ed52fe60ebe82937133104d4b3614592049094f9786b871a3f2eb217bcf67f7e1d7972dc1213034b6e05e77f13ff61c53eb2f8121988
7
+ data.tar.gz: 6e577d2373c243417000297572f27515ab0548474be4007acbaade3acbe284ac1581846e843f72c9c34a442eb66bdc9534905771a716d477121d20fcb354cc20
data/README.md CHANGED
@@ -44,7 +44,7 @@ bs_icon 'user'
44
44
  # => <span class="glyphicon glyphicon-user"></span>
45
45
  ```
46
46
 
47
- BUTTONS
47
+ LINK BUTTONS
48
48
 
49
49
  ``` ruby
50
50
  link_button 'link_label', '/'
@@ -65,6 +65,11 @@ link_button 'link-button', '/', label_hidden: 'xs'
65
65
  # => <a class="btn btn-default" href="/"><span class="hidden-xs">link_label</span></a>
66
66
  link_button 'link_label', '/', icon: 'user'
67
67
  # => <a class="btn btn-default" href="/"><i class="fa fa-user"></i> link_label</a>
68
+ ```
69
+
70
+ BUTTONS
71
+
72
+ ``` ruby
68
73
  button 'button'
69
74
  # => <button name="button" type="button" class="btn btn-default">button</button>
70
75
  submit_button 'submit'
@@ -73,6 +78,24 @@ reset_button 'reset'
73
78
  # => <button name="reset" type="reset" class="btn btn-default"><i class="fa fa-eraser"></i> reset</button>
74
79
  ```
75
80
 
81
+ RADIO BUTTONS GROUP
82
+
83
+ ``` ruby
84
+ = radio_buttons_group name: 'sex' do |radios|
85
+ - radios << { label: 'Male', value: 'male', active: params[:sex] == 'male', icon: 'male' }
86
+ - radios << { label: 'Female', value: 'female', active: params[:sex] == 'female', icon: 'female' }
87
+ # => <div data-toggle="buttons" class="btn-group">
88
+ # => <label class="btn btn-default" for="male">
89
+ # => <input type="radio" name="sex" id="sex_male" value="male" />
90
+ # => <i class="fa fa-male"></i> Male
91
+ # => </label>
92
+ # => <label class="btn btn-default" for="female">
93
+ # => <input type="radio" name="sex" id="sex_female" value="female" />
94
+ # => <i class="fa fa-female"></i> Female
95
+ # => </label>
96
+ # => </div>
97
+ ```
98
+
76
99
  IMAGES
77
100
 
78
101
  ``` ruby
@@ -12,7 +12,7 @@ module BootstrapHelper
12
12
  if html_options[:class]
13
13
  classes << html_options[:class]
14
14
  end
15
- html_options[:class] = classes * ' '
15
+ html_options[:class] = classes * ' ' if classes.present?
16
16
 
17
17
  content_tag(:span, nil, html_options)
18
18
  end
@@ -50,7 +50,7 @@ module BootstrapHelper
50
50
 
51
51
  def new_button(label = nil, options = nil, html_options = {})
52
52
  button_options = { icon: 'plus', color: 'primary' }
53
- html_options.update button_options
53
+ html_options = button_options.update html_options
54
54
 
55
55
  link_button(label, options, html_options)
56
56
  end
@@ -58,7 +58,7 @@ module BootstrapHelper
58
58
  # Generates a link show button.
59
59
  def show_button(label = nil, options = nil, html_options = {})
60
60
  button_options = { icon: 'search', color: 'info' }
61
- html_options.update button_options
61
+ html_options = button_options.update html_options
62
62
 
63
63
  link_button(label, options, html_options)
64
64
  end
@@ -66,7 +66,7 @@ module BootstrapHelper
66
66
  # Generates a link edit button.
67
67
  def edit_button(label = nil, options = nil, html_options = {})
68
68
  button_options = { icon: 'edit', color: 'warning' }
69
- html_options.update button_options
69
+ html_options = button_options.update html_options
70
70
 
71
71
  link_button(label, options, html_options)
72
72
  end
@@ -74,7 +74,7 @@ module BootstrapHelper
74
74
  # Generates a link destroy button.
75
75
  def destroy_button(label = nil, options = nil, html_options = {})
76
76
  button_options = { icon: 'trash', color: 'danger', method: :delete, confirm: 'Are you sure?' }
77
- html_options.update button_options
77
+ html_options = button_options.update html_options
78
78
 
79
79
  link_button(label, options, html_options)
80
80
  end
@@ -82,7 +82,7 @@ module BootstrapHelper
82
82
  # Generates a link back button.
83
83
  def back_button(label = nil, options = nil, html_options = {})
84
84
  button_options = { icon: 'reply' }
85
- html_options.update button_options
85
+ html_options = button_options.update html_options
86
86
 
87
87
  link_button(label, options, html_options)
88
88
  end
@@ -90,7 +90,7 @@ module BootstrapHelper
90
90
  # Generates a link cancel button.
91
91
  def cancel_button(label = nil, options = nil, html_options = {})
92
92
  button_options = { icon: 'ban' }
93
- html_options.update button_options
93
+ html_options = button_options.update html_options
94
94
 
95
95
  link_button(label, options, html_options)
96
96
  end
@@ -131,7 +131,7 @@ module BootstrapHelper
131
131
  # Generates a submit button.
132
132
  def submit_button(label = nil, html_options = {})
133
133
  button_options = { icon: 'check', color: 'primary', name: 'submit', type: 'submit' }
134
- html_options.update button_options
134
+ html_options = button_options.update html_options
135
135
 
136
136
  button(label, html_options)
137
137
  end
@@ -139,11 +139,66 @@ module BootstrapHelper
139
139
  # Generates a reset button.
140
140
  def reset_button(label = nil, html_options = {})
141
141
  button_options = { icon: 'eraser', name: 'reset', type: 'reset' }
142
- html_options.update button_options
142
+ html_options = button_options.update html_options
143
143
 
144
144
  button(label, html_options)
145
145
  end
146
146
 
147
+ # Generates a radio buttons group
148
+ def radio_buttons_group(html_options = nil, &block)
149
+ # Set html_options
150
+ html_options ||= {}
151
+ html_options['data-toggle'] = 'buttons'
152
+ html_options = html_options.symbolize_keys
153
+
154
+ # Set html_options class
155
+ classes = ['btn-group']
156
+ classes << html_options[:class] if html_options[:class]
157
+ html_options[:class] = classes * ' ' if classes.present?
158
+
159
+ # Set radios options
160
+ radios = []
161
+ yield radios
162
+
163
+ # Set radio input name
164
+ name = html_options.delete(:name)
165
+
166
+ # Set radio_items
167
+ radio_items = []
168
+ radios.each do |radio|
169
+ radio_html_options = radio.symbolize_keys
170
+
171
+ label = radio_html_options.delete(:label)
172
+
173
+ if label_hidden = radio_html_options.delete(:label_hidden)
174
+ label = content_tag :span, label, class: "hidden-#{label_hidden}"
175
+ end
176
+
177
+ if icon = radio_html_options.delete(:icon)
178
+ label = fa_icon(icon, text: label)
179
+ end
180
+
181
+ value = radio_html_options.delete(:value)
182
+ radio_input = radio_button_tag(name, value, radio_html_options[:active])
183
+
184
+ classes = ['btn', 'btn-default']
185
+ classes << radio_html_options[:class] if radio_html_options[:class]
186
+ classes << 'active' if radio_html_options.delete(:active)
187
+ radio_html_options[:class] = classes * ' ' if classes.present?
188
+
189
+ radio_item = label_tag value, radio_html_options do
190
+ radio_input + ' ' + label
191
+ end
192
+
193
+ radio_items << radio_item
194
+ end
195
+
196
+ # Set output
197
+ content_tag :div, html_options do
198
+ (radio_items * '').html_safe
199
+ end
200
+ end
201
+
147
202
  # ---------- #
148
203
  # - IMAGES - #
149
204
  # ---------- #
@@ -157,7 +212,7 @@ module BootstrapHelper
157
212
  classes << html_options[:class]
158
213
  end
159
214
 
160
- html_options[:class] = classes * ' '
215
+ html_options[:class] = classes * ' ' if classes.present?
161
216
 
162
217
  image_tag(source, html_options)
163
218
  end
@@ -171,7 +226,7 @@ module BootstrapHelper
171
226
  classes << html_options[:class]
172
227
  end
173
228
 
174
- html_options[:class] = classes * ' '
229
+ html_options[:class] = classes * ' ' if classes.present?
175
230
 
176
231
  image_tag(source, html_options)
177
232
  end
@@ -185,7 +240,7 @@ module BootstrapHelper
185
240
  classes << html_options[:class]
186
241
  end
187
242
 
188
- html_options[:class] = classes * ' '
243
+ html_options[:class] = classes * ' ' if classes.present?
189
244
 
190
245
  image_tag(source, html_options)
191
246
  end
@@ -199,7 +254,7 @@ module BootstrapHelper
199
254
  classes << html_options[:class]
200
255
  end
201
256
 
202
- html_options[:class] = classes * ' '
257
+ html_options[:class] = classes * ' ' if classes.present?
203
258
 
204
259
  image_tag(source, html_options)
205
260
  end
@@ -249,7 +304,7 @@ module BootstrapHelper
249
304
  classes << html_options[:class]
250
305
  end
251
306
 
252
- html_options[:class] = classes * ' '
307
+ html_options[:class] = classes * ' ' if classes.present?
253
308
  html_options
254
309
  end
255
310
 
@@ -274,7 +329,7 @@ module BootstrapHelper
274
329
  classes << html_options[:class]
275
330
  end
276
331
 
277
- html_options[:class] = classes * ' '
332
+ html_options[:class] = classes * ' ' if classes.present?
278
333
  html_options
279
334
  end
280
335
  end
@@ -1,3 +1,3 @@
1
1
  module AndyRailsToolbox
2
- VERSION = '1.2.1'
2
+ VERSION = '1.3.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: andy_rails_toolbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ChouAndy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-01 00:00:00.000000000 Z
11
+ date: 2015-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -177,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
177
  version: '0'
178
178
  requirements: []
179
179
  rubyforge_project:
180
- rubygems_version: 2.4.7
180
+ rubygems_version: 2.4.5.1
181
181
  signing_key:
182
182
  specification_version: 4
183
183
  summary: Includes many useful helpers for rails development.