bootstrap_forms 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -69,12 +69,12 @@ See description above...
69
69
  = f.collection_radio_buttons :primary_category_id, Category.all, :id, :name
70
70
  ```
71
71
 
72
- Uneditable Field
72
+ Uneditable Input
73
73
  ----------------
74
- Bootstrap Forms adds another helper method that generates the necessary markup for uneditable fields:
74
+ Bootstrap Forms adds another helper method that generates the necessary markup for uneditable inputs:
75
75
 
76
76
  ```haml
77
- = f.uneditable_field :name
77
+ = f.uneditable_input :name
78
78
  ```
79
79
 
80
80
  yields:
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "bootstrap_forms"
6
- s.version = "1.0.2"
6
+ s.version = "1.0.3"
7
7
  s.author = "Seth Vargo"
8
8
  s.email = "sethvargo@gmail.com"
9
9
  s.homepage = "https://github.com/sethvargo/bootstrap_forms"
@@ -1,12 +1,12 @@
1
1
  module BootstrapForms
2
2
  class FormBuilder < ActionView::Helpers::FormBuilder
3
- delegate :content_tag, :hidden_field_tag, :check_box_tag, :radio_button_tag, :link_to, :to => :@template
3
+ delegate :content_tag, :hidden_field_tag, :check_box_tag, :radio_button_tag, :button_tag, :link_to, :to => :@template
4
4
 
5
5
  def error_messages
6
6
  if object.errors.full_messages.any?
7
- content_tag(:div, :class => 'alert alert-error') do
8
- link_to('&times;'.html_safe, '#', {:class => 'close', :data => { :dismiss => "alert" }}) +
9
- content_tag(:p, I18n.t('bootstrap_forms.errors.header', :model => object.class.model_name.humanize)) +
7
+ content_tag(:div, :class => 'alert alert-block alert-error') do
8
+ link_to('&times;'.html_safe, '#', {:class => 'close', :data => { :dismiss => 'alert' }}) +
9
+ content_tag(:h4, I18n.t('bootstrap_forms.errors.header', :model => object.class.model_name.humanize), :class => 'alert-heading') +
10
10
  content_tag(:ul) do
11
11
  object.errors.full_messages.map do |message|
12
12
  content_tag(:li, message)
@@ -29,7 +29,7 @@ module BootstrapForms
29
29
  @options = args.extract_options!
30
30
  @args = args
31
31
 
32
- clearfix_div do
32
+ control_group_div do
33
33
  label_field + input_div do
34
34
  extras { super(name, *(@args << @options)) }
35
35
  end
@@ -42,7 +42,7 @@ module BootstrapForms
42
42
  @options = args.extract_options!
43
43
  @args = args
44
44
 
45
- clearfix_div do
45
+ control_group_div do
46
46
  input_div do
47
47
  label(@name, :class => [ 'checkbox', required_class ].compact.join(' ')) do
48
48
  extras { super(name, *(@args << @options)) + object.class.human_attribute_name(name) }
@@ -56,23 +56,19 @@ module BootstrapForms
56
56
  @options = args.extract_options!
57
57
  @args = args
58
58
 
59
- clearfix_div do
60
- label_field + input_div do
61
- extras do
62
- content_tag(:ul, :class => 'inputs-list') do
63
- records.collect do |record|
64
- element_id = "#{object_name}_#{attribute}_#{record.send(record_id)}"
65
- checkbox = check_box_tag("#{object_name}[#{attribute}][]", record.send(record_id), object.send(attribute).include?(record.send(record_id)), :id => element_id)
66
-
67
- content_tag(:li) do
68
- content_tag(:label) do
69
- checkbox + content_tag(:span, record.send(record_name))
70
- end
71
- end
72
- end.join('').html_safe
73
- end
59
+ control_group_div do
60
+ label_field + extras do
61
+ content_tag(:div, :class => 'controls') do
62
+ records.collect do |record|
63
+ element_id = "#{object_name}_#{attribute}_#{record.send(record_id)}"
64
+ checkbox = check_box_tag("#{object_name}[#{attribute}][]", record.send(record_id), [object.send(attribute)].flatten.include?(record.send(record_id)), @options.merge({:id => element_id}))
65
+
66
+ content_tag(:label, :class => ['checkbox', ('inline' if @options[:inline])].compact.join(' ')) do
67
+ checkbox + content_tag(:span, record.send(record_name))
68
+ end
69
+ end.join('').html_safe
74
70
  end
75
- end + hidden_field_tag("#{object_name}[#{attribute}][]")
71
+ end
76
72
  end
77
73
  end
78
74
 
@@ -81,32 +77,28 @@ module BootstrapForms
81
77
  @options = args.extract_options!
82
78
  @args = args
83
79
 
84
- clearfix_div do
85
- label_field + input_div do
86
- extras do
87
- content_tag(:ul, :class => 'inputs-list') do
88
- records.collect do |record|
89
- element_id = "#{object_name}_#{attribute}_#{record.send(record_id)}"
90
- radiobutton = radio_button_tag("#{object_name}[#{attribute}][]", record.send(record_id), object.send(attribute) == record.send(record_id), :id => element_id)
91
-
92
- content_tag(:li) do
93
- content_tag(:label) do
94
- radiobutton + content_tag(:span, record.send(record_name))
95
- end
96
- end
97
- end.join('').html_safe
98
- end
80
+ control_group_div do
81
+ label_field + extras do
82
+ content_tag(:div, :class => 'controls') do
83
+ records.collect do |record|
84
+ element_id = "#{object_name}_#{attribute}_#{record.send(record_id)}"
85
+ radiobutton = radio_button_tag("#{object_name}[#{attribute}][]", record.send(record_id), object.send(attribute) == record.send(record_id), @options.merge({:id => element_id}))
86
+
87
+ content_tag(:label, :class => ['radio', ('inline' if @options[:inline])].compact.join(' ')) do
88
+ radiobutton + content_tag(:span, record.send(record_name))
89
+ end
90
+ end.join('').html_safe
99
91
  end
100
92
  end
101
93
  end
102
94
  end
103
95
 
104
- def uneditable_field(name, *args)
96
+ def uneditable_input(name, *args)
105
97
  @name = name
106
98
  @options = args.extract_options!
107
99
  @args = args
108
100
 
109
- clearfix_div do
101
+ control_group_div do
110
102
  label_field + input_div do
111
103
  extras do
112
104
  content_tag(:span, :class => 'uneditable-input') do
@@ -125,12 +117,12 @@ module BootstrapForms
125
117
  @options[:class] = 'btn btn-primary'
126
118
 
127
119
  content_tag(:div, :class => 'form-actions') do
128
- super(name, *(args << @options)) + ' ' + link_to(I18n.t('bootstrap_forms.buttons.cancel'), @options[:back_path] || :back, :class => 'btn cancel')
120
+ super(name, *(args << @options)) + ' ' + button_tag(I18n.t('bootstrap_forms.buttons.cancel'), :type => 'reset', :class => 'btn cancel')
129
121
  end
130
122
  end
131
123
 
132
124
  private
133
- def clearfix_div(&block)
125
+ def control_group_div(&block)
134
126
  @options[:error] = object.errors[@name].collect{|e| "#{@options[:label] || @name} #{e}".humanize}.join(', ') unless object.errors[@name].empty?
135
127
 
136
128
  klasses = ['control-group']
@@ -155,15 +147,12 @@ module BootstrapForms
155
147
  end
156
148
 
157
149
  def label_field(&block)
158
- label(@name, block_given? ? block : @options[:label], :class => [ 'control-label', required_class ].compact.join(' '))
150
+ label(@name, block_given? ? block : @options[:label], :class => ['control-label', required_class].compact.join(' '))
159
151
  end
160
152
 
161
153
  def required_class
162
- if object.class.validators_on(@name).any? { |v| v.kind_of? ActiveModel::Validations::PresenceValidator }
163
- 'required'
164
- else
165
- nil
166
- end
154
+ 'required' if object.class.validators_on(@name).any? { |v| v.kind_of? ActiveModel::Validations::PresenceValidator }
155
+ nil
167
156
  end
168
157
 
169
158
  %w(help_inline error success warning help_block append prepend).each do |method_name|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap_forms
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
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: 2012-02-07 00:00:00.000000000 Z
12
+ date: 2012-02-08 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Bootstrap Forms makes Twitter's Bootstrap on Rails easy to use by creating
15
15
  helpful form builders that minimize markup in your views.