speedo-formstrap 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -2
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/formtastic-bootstrap.gemspec +1 -1
- data/lib/formtastic-bootstrap.rb +5 -5
- data/lib/formtastic-bootstrap/actions.rb +4 -4
- data/lib/formtastic-bootstrap/actions/base.rb +1 -1
- data/lib/formtastic-bootstrap/actions/button_action.rb +1 -1
- data/lib/formtastic-bootstrap/actions/input_action.rb +1 -1
- data/lib/formtastic-bootstrap/actions/link_action.rb +1 -1
- data/lib/formtastic-bootstrap/engine.rb +1 -1
- data/lib/formtastic-bootstrap/form_builder.rb +9 -11
- data/lib/formtastic-bootstrap/helpers.rb +6 -8
- data/lib/formtastic-bootstrap/helpers/action_helper.rb +2 -2
- data/lib/formtastic-bootstrap/helpers/actions_helper.rb +2 -2
- data/lib/formtastic-bootstrap/helpers/buttons_helper.rb +10 -14
- data/lib/formtastic-bootstrap/helpers/fieldset_wrapper.rb +7 -12
- data/lib/formtastic-bootstrap/helpers/input_helper.rb +2 -2
- data/lib/formtastic-bootstrap/helpers/inputs_helper.rb +6 -6
- data/lib/formtastic-bootstrap/inputs.rb +21 -21
- data/lib/formtastic-bootstrap/inputs/base.rb +10 -11
- data/lib/formtastic-bootstrap/inputs/base/choices.rb +24 -13
- data/lib/formtastic-bootstrap/inputs/base/errors.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/base/hints.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/base/html.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/base/labelling.rb +7 -17
- data/lib/formtastic-bootstrap/inputs/base/numeric.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/base/stringish.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/base/timeish.rb +13 -6
- data/lib/formtastic-bootstrap/inputs/base/wrapping.rb +15 -33
- data/lib/formtastic-bootstrap/inputs/boolean_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/check_boxes_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/date_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/datetime_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/email_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/file_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/hidden_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/number_input.rb +3 -3
- data/lib/formtastic-bootstrap/inputs/password_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/phone_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/radio_input.rb +13 -14
- data/lib/formtastic-bootstrap/inputs/range_input.rb +3 -3
- data/lib/formtastic-bootstrap/inputs/search_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/select_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/string_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/text_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/time_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/time_zone_input.rb +1 -1
- data/lib/formtastic-bootstrap/inputs/url_input.rb +1 -1
- data/spec/actions/button_action_spec.rb +1 -1
- data/spec/actions/generic_action_spec.rb +1 -1
- data/spec/actions/input_action_spec.rb +1 -1
- data/spec/actions/link_action_spec.rb +1 -1
- data/spec/builder/semantic_fields_for_spec.rb +16 -16
- data/spec/helpers/action_helper_spec.rb +1 -1
- data/spec/helpers/actions_helper_spec.rb +1 -1
- data/spec/helpers/buttons_helper_spec.rb +46 -56
- data/spec/helpers/input_helper_spec.rb +209 -209
- data/spec/helpers/inputs_helper_spec.rb +103 -117
- data/spec/inputs/boolean_input_spec.rb +46 -74
- data/spec/inputs/check_boxes_input_spec.rb +82 -110
- data/spec/inputs/date_input_spec.rb +15 -81
- data/spec/inputs/datetime_input_spec.rb +13 -13
- data/spec/inputs/email_input_spec.rb +6 -34
- data/spec/inputs/file_input_spec.rb +6 -34
- data/spec/inputs/hidden_input_spec.rb +13 -41
- data/spec/inputs/number_input_spec.rb +97 -127
- data/spec/inputs/password_input_spec.rb +6 -34
- data/spec/inputs/phone_input_spec.rb +6 -34
- data/spec/inputs/radio_input_spec.rb +45 -73
- data/spec/inputs/range_input_spec.rb +66 -94
- data/spec/inputs/search_input_spec.rb +6 -33
- data/spec/inputs/select_input_spec.rb +78 -124
- data/spec/inputs/string_input_spec.rb +22 -67
- data/spec/inputs/text_input_spec.rb +15 -42
- data/spec/inputs/time_input_spec.rb +23 -23
- data/spec/inputs/time_zone_input_spec.rb +20 -20
- data/spec/inputs/url_input_spec.rb +6 -34
- data/spec/support/custom_macros.rb +196 -67
- data/spec/support/formtastic_spec_helper.rb +6 -22
- data/speedo-formstrap.gemspec +146 -0
- metadata +18 -17
@@ -1,28 +1,18 @@
|
|
1
|
-
module
|
1
|
+
module SpeedoFormstrap
|
2
2
|
module Inputs
|
3
3
|
module Base
|
4
4
|
module Labelling
|
5
5
|
|
6
6
|
include Formtastic::Inputs::Base::Labelling
|
7
7
|
|
8
|
-
def label_html
|
9
|
-
render_label? ? builder.label(input_name, label_text, control_label_html_options) : "".html_safe
|
10
|
-
end
|
11
|
-
|
12
8
|
def label_html_options
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
opts
|
9
|
+
{}.tap do |opts|
|
10
|
+
opts[:for] ||= input_html_options[:id]
|
11
|
+
opts[:class] = [opts[:class]]
|
12
|
+
end
|
18
13
|
end
|
19
|
-
|
20
|
-
def control_label_html_options
|
21
|
-
new_class = [label_html_options[:class], "control-label"].compact.join(" ")
|
22
|
-
label_html_options.merge(:class => new_class)
|
23
|
-
end
|
24
|
-
|
14
|
+
|
25
15
|
end
|
26
16
|
end
|
27
17
|
end
|
28
|
-
end
|
18
|
+
end
|
@@ -1,8 +1,15 @@
|
|
1
|
-
module
|
1
|
+
module SpeedoFormstrap
|
2
2
|
module Inputs
|
3
3
|
module Base
|
4
4
|
module Timeish
|
5
5
|
|
6
|
+
def label_html
|
7
|
+
# TODO Supress the "for" field?
|
8
|
+
template.content_tag(:label, label_html_options) do
|
9
|
+
render_label? ? label_text : "".html_safe
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
6
13
|
def date_input_html
|
7
14
|
fragment_input_html(:date, "small")
|
8
15
|
end
|
@@ -10,19 +17,19 @@ module FormtasticBootstrap
|
|
10
17
|
def time_input_html
|
11
18
|
fragment_input_html(:time, "mini")
|
12
19
|
end
|
13
|
-
|
20
|
+
|
14
21
|
def fragment_id(fragment)
|
15
22
|
# TODO is this right?
|
16
23
|
# "#{input_html_options[:id]}_#{position(fragment)}i"
|
17
24
|
"#{input_html_options[:id]}[#{fragment}]"
|
18
25
|
end
|
19
|
-
|
26
|
+
|
20
27
|
def fragment_input_html(fragment, klass)
|
21
|
-
opts = input_options.merge(:prefix =>
|
28
|
+
opts = input_options.merge(:prefix => object_name, :field_name => fragment_name(fragment), :default => value, :include_blank => include_blank?)
|
22
29
|
template.send(:"text_field_#{fragment}", value, opts, input_html_options.merge(:id => fragment_id(fragment), :class => klass))
|
23
30
|
end
|
24
|
-
|
31
|
+
|
25
32
|
end
|
26
33
|
end
|
27
34
|
end
|
28
|
-
end
|
35
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module SpeedoFormstrap
|
2
2
|
module Inputs
|
3
3
|
module Base
|
4
4
|
module Wrapping
|
@@ -6,29 +6,23 @@ module FormtasticBootstrap
|
|
6
6
|
include Formtastic::Inputs::Base::Wrapping
|
7
7
|
|
8
8
|
def generic_input_wrapping(&block)
|
9
|
-
|
9
|
+
clearfix_div_wrapping do
|
10
10
|
label_html <<
|
11
11
|
input_div_wrapping do
|
12
|
-
|
13
|
-
prepended_input_wrapping do
|
14
|
-
[template.content_tag(:span, options[:prepend], :class => 'add-on'), yield].join("\n").html_safe
|
15
|
-
end
|
16
|
-
else
|
17
|
-
yield
|
18
|
-
end
|
12
|
+
yield
|
19
13
|
end
|
20
14
|
end
|
21
15
|
end
|
22
16
|
|
23
|
-
def
|
17
|
+
def clearfix_div_wrapping(&block)
|
24
18
|
template.content_tag(:div, wrapper_html_options) do
|
25
19
|
yield
|
26
20
|
end
|
27
21
|
end
|
28
22
|
|
29
23
|
def input_div_wrapping(inline_or_block_errors = :inline)
|
30
|
-
template.content_tag(:div, :class => "
|
31
|
-
[yield, error_html(inline_or_block_errors), hint_html(inline_or_block_errors)].join("\n").html_safe
|
24
|
+
template.content_tag(:div, :class => "input") do
|
25
|
+
[yield, error_html(inline_or_block_errors), hint_html(inline_or_block_errors)].join("\n").html_safe
|
32
26
|
end
|
33
27
|
end
|
34
28
|
|
@@ -39,36 +33,24 @@ module FormtasticBootstrap
|
|
39
33
|
end
|
40
34
|
|
41
35
|
def wrapper_html_options
|
42
|
-
opts =
|
43
|
-
opts[:class]
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
when nil
|
48
|
-
[]
|
49
|
-
else
|
50
|
-
[opts[:class].to_s]
|
51
|
-
end
|
52
|
-
opts[:class] << "#{as}-wrapper"
|
53
|
-
opts[:class] << "control-group"
|
36
|
+
opts = options[:wrapper_html] || {}
|
37
|
+
opts[:class] ||= []
|
38
|
+
opts[:class] = [opts[:class].to_s] unless opts[:class].is_a?(Array)
|
39
|
+
opts[:class] << as
|
40
|
+
opts[:class] << "clearfix"
|
54
41
|
# opts[:class] << "input"
|
55
42
|
opts[:class] << "error" if errors?
|
56
43
|
opts[:class] << "optional" if optional?
|
57
44
|
opts[:class] << "required" if required?
|
58
45
|
opts[:class] << "autofocus" if autofocus?
|
59
46
|
opts[:class] = opts[:class].join(' ')
|
60
|
-
|
47
|
+
|
61
48
|
opts[:id] ||= wrapper_dom_id
|
62
|
-
|
49
|
+
|
63
50
|
opts
|
64
51
|
end
|
65
|
-
|
66
|
-
def prepended_input_wrapping(&block)
|
67
|
-
template.content_tag(:div, :class => 'input-prepend') do
|
68
|
-
yield
|
69
|
-
end
|
70
|
-
end
|
52
|
+
|
71
53
|
end
|
72
54
|
end
|
73
55
|
end
|
74
|
-
end
|
56
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
module
|
1
|
+
module SpeedoFormstrap
|
2
2
|
module Inputs
|
3
3
|
class NumberInput < Formtastic::Inputs::NumberInput
|
4
4
|
include Base
|
5
|
-
include Base::
|
5
|
+
include Base::Stringish
|
6
6
|
|
7
7
|
def to_html
|
8
8
|
generic_input_wrapping do
|
@@ -12,4 +12,4 @@ module FormtasticBootstrap
|
|
12
12
|
|
13
13
|
end
|
14
14
|
end
|
15
|
-
end
|
15
|
+
end
|
@@ -1,33 +1,32 @@
|
|
1
|
-
module
|
1
|
+
module SpeedoFormstrap
|
2
2
|
module Inputs
|
3
3
|
class RadioInput < Formtastic::Inputs::RadioInput
|
4
4
|
include Base
|
5
5
|
include Base::Choices
|
6
6
|
|
7
7
|
def to_html
|
8
|
-
|
8
|
+
clearfix_div_wrapping do
|
9
9
|
legend_html <<
|
10
10
|
input_div_wrapping do
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
choices_group_wrapping do
|
12
|
+
collection.map { |choice|
|
13
|
+
choice_wrapping(choice_wrapping_html_options(choice)) do
|
14
|
+
choice_html(choice)
|
15
|
+
end
|
16
|
+
}.join("\n").html_safe
|
17
|
+
end
|
14
18
|
end
|
15
19
|
end
|
16
20
|
end
|
17
21
|
|
18
|
-
def choice_html(choice)
|
19
|
-
template.content_tag(:label, label_html_options.merge(:for => choice_input_dom_id(choice))
|
20
|
-
builder.radio_button(input_name, choice_value(choice), input_html_options.merge(choice_html_options(choice)).merge(:required => false)) <<
|
22
|
+
def choice_html(choice)
|
23
|
+
template.content_tag(:label, label_html_options.merge(:for => choice_input_dom_id(choice), :class => nil)) do
|
24
|
+
builder.radio_button(input_name, choice_value(choice), input_html_options.merge(choice_html_options(choice)).merge(:required => false)) <<
|
21
25
|
|
22
26
|
choice_label(choice)
|
23
27
|
end
|
24
28
|
end
|
25
29
|
|
26
|
-
def choice_wrapping_html_options(choice)
|
27
|
-
new_class = [super[:class], 'radio'].join(' ')
|
28
|
-
super.merge(:class => new_class)
|
29
|
-
end
|
30
|
-
|
31
30
|
end
|
32
31
|
end
|
33
|
-
end
|
32
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
module
|
1
|
+
module SpeedoFormstrap
|
2
2
|
module Inputs
|
3
3
|
class RangeInput < Formtastic::Inputs::RangeInput
|
4
4
|
include Base
|
5
|
-
include Base::
|
5
|
+
include Base::Stringish
|
6
6
|
|
7
7
|
def to_html
|
8
8
|
generic_input_wrapping do
|
@@ -12,4 +12,4 @@ module FormtasticBootstrap
|
|
12
12
|
|
13
13
|
end
|
14
14
|
end
|
15
|
-
end
|
15
|
+
end
|
@@ -8,7 +8,7 @@ describe 'ButtonAction', 'when submitting' do
|
|
8
8
|
before do
|
9
9
|
@output_buffer = ''
|
10
10
|
mock_everything
|
11
|
-
Formtastic::Helpers::FormHelper.builder =
|
11
|
+
Formtastic::Helpers::FormHelper.builder = SpeedoFormstrap::FormBuilder
|
12
12
|
|
13
13
|
concat(semantic_form_for(@new_post) do |builder|
|
14
14
|
concat(builder.action(:submit, :as => :button))
|
@@ -23,7 +23,7 @@ describe 'InputAction::Base' do
|
|
23
23
|
before do
|
24
24
|
@output_buffer = ''
|
25
25
|
mock_everything
|
26
|
-
Formtastic::Helpers::FormHelper.builder =
|
26
|
+
Formtastic::Helpers::FormHelper.builder = SpeedoFormstrap::FormBuilder
|
27
27
|
end
|
28
28
|
|
29
29
|
describe 'wrapping HTML' do
|
@@ -8,7 +8,7 @@ describe 'InputAction', 'when submitting' do
|
|
8
8
|
before do
|
9
9
|
@output_buffer = ''
|
10
10
|
mock_everything
|
11
|
-
Formtastic::Helpers::FormHelper.builder =
|
11
|
+
Formtastic::Helpers::FormHelper.builder = SpeedoFormstrap::FormBuilder
|
12
12
|
|
13
13
|
concat(semantic_form_for(@new_post) do |builder|
|
14
14
|
concat(builder.action(:submit, :as => :input))
|
@@ -8,7 +8,7 @@ describe 'LinkAction', 'when cancelling' do
|
|
8
8
|
before do
|
9
9
|
@output_buffer = ''
|
10
10
|
mock_everything
|
11
|
-
Formtastic::Helpers::FormHelper.builder =
|
11
|
+
Formtastic::Helpers::FormHelper.builder = SpeedoFormstrap::FormBuilder
|
12
12
|
end
|
13
13
|
|
14
14
|
context 'without a :url' do
|