Skip to content

Commit

Permalink
Merge branch 'eonasdan' version 4.7.15
Browse files Browse the repository at this point in the history
  • Loading branch information
zpaulovics committed Mar 21, 2015
2 parents 8f3ce7d + ba90e7b commit 5e70495
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 83 deletions.
31 changes: 23 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ This gem packages the bootstrap-datetimepicker for Rails asset pipeline and crea
- You can customise the picker's iconset to use the Font-Awesome icons (dafault: Glyphicon)
- Easy to install and use in your projects

### The current 4.3.5 version compatibility
### The current 4.7.15 version compatibility
- Ruby 2.2.0
- Rails 4.2
- Simpleform 3.1
- Momentjs-rails 2.9
- http://eonasdan.github.io/bootstrap-datetimepicker version 4.3.5
- http://eonasdan.github.io/bootstrap-datetimepicker version 4.7.15


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

### Dependency

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').
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:
``` bash
gem 'momentjs-rails', '~> 2.9', :github => 'derekprior/momentjs-rails'
```


### Credits and references

Expand Down Expand Up @@ -157,6 +161,13 @@ Just call datetimepicker() with any selector.
</div>
```

Options can be passed from SimpleForm (from version 4.6.10 or later)
```html
<%= f.input :date_field, as: :date_picker, :label => 'Date field',
input_html: {data: {date_options: {defaultDate: '2012/12/25'}}} %>
```


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+:
Expand Down Expand Up @@ -237,7 +248,8 @@ The default values of the options:
previous: 'glyphicon glyphicon-chevron-left',
next: 'glyphicon glyphicon-chevron-right',
today: 'glyphicon glyphicon-screenshot',
clear: 'glyphicon glyphicon-trash'
clear: 'glyphicon glyphicon-trash',
close: 'glyphicon glyphicon-remove'
},
useStrict: false,
sideBySide: false,
Expand All @@ -247,13 +259,16 @@ The default values of the options:
toolbarPlacement: 'default',
showTodayButton: false,
showClear: false,
showClose: false,
widgetPositioning: {
horizontal: 'auto',
vertical: 'auto'
},
disallowReadOnly: true,
widgetParent: null,
ignoreReadonly: false,
keepOpen: false,
inline: false
inline: false,
keepInvalid: false,
```
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 Expand Up @@ -322,7 +337,7 @@ This should be applied for any version.

### For more details of usage

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


See the documentation & excellent demos provided by plugin's authors:
Expand All @@ -338,4 +353,4 @@ See the documentation & excellent demos provided by plugin's authors:
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
5. Create new Pull Request (PR request need to be submitted to the development branch)
2 changes: 1 addition & 1 deletion bootstrap-datetimepicker
Submodule bootstrap-datetimepicker updated from d072d9 to 6b255a
4 changes: 4 additions & 0 deletions datetimepicker-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@ Gem::Specification.new do |gem|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.require_paths = ["lib"]

gem.add_development_dependency 'bundler', '~> 1.3'
gem.add_development_dependency 'rake'
gem.add_runtime_dependency 'momentjs-rails', '>= 2.9.0'
end
2 changes: 1 addition & 1 deletion lib/datetimepicker-rails/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Datetimepicker
module Rails
VERSION = "4.3.5"
VERSION = "4.7.15"
end
end
6 changes: 4 additions & 2 deletions lib/generators/datetimepicker_rails/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class InstallGenerator < Rails::Generators::Base
previous: 'fa fa-chevron-left',
next: 'fa fa-chevron-right',
today: 'fa fa-crosshairs',
clear: 'fa fa-trash-o'
clear: 'fa fa-trash-o',
close: 'fa fa-times'
}

def source_path
Expand Down Expand Up @@ -140,7 +141,8 @@ def get_icons
icons += " previous: \'#{options[:custom_icons][:previous]}\',\n"
icons += " next: \'#{options[:custom_icons][:next]}\',\n"
icons += " today: \'#{options[:custom_icons][:today]}\',\n"
icons += " clear: \'#{options[:custom_icons][:clear]}\'\n"
icons += " clear: \'#{options[:custom_icons][:clear]}\',\n"
icons += " close: \'#{options[:custom_icons][:close]}\'\n"
icons += " }\n"
end

Expand Down
72 changes: 52 additions & 20 deletions lib/generators/templates/inputs/date_picker_input.rb
Original file line number Diff line number Diff line change
@@ -1,32 +1,64 @@
class DatePickerInput < SimpleForm::Inputs::StringInput
def input(wrapper_options)
value = object.send(attribute_name) if object.respond_to? attribute_name
display_pattern = I18n.t('datepicker.dformat', :default => '%d/%m/%Y')
input_html_options[:value] ||= I18n.localize(value, :format => display_pattern) if value.present?

input_html_options[:type] = 'text'
picker_pattern = I18n.t('datepicker.pformat', :default => 'DD/MM/YYYY')
dayViewHeaderFormat = I18n.t('dayViewHeaderFormat', :default => 'MMMM YYYY')
date_options = {
locale: I18n.locale.to_s,
dayViewHeaderFormat: dayViewHeaderFormat,
format: picker_pattern
}
input_html_options[:data] ||= {}
input_html_options[:data].merge!({date_options: date_options })
set_html_options
set_value_html_option

template.content_tag :div, class: 'input-group date datepicker' do
input = super(wrapper_options) # leave StringInput do the real rendering
input += template.content_tag :span, class: 'input-group-btn' do
template.content_tag :button, class: 'btn btn-default', type: 'button' do
template.content_tag :span, '', class: 'glyphicon glyphicon-calendar'
end
end
input
input + input_button
end
end

def input_html_classes
super.push '' # 'form-control'
end

private

def input_button
template.content_tag :span, class: 'input-group-btn' do
template.content_tag :button, class: 'btn btn-default', type: 'button' do
template.content_tag :span, '', class: 'glyphicon glyphicon-calendar'
end
end
end

def set_html_options
input_html_options[:type] = 'text'
input_html_options[:data] ||= {}
input_html_options[:data].merge!(date_options: date_options)
end

def set_value_html_option
return unless value.present?
input_html_options[:value] ||= I18n.localize(value, format: display_pattern)
end

def value
object.send(attribute_name) if object.respond_to? attribute_name
end

def display_pattern
I18n.t('datepicker.dformat', default: '%d/%m/%Y')
end

def picker_pattern
I18n.t('datepicker.pformat', default: 'DD/MM/YYYY')
end

def date_view_header_format
I18n.t('dayViewHeaderFormat', default: 'MMMM YYYY')
end

def date_options_base
{
locale: I18n.locale.to_s,
format: picker_pattern
}
end

def date_options
date_options_base.merge!({dayViewHeaderFormat: date_view_header_format})
end

end
35 changes: 8 additions & 27 deletions lib/generators/templates/inputs/datetime_picker_input.rb
Original file line number Diff line number Diff line change
@@ -1,32 +1,13 @@
class DatetimePickerInput < SimpleForm::Inputs::StringInput
def input(wrapper_options)
value = object.send(attribute_name) if object.respond_to? attribute_name
display_pattern = I18n.t('datepicker.dformat', :default => '%d/%m/%Y') + ' ' + I18n.t('timepicker.dformat', :default => '%R')
input_html_options[:value] ||= I18n.localize(value, :format => display_pattern) if value.present?
class DatetimePickerInput < DatePickerInput
private

input_html_options[:type] = 'text'
picker_pattern = I18n.t('datepicker.pformat', :default => 'DD/MM/YYYY') + ' ' + I18n.t('timepicker.pformat', :default => 'HH:mm')
dayViewHeaderFormat = I18n.t('dayViewHeaderFormat', :default => 'MMMM YYYY')
date_options = {
locale: I18n.locale.to_s,
dayViewHeaderFormat: dayViewHeaderFormat,
format: picker_pattern
}
input_html_options[:data] ||= {}
input_html_options[:data].merge!({date_options: date_options })

template.content_tag :div, class: 'input-group date datetimepicker' do
input = super(wrapper_options) # leave StringInput do the real rendering
input += template.content_tag :span, class: 'input-group-btn' do
template.content_tag :button, class: 'btn btn-default', type: 'button' do
template.content_tag :span, '', class: 'glyphicon glyphicon-calendar'
end
end
input
end
def display_pattern
I18n.t('datepicker.dformat', default: '%d/%m/%Y') + ' ' +
I18n.t('timepicker.dformat', default: '%R')
end

def input_html_classes
super.push '' # 'form-control'
def picker_pattern
I18n.t('datepicker.pformat', default: 'DD/MM/YYYY') + ' ' +
I18n.t('timepicker.pformat', default: 'HH:mm')
end
end
33 changes: 9 additions & 24 deletions lib/generators/templates/inputs/time_picker_input.rb
Original file line number Diff line number Diff line change
@@ -1,30 +1,15 @@
class TimePickerInput < SimpleForm::Inputs::StringInput
def input(wrapper_options)
value = object.send(attribute_name) if object.respond_to? attribute_name
display_pattern = I18n.t('timepicker.dformat', :default => '%R')
input_html_options[:value] ||= I18n.localize(value, :format => display_pattern) if value.present?
class TimePickerInput < DatePickerInput
private

input_html_options[:type] = 'text'
picker_pattern = I18n.t('timepicker.pformat', :default => 'HH:mm')
date_options = {
locale: I18n.locale.to_s,
format: picker_pattern
}
input_html_options[:data] ||= {}
input_html_options[:data].merge!({date_options: date_options })
def display_pattern
I18n.t('timepicker.dformat', default: '%R')
end

template.content_tag :div, class: 'input-group date timepicker' do
input = super(wrapper_options) # leave StringInput do the real rendering
input += template.content_tag :span, class: 'input-group-btn' do
template.content_tag :button, class: 'btn btn-default', type: 'button' do
template.content_tag :span, '', class: 'glyphicon glyphicon-time'
end
end
input
end
def picker_pattern
I18n.t('timepicker.pformat', default: 'HH:mm')
end

def input_html_classes
super.push '' # 'form-control'
def date_options
date_options_base
end
end

0 comments on commit 5e70495

Please sign in to comment.