Skip to content

Commit

Permalink
Clean-up
Browse files Browse the repository at this point in the history
  - cleaned-up the picker.js used for the refactored input templates
  - corrections in README and added the new datepickerInput option
  • Loading branch information
zpaulovics committed Mar 21, 2015
1 parent 5e70495 commit 5070e3a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 32 deletions.
27 changes: 5 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,31 +170,13 @@ Options can be passed from SimpleForm (from version 4.6.10 or later)

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.

Version 4.3.5+:
Version 4.7.15+:

```javascript
var default_picker_options = {
// put here your default options that should be applied for all pickers

// icons will be inserted if you run the generator with Font-Awesome parameter
icons: {
date: 'fa fa-calendar',
time: 'fa fa-clock-o',
up: 'fa fa-chevron-up',
down: 'fa fa-chevron-down',
previous: 'fa fa-chevron-left',
next: 'fa fa-chevron-right',
today: 'fa fa-crosshairs',
clear: 'fa fa-trash-o'
}
}

$(document).on('ready page:change', function() {
$('.datetimepicker').datetimepicker(default_picker_options);

$('.timepicker').datetimepicker(default_picker_options);

$('.datepicker').datetimepicker(default_picker_options);
$('.datetimepicker').datetimepicker({
// put here your custom picker options, that should be applied for all pickers
});

$('.datetimerange').each(function(){
var $this = $(this)
Expand Down Expand Up @@ -269,6 +251,7 @@ The default values of the options:
keepOpen: false,
inline: false,
keepInvalid: false,
datepickerInput: '.datepickerinput'
```
For more details, please refer to Bootstrap 3 Datepicker v4 Docs site:
- [for public API documentation](http://eonasdan.github.io/bootstrap-datetimepicker/#bootstrap-3-datepicker-v4-docs)
Expand Down
13 changes: 4 additions & 9 deletions lib/generators/datetimepicker_rails/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,11 @@ def create_pickers_js
icons = icon_family == 'Glyphicon' ? '' : get_icons

vendor 'assets/javascripts/pickers.js' do <<-FILE
var default_picker_options = {
#{icons}
}
$(document).on('ready page:change', function() {
$('.datetimepicker').datetimepicker(default_picker_options);
$('.timepicker').datetimepicker(default_picker_options);
$('.datepicker').datetimepicker(default_picker_options);
$('.datetimepicker').datetimepicker({
// put here your custom picker options, that should be applied for all pickers
#{icons}
});
$('.datetimerange').each(function(){
var $this = $(this)
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/templates/inputs/date_picker_input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ def input(wrapper_options)
set_html_options
set_value_html_option

template.content_tag :div, class: 'input-group date datepicker' do
template.content_tag :div, class: 'input-group date datetimepicker' do
input = super(wrapper_options) # leave StringInput do the real rendering
input + input_button
end
Expand Down

0 comments on commit 5070e3a

Please sign in to comment.