Module: UnobtrusiveDatePicker::UnobtrusiveDatePickerHelper

Included in:
ActionView::Helpers::InstanceTag
Defined in:
lib/unobtrusive_date_picker.rb

Overview

Unobtrusive Date-Picker Helper

This Module helps to create date and date-time fields that use the Unobtrusive Date-Picker Javascript Widget.

They also use the 12-hour AM/PM time format.

Instance Method Summary collapse

Instance Method Details

#unobtrusive_date_picker(object_name, method, options = {}, html_options = {}) ⇒ Object

Creates the date picker with the calendar widget.



36
37
38
# File 'lib/unobtrusive_date_picker.rb', line 36

def unobtrusive_date_picker(object_name, method, options = {}, html_options = {})
  ActionView::Helpers::InstanceTag.new(object_name, method, self, options.delete(:object)).to_datepicker_date_select_tag(options, html_options)
end

#unobtrusive_date_picker_tags(date = Date.current, options = {}, html_options = {}) ⇒ Object



59
60
61
62
# File 'lib/unobtrusive_date_picker.rb', line 59

def unobtrusive_date_picker_tags(date = Date.current, options = {}, html_options = {})
  date ||= Date.current
  DateTimePickerSelector.new(date, options, html_options).select_date
end

#unobtrusive_date_text_picker(object_name, method, options = {}, html_options = {}) ⇒ Object

Creates the date picker with the calendar widget.



50
51
52
# File 'lib/unobtrusive_date_picker.rb', line 50

def unobtrusive_date_text_picker(object_name, method, options = {}, html_options = {})
  ActionView::Helpers::InstanceTag.new(object_name, method, self, options.delete(:object)).to_datepicker_text_tag(options, html_options)
end

#unobtrusive_date_text_picker_tag(name, date = Date.current, options = {}, html_options = {}) ⇒ Object

Creates the text field based date picker with the calendar widget without a model object.



67
68
69
70
71
# File 'lib/unobtrusive_date_picker.rb', line 67

def unobtrusive_date_text_picker_tag(name, date = Date.current, options = {}, html_options = {})
  date ||= Date.current
  options = merge_defaults_for_text_picker(options)
  DateTimePickerSelector.new(date, options, html_options).text_date_picker(name)
end

#unobtrusive_datetime_picker(object_name, method, options = {}, html_options = {}) ⇒ Object

Creates the date-time picker with the calendar widget, and AM/PM select.



43
44
45
# File 'lib/unobtrusive_date_picker.rb', line 43

def unobtrusive_datetime_picker(object_name, method, options = {}, html_options = {})
  ActionView::Helpers::InstanceTag.new(object_name, method, self, options.delete(:object)).to_datepicker_datetime_select_tag(options, html_options)
end

#unobtrusive_datetime_picker_tags(datetime = Time.current, options = {}, html_options = {}) ⇒ Object



54
55
56
57
# File 'lib/unobtrusive_date_picker.rb', line 54

def unobtrusive_datetime_picker_tags(datetime = Time.current, options = {}, html_options = {})
  datetime ||= Time.current
  DateTimePickerSelector.new(datetime, options.merge(:twelve_hour => true), html_options).select_datetime
end