bootstrap_form_extensions 1.2.1 → 4.0.0
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.
- checksums.yaml +5 -5
- data/app/assets/javascripts/bootstrap_form_extensions/index.js +0 -1
- data/app/assets/javascripts/bootstrap_form_extensions/select_or_new.js +1 -1
- data/app/assets/stylesheets/bootstrap_form_extensions/index.css +0 -1
- data/app/assets/stylesheets/bootstrap_form_extensions/select_or_new.css +5 -2
- data/app/views/bootstrap_form_extensions/_submit_bar.html.erb +18 -13
- data/lib/bootstrap_form_extensions.rb +0 -3
- data/lib/bootstrap_form_extensions/arrayed_field.rb +8 -8
- data/lib/bootstrap_form_extensions/helpers.rb +0 -7
- data/lib/bootstrap_form_extensions/select_or_new.rb +3 -2
- data/lib/bootstrap_form_extensions/version.rb +1 -1
- data/test/arrayed_field_test.rb +9 -9
- data/test/dummy/app/models/thing.rb +0 -2
- data/test/dummy/config/application.rb +0 -3
- data/test/dummy/db/migrate/20150918185031_create_things.rb +1 -1
- data/test/dummy/db/migrate/20150924203053_add_timespan.rb +1 -1
- data/test/dummy/db/migrate/20150929213249_add_arrayed_field.rb +1 -1
- data/test/dummy/db/migrate/20151006171627_add_another_arrayed_field.rb +1 -1
- data/test/dummy/db/migrate/20151006181943_add_json_field.rb +1 -1
- data/test/dummy/db/migrate/20151007213131_add_scheduler_field.rb +1 -1
- data/test/dummy/db/migrate/20151106165522_add_category.rb +1 -1
- data/test/dummy/db/migrate/20151119160842_add_duration.rb +1 -1
- data/test/dummy/db/schema.rb +9 -10
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +4161 -843
- data/test/duration_test.rb +1 -1
- data/test/javascripts/arrayed_field_spec.js +15 -15
- data/test/javascripts/scheduler_spec.js +2 -2
- data/test/javascripts/select_or_new_spec.js +7 -7
- data/test/scheduler_test.rb +1 -1
- data/test/select_or_new_test.rb +4 -4
- data/test/submit_bar_test.rb +19 -14
- data/test/test_helper.rb +1 -1
- metadata +50 -77
- data/app/assets/javascripts/bootstrap_form_extensions/bootstrap-timepicker.min.js +0 -5
- data/app/assets/javascripts/bootstrap_form_extensions/time_picker.js +0 -61
- data/app/assets/stylesheets/bootstrap_form_extensions/bootstrap-timepicker.min.css +0 -10
- data/app/assets/stylesheets/bootstrap_form_extensions/common.css +0 -11
- data/app/assets/stylesheets/bootstrap_form_extensions/submit_bar.css +0 -4
- data/lib/bootstrap_form_extensions/date_time_pickers.rb +0 -83
- data/test/date_time_pickers_test.rb +0 -50
- data/test/dummy/db/migrate/20151030194330_add_date_time.rb +0 -7
- data/test/javascripts/time_picker_spec.js +0 -42
@@ -1,61 +0,0 @@
|
|
1
|
-
+function ($) {
|
2
|
-
'use strict';
|
3
|
-
|
4
|
-
|
5
|
-
// TIME PICKER CLASS DEFINITION
|
6
|
-
// ============================
|
7
|
-
|
8
|
-
var TimePicker = function (element, options) {
|
9
|
-
var defaults = {
|
10
|
-
minuteStep: 1,
|
11
|
-
showSeconds: true,
|
12
|
-
secondStep: 1,
|
13
|
-
showMeridian: false,
|
14
|
-
defaultTime: false
|
15
|
-
}
|
16
|
-
$(element).timepicker($.extend(defaults, options))
|
17
|
-
}
|
18
|
-
|
19
|
-
TimePicker.VERSION = '1.2.1'
|
20
|
-
|
21
|
-
|
22
|
-
// TIME PICKER PLUGIN DEFINITION
|
23
|
-
// =============================
|
24
|
-
|
25
|
-
function Plugin(options) {
|
26
|
-
return $(this).each(function () {
|
27
|
-
var $this = $(this)
|
28
|
-
var data = $this.data('bsfe.timepicker')
|
29
|
-
|
30
|
-
if (!data) $this.data('bsfe.timepicker', (data = new TimePicker(this, options)))
|
31
|
-
})
|
32
|
-
}
|
33
|
-
|
34
|
-
var old = $.fn.timePicker
|
35
|
-
|
36
|
-
$.fn.timePicker = Plugin
|
37
|
-
$.fn.timePicker.Constructor = TimePicker
|
38
|
-
|
39
|
-
|
40
|
-
// TIME PICKER NO CONFLICT
|
41
|
-
// =======================
|
42
|
-
|
43
|
-
$.fn.timePicker.noConflict = function () {
|
44
|
-
$.fn.timePicker = old
|
45
|
-
return this
|
46
|
-
}
|
47
|
-
|
48
|
-
|
49
|
-
// TIME PICKER DATA-API
|
50
|
-
// ====================
|
51
|
-
|
52
|
-
$(window).on('load page:load turbolinks:load page:restore', function () {
|
53
|
-
$('[data-provide="timepicker"]').each(function () {
|
54
|
-
var $picker = $(this)
|
55
|
-
var options = $picker.html5data('time')
|
56
|
-
|
57
|
-
Plugin.call($picker, options)
|
58
|
-
})
|
59
|
-
})
|
60
|
-
|
61
|
-
}(jQuery);
|
@@ -1,10 +0,0 @@
|
|
1
|
-
/*!
|
2
|
-
* Timepicker Component for Twitter Bootstrap
|
3
|
-
*
|
4
|
-
* Copyright 2013 Joris de Wit
|
5
|
-
*
|
6
|
-
* Contributors https://github.com/jdewit/bootstrap-timepicker/graphs/contributors
|
7
|
-
*
|
8
|
-
* For the full copyright and license information, please view the LICENSE
|
9
|
-
* file that was distributed with this source code.
|
10
|
-
*/.bootstrap-timepicker{position:relative}.bootstrap-timepicker.pull-right .bootstrap-timepicker-widget.dropdown-menu{left:auto;right:0}.bootstrap-timepicker.pull-right .bootstrap-timepicker-widget.dropdown-menu:before{left:auto;right:12px}.bootstrap-timepicker.pull-right .bootstrap-timepicker-widget.dropdown-menu:after{left:auto;right:13px}.bootstrap-timepicker .input-group-addon{cursor:pointer}.bootstrap-timepicker .input-group-addon i{display:inline-block;width:16px;height:16px}.bootstrap-timepicker-widget.dropdown-menu{padding:4px}.bootstrap-timepicker-widget.dropdown-menu.open{display:inline-block}.bootstrap-timepicker-widget.dropdown-menu:before{border-bottom:7px solid rgba(0,0,0,0.2);border-left:7px solid transparent;border-right:7px solid transparent;content:"";display:inline-block;position:absolute}.bootstrap-timepicker-widget.dropdown-menu:after{border-bottom:6px solid #fff;border-left:6px solid transparent;border-right:6px solid transparent;content:"";display:inline-block;position:absolute}.bootstrap-timepicker-widget.timepicker-orient-left:before{left:6px}.bootstrap-timepicker-widget.timepicker-orient-left:after{left:7px}.bootstrap-timepicker-widget.timepicker-orient-right:before{right:6px}.bootstrap-timepicker-widget.timepicker-orient-right:after{right:7px}.bootstrap-timepicker-widget.timepicker-orient-top:before{top:-7px}.bootstrap-timepicker-widget.timepicker-orient-top:after{top:-6px}.bootstrap-timepicker-widget.timepicker-orient-bottom:before{bottom:-7px;border-bottom:0;border-top:7px solid #999}.bootstrap-timepicker-widget.timepicker-orient-bottom:after{bottom:-6px;border-bottom:0;border-top:6px solid #fff}.bootstrap-timepicker-widget a.btn,.bootstrap-timepicker-widget input{border-radius:4px}.bootstrap-timepicker-widget table{width:100%;margin:0}.bootstrap-timepicker-widget table td{text-align:center;height:30px;margin:0;padding:2px}.bootstrap-timepicker-widget table td:not(.separator){min-width:30px}.bootstrap-timepicker-widget table td span{width:100%}.bootstrap-timepicker-widget table td a{border:1px transparent solid;width:100%;display:inline-block;margin:0;padding:8px 0;outline:0;color:#333}.bootstrap-timepicker-widget table td a:hover{text-decoration:none;background-color:#eee;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;border-color:#ddd}.bootstrap-timepicker-widget table td a i{margin-top:2px;font-size:18px}.bootstrap-timepicker-widget table td input{width:25px;margin:0;text-align:center}.bootstrap-timepicker-widget .modal-content{padding:4px}@media(min-width:767px){.bootstrap-timepicker-widget.modal{width:200px;margin-left:-100px}}@media(max-width:767px){.bootstrap-timepicker{width:100%}.bootstrap-timepicker .dropdown-menu{width:100%}}
|
@@ -1,11 +0,0 @@
|
|
1
|
-
// Vertical space
|
2
|
-
.voffset { margin-top: 2px; }
|
3
|
-
.voffset1 { margin-top: 5px; }
|
4
|
-
.voffset2 { margin-top: 10px; }
|
5
|
-
.voffset3 { margin-top: 15px; }
|
6
|
-
.voffset4 { margin-top: 30px; }
|
7
|
-
.voffset5 { margin-top: 40px; }
|
8
|
-
.voffset6 { margin-top: 60px; }
|
9
|
-
.voffset7 { margin-top: 80px; }
|
10
|
-
.voffset8 { margin-top: 100px; }
|
11
|
-
.voffset9 { margin-top: 150px; }
|
@@ -1,83 +0,0 @@
|
|
1
|
-
module BootstrapFormExtensions
|
2
|
-
|
3
|
-
module DateTimePickers
|
4
|
-
|
5
|
-
include BootstrapFormExtensions::Helpers
|
6
|
-
|
7
|
-
def date_time_picker attribute, **options
|
8
|
-
name = attribute.to_s.sub /_at$/, ''
|
9
|
-
date_method = options.delete(:date_method) { "#{name}_date".to_sym }
|
10
|
-
time_method = options.delete(:time_method) { "#{name}_time".to_sym }
|
11
|
-
|
12
|
-
date_options = options.delete(:date_options) { {} }
|
13
|
-
time_options = options.delete(:time_options) { {} }
|
14
|
-
date_options[:class] = merge_css_classes 'form-control', date_options[:class]
|
15
|
-
time_options[:class] = merge_css_classes 'form-control', time_options[:class]
|
16
|
-
|
17
|
-
# TODO: Replace for these commented out lines, once this pull request is merged: https://github.com/bootstrap-ruby/rails-bootstrap-forms/pull/238
|
18
|
-
# options[:wrapper] ||= {}
|
19
|
-
# options[:wrapper].merge! inline: true
|
20
|
-
options[:control_col] = control_col_for_date_time_pickers options
|
21
|
-
|
22
|
-
date_picker_html = content_tag :div, date_picker_builder(date_method, date_options), class: 'form-group'
|
23
|
-
time_picker_html = content_tag :div, time_picker_builder(time_method, time_options), class: 'form-group'
|
24
|
-
form_group_builder(attribute, options) { date_picker_html + ' '.html_safe + time_picker_html }
|
25
|
-
end
|
26
|
-
|
27
|
-
def date_picker method, **options
|
28
|
-
# TODO: Replace for these commented out lines, once this pull request is merged: https://github.com/bootstrap-ruby/rails-bootstrap-forms/pull/238
|
29
|
-
# options[:wrapper] ||= {}
|
30
|
-
# options[:wrapper].merge! inline: true
|
31
|
-
options[:control_col] = control_col_for_date_time_pickers options
|
32
|
-
form_group_builder(method, options) { date_picker_builder method, options }
|
33
|
-
end
|
34
|
-
|
35
|
-
def time_picker method, **options
|
36
|
-
# TODO: Replace for these commented out lines, once this pull request is merged: https://github.com/bootstrap-ruby/rails-bootstrap-forms/pull/238
|
37
|
-
# options[:wrapper] ||= {}
|
38
|
-
# options[:wrapper].merge! inline: true
|
39
|
-
options[:control_col] = control_col_for_date_time_pickers options
|
40
|
-
form_group_builder(method, options) { time_picker_builder method, options }
|
41
|
-
end
|
42
|
-
|
43
|
-
private
|
44
|
-
|
45
|
-
def date_picker_builder method, **options
|
46
|
-
widget_options = {
|
47
|
-
provide: 'datepicker',
|
48
|
-
date_today_highlight: true,
|
49
|
-
date_format: 'yyyy-mm-dd',
|
50
|
-
date_today_btn: 'linked',
|
51
|
-
date_autoclose: true,
|
52
|
-
date_disable_touch_keyboard: true,
|
53
|
-
date_enable_on_readonly: false,
|
54
|
-
date_show_on_focus: false
|
55
|
-
}
|
56
|
-
widget = options.delete(:widget) { {} }
|
57
|
-
widget.each { |option, value| widget_options["date_#{option.to_s.underscore}".to_sym] = value }
|
58
|
-
|
59
|
-
text = self.text_field_without_bootstrap method, { size: 10 }.merge(options)
|
60
|
-
icon = content_tag :span, glyphicon_tag('calendar'), class: 'input-group-addon'
|
61
|
-
content_tag :div, text + icon, class: 'input-group date', data: widget_options
|
62
|
-
end
|
63
|
-
|
64
|
-
def time_picker_builder method, **options
|
65
|
-
widget_options = { provide: 'timepicker' }
|
66
|
-
widget = options.delete(:widget) { {} }
|
67
|
-
widget.each { |option, value| widget_options["time_#{option.to_s.underscore}".to_sym] = value }
|
68
|
-
|
69
|
-
options.reverse_merge! size: 8, data: {}
|
70
|
-
options[:data].merge! widget_options
|
71
|
-
|
72
|
-
text = self.text_field_without_bootstrap method, options
|
73
|
-
icon = content_tag :span, glyphicon_tag('time'), class: 'input-group-addon'
|
74
|
-
content_tag :div, text + icon, class: 'input-group bootstrap-timepicker'
|
75
|
-
end
|
76
|
-
|
77
|
-
def control_col_for_date_time_pickers options
|
78
|
-
(options[:control_col] || control_col.clone) + ' form-inline'
|
79
|
-
end
|
80
|
-
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class DateTimePickersTest < ActionView::TestCase
|
4
|
-
include BootstrapFormExtensions::DateTimePickers
|
5
|
-
|
6
|
-
def setup
|
7
|
-
setup_test_fixture
|
8
|
-
end
|
9
|
-
|
10
|
-
test "date_picker" do
|
11
|
-
expected = '<div class="form-group"><label class="control-label col-sm-2" for="thing_start_date">Start date</label><div class="col-sm-10 form-inline"><div class="input-group date" data-provide="datepicker" data-date-today-highlight="true" data-date-format="yyyy-mm-dd" data-date-today-btn="linked" data-date-autoclose="true" data-date-disable-touch-keyboard="true" data-date-enable-on-readonly="false" data-date-show-on-focus="false"><input size="10" class="form-control" type="text" value="1971-10-21" name="thing[start_date]" id="thing_start_date" /><span class="input-group-addon"><i class=" glyphicon glyphicon-calendar"></i></span></div></div></div>'
|
12
|
-
assert_equal expected, @builder.date_picker(:start_date)
|
13
|
-
end
|
14
|
-
|
15
|
-
test "add an option to date_picker" do
|
16
|
-
@output_buffer = @builder.date_picker :start_date, widget: { clear_btn: true }
|
17
|
-
assert_select 'div.date[data-date-clear-btn=true]'
|
18
|
-
end
|
19
|
-
|
20
|
-
test "overwrite one of the default options to date_picker" do
|
21
|
-
@output_buffer = @builder.date_picker :start_date, widget: { format: 'dd-mm-yyyy' }
|
22
|
-
assert_select 'div.date[data-date-format="dd-mm-yyyy"]'
|
23
|
-
end
|
24
|
-
|
25
|
-
test "time_picker" do
|
26
|
-
expected = '<div class="form-group"><label class="control-label col-sm-2" for="thing_start_time">Start time</label><div class="col-sm-10 form-inline"><div class="input-group bootstrap-timepicker"><input class="form-control" size="8" data-provide="timepicker" type="text" value="07:30:00" name="thing[start_time]" id="thing_start_time" /><span class="input-group-addon"><i class=" glyphicon glyphicon-time"></i></span></div></div></div>'
|
27
|
-
assert_equal expected, @builder.time_picker(:start_time)
|
28
|
-
end
|
29
|
-
|
30
|
-
test "add an option to time_picker" do
|
31
|
-
@output_buffer = @builder.time_picker :start_time, widget: { disable_mousewheel: true }
|
32
|
-
assert_select 'input[data-time-disable-mousewheel=true]'
|
33
|
-
end
|
34
|
-
|
35
|
-
test "date_time_picker" do
|
36
|
-
expected = '<div class="form-group"><label class="control-label col-sm-2" for="thing_start_at">Start at</label><div class="col-sm-10 form-inline"><div class="form-group"><div class="input-group date" data-provide="datepicker" data-date-today-highlight="true" data-date-format="yyyy-mm-dd" data-date-today-btn="linked" data-date-autoclose="true" data-date-disable-touch-keyboard="true" data-date-enable-on-readonly="false" data-date-show-on-focus="false"><input size="10" class="form-control" type="text" value="1971-10-21" name="thing[start_date]" id="thing_start_date" /><span class="input-group-addon"><i class=" glyphicon glyphicon-calendar"></i></span></div></div> <div class="form-group"><div class="input-group bootstrap-timepicker"><input class="form-control" size="8" data-provide="timepicker" type="text" value="07:30:00" name="thing[start_time]" id="thing_start_time" /><span class="input-group-addon"><i class=" glyphicon glyphicon-time"></i></span></div></div></div></div>'
|
37
|
-
assert_equal expected, @builder.date_time_picker(:start_at)
|
38
|
-
end
|
39
|
-
|
40
|
-
test "add an option to the date control in the date_time_picker" do
|
41
|
-
@output_buffer = @builder.date_time_picker :start_at, date_options: { widget: { clear_btn: true } }
|
42
|
-
assert_select 'div.date[data-date-clear-btn=true]'
|
43
|
-
end
|
44
|
-
|
45
|
-
test "add an option to the time control in the date_time_picker" do
|
46
|
-
@output_buffer = @builder.date_time_picker :start_at, time_options: { widget: { disable_mousewheel: true } }
|
47
|
-
assert_select 'input[data-time-disable-mousewheel=true]'
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
describe("TimePicker", function() {
|
2
|
-
|
3
|
-
describe("Plugin", function() {
|
4
|
-
|
5
|
-
it("should be defined on jQuery object", function() {
|
6
|
-
expect($(document.body).timePicker).not.toThrow()
|
7
|
-
})
|
8
|
-
|
9
|
-
})
|
10
|
-
|
11
|
-
describe("Run tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode", function() {
|
12
|
-
|
13
|
-
beforeEach(function() {
|
14
|
-
$.fn.bootstrapTimePicker = $.fn.timePicker.noConflict()
|
15
|
-
})
|
16
|
-
|
17
|
-
afterEach(function() {
|
18
|
-
$.fn.timePicker = $.fn.bootstrapTimePicker
|
19
|
-
delete $.fn.bootstrapTimePicker
|
20
|
-
})
|
21
|
-
|
22
|
-
describe("initialization", function() {
|
23
|
-
|
24
|
-
it("should provide no conflict - timePicker was set back to undefined (orig value)", function() {
|
25
|
-
expect($.fn.timePicker).toBeUndefined()
|
26
|
-
})
|
27
|
-
|
28
|
-
it("should return jquery collection containing the element", function() {
|
29
|
-
var $el = $('<div/>')
|
30
|
-
var $timePicker = $el.bootstrapTimePicker()
|
31
|
-
expect($timePicker).toEqual(jasmine.any($))
|
32
|
-
expect($timePicker[0]).toBe($el[0])
|
33
|
-
})
|
34
|
-
|
35
|
-
})
|
36
|
-
|
37
|
-
describe("behaviour", function() {
|
38
|
-
})
|
39
|
-
|
40
|
-
})
|
41
|
-
|
42
|
-
})
|