simple_form_bootstrap3 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1fe204090932d4f58760c87769125addab47fe11
4
+ data.tar.gz: a7f1fb11538b6f410289d046aec04ad388b3efce
5
+ SHA512:
6
+ metadata.gz: 989d694b2a96de43d4818863855f45e46368631bf43335da4cdb6f7383503c8e1feefc261a338c48b8e9c54458d70f81403092acd1f5d8c5528891bb3fcc9207
7
+ data.tar.gz: 17e267e9368287e429028e9e914704ec187f555caa6fd316941c9667358950c30bcd84045cb35fd46be41e48bdd7e43e26c43448a8fc897cadadaf71e67a12bb
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Yuriy Kolodovskyy
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # Rails form generator with simple_form and bootstrap3
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ gem 'simple_form_bootstrap3'
8
+
9
+ or this line:
10
+
11
+ gem 'simple_form_bootstrap3', git: 'https://github.com/kolodovskyy/simple_form_bootstrap3.git'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install simple_form_bootstrap3
20
+
21
+ ## Maintainers and Authors
22
+
23
+ Yuriy Kolodovskyy (https://github.com/kolodovskyy)
24
+
25
+ ## License
26
+
27
+ MIT License. Copyright 2014 [Yuriy Kolodovskyy](http://twitter.com/kolodovskyy)
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'SimpleFormBoostrap3'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ task default: :rdoc
@@ -0,0 +1,33 @@
1
+ module SimpleFormBootstrap3
2
+ module ApplicationHelper
3
+ def horizontal_form_for(object, *args, &block)
4
+ options = args.extract_options!
5
+ options[:wrapper] ||= :horizontal
6
+ options[:html] ||= {}
7
+ options[:html][:role] = 'form'
8
+ options[:html][:class] = [ options[:html][:class], 'form-horizontal' ].compact.join(' ')
9
+
10
+ simple_form_for object, *(args << options), &block
11
+ end
12
+
13
+ def default_form_for(object, *args, &block)
14
+ options = args.extract_options!
15
+ options[:wrapper] ||= :default
16
+ options[:html] ||= {}
17
+ options[:html][:role] = 'form'
18
+
19
+ simple_form_for object, *(args << options), &block
20
+ end
21
+
22
+ def inline_form_for(object, *args, &block)
23
+ options = args.extract_options!
24
+ options[:wrapper] ||= :inline
25
+ options[:builder] ||= SimpleForm::PlaceholderFormBuilder
26
+ options[:html] ||= {}
27
+ options[:html][:role] = 'form'
28
+ options[:html][:class] = [ options[:html][:class], 'form-inline' ].compact.join(' ')
29
+
30
+ simple_form_for object, *(args << options), &block
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,61 @@
1
+ [
2
+ SimpleForm::Inputs::CollectionSelectInput,
3
+ SimpleForm::Inputs::DateTimeInput,
4
+ SimpleForm::Inputs::FileInput,
5
+ SimpleForm::Inputs::GroupedCollectionSelectInput,
6
+ SimpleForm::Inputs::NumericInput,
7
+ SimpleForm::Inputs::PasswordInput,
8
+ SimpleForm::Inputs::RangeInput,
9
+ SimpleForm::Inputs::StringInput,
10
+ SimpleForm::Inputs::TextInput
11
+ ].each do |input_class|
12
+ input_class.class_eval do
13
+ def input_html_classes_with_extra
14
+ classes = input_html_classes_without_extra
15
+ classes.include?('form-control') ? classes : classes.push('form-control')
16
+ end
17
+ alias_method_chain :input_html_classes, :extra
18
+ end
19
+ end
20
+
21
+ SimpleForm::Components::Labels.class_eval do
22
+ def label_text_with_spaces
23
+ " #{label_text_without_spaces} ".html_safe
24
+ end
25
+ alias_method_chain :label_text, :spaces
26
+ end
27
+
28
+ SimpleForm.setup do |config|
29
+ config.boolean_style = :inline
30
+ config.button_class = 'btn btn-primary'
31
+ config.error_notification_tag = :div
32
+ config.error_notification_class = 'alert alert-danger'
33
+ config.browser_validations = false
34
+ config.default_wrapper = :default
35
+
36
+ #config.wrappers :prepend, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
37
+ # b.use :html5
38
+ # b.use :placeholder
39
+ # b.wrapper tag: 'div', class: 'controls' do |input|
40
+ # input.wrapper tag: 'div', class: 'input-group' do |prepend|
41
+ # prepend.use :label , class: 'input-group-addon' ###Please note setting class here fro the label does not currently work (let me know if you know a workaround as this is the final hurdle)
42
+ # prepend.use :input
43
+ # end
44
+ # input.use :hint, wrap_with: { tag: 'span', class: 'help-block' }
45
+ # input.use :error, wrap_with: { tag: 'span', class: 'help-block has-error' }
46
+ # end
47
+ #end
48
+ #
49
+ #config.wrappers :append, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
50
+ # b.use :html5
51
+ # b.use :placeholder
52
+ # b.wrapper tag: 'div', class: 'controls' do |input|
53
+ # input.wrapper tag: 'div', class: 'input-group' do |prepend|
54
+ # prepend.use :input
55
+ # prepend.use :label , class: 'input-group-addon' ###Please note setting class here fro the label does not currently work (let me know if you know a workaround as this is the final hurdle)
56
+ # end
57
+ # input.use :hint, wrap_with: { tag: 'span', class: 'help-block' }
58
+ # input.use :error, wrap_with: { tag: 'span', class: 'help-block has-error' }
59
+ # end
60
+ #end
61
+ end
@@ -0,0 +1,44 @@
1
+ SimpleForm.setup do |config|
2
+ config.wrappers :default, tag: :div, class: 'form-group', error_class: 'has-error' do |b|
3
+ b.use :html5
4
+ b.use :min_max
5
+ b.use :maxlength
6
+ b.use :placeholder
7
+
8
+ b.optional :pattern
9
+ b.optional :readonly
10
+
11
+ b.use :label
12
+ b.use :input
13
+ b.use :error, wrap_with: { tag: :span, class: 'help-block' }
14
+ b.use :hint, wrap_with: { tag: :p, class: 'help-block' }
15
+ end
16
+
17
+ config.wrappers :checkbox, tag: :div, class: "form-group", error_class: "has-error" do |b|
18
+ b.use :html5
19
+ b.optional :readonly
20
+
21
+ b.wrapper tag: :div, class: 'checkbox' do |c|
22
+ c.wrapper tag: :label do |a|
23
+ a.use :input
24
+ a.use :label_text
25
+ end
26
+ end
27
+ b.use :error, wrap_with: { tag: :span, class: "help-block" }
28
+ b.use :hint, wrap_with: { tag: :p, class: "help-block" }
29
+ end
30
+
31
+ config.wrappers :radio, tag: :div, class: "form-group", error_class: "has-error" do |b|
32
+ b.use :html5
33
+ b.optional :readonly
34
+
35
+ b.wrapper tag: :div, class: 'radio' do |c|
36
+ c.wrapper tag: :label do |a|
37
+ a.use :input
38
+ a.use :label_text
39
+ end
40
+ end
41
+ b.use :error, wrap_with: { tag: :span, class: "help-block" }
42
+ b.use :hint, wrap_with: { tag: :p, class: "help-block" }
43
+ end
44
+ end
@@ -0,0 +1,51 @@
1
+ SimpleForm.setup do |config|
2
+ config.wrappers :horizontal, tag: :div, class: 'form-group', error_class: 'has-error',
3
+ label_html: { class: 'col-sm-2 control-label' } do |b|
4
+ b.use :html5
5
+ b.use :min_max
6
+ b.use :maxlength
7
+ b.use :placeholder
8
+
9
+ b.optional :pattern
10
+ b.optional :readonly
11
+
12
+ b.use :label
13
+ b.wrapper tag: :div, class: 'col-sm-10' do |i|
14
+ i.use :input
15
+ i.use :error, wrap_with: { tag: :span, class: 'help-block' }
16
+ i.use :hint, wrap_with: { tag: :p, class: 'help-block' }
17
+ end
18
+ end
19
+
20
+ config.wrappers :horizontal_checkbox, tag: :div, class: "form-group", error_class: "has-error" do |b|
21
+ b.use :html5
22
+ b.optional :readonly
23
+
24
+ b.wrapper tag: :div, class: 'col-sm-offset-2 col-sm-10' do |i|
25
+ i.wrapper tag: :div, class: 'checkbox' do |c|
26
+ c.wrapper tag: :label do |a|
27
+ a.use :input
28
+ a.use :label_text
29
+ end
30
+ end
31
+ i.use :error, wrap_with: { tag: :span, class: "help-block" }
32
+ i.use :hint, wrap_with: { tag: :p, class: "help-block" }
33
+ end
34
+ end
35
+
36
+ config.wrappers :horizontal_radio, tag: :div, class: "form-group", error_class: "has-error" do |b|
37
+ b.use :html5
38
+ b.optional :readonly
39
+
40
+ b.wrapper tag: :div, class: 'col-sm-offset-2 col-sm-10' do |i|
41
+ i.wrapper tag: :div, class: 'radio' do |c|
42
+ c.wrapper tag: :label do |a|
43
+ a.use :input
44
+ a.use :label_text
45
+ end
46
+ end
47
+ i.use :error, wrap_with: { tag: :span, class: "help-block" }
48
+ i.use :hint, wrap_with: { tag: :p, class: "help-block" }
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,38 @@
1
+ SimpleForm.setup do |config|
2
+ config.wrappers :inline, tag: :div, class: 'form-group', error_class: 'has-error',
3
+ label_html: { class: 'sr-only' } do |b|
4
+ b.use :html5
5
+ b.use :min_max
6
+ b.use :placeholder
7
+
8
+ b.optional :pattern
9
+ b.optional :readonly
10
+
11
+ b.use :label
12
+ b.use :input
13
+ end
14
+
15
+ config.wrappers :inline_checkbox, tag: :div, class: "form-group", error_class: "has-error" do |b|
16
+ b.use :html5
17
+ b.optional :readonly
18
+
19
+ b.wrapper tag: :div, class: 'checkbox' do |c|
20
+ c.wrapper tag: :label do |a|
21
+ a.use :input
22
+ a.use :label_text
23
+ end
24
+ end
25
+ end
26
+
27
+ config.wrappers :inline_radio, tag: :div, class: "form-group", error_class: "has-error" do |b|
28
+ b.use :html5
29
+ b.optional :readonly
30
+
31
+ b.wrapper tag: :div, class: 'radio' do |c|
32
+ c.wrapper tag: :label do |a|
33
+ a.use :input
34
+ a.use :label_text
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,13 @@
1
+ module SimpleForm
2
+ class PlaceholderFormBuilder < SimpleForm::FormBuilder
3
+ def input(attribute_name, options = {}, &block)
4
+ if options[:placeholder].nil?
5
+ options[:placeholder] ||= object.class.respond_to?(:human_attribute_name) ?
6
+ object.class.human_attribute_name(attribute_name.to_s) : attribute_name.to_s.humanize
7
+ end
8
+ options[:label] = false if options[:label].nil?
9
+
10
+ super
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ module SimpleFormBootstrap3
2
+ class Engine < ::Rails::Engine
3
+ config.autoload_paths << File.expand_path("../../../lib", __FILE__)
4
+
5
+ initializer 'simple_form_bootstrap3.initialize' do
6
+ ActiveSupport.on_load :action_controller do
7
+ helper SimpleFormBootstrap3::ApplicationHelper
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module SimpleFormBootstrap3
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,7 @@
1
+ require 'bootstrap-sass'
2
+ require 'simple_form'
3
+
4
+ require 'simple_form_bootstrap3/engine'
5
+
6
+ module SimpleFormBootstrap3
7
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simple_form_bootstrap3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Yuriy Kolodovskyy
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bootstrap-sass
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 3.1.1.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 3.1.1.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: simple_form
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 3.0.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 3.0.1
41
+ description: Rails form generator with simple_form and bootstrap3.
42
+ email:
43
+ - kolodovskyy@ukrindex.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - app/helpers/simple_form_bootstrap3/application_helper.rb
49
+ - config/initializers/simple_form.rb
50
+ - config/initializers/simple_form_default.rb
51
+ - config/initializers/simple_form_horizontal.rb
52
+ - config/initializers/simple_form_inline.rb
53
+ - lib/simple_form/placeholder_form_builder.rb
54
+ - lib/simple_form_bootstrap3/engine.rb
55
+ - lib/simple_form_bootstrap3/version.rb
56
+ - lib/simple_form_bootstrap3.rb
57
+ - LICENSE.txt
58
+ - Rakefile
59
+ - README.md
60
+ homepage: https://github.com/kolodovskyy/simple_form_boostrap3
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.1.11
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: Rails form generator with simple_form and bootstrap3.
84
+ test_files: []