formtastic-bootstrap 2.1.3 → 3.0.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +43 -56
  3. data/VERSION +1 -1
  4. data/lib/action_view/helpers/text_field_date_helper.rb +7 -7
  5. data/lib/formtastic-bootstrap/actions/base.rb +11 -6
  6. data/lib/formtastic-bootstrap/form_builder.rb +5 -5
  7. data/lib/formtastic-bootstrap/helpers.rb +1 -1
  8. data/lib/formtastic-bootstrap/helpers/actions_helper.rb +4 -4
  9. data/lib/formtastic-bootstrap/helpers/errors_helper.rb +1 -1
  10. data/lib/formtastic-bootstrap/helpers/fieldset_wrapper.rb +2 -2
  11. data/lib/formtastic-bootstrap/helpers/input_helper.rb +3 -3
  12. data/lib/formtastic-bootstrap/helpers/inputs_helper.rb +3 -3
  13. data/lib/formtastic-bootstrap/inputs.rb +19 -19
  14. data/lib/formtastic-bootstrap/inputs/base.rb +1 -1
  15. data/lib/formtastic-bootstrap/inputs/base/errors.rb +2 -2
  16. data/lib/formtastic-bootstrap/inputs/base/hints.rb +3 -3
  17. data/lib/formtastic-bootstrap/inputs/base/html.rb +8 -2
  18. data/lib/formtastic-bootstrap/inputs/base/labelling.rb +6 -11
  19. data/lib/formtastic-bootstrap/inputs/base/stringish.rb +4 -4
  20. data/lib/formtastic-bootstrap/inputs/base/timeish.rb +24 -18
  21. data/lib/formtastic-bootstrap/inputs/base/wrapping.rb +30 -52
  22. data/lib/formtastic-bootstrap/inputs/boolean_input.rb +18 -10
  23. data/lib/formtastic-bootstrap/inputs/check_boxes_input.rb +19 -18
  24. data/lib/formtastic-bootstrap/inputs/email_input.rb +1 -1
  25. data/lib/formtastic-bootstrap/inputs/number_input.rb +3 -3
  26. data/lib/formtastic-bootstrap/inputs/password_input.rb +1 -1
  27. data/lib/formtastic-bootstrap/inputs/phone_input.rb +1 -1
  28. data/lib/formtastic-bootstrap/inputs/radio_input.rb +19 -18
  29. data/lib/formtastic-bootstrap/inputs/range_input.rb +1 -1
  30. data/lib/formtastic-bootstrap/inputs/search_input.rb +1 -1
  31. data/lib/formtastic-bootstrap/inputs/select_input.rb +17 -0
  32. data/lib/formtastic-bootstrap/inputs/text_input.rb +4 -4
  33. data/lib/formtastic-bootstrap/inputs/url_input.rb +1 -1
  34. data/lib/formtastic-bootstrap/version.rb +1 -1
  35. data/vendor/assets/stylesheets/formtastic-bootstrap.css +32 -0
  36. metadata +51 -55
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ecb19013ed0931f06bd003f1ea90049610323e95
4
+ data.tar.gz: 689d4e4702a9fe931cc3123291dada9d8df21d35
5
+ SHA512:
6
+ metadata.gz: 5be322ff2419bc7915198e7d34bcdf98ff62843f6119c6f293ce87d799f33972e0fadfcb9dbd7d9bb10aa08dc0fca56c777612bc15c5ab20d1c3b74e55979049
7
+ data.tar.gz: 0b30ebf52df315ad4223bb91f28804c74161c2a59fe33d45723a752e7dc11c5a1d330d1b237e1023e737424038e6c4f6b291fa2e7f0d1ea758419fc910fe8243
data/README.md CHANGED
@@ -8,7 +8,27 @@ You can follow [FormBoot on twitter](http://twitter.com/FormBoot) for update ann
8
8
 
9
9
  ### Dependencies
10
10
 
11
- Formtastic Bootstrap has only been tested with Ruby 1.9.2, Rails 3.2.x, Formtastic 2.2.x and Twitter Bootstrap 2.x.
11
+ This version of Formtastic Bootstrap should support the following:
12
+
13
+ *Bootstrap*
14
+
15
+ * Bootstrap 3.x
16
+
17
+ *Rails*
18
+
19
+ * Rails 3.2.x
20
+ * Rails 4.0.x
21
+
22
+ *Formtastic*
23
+
24
+ * Formtastic 2.2.x
25
+ * Formtastic 2.3.x
26
+
27
+ *Ruby*
28
+
29
+ * 1.9.2
30
+ * 1.9.3
31
+ * 2.0.x
12
32
 
13
33
  #### Installation
14
34
 
@@ -43,58 +63,12 @@ THIS SECTION IS OUT OF DATE.
43
63
 
44
64
  ### Overview
45
65
 
46
- In general, Formtastic creates very verbose HTML whereas Bootstrap expects simpler HTML. Every attempt has been
47
- made to generate the HTML expected by Bootstrap while still generating the rich HTML provided by Formtastic. Here's a pretty typical (simplified) example of what Formtastic generates and what Formtastic Bootstrap generates.
48
-
49
- #### ERB
50
-
51
- <%= semantic_form_for @post do |f| %>
52
- <%= f.semantic_errors %>
53
- <%= f.inputs do %>
54
- <%= f.input :title, :hint => "This is the title!" %>
55
- <% end %>
56
- <%= f.actions do %>
57
- <%= f.action :submit %>
58
- <% end %>
59
- <% end %>
66
+ In general, Formtastic creates very verbose HTML whereas
67
+ Bootstrap expects (ever) simpler HTML. Every attempt has been
68
+ made to generate the HTML expected by Bootstrap while still
69
+ generating the rich HTML provided by Formtastic. When there
70
+ is a conflict, Bootstrap wins.
60
71
 
61
- #### Formtastic
62
-
63
- <form accept-charset="UTF-8" action="/posts" class="formtastic post" id="new_post" method="post">
64
- <fieldset class="inputs">
65
- <ol>
66
- <li class="string input optional stringish" id="post_title_input">
67
- <label class=" label" for="post_title">Title</label>
68
- <input id="post_title" maxlength="255" name="post[title]" type="text" value="" />
69
- <p class="inline-hints">This is the title!</p>
70
- </li>
71
- </ol>
72
- </fieldset>
73
- <fieldset class="buttons">
74
- <ol>
75
- <li class="commit button">
76
- <input class="create" name="commit" type="submit" value="Create Post" />
77
- </li>
78
- </ol>
79
- </fieldset>
80
- </form>
81
-
82
- #### Formtastic Bootstrap
83
-
84
- <form accept-charset="UTF-8" action="/posts" class="formtastic post" id="new_post" method="post">
85
- <fieldset class="inputs">
86
- <div class="string clearfix optional stringish" id="post_title_input">
87
- <label class="" for="post_title">Title</label>
88
- <div class="input">
89
- <input id="post_title" maxlength="255" name="post[title]" type="text" value="" />
90
- <span class="help-inline">This is the title!</span>
91
- </div>
92
- </div>
93
- </fieldset>
94
- <div class="actions">
95
- <input class="btn create commit" name="commit" type="submit" value="Create Post" />
96
- </div>
97
- </form>
98
72
 
99
73
  ### Major Difference in Behavior
100
74
 
@@ -114,7 +88,10 @@ The gem also provides some "shim" CSS where Bootstrap is missing styles provided
114
88
 
115
89
  ### Other
116
90
 
117
- A lot of the code (especially the test suite) was copied over from Formtastic and then beaten into submission. I'm sure you'll find some ugliness in there. In general, I mimicked the Formtastic code structure as much as possible.
91
+ A lot of the code (especially the test suite) was copied
92
+ over from Formtastic and then beaten into submission. I'm
93
+ sure you'll find some ugliness in there. In general, I
94
+ mimicked the Formtastic code structure as much as possible.
118
95
 
119
96
  In particular:
120
97
 
@@ -130,7 +107,7 @@ In particular:
130
107
  Contributions are welcome!
131
108
 
132
109
  * Formtastic's <tt>:country</tt> has not yet been implemented.
133
- * Twitter Bootstrap's Date Range, Prepend Checkbox and Appended Checkbox controls have not yet been implemented.
110
+ * I'm sure there's lots ...
134
111
 
135
112
  ## Usage
136
113
 
@@ -156,6 +133,16 @@ To create an Appended Text field, use the ```:append``` option. This works on a
156
133
  <% end %>
157
134
  <% end %>
158
135
 
136
+ #### Appended Content
137
+ To add appended elements that are not contained within an add-on span
138
+ use the ```:append_content``` or ```:prepend_content``` option.
139
+
140
+ <%= semantic_form_for @user do |f| %>
141
+ <%= f.inputs do %>
142
+ <%= f.input :handle, :append_content => content_tag(:a, "Click Here", :class => 'btn') %>
143
+ <% end %>
144
+ <% end %>
145
+
159
146
  ## Contributing
160
147
 
161
148
  ### Contributors
@@ -198,16 +185,16 @@ Source contributions are very welcome! Most of the recent work on this package
198
185
  * As rich functionally as their Rails counterparts.
199
186
  * Extract into a standalone gem.
200
187
  * Tests
188
+ * Get them passing!
201
189
  * Refactor
202
190
  * More -- See if I'm making sure the Bootstrap classes are present.
203
191
  * Documentation
204
192
  * Refactor :boolean to use common "choices" code (if possible.) (Not sure it is.)
205
193
  * Boostrap
206
- * Ask why they use 'inline-inputs' class instead of a fieldset tag.
207
194
  * Why 'help-inline' and 'help-block' when they could have done p.help and span.help?
208
195
 
209
196
 
210
197
  ## Copyright
211
198
 
212
- Copyright (c) 2011 Matthew Bellantoni. See LICENSE.txt for further details.
199
+ Copyright (c) 2013 Matthew Bellantoni. See LICENSE.txt for further details.
213
200
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.3
1
+ 3.0.0.rc.1
@@ -40,8 +40,8 @@ module ActionView
40
40
  @options[:discard_day] ||= true if @options[:discard_month] || !order.include?(:day)
41
41
 
42
42
  # Save this so we can restore it.
43
- original_datetime_separator_separator = @options[:datetime_separator]
44
- original_date_separator = @options[:date_separator]
43
+ original_datetime_separator_separator = @options[:datetime_separator]
44
+ original_date_separator = @options[:date_separator]
45
45
 
46
46
  @options[:datetime_separator] = ""
47
47
  @options[:date_separator] = " "
@@ -71,8 +71,8 @@ module ActionView
71
71
 
72
72
  # Save this so we can restore it.
73
73
  original_datetime_separator = @options[:datetime_separator]
74
- original_time_separator = @options[:time_separator]
75
- original_date_separator = @options[:date_separator]
74
+ original_time_separator = @options[:time_separator]
75
+ original_date_separator = @options[:date_separator]
76
76
 
77
77
  @options[:datetime_separator] = ''
78
78
  @options[:time_separator] = ':'
@@ -85,7 +85,7 @@ module ActionView
85
85
 
86
86
  build_text_field_from_types(order).tap do
87
87
  # Restore.
88
- @options[:datetime_separator] = original_datetime_separator
88
+ @options[:datetime_separator] = original_datetime_separator
89
89
  @options[:date_separator] = original_date_separator
90
90
  @options[:time_separator] = original_time_separator
91
91
  end
@@ -131,7 +131,7 @@ module ActionView
131
131
  input = ''
132
132
  order.reverse.each do |type|
133
133
  separator = separator(type) unless type == order.first # don't add on last field
134
- input.insert(0, separator.to_s + send("text_field_#{type}").to_s)
134
+ input.insert(0, separator.to_s + send("text_field_#{type}").to_s)
135
135
  end
136
136
  text_field_tag("", input.html_safe, @html_options).html_safe
137
137
  end
@@ -163,4 +163,4 @@ module ActionView
163
163
  include TextFieldDateHelper
164
164
 
165
165
  end
166
- end
166
+ end
@@ -4,19 +4,24 @@ module FormtasticBootstrap
4
4
 
5
5
  # Bootstrap doesn't have wrappers.
6
6
  def wrapper(&block)
7
- # TODO Detect if user passed wrapper_html_options and issue
8
- # a warning that they're ignored. (See the original in
9
- # Formtastic.)
10
7
  template.capture(&block)
11
8
  end
12
9
 
10
+ # Default button class
11
+ def default_wrapper_classes
12
+ ["btn"]
13
+ end
14
+
15
+ # :wrapper_html member :class is prefixed with btn
16
+ # :button_html member :class is all encompassing
13
17
  def default_button_html
14
- {
18
+ {
15
19
  :accesskey => accesskey,
16
- :class => "btn"
20
+ :class => wrapper_class.strip,
21
+ :id => wrapper_id
17
22
  }
18
23
  end
19
24
 
20
25
  end
21
26
  end
22
- end
27
+ end
@@ -1,5 +1,5 @@
1
1
  module FormtasticBootstrap
2
-
2
+
3
3
  class FormBuilder < Formtastic::FormBuilder
4
4
 
5
5
  configure :default_inline_error_class, 'help-inline'
@@ -11,18 +11,18 @@ module FormtasticBootstrap
11
11
  # self.default_inline_error_class
12
12
  raise
13
13
  end
14
-
14
+
15
15
  def self.default_error_class=(error_class)
16
16
  # self.default_inline_error_class = error_class
17
17
  # self.default_block_error_class = error_class
18
18
  raise
19
19
  end
20
-
20
+
21
21
  def self.default_hint_class
22
22
  # self.default_inline_hint_class
23
23
  raise
24
24
  end
25
-
25
+
26
26
  def self.default_hint_class=(hint_class)
27
27
  # self.default_inline_hint_class = hint_class
28
28
  # self.default_block_hint_class = hint_class
@@ -38,4 +38,4 @@ module FormtasticBootstrap
38
38
 
39
39
  end
40
40
 
41
- end
41
+ end
@@ -9,7 +9,7 @@ module FormtasticBootstrap
9
9
  # autoload :FormHelper, 'formtastic/helpers/form_helper'
10
10
  autoload :InputHelper, 'formtastic-bootstrap/helpers/input_helper'
11
11
  autoload :InputsHelper, 'formtastic-bootstrap/helpers/inputs_helper'
12
- # autoload :LabelHelper, 'formtastic/helpers/label_helper'
12
+ # autoload :LabelHelper, 'formtastic/helpers/label_helper'
13
13
  # autoload :SemanticFormHelper, 'formtastic/helpers/semantic_form_helper'
14
14
  # autoload :Reflection, 'formtastic/helpers/reflection'
15
15
  end
@@ -4,12 +4,12 @@ module FormtasticBootstrap
4
4
 
5
5
  include Formtastic::Helpers::ActionsHelper
6
6
  include FormtasticBootstrap::Helpers::FieldsetWrapper
7
-
7
+
8
8
  def actions(*args, &block)
9
9
 
10
10
  html_options = args.extract_options!
11
11
  html_options[:class] ||= "form-actions"
12
-
12
+
13
13
  if block_given?
14
14
  field_set_and_list_wrapping(html_options, &block)
15
15
  else
@@ -18,7 +18,7 @@ module FormtasticBootstrap
18
18
  field_set_and_list_wrapping(html_options, contents)
19
19
  end
20
20
  end
21
-
21
+
22
22
  end
23
23
  end
24
- end
24
+ end
@@ -59,7 +59,7 @@ module FormtasticBootstrap
59
59
  end
60
60
 
61
61
  template.content_tag(:div, html_options) do
62
- template.content_tag(:button, "&times;".html_safe, :class => "close", "data-dismiss" => "alert") +
62
+ template.content_tag(:a, "&times;".html_safe, :class => "close", "data-dismiss" => "alert") +
63
63
  template.content_tag(:ul, {:class => "error-list"}) do
64
64
  Formtastic::Util.html_safe(full_errors.map { |error| template.content_tag(:li, Formtastic::Util.html_safe(error)) }.join)
65
65
  end
@@ -3,7 +3,7 @@ module FormtasticBootstrap
3
3
  module FieldsetWrapper
4
4
 
5
5
  include Formtastic::Helpers::FieldsetWrapper
6
-
6
+
7
7
  protected
8
8
 
9
9
  def field_set_and_list_wrapping(*args, &block) #:nodoc:
@@ -32,4 +32,4 @@ module FormtasticBootstrap
32
32
 
33
33
  end
34
34
  end
35
- end
35
+ end
@@ -2,11 +2,11 @@ module FormtasticBootstrap
2
2
  module Helpers
3
3
  module InputHelper
4
4
  include Formtastic::Helpers::InputHelper
5
-
5
+
6
6
  def standard_input_class_name(as)
7
7
  "FormtasticBootstrap::Inputs::#{as.to_s.camelize}Input"
8
8
  end
9
-
9
+
10
10
  end
11
11
  end
12
- end
12
+ end
@@ -5,7 +5,7 @@ module FormtasticBootstrap
5
5
  def inputs(*args, &block)
6
6
  wrap_it = @already_in_an_inputs_block ? true : false
7
7
  @already_in_an_inputs_block = true
8
-
8
+
9
9
  title = field_set_title_from_args(*args)
10
10
  html_options = args.extract_options!
11
11
  html_options[:class] ||= "inputs"
@@ -24,11 +24,11 @@ module FormtasticBootstrap
24
24
  field_set_and_list_wrapping(*((args << html_options) << contents))
25
25
  end
26
26
  end
27
-
27
+
28
28
  @already_in_an_inputs_block = false
29
29
  out
30
30
  end
31
31
 
32
32
  end
33
33
  end
34
- end
34
+ end
@@ -2,33 +2,33 @@ module FormtasticBootstrap
2
2
  module Inputs
3
3
 
4
4
  autoload :Base, "formtastic-bootstrap/inputs/base"
5
- # autoload :Basic
6
- autoload :BooleanInput, "formtastic-bootstrap/inputs/boolean_input"
5
+ # autoload :Basic
6
+ autoload :BooleanInput, "formtastic-bootstrap/inputs/boolean_input"
7
7
  autoload :CheckBoxesInput, "formtastic-bootstrap/inputs/check_boxes_input"
8
- autoload :CountryInput, "formtastic-bootstrap/inputs/country_input"
9
- autoload :DateInput, "formtastic-bootstrap/inputs/date_input"
10
- autoload :DatePickerInput, "formtastic-bootstrap/inputs/date_picker_input"
11
- autoload :DatetimePickerInput, "formtastic-bootstrap/inputs/datetime_picker_input"
8
+ autoload :CountryInput, "formtastic-bootstrap/inputs/country_input"
9
+ autoload :DateInput, "formtastic-bootstrap/inputs/date_input"
10
+ autoload :DatePickerInput, "formtastic-bootstrap/inputs/date_picker_input"
11
+ autoload :DatetimePickerInput, "formtastic-bootstrap/inputs/datetime_picker_input"
12
12
  autoload :DateSelectInput, "formtastic-bootstrap/inputs/date_select_input"
13
- autoload :DatetimeInput, "formtastic-bootstrap/inputs/datetime_input"
14
- autoload :DatetimeSelectInput, "formtastic-bootstrap/inputs/datetime_select_input"
15
- autoload :EmailInput, "formtastic-bootstrap/inputs/email_input"
16
- autoload :FileInput, "formtastic-bootstrap/inputs/file_input"
17
- autoload :HiddenInput, "formtastic-bootstrap/inputs/hidden_input"
18
- autoload :NumberInput, "formtastic-bootstrap/inputs/number_input"
13
+ autoload :DatetimeInput, "formtastic-bootstrap/inputs/datetime_input"
14
+ autoload :DatetimeSelectInput, "formtastic-bootstrap/inputs/datetime_select_input"
15
+ autoload :EmailInput, "formtastic-bootstrap/inputs/email_input"
16
+ autoload :FileInput, "formtastic-bootstrap/inputs/file_input"
17
+ autoload :HiddenInput, "formtastic-bootstrap/inputs/hidden_input"
18
+ autoload :NumberInput, "formtastic-bootstrap/inputs/number_input"
19
19
  # autoload :NumericInput # TODO Where does Formtastic actually define this?
20
- autoload :PasswordInput, "formtastic-bootstrap/inputs/password_input"
21
- autoload :PhoneInput, "formtastic-bootstrap/inputs/phone_input"
22
- autoload :RadioInput, "formtastic-bootstrap/inputs/radio_input"
23
- autoload :RangeInput, "formtastic-bootstrap/inputs/range_input"
24
- autoload :SearchInput, "formtastic-bootstrap/inputs/search_input"
25
- autoload :SelectInput, "formtastic-bootstrap/inputs/select_input"
20
+ autoload :PasswordInput, "formtastic-bootstrap/inputs/password_input"
21
+ autoload :PhoneInput, "formtastic-bootstrap/inputs/phone_input"
22
+ autoload :RadioInput, "formtastic-bootstrap/inputs/radio_input"
23
+ autoload :RangeInput, "formtastic-bootstrap/inputs/range_input"
24
+ autoload :SearchInput, "formtastic-bootstrap/inputs/search_input"
25
+ autoload :SelectInput, "formtastic-bootstrap/inputs/select_input"
26
26
  autoload :StringInput, "formtastic-bootstrap/inputs/string_input"
27
27
  autoload :TextInput, "formtastic-bootstrap/inputs/text_input"
28
28
  autoload :TimeInput, "formtastic-bootstrap/inputs/time_input"
29
29
  # autoload :TimePickerInput # TODO Come back to this.
30
30
  autoload :TimeSelectInput, "formtastic-bootstrap/inputs/time_select_input"
31
- autoload :TimeZoneInput, "formtastic-bootstrap/inputs/time_zone_input"
31
+ autoload :TimeZoneInput, "formtastic-bootstrap/inputs/time_zone_input"
32
32
  # autoload :Timeish # This seems like a mistake.
33
33
  autoload :UrlInput, "formtastic-bootstrap/inputs/url_input"
34
34
 
@@ -26,7 +26,7 @@ module FormtasticBootstrap
26
26
  autoload :Timeish, "formtastic-bootstrap/inputs/base/timeish"
27
27
  # autoload :Validations
28
28
  autoload :Wrapping, "formtastic-bootstrap/inputs/base/wrapping"
29
-
29
+
30
30
  include Html
31
31
  # include Options
32
32
  # include Database
@@ -27,7 +27,7 @@ module FormtasticBootstrap
27
27
  # end
28
28
  # template.content_tag(:ul, Formtastic::Util.html_safe(list_elements.join("\n")), :class => error_class)
29
29
  end
30
-
30
+
31
31
  def error_first_html(inline_or_block = :inline)
32
32
  error_class = if inline_or_block == :inline
33
33
  options[:error_class] || builder.default_inline_error_class
@@ -45,4 +45,4 @@ module FormtasticBootstrap
45
45
  end
46
46
  end
47
47
  end
48
- end
48
+ end