simple_form_bootstrap_datepicker 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4ec65ac80897447bab10b00d0a72f8fe8bb870c5
4
+ data.tar.gz: 3be45a1f2273a956bdecd2db5bd1fa3b48001ad2
5
+ SHA512:
6
+ metadata.gz: 295d34f5dccc9e3b62eb9ab3b7a03ea75e2d1e0f84183cc1afd11d43e87c41a5b52bca712b91717365a2337655a78e23f351a24a3ee97384f0ef80272bbc4359
7
+ data.tar.gz: da7a3aaa6844d9cb5ba8f945eb01757f3f1240c7174eb33e11ab0e140ab4cde2cd55dbdafc100b6478152552d414ca8d8e25336782890eae808da7aa8dbe3ed2
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
@@ -0,0 +1,6 @@
1
+ Style/StringLiterals:
2
+ EnforcedStyle: double_quotes
3
+ Enabled: true
4
+
5
+ Documentation:
6
+ Enabled: false
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in simple_form_bootstrap_datepicker.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 arianamador
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.
@@ -0,0 +1,52 @@
1
+ # Simple Form Bootstrap Datepicker
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/simple-form-bootstrap-datepicker.svg)](http://badge.fury.io/rb/simple-form-bootstrap-datepicker)
4
+
5
+ Adds a bootstrap date picker for [Simple Form](https://github.com/plataformatec/simple_form).
6
+
7
+ Includes support for [Bootstrap](http://getbootstrap.com/components/#glyphicons), [FontAwesome](http://fortawesome.github.io/Font-Awesome/icons/), and [Foundation](http://zurb.com/playground/foundation-icon-fonts-3) icon libraries used in the bootstrap input group.
8
+
9
+ ## Requirements
10
+ * [simple_form](https://github.com/plataformatec/simple_form)
11
+ * bootstrap ([sass](https://github.com/twbs/bootstrap-sass) / [less](https://github.com/metaskills/less-rails-bootstrap))
12
+ * [bootstrap-datepicker-rails](https://github.com/Nerian/bootstrap-datepicker-rails)
13
+
14
+ ## Optional
15
+ * [font-awesome-rails](https://github.com/bokmann/font-awesome-rails)
16
+ * [foundation-icons-sass-rails](https://github.com/zaiste/foundation-icons-sass-rails)
17
+
18
+ ## Installation
19
+
20
+ Add it to your Gemfile:
21
+ ```ruby
22
+ gem 'simple_form_bootstrap_datepicker'
23
+ ```
24
+
25
+ Run the following command to install it:
26
+ ```console
27
+ bundle install
28
+ ```
29
+
30
+ Run the generator:
31
+ ```console
32
+ rails generate simple_form_bootstrap_datepicker:install
33
+ ```
34
+
35
+ ## Usage
36
+
37
+ ```erb
38
+ <%= simple_form_for @user do |f| %>
39
+ <%= f.input :start_date, as: :date_picker, wrapper: date_picker, input_html: {icon: :bs} %>
40
+ <%= f.button :submit %>
41
+ <% end %>
42
+ ```
43
+
44
+ A default placeholder is added `mm/dd/yyyy` if one is not specified. There are currently three icon libraries which can be specified with `:bs` for bootstrap, `:fa` for font-awesome, and `:fi` for foundation. If an icon library isn't specified then a default `Date` will be added the icon section.
45
+
46
+ ## Contributing
47
+
48
+ 1. Fork it ( https://github.com/arian-amador/biostars-api/fork )
49
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
50
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
51
+ 4. Push to the branch (`git push origin my-new-feature`)
52
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,18 @@
1
+ module SimpleFormBootstrapDatepicker
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+
5
+ desc "Copies an initializer file /config/initializers/simple_form_bootstrap_datepicker.rb for the input wrapper and copies a Simple Form custom input /app/inputs/date_picker_input.rb"
6
+
7
+ source_root File.expand_path("../templates", __FILE__)
8
+
9
+ def copy_config
10
+ directory "config"
11
+ end
12
+
13
+ def copy_input
14
+ directory "app"
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,33 @@
1
+ class DatePickerInput < SimpleForm::Inputs::StringInput
2
+ def input(wrapper_options = nil)
3
+ input_html_classes.unshift("datepicker form-control")
4
+
5
+ merged_input_options = merge_wrapper_options(input_options,
6
+ wrapper_options)
7
+ out = ActiveSupport::SafeBuffer.new
8
+ out << template.content_tag(:span, set_icon.html_safe,
9
+ class: "input-group-addon")
10
+ out << @builder.text_field(attribute_name, merged_input_options)
11
+ end
12
+
13
+ private
14
+
15
+ def input_options
16
+ input_html_options[:type] ||= input_type if html5?
17
+ input_html_options[:placeholder] ||= "mm/dd/yyyy"
18
+ input_html_options
19
+ end
20
+
21
+ def set_icon
22
+ case input_html_options[:icon]
23
+ when :fa # font-awesome
24
+ return "<i class='fa fa-calendar'></i>"
25
+ when :bs # bootstrap glyphs
26
+ return "<span class='glyphicon glyphicon-calendar'></span>"
27
+ when :fi # foundation
28
+ return "<i class='fi-calendar'></i>"
29
+ else # default
30
+ return "<span>Date</span>"
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,15 @@
1
+ SimpleForm.setup do |config|
2
+ config.wrappers(:date_picker, tag: "div", class: "form-group", error_class: "has-error") do |b|
3
+ b.use :html5
4
+ b.use :placeholder
5
+ b.use :label, class: "control-label"
6
+
7
+ b.wrapper tag: "div" do |ba|
8
+ ba.wrapper tag: "div", class: "input-group" do |append|
9
+ append.use :input
10
+ end
11
+ ba.use :error, wrap_with: { tag: "span", class: "help-block" }
12
+ ba.use :hint, wrap_with: { tag: "p", class: "help-block" }
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,6 @@
1
+ require "simple_form_bootstrap_datepicker/version"
2
+
3
+ module SimpleFormBootstrapDatepicker
4
+ class Engine < ::Rails::Engine
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module SimpleFormBootstrapDatepicker
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "simple_form_bootstrap_datepicker/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "simple_form_bootstrap_datepicker"
8
+ spec.version = SimpleFormBootstrapDatepicker::VERSION
9
+ spec.authors = ["arianamador"]
10
+ spec.email = ["arian@arianamador.com"]
11
+ spec.summary = "Adds a bootstrap date picker simple form input with wrapper."
12
+ spec.description = "Adds a bootstrap date picker simple form input with wrapper. Creates an input group with a calendar icon with support for Bootstrap, FontAwesome, and Foundation glyph libraries."
13
+ spec.homepage = "https://github.com/arian-amador/simple_form_bootstrap_datepicker"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simple_form_bootstrap_datepicker
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - arianamador
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Adds a bootstrap date picker simple form input with wrapper. Creates
42
+ an input group with a calendar icon with support for Bootstrap, FontAwesome, and
43
+ Foundation glyph libraries.
44
+ email:
45
+ - arian@arianamador.com
46
+ executables: []
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - ".gitignore"
51
+ - ".rubocop.yml"
52
+ - Gemfile
53
+ - LICENSE.txt
54
+ - README.md
55
+ - Rakefile
56
+ - lib/rails/generators/simple_form_bootstrap_datepicker/install/install_generator.rb
57
+ - lib/rails/generators/simple_form_bootstrap_datepicker/install/templates/app/inputs/date_picker_input.rb
58
+ - lib/rails/generators/simple_form_bootstrap_datepicker/install/templates/config/initializers/simple_form_bootstrap_datepicker.rb
59
+ - lib/simple_form_bootstrap_datepicker.rb
60
+ - lib/simple_form_bootstrap_datepicker/version.rb
61
+ - simple_form_bootstrap_datepicker.gemspec
62
+ homepage: https://github.com/arian-amador/simple_form_bootstrap_datepicker
63
+ licenses:
64
+ - MIT
65
+ metadata: {}
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 2.4.1
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: Adds a bootstrap date picker simple form input with wrapper.
86
+ test_files: []