Skip to content

Commit 5e70495

Browse files
committed
Merge branch 'eonasdan' version 4.7.15
2 parents 8f3ce7d + ba90e7b commit 5e70495

File tree

8 files changed

+102
-83
lines changed

8 files changed

+102
-83
lines changed

README.md

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ This gem packages the bootstrap-datetimepicker for Rails asset pipeline and crea
1414
- You can customise the picker's iconset to use the Font-Awesome icons (dafault: Glyphicon)
1515
- Easy to install and use in your projects
1616

17-
### The current 4.3.5 version compatibility
17+
### The current 4.7.15 version compatibility
1818
- Ruby 2.2.0
1919
- Rails 4.2
2020
- Simpleform 3.1
2121
- Momentjs-rails 2.9
22-
- http://eonasdan.github.io/bootstrap-datetimepicker version 4.3.5
22+
- http://eonasdan.github.io/bootstrap-datetimepicker version 4.7.15
2323

2424

2525
### Branches
@@ -31,7 +31,11 @@ Tag v1.0.0: Rails 3.2, Bootstrap 2.3.2 & SimpleForm >= 2.0.4 - It is archived. N
3131

3232
### Dependency
3333

34-
Versions v4.3.5+ has a dependency on the moment.js version 2.9+ javascript library (for details refer to: http://momentjs.com/). Includes the dependency reference in its Gemfile (gem 'momentjs-rails', '~> 2.9', :github => 'derekprior/momentjs-rails').
34+
Versions v4.3.5+ has a dependency on the moment.js version 2.9+ javascript library (for details refer to: http://momentjs.com/). Includes the dependency reference in its Gemfile:
35+
``` bash
36+
gem 'momentjs-rails', '~> 2.9', :github => 'derekprior/momentjs-rails'
37+
```
38+
3539

3640
### Credits and references
3741

@@ -157,6 +161,13 @@ Just call datetimepicker() with any selector.
157161
</div>
158162
```
159163

164+
Options can be passed from SimpleForm (from version 4.6.10 or later)
165+
```html
166+
<%= f.input :date_field, as: :date_picker, :label => 'Date field',
167+
input_html: {data: {date_options: {defaultDate: '2012/12/25'}}} %>
168+
```
169+
170+
160171
The scripts below will be included when you use the "require pickers" (for version v4.0.0+) or "require bootstrap-datetimepicker/pickers" (for version v1.0.0). If you need different activation scripts, ignore the //= require pickers (for version v4.0.0+) or //= require bootstrap-datetimepicker/pickers (for version v1.0.0) line in app/assets/javascripts/application.js.
161172

162173
Version 4.3.5+:
@@ -237,7 +248,8 @@ The default values of the options:
237248
previous: 'glyphicon glyphicon-chevron-left',
238249
next: 'glyphicon glyphicon-chevron-right',
239250
today: 'glyphicon glyphicon-screenshot',
240-
clear: 'glyphicon glyphicon-trash'
251+
clear: 'glyphicon glyphicon-trash',
252+
close: 'glyphicon glyphicon-remove'
241253
},
242254
useStrict: false,
243255
sideBySide: false,
@@ -247,13 +259,16 @@ The default values of the options:
247259
toolbarPlacement: 'default',
248260
showTodayButton: false,
249261
showClear: false,
262+
showClose: false,
250263
widgetPositioning: {
251264
horizontal: 'auto',
252265
vertical: 'auto'
253266
},
254-
disallowReadOnly: true,
267+
widgetParent: null,
268+
ignoreReadonly: false,
255269
keepOpen: false,
256-
inline: false
270+
inline: false,
271+
keepInvalid: false,
257272
```
258273
For more details, please refer to Bootstrap 3 Datepicker v4 Docs site:
259274
- [for public API documentation](http://eonasdan.github.io/bootstrap-datetimepicker/#bootstrap-3-datepicker-v4-docs)
@@ -322,7 +337,7 @@ This should be applied for any version.
322337

323338
### For more details of usage
324339

325-
[You can find a demo application using the datetimeoicker-rails gem here] (https://github.com/zpaulovics/dateTimeDemo)
340+
[You can find a demo application using the datetimepicker-rails gem here] (https://github.com/zpaulovics/dateTimeDemo)
326341

327342

328343
See the documentation & excellent demos provided by plugin's authors:
@@ -338,4 +353,4 @@ See the documentation & excellent demos provided by plugin's authors:
338353
2. Create your feature branch (`git checkout -b my-new-feature`)
339354
3. Commit your changes (`git commit -am 'Add some feature'`)
340355
4. Push to the branch (`git push origin my-new-feature`)
341-
5. Create new Pull Request
356+
5. Create new Pull Request (PR request need to be submitted to the development branch)

bootstrap-datetimepicker

Submodule bootstrap-datetimepicker updated from d072d92 to 6b255a9

datetimepicker-rails.gemspec

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,8 @@ Gem::Specification.new do |gem|
1616
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
1717
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
1818
gem.require_paths = ["lib"]
19+
20+
gem.add_development_dependency 'bundler', '~> 1.3'
21+
gem.add_development_dependency 'rake'
22+
gem.add_runtime_dependency 'momentjs-rails', '>= 2.9.0'
1923
end

lib/datetimepicker-rails/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Datetimepicker
22
module Rails
3-
VERSION = "4.3.5"
3+
VERSION = "4.7.15"
44
end
55
end

lib/generators/datetimepicker_rails/install_generator.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ class InstallGenerator < Rails::Generators::Base
1515
previous: 'fa fa-chevron-left',
1616
next: 'fa fa-chevron-right',
1717
today: 'fa fa-crosshairs',
18-
clear: 'fa fa-trash-o'
18+
clear: 'fa fa-trash-o',
19+
close: 'fa fa-times'
1920
}
2021

2122
def source_path
@@ -140,7 +141,8 @@ def get_icons
140141
icons += " previous: \'#{options[:custom_icons][:previous]}\',\n"
141142
icons += " next: \'#{options[:custom_icons][:next]}\',\n"
142143
icons += " today: \'#{options[:custom_icons][:today]}\',\n"
143-
icons += " clear: \'#{options[:custom_icons][:clear]}\'\n"
144+
icons += " clear: \'#{options[:custom_icons][:clear]}\',\n"
145+
icons += " close: \'#{options[:custom_icons][:close]}\'\n"
144146
icons += " }\n"
145147
end
146148

Lines changed: 52 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,64 @@
11
class DatePickerInput < SimpleForm::Inputs::StringInput
22
def input(wrapper_options)
3-
value = object.send(attribute_name) if object.respond_to? attribute_name
4-
display_pattern = I18n.t('datepicker.dformat', :default => '%d/%m/%Y')
5-
input_html_options[:value] ||= I18n.localize(value, :format => display_pattern) if value.present?
6-
7-
input_html_options[:type] = 'text'
8-
picker_pattern = I18n.t('datepicker.pformat', :default => 'DD/MM/YYYY')
9-
dayViewHeaderFormat = I18n.t('dayViewHeaderFormat', :default => 'MMMM YYYY')
10-
date_options = {
11-
locale: I18n.locale.to_s,
12-
dayViewHeaderFormat: dayViewHeaderFormat,
13-
format: picker_pattern
14-
}
15-
input_html_options[:data] ||= {}
16-
input_html_options[:data].merge!({date_options: date_options })
3+
set_html_options
4+
set_value_html_option
175

186
template.content_tag :div, class: 'input-group date datepicker' do
197
input = super(wrapper_options) # leave StringInput do the real rendering
20-
input += template.content_tag :span, class: 'input-group-btn' do
21-
template.content_tag :button, class: 'btn btn-default', type: 'button' do
22-
template.content_tag :span, '', class: 'glyphicon glyphicon-calendar'
23-
end
24-
end
25-
input
8+
input + input_button
269
end
2710
end
2811

2912
def input_html_classes
3013
super.push '' # 'form-control'
3114
end
15+
16+
private
17+
18+
def input_button
19+
template.content_tag :span, class: 'input-group-btn' do
20+
template.content_tag :button, class: 'btn btn-default', type: 'button' do
21+
template.content_tag :span, '', class: 'glyphicon glyphicon-calendar'
22+
end
23+
end
24+
end
25+
26+
def set_html_options
27+
input_html_options[:type] = 'text'
28+
input_html_options[:data] ||= {}
29+
input_html_options[:data].merge!(date_options: date_options)
30+
end
31+
32+
def set_value_html_option
33+
return unless value.present?
34+
input_html_options[:value] ||= I18n.localize(value, format: display_pattern)
35+
end
36+
37+
def value
38+
object.send(attribute_name) if object.respond_to? attribute_name
39+
end
40+
41+
def display_pattern
42+
I18n.t('datepicker.dformat', default: '%d/%m/%Y')
43+
end
44+
45+
def picker_pattern
46+
I18n.t('datepicker.pformat', default: 'DD/MM/YYYY')
47+
end
48+
49+
def date_view_header_format
50+
I18n.t('dayViewHeaderFormat', default: 'MMMM YYYY')
51+
end
52+
53+
def date_options_base
54+
{
55+
locale: I18n.locale.to_s,
56+
format: picker_pattern
57+
}
58+
end
59+
60+
def date_options
61+
date_options_base.merge!({dayViewHeaderFormat: date_view_header_format})
62+
end
63+
3264
end
Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,13 @@
1-
class DatetimePickerInput < SimpleForm::Inputs::StringInput
2-
def input(wrapper_options)
3-
value = object.send(attribute_name) if object.respond_to? attribute_name
4-
display_pattern = I18n.t('datepicker.dformat', :default => '%d/%m/%Y') + ' ' + I18n.t('timepicker.dformat', :default => '%R')
5-
input_html_options[:value] ||= I18n.localize(value, :format => display_pattern) if value.present?
1+
class DatetimePickerInput < DatePickerInput
2+
private
63

7-
input_html_options[:type] = 'text'
8-
picker_pattern = I18n.t('datepicker.pformat', :default => 'DD/MM/YYYY') + ' ' + I18n.t('timepicker.pformat', :default => 'HH:mm')
9-
dayViewHeaderFormat = I18n.t('dayViewHeaderFormat', :default => 'MMMM YYYY')
10-
date_options = {
11-
locale: I18n.locale.to_s,
12-
dayViewHeaderFormat: dayViewHeaderFormat,
13-
format: picker_pattern
14-
}
15-
input_html_options[:data] ||= {}
16-
input_html_options[:data].merge!({date_options: date_options })
17-
18-
template.content_tag :div, class: 'input-group date datetimepicker' do
19-
input = super(wrapper_options) # leave StringInput do the real rendering
20-
input += template.content_tag :span, class: 'input-group-btn' do
21-
template.content_tag :button, class: 'btn btn-default', type: 'button' do
22-
template.content_tag :span, '', class: 'glyphicon glyphicon-calendar'
23-
end
24-
end
25-
input
26-
end
4+
def display_pattern
5+
I18n.t('datepicker.dformat', default: '%d/%m/%Y') + ' ' +
6+
I18n.t('timepicker.dformat', default: '%R')
277
end
288

29-
def input_html_classes
30-
super.push '' # 'form-control'
9+
def picker_pattern
10+
I18n.t('datepicker.pformat', default: 'DD/MM/YYYY') + ' ' +
11+
I18n.t('timepicker.pformat', default: 'HH:mm')
3112
end
3213
end
Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,15 @@
1-
class TimePickerInput < SimpleForm::Inputs::StringInput
2-
def input(wrapper_options)
3-
value = object.send(attribute_name) if object.respond_to? attribute_name
4-
display_pattern = I18n.t('timepicker.dformat', :default => '%R')
5-
input_html_options[:value] ||= I18n.localize(value, :format => display_pattern) if value.present?
1+
class TimePickerInput < DatePickerInput
2+
private
63

7-
input_html_options[:type] = 'text'
8-
picker_pattern = I18n.t('timepicker.pformat', :default => 'HH:mm')
9-
date_options = {
10-
locale: I18n.locale.to_s,
11-
format: picker_pattern
12-
}
13-
input_html_options[:data] ||= {}
14-
input_html_options[:data].merge!({date_options: date_options })
4+
def display_pattern
5+
I18n.t('timepicker.dformat', default: '%R')
6+
end
157

16-
template.content_tag :div, class: 'input-group date timepicker' do
17-
input = super(wrapper_options) # leave StringInput do the real rendering
18-
input += template.content_tag :span, class: 'input-group-btn' do
19-
template.content_tag :button, class: 'btn btn-default', type: 'button' do
20-
template.content_tag :span, '', class: 'glyphicon glyphicon-time'
21-
end
22-
end
23-
input
24-
end
8+
def picker_pattern
9+
I18n.t('timepicker.pformat', default: 'HH:mm')
2510
end
2611

27-
def input_html_classes
28-
super.push '' # 'form-control'
12+
def date_options
13+
date_options_base
2914
end
3015
end

0 commit comments

Comments
 (0)