Module: Railsstrap::Helpers::DatePicker

Defined in:
lib/railsstrap/helpers/date_picker_helper.rb

Instance Method Summary collapse

Instance Method Details

#date_picker(options = {}) ⇒ Object



25
26
27
28
29
30
# File 'lib/railsstrap/helpers/date_picker_helper.rb', line 25

def date_picker(options = {})
  opts = default_dp_options.deep_merge(options)
  (:div, class: "input-group date #{opts[:class]}", id: opts[:id], data: opts[:data]) {
    opts[:show_input] ? date_picker_input(opts) + date_picker_icon(opts) : date_picker_icon(opts)
  }
end

#date_picker_icon(options = {}) ⇒ Object



32
33
34
35
# File 'lib/railsstrap/helpers/date_picker_helper.rb', line 32

def date_picker_icon(options = {})
  opts = default_dp_options.deep_merge(options)
   opts[:icon_wrapper_tag], icon(opts[:icon]), class: opts[:icon_wrapper_class]
end

#date_picker_input(options = {}) ⇒ Object



37
38
39
40
# File 'lib/railsstrap/helpers/date_picker_helper.rb', line 37

def date_picker_input(options = {})
  opts = default_dp_options.deep_merge(options)
  text_field_tag opts[:input_name], '', class: opts[:input_class]
end

#date_picker_javascript(options = {}) ⇒ Object



42
43
44
45
# File 'lib/railsstrap/helpers/date_picker_helper.rb', line 42

def date_picker_javascript(options = {})
  opts = default_js_options.deep_merge(options)
  javascript_tag "(function ($) { $('#{opts[:selector]}').datetimepicker(#{opts.to_json});})(jQuery);"
end