negative_captcha 0.4 → 0.5

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.
@@ -121,7 +121,9 @@ Modify your form to include the honeypots and other fields. You can probably lea
121
121
  <%= negative_text_field_tag(@captcha, :email) %>
122
122
  </li>
123
123
  <li>
124
- <%= negative_label_tag(@captcha, :body, 'Your Comment:') %>
124
+ <%= negative_label_tag(@captcha, :body, 'Your Comment:') do %>
125
+ <span>Accepts a block.</span>
126
+ <% end %>
125
127
  <%= negative_text_area_tag(@captcha, :body) %>
126
128
  </li>
127
129
  <li>
@@ -15,6 +15,20 @@ module ActionView
15
15
  html.html_safe
16
16
  end
17
17
 
18
+ def negative_email_field(captcha, method, options = {})
19
+ html = @template.negative_email_field_tag(
20
+ captcha,
21
+ method,
22
+ options
23
+ ).html_safe
24
+
25
+ if @object.errors[method].present?
26
+ html = "<div class='fieldWithErrors'>#{html}</div>"
27
+ end
28
+
29
+ html.html_safe
30
+ end
31
+
18
32
  def negative_text_area(captcha, method, options = {})
19
33
  html = @template.negative_text_area_tag(
20
34
  captcha,
@@ -75,12 +89,13 @@ module ActionView
75
89
  html.html_safe
76
90
  end
77
91
 
78
- def negative_label(captcha, method, name, options = {})
92
+ def negative_label(captcha, method, name, options = {}, &block)
79
93
  html = @template.negative_label_tag(
80
94
  captcha,
81
95
  method,
82
96
  name,
83
- options
97
+ options,
98
+ &block
84
99
  ).html_safe
85
100
 
86
101
  if @object.errors[method].present?
@@ -19,6 +19,17 @@ module ActionView
19
19
  end.html_safe
20
20
  end
21
21
 
22
+ def negative_email_field_tag(negative_captcha, field, options={})
23
+ email_field_tag(
24
+ negative_captcha.fields[field],
25
+ negative_captcha.values[field],
26
+ options
27
+ ) +
28
+ content_tag('div', :style => 'position: absolute; left: -2000px;') do
29
+ email_field_tag(field, '', :tabindex => '999', :autocomplete => 'off')
30
+ end.html_safe
31
+ end
32
+
22
33
  def negative_text_area_tag(negative_captcha, field, options={})
23
34
  text_area_tag(
24
35
  negative_captcha.fields[field],
@@ -73,8 +84,8 @@ module ActionView
73
84
  end.html_safe
74
85
  end
75
86
 
76
- def negative_label_tag(negative_captcha, field, name, options={})
77
- label_tag(negative_captcha.fields[field], name, options)
87
+ def negative_label_tag(negative_captcha, field, name, options={}, &block)
88
+ label_tag(negative_captcha.fields[field], name, options, &block)
78
89
  end
79
90
  end
80
91
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: negative_captcha
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.4'
4
+ version: '0.5'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-12-08 00:00:00.000000000 Z
12
+ date: 2016-04-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack