bh 1.3.1 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3044213572c129233bf23c8f9d4e9ddf67307c3c
4
- data.tar.gz: 3dce30164e6a204a736c4dda91b775d427ac0c0e
3
+ metadata.gz: 7f5835cd462fb3d11c1aed1d680b9cad2e07118a
4
+ data.tar.gz: a790bdc43c1d08155d6768fb871c4c1317dfd3f8
5
5
  SHA512:
6
- metadata.gz: 5716a1e8ee975c605c011b967f10d2e01b878504837e1bbbb8dc763c8aff9de5d682243f9e73fc4e75e94fe955cffec358241e39d918d587175a10f7a5668bc4
7
- data.tar.gz: 664b527fb7fac7619fe9e1f7917cc784d0cfc35476f1a37dbc45c5f376282323ce21f2a73267720b6d27fd23ce211e300c383bd14b2d586d89f9ada2501e4346
6
+ metadata.gz: ccf655fafab88fbb6b66c7e5b65fca87bcec689a4e23f3d75b934555146d703e3b01509491b8d348cb4f1a113491e7f4c572eafbedd62a01669e639543c94b0d
7
+ data.tar.gz: 9286a9d3ae256ba18927d8c5f2b9dfcfa29b2ef2455c83f00cd65e8f052481a36322fc8129181e5496147ba52b0722389f146201eb48bddb3abbf2c48fd84d35
@@ -6,6 +6,14 @@ For more information about changelogs, check
6
6
  [Keep a Changelog](http://keepachangelog.com) and
7
7
  [Vandamme](http://tech-angels.github.io/vandamme).
8
8
 
9
+ ## 1.3.3 - 2014-03-11
10
+
11
+ * [BUGFIX] Correctly align the "X" icon at the right of the field in basic forms
12
+
13
+ ## 1.3.2 - 2014-03-05
14
+
15
+ * [BUGFIX] Respect the original behavior of Padrino/Rails when calling `link_to` with `nil` as the name
16
+
9
17
  ## 1.3.1 - 2014-02-03
10
18
 
11
19
  * [BUGFIX] Do not render the `:offset` option of the field helpers in the DOM
@@ -17,6 +17,10 @@ module Bh
17
17
  request.path_info == @app.url_for(@url)
18
18
  end
19
19
  end
20
+
21
+ def content
22
+ super if @content
23
+ end
20
24
  end
21
25
  end
22
26
  end
@@ -11,7 +11,7 @@ module Bh
11
11
 
12
12
  def base_field(method, field_type, options = {}, &block)
13
13
  errors = (object.errors.get method if object) || {}
14
- label = label_for method, errors, options
14
+ label = label_for method, errors, field_type, options
15
15
  field = field_container(options) do
16
16
  field_tags errors, field_type, options, &block
17
17
  end
@@ -35,7 +35,9 @@ module Bh
35
35
  help_text = options.delete(:help)
36
36
  field = @template.capture(&block)
37
37
  tags = [field_in_group(field, prefix, suffix)]
38
- tags << error_icon_tag if show_error_icon?(field_type, errors, suffix)
38
+ if show_error_icon?(field_type, errors, suffix) && !basic_form?
39
+ tags << error_icon_tag
40
+ end
39
41
  if errors.any? && show_error_help?
40
42
  tags << help_tag(errors.to_sentence)
41
43
  elsif help_text
@@ -86,10 +88,18 @@ module Bh
86
88
  content_tag :span, help_text, class: klass.join(' ')
87
89
  end
88
90
 
89
- def label_for(method, errors, options)
91
+ # Rails wraps the label in <div class='field_with_errors'> in case of
92
+ # error, which messes up the error icon in Bootstrap basic forms unless
93
+ # the icon is appended to the label itself, rather than at the end.
94
+ def label_for(method, errors, field_type, options)
90
95
  if options.delete(:use_label) { true }
91
- args = [method, options.delete(:label), label_options(errors)]
92
- label *args.compact
96
+ args = [method, options.delete(:label), label_options(errors)]
97
+ label(*args.compact).tap do |label|
98
+ error_icon = show_error_icon? field_type, errors, options[:suffix]
99
+ if (index = label =~ %r{</div>$}) && error_icon && basic_form?
100
+ label.insert index, error_icon_tag
101
+ end
102
+ end
93
103
  end
94
104
  end
95
105
 
@@ -1,3 +1,3 @@
1
1
  module Bh
2
- VERSION = '1.3.1'
2
+ VERSION = '1.3.3'
3
3
  end
@@ -0,0 +1,12 @@
1
+ shared_examples_for 'the link_to helper (Padrino)' do
2
+ all_tests_pass_with 'no link_to caption (Padrino)'
3
+ end
4
+
5
+ #--
6
+
7
+ shared_examples_for 'no link_to caption (Padrino)' do
8
+ specify 'uses the original link_to helper which sets an empty link text' do
9
+ html = '<a href="/"></a>'
10
+ expect(link_to: :nil_name).to generate html
11
+ end
12
+ end
@@ -24,5 +24,6 @@ describe 'When used in Padrino or Middleman' do
24
24
  all_tests_pass_for 'the vertical helper'
25
25
 
26
26
  all_tests_pass_for 'the button_to helper (Padrino)'
27
+ all_tests_pass_for 'the link_to helper (Padrino)'
27
28
  all_tests_pass_for 'the link_to helper'
28
29
  end
@@ -0,0 +1,12 @@
1
+ shared_examples_for 'the link_to helper (Rails)' do
2
+ all_tests_pass_with 'no link_to caption (Rails)'
3
+ end
4
+
5
+ #--
6
+
7
+ shared_examples_for 'no link_to caption (Rails)' do
8
+ specify 'uses the original link_to helper which sets the link to the caption' do
9
+ html = '<a href="/">/</a>'
10
+ expect(link_to: :nil_name).to generate html
11
+ end
12
+ end
@@ -24,5 +24,6 @@ describe 'When used in Rails' do
24
24
  all_tests_pass_for 'the vertical helper'
25
25
 
26
26
  all_tests_pass_for 'the button_to helper (Rails)'
27
+ all_tests_pass_for 'the link_to helper (Rails)'
27
28
  all_tests_pass_for 'the link_to helper'
28
29
  end
@@ -4,7 +4,10 @@ RSpec::Matchers.define :generate do |html|
4
4
  helper, options = helper.keys.first, helper.values.first
5
5
  end
6
6
 
7
- if helper == :link_to || helper == :button_to
7
+ if helper == :link_to && options == :nil_name
8
+ @inline = bh.send helper, nil, '/'
9
+ @block = @inline
10
+ elsif helper == :link_to || helper == :button_to
8
11
  @inline = bh.send helper, *['content', '/', options].compact
9
12
  if bh.test_button_to_with_block
10
13
  @block = bh.send(helper, *['/', options].compact) { 'content' }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bh
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-04 00:00:00.000000000 Z
11
+ date: 2015-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -265,6 +265,7 @@ files:
265
265
  - lib/bh/views/bh/_modal.html.erb
266
266
  - lib/bh/views/bh/_navbar.html.erb
267
267
  - spec/padrino/button_to_helper.rb
268
+ - spec/padrino/link_to_helper.rb
268
269
  - spec/padrino_spec.rb
269
270
  - spec/rails/button_to_helper.rb
270
271
  - spec/rails/form/check_box_helper_spec.rb
@@ -278,6 +279,7 @@ files:
278
279
  - spec/rails/form/static_control_helper_spec.rb
279
280
  - spec/rails/form/submit_helper_spec.rb
280
281
  - spec/rails/form_for_helper_spec.rb
282
+ - spec/rails/link_to_helper.rb
281
283
  - spec/rails_helper.rb
282
284
  - spec/rails_spec.rb
283
285
  - spec/shared/alert_box_helper.rb
@@ -327,6 +329,7 @@ summary: Bh provides a set of powerful helpers that streamlines the use of Boots
327
329
  components in Rails views.
328
330
  test_files:
329
331
  - spec/padrino/button_to_helper.rb
332
+ - spec/padrino/link_to_helper.rb
330
333
  - spec/padrino_spec.rb
331
334
  - spec/rails/button_to_helper.rb
332
335
  - spec/rails/form/check_box_helper_spec.rb
@@ -340,6 +343,7 @@ test_files:
340
343
  - spec/rails/form/static_control_helper_spec.rb
341
344
  - spec/rails/form/submit_helper_spec.rb
342
345
  - spec/rails/form_for_helper_spec.rb
346
+ - spec/rails/link_to_helper.rb
343
347
  - spec/rails_helper.rb
344
348
  - spec/rails_spec.rb
345
349
  - spec/shared/alert_box_helper.rb