simple_form-bootstrap 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d6ea0957545a4c17950bdf09f9237b1b9d65aa21
4
- data.tar.gz: db3a33a12b1795eabd4815608cb34fab6a8e6ed5
3
+ metadata.gz: 26489ef93ca2d29986f6fc2d779623da2c704f43
4
+ data.tar.gz: a454186a41d7d02312d8112171226a86eae7ce2d
5
5
  SHA512:
6
- metadata.gz: d4cecfc6d0e988e6887a37f92bf69ded8cd6684745037394b26c684b7496c06c933e9403d953a3e46325f326fa7d860b68a90bbbed5328d7b04cb2b6b74c17c1
7
- data.tar.gz: db340e776a16319c2a82c7fd824b9daf20fd3c98d13ac4189cb24fe8d711f33df0acbef15bcdab878c3a98601de3b37aa1ff9117a526574f57aab27af4bf9c42
6
+ metadata.gz: 07fa325718226174d0578ee1a50e63303ef02496a428c848a6eade551e3f10e3692af548120d27ff0157778d5ac09c7513dc81d229f98fc1d1f91e693eb22634
7
+ data.tar.gz: da29bb5246335fa3a0133618bf87932e7c1db353ff949393b07d3a77eb8b2fcc92bd3bf8c0a36d2309e69677a62e436c42f85292bc56a33947cf011557f296e0
@@ -0,0 +1,34 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /lib/bundler/man/
26
+
27
+ # for a library or gem, you might want to ignore these files since the code is
28
+ # intended to run in multiple environments; otherwise, check them in:
29
+ # Gemfile.lock
30
+ # .ruby-version
31
+ # .ruby-gemset
32
+
33
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
34
+ .rvmrc
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1,17 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.0.0
5
+ - 2.1.6
6
+ - 2.2.2
7
+ - ruby-head
8
+ matrix:
9
+ allow_failures:
10
+ - rvm: ruby-head
11
+ bundler_args: "--jobs=3 --retry=3"
12
+
13
+ before_install:
14
+ - bundle config build.nokogiri --use-system-libraries
15
+
16
+ script:
17
+ - bundle exec rake spec
@@ -0,0 +1,34 @@
1
+ ## master
2
+
3
+ ### enhancements
4
+
5
+ ### bug fixes
6
+
7
+ ## 1.2.0
8
+
9
+ ### enhancements
10
+ * It allows `submit` buttons to accept blocks. When a block is specified, the submit button will
11
+ use a \<button> tag instead of an \<input> tag. [@lowjoel](https://github.com/lowjoel)
12
+
13
+ ### bug fixes
14
+
15
+ ## 1.1.2
16
+
17
+ ### bug fixes
18
+ * The proper ID for date/time pickers should be generated for non-JavaScript aware browsers first;
19
+ Browsers with JavaScript would reassign the label to the hidden date/time picker. This fixes
20
+ tests written using Capybara, without JavaScript support.
21
+ * Specifying the button size (e.g. `btn-lg`) should still generate the appropriate button class
22
+ (`btn-default` or `btn-primary`). [@lowjoel](https://github.com/lowjoel)
23
+
24
+ ## 1.1.1
25
+
26
+ Never released.
27
+
28
+ ## 1.1.0
29
+
30
+ ### enhancements
31
+ * There is no longer a need to retain a Simple Form initialiser, as well as a Simple
32
+ Form-Bootstrap initialiser. Just call `SimpleForm::setup` and the Bootstrap defaults would be
33
+ automatically applied. [@lowjoel](https://github.com/lowjoel)
34
+ * Started writing specs and running them on Travis!
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Joel Low
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,36 @@
1
+ simple_form-bootstrap
2
+ ===
3
+ [![Build Status](https://travis-ci.org/lowjoel/simple_form-bootstrap.svg?branch=master)](https://travis-ci.org/lowjoel/simple_form-bootstrap) [![Coverage Status](https://coveralls.io/repos/lowjoel/simple_form-bootstrap/badge.svg)](https://coveralls.io/r/lowjoel/simple_form-bootstrap) [![Code Climate](https://codeclimate.com/github/lowjoel/simple_form-bootstrap/badges/gpa.svg)](https://codeclimate.com/github/lowjoel/simple_form-bootstrap)
4
+
5
+ Integrating Bootstrap-looking form controls with Simple Form.
6
+
7
+ ## Installation
8
+
9
+ 1. Add to your application's Gemfile: `gem 'simple_form-bootstrap'`. The following types of
10
+ input controls are supported, so long they are properly installed in your application. Ensure
11
+ that the control is included in your `application.js` _before_ the Simple Form-Bootstrap
12
+ JavaScript.
13
+
14
+ 1. If you want to use Date/Time pickers, install the `bootstrap3-datetimepicker-rails` gem.
15
+ 2. If you want to use the nicely styled Bootstrap Select picker, install the
16
+ `bootstrap-select-rails` gem.
17
+
18
+ 2. Add to your application's javascript: `//= require simple_form-bootstrap`
19
+ 3. Empty the Simple Form initializer:
20
+ ```ruby
21
+ # config/initializers/simple_form.rb
22
+ # Use this setup block to configure all options available in SimpleForm.
23
+ SimpleForm.setup do |config|
24
+ end
25
+ ```
26
+
27
+ 1. You can still put configuration settings in, but it should no longer be necessary.
28
+
29
+ 4. Restart your development server.
30
+
31
+ ## Features
32
+
33
+ 1. It adds the appropriate button styling to all buttons. By default, the `btn` and `btn-default`
34
+ styles are added to all buttons. Submit buttons get `btn-primary` instead of `btn-default`.
35
+ 2. It allows `submit` buttons to accept blocks. When a block is specified, the submit button will
36
+ use a \<button> tag instead of an \<input> tag.
data/Rakefile CHANGED
@@ -1,12 +1,12 @@
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 "rspec/core/rake_task"
8
-
9
- RSpec::Core::RakeTask.new
10
-
11
- task :default => :spec
12
- task :test => :spec
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 "rspec/core/rake_task"
8
+
9
+ RSpec::Core::RakeTask.new
10
+
11
+ task :default => :spec
12
+ task :test => :spec
@@ -1,24 +1,24 @@
1
- //= require simple_form-bootstrap/date_time_input
2
-
3
- (function($) {
4
- 'use strict';
5
- function initializeComponents(node) {
6
- // Enable our date/time pickers
7
- var datePickers = $('input.bootstrap-datepicker', node);
8
- datePickers.datetimepicker();
9
-
10
- // Enable our styled Bootstrap select controls, except Twitter Typeahead controls.
11
- var selects = $('select.form-control:not(.typeahead)', node);
12
- selects.selectpicker();
13
- }
14
-
15
- $(document).on('ready', function(e) {
16
- initializeComponents(document);
17
- });
18
- $(document).on('DOMNodeInserted', function(e) {
19
- initializeComponents(e.target);
20
- });
21
- $(document).on('nested:fieldAdded', function(e) {
22
- initializeComponents(e.field);
23
- });
24
- })(jQuery);
1
+ //= require simple_form-bootstrap/date_time_input
2
+
3
+ (function($) {
4
+ 'use strict';
5
+ function initializeComponents(node) {
6
+ // Enable our date/time pickers
7
+ var datePickers = $('input.bootstrap-datepicker', node);
8
+ datePickers.datetimepicker();
9
+
10
+ // Enable our styled Bootstrap select controls, except Twitter Typeahead controls.
11
+ var selects = $('select.form-control:not(.typeahead)', node);
12
+ selects.selectpicker();
13
+ }
14
+
15
+ $(document).on('ready', function(e) {
16
+ initializeComponents(document);
17
+ });
18
+ $(document).on('DOMNodeInserted', function(e) {
19
+ initializeComponents(e.target);
20
+ });
21
+ $(document).on('nested:fieldAdded', function(e) {
22
+ initializeComponents(e.field);
23
+ });
24
+ })(jQuery);
@@ -1,77 +1,77 @@
1
- // Hijacks the default Bootstrap date-time picker to always format dates in the specified format
2
- // through the use of a hidden field.
3
- (function($) {
4
- 'use strict';
5
- /* global moment */
6
-
7
- // Machine-readable formats used to store dates in hidden fields
8
- var DATE_FORMAT = 'YYYY-MM-DD';
9
- var DATETIME_FORMAT = 'YYYY-MM-DDTHH:mm:ssZZ';
10
- var DATETIME_FORMAT_RAILS = 'YYYY-MM-DD HH:mm:ss ZZ';
11
-
12
- var oldDateTimePicker = $.fn.datetimepicker;
13
- if (!oldDateTimePicker) {
14
- return;
15
- }
16
-
17
- var methods = {
18
- initialise: function(arg) {
19
- // Synchronise the proper display format
20
- this.each(methods.initialiseFormat);
21
-
22
- // Create the controls
23
- arg = arg || {};
24
- oldDateTimePicker.call(
25
- this.filter(':not(input.bootstrap-timepicker)').parent(),
26
- $.extend({}, arg, { pickTime: false }));
27
- oldDateTimePicker.call(
28
- this.filter('input.bootstrap-timepicker').parent(),
29
- arg);
30
-
31
- // Hide the backing date picker and show the actual date picker.
32
- this.attr('type', 'text');
33
- this.parent().css('display', '');
34
- this.parent().next('input[type=text]').attr('type', 'hidden');
35
- this.parent().prev('label').attr('for', this.attr('id'))
36
-
37
- return this;
38
- },
39
-
40
- initialiseFormat: function() {
41
- var $textField = $(this);
42
- var displayFormat = $textField.data('dateFormat');
43
-
44
- // Parse date in field (if provided)
45
- var thisDate = moment($textField.val(), [DATETIME_FORMAT_RAILS, displayFormat]);
46
- if (thisDate.isValid()) {
47
- // Set displayed text field
48
- $textField.val(thisDate.format(displayFormat));
49
-
50
- // Set hidden field
51
- var hiddenFormat = $textField.hasClass('bootstrap-timepicker') ? DATETIME_FORMAT :
52
- DATE_FORMAT;
53
- $textField.parent().next('input').val(thisDate.format(hiddenFormat));
54
- }
55
- }
56
- };
57
-
58
- // Replace the datetimepicker prototypes
59
- $.fn.datetimepicker = function(arg) {
60
- return methods.initialise.call(this, arg);
61
- };
62
- $.fn.datetimepicker.defaults = oldDateTimePicker.defaults;
63
-
64
- // Ensure that the dates are properly formatted in the text field.
65
- $(document).on('dp.change dp.show', '.bootstrap-datepicker:' +
66
- 'not(.bootstrap-timepicker)', function (e) {
67
- var date = e.date;
68
- var rails_date_format = date.format(DATE_FORMAT);
69
- $(this).next('input[type=hidden]').val(rails_date_format);
70
- });
71
-
72
- $(document).on('dp.change dp.show', '.bootstrap-timepicker', function (e) {
73
- var date = e.date;
74
- var rails_date_format = date.format(DATETIME_FORMAT);
75
- $(this).next('input[type=hidden]').val(rails_date_format);
76
- });
77
- }(jQuery));
1
+ // Hijacks the default Bootstrap date-time picker to always format dates in the specified format
2
+ // through the use of a hidden field.
3
+ (function($) {
4
+ 'use strict';
5
+ /* global moment */
6
+
7
+ // Machine-readable formats used to store dates in hidden fields
8
+ var DATE_FORMAT = 'YYYY-MM-DD';
9
+ var DATETIME_FORMAT = 'YYYY-MM-DDTHH:mm:ssZZ';
10
+ var DATETIME_FORMAT_RAILS = 'YYYY-MM-DD HH:mm:ss ZZ';
11
+
12
+ var oldDateTimePicker = $.fn.datetimepicker;
13
+ if (!oldDateTimePicker) {
14
+ return;
15
+ }
16
+
17
+ var methods = {
18
+ initialise: function(arg) {
19
+ // Synchronise the proper display format
20
+ this.each(methods.initialiseFormat);
21
+
22
+ // Create the controls
23
+ arg = arg || {};
24
+ oldDateTimePicker.call(
25
+ this.filter(':not(input.bootstrap-timepicker)').parent(),
26
+ $.extend({}, arg, { pickTime: false }));
27
+ oldDateTimePicker.call(
28
+ this.filter('input.bootstrap-timepicker').parent(),
29
+ arg);
30
+
31
+ // Hide the backing date picker and show the actual date picker.
32
+ this.attr('type', 'text');
33
+ this.parent().css('display', '');
34
+ this.parent().next('input[type=text]').attr('type', 'hidden');
35
+ this.parent().prev('label').attr('for', this.attr('id'))
36
+
37
+ return this;
38
+ },
39
+
40
+ initialiseFormat: function() {
41
+ var $textField = $(this);
42
+ var displayFormat = $textField.data('dateFormat');
43
+
44
+ // Parse date in field (if provided)
45
+ var thisDate = moment($textField.val(), [DATETIME_FORMAT_RAILS, displayFormat]);
46
+ if (thisDate.isValid()) {
47
+ // Set displayed text field
48
+ $textField.val(thisDate.format(displayFormat));
49
+
50
+ // Set hidden field
51
+ var hiddenFormat = $textField.hasClass('bootstrap-timepicker') ? DATETIME_FORMAT :
52
+ DATE_FORMAT;
53
+ $textField.parent().next('input').val(thisDate.format(hiddenFormat));
54
+ }
55
+ }
56
+ };
57
+
58
+ // Replace the datetimepicker prototypes
59
+ $.fn.datetimepicker = function(arg) {
60
+ return methods.initialise.call(this, arg);
61
+ };
62
+ $.fn.datetimepicker.defaults = oldDateTimePicker.defaults;
63
+
64
+ // Ensure that the dates are properly formatted in the text field.
65
+ $(document).on('dp.change dp.show', '.bootstrap-datepicker:' +
66
+ 'not(.bootstrap-timepicker)', function (e) {
67
+ var date = e.date;
68
+ var rails_date_format = date.format(DATE_FORMAT);
69
+ $(this).next('input[type=hidden]').val(rails_date_format);
70
+ });
71
+
72
+ $(document).on('dp.change dp.show', '.bootstrap-timepicker', function (e) {
73
+ var date = e.date;
74
+ var rails_date_format = date.format(DATETIME_FORMAT);
75
+ $(this).next('input[type=hidden]').val(rails_date_format);
76
+ });
77
+ }(jQuery));
@@ -1,12 +1,12 @@
1
- // Hijacks the default Bootstrap date-time picker to always format dates in the specified format
2
- // through the use of a hidden field.
3
- (function($) {
4
- 'use strict';
5
- if ($.fn.selectpicker) {
6
- return;
7
- }
8
-
9
- $.fn.selectpicker = function(arg) {
10
- return methods.initialise.call(this, arg);
11
- };
12
- }(jQuery));
1
+ // Hijacks the default Bootstrap date-time picker to always format dates in the specified format
2
+ // through the use of a hidden field.
3
+ (function($) {
4
+ 'use strict';
5
+ if ($.fn.selectpicker) {
6
+ return;
7
+ }
8
+
9
+ $.fn.selectpicker = function(arg) {
10
+ return methods.initialise.call(this, arg);
11
+ };
12
+ }(jQuery));
@@ -1,26 +1,26 @@
1
- module SimpleForm::Bootstrap
2
- extend ActiveSupport::Autoload
3
-
4
- autoload :Setup
5
- autoload :FormBuilders
6
-
7
- eager_autoload do
8
- autoload :Inputs
9
- end
10
-
11
- # Because we are augmenting Simple Form with our input fields, we need to load even when eager
12
- # loading is not enabled
13
- SimpleForm::Bootstrap::FormBuilders.load!
14
- end
15
-
16
- module SimpleForm
17
- class << self
18
- # Extend the normal Simple Form configuration options with ours.
19
- prepend SimpleForm::Bootstrap::Setup
20
- end
21
- end
22
-
23
- if defined?(Rails)
24
- require 'simple_form/bootstrap/railtie'
25
- require 'simple_form/bootstrap/engine'
26
- end
1
+ module SimpleForm::Bootstrap
2
+ extend ActiveSupport::Autoload
3
+
4
+ autoload :Setup
5
+ autoload :FormBuilders
6
+
7
+ eager_autoload do
8
+ autoload :Inputs
9
+ end
10
+
11
+ # Because we are augmenting Simple Form with our input fields, we need to load even when eager
12
+ # loading is not enabled
13
+ SimpleForm::Bootstrap::FormBuilders.load!
14
+ end
15
+
16
+ module SimpleForm
17
+ class << self
18
+ # Extend the normal Simple Form configuration options with ours.
19
+ prepend SimpleForm::Bootstrap::Setup
20
+ end
21
+ end
22
+
23
+ if defined?(Rails)
24
+ require 'simple_form/bootstrap/railtie'
25
+ require 'simple_form/bootstrap/engine'
26
+ end