Module: Wice::JsCalendarHelpers

Included in:
Columns::ViewColumnJqueryDatepicker
Defined in:
lib/wice/helpers/js_calendar_helpers.rb

Overview

:nodoc:

Defined Under Namespace

Classes: CalendarData

Instance Method Summary collapse

Instance Method Details

#date_calendar_jquery(calendar_data) ⇒ Object

:nodoc:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/wice/helpers/js_calendar_helpers.rb', line 20

def date_calendar_jquery(calendar_data)  #:nodoc:
  hidden_field_tag_options = {
    :id                 => calendar_data.dom_id,
    'data-locale'       => I18n.locale,
    'data-date-format'  => Wice::ConfigurationProvider.value_for(:DATE_FORMAT_JQUERY),
    'data-button-text'  => calendar_data.title
  }

  if calendar_data.fire_event
    hidden_field_tag_options['data-close-calendar-event-name'] = calendar_data.close_calendar_event_name
  end

  if Rails.env.development?
    hidden_field_tag_options['class'] = 'check-for-datepicker'
  end

  if calendar_data.the_other_datepicker_id_to
    hidden_field_tag_options['data-the-other-datepicker-id-to'] = calendar_data.the_other_datepicker_id_to
  end

  if calendar_data.the_other_datepicker_id_from
    hidden_field_tag_options['data-the-other-datepicker-id-from'] = calendar_data.the_other_datepicker_id_from
  end

  if year_range = ConfigurationProvider.value_for(:DATEPICKER_YEAR_RANGE)
    hidden_field_tag_options['data-date-year-range'] = year_range
  end

  date_picker = hidden_field_tag(calendar_data.name, calendar_data.date_string, hidden_field_tag_options) + ' ' +

  link_to(
    calendar_data.date_string,
    '#',
    :id           => calendar_data.date_span_id,
    :class        => 'date-label',
    :title        => ::Wice::NlMessage['date_string_tooltip'],
    'data-dom-id' => calendar_data.dom_id
  )

  (
    :span,
    date_picker,
    id: calendar_data.datepicker_placeholder_id,
    class: 'jq-datepicker-container'
  )
end

#prepare_data_for_calendar(options) ⇒ Object

:nodoc:



67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/wice/helpers/js_calendar_helpers.rb', line 67

def prepare_data_for_calendar(options)  #:nodoc:
  date_format = Wice::ConfigurationProvider.value_for(:DATE_FORMAT)

  CalendarData.new.tap do |calendar_data|
    calendar_data.name                      = options[:name]
    calendar_data.date_string               = options[:initial_date].nil? ? '' : options[:initial_date].strftime(date_format)
    calendar_data.dom_id                    = options[:name].gsub(/([\[\(])|(\]\[)/, '_').gsub(/[\]\)]/, '').gsub(/\./, '_').gsub(/_+/, '_')
    calendar_data.datepicker_placeholder_id = calendar_data.dom_id + '_date_placeholder'
    calendar_data.date_span_id              = calendar_data.dom_id + '_date_view'
    calendar_data.close_calendar_event_name = "wg:calendarChanged_#{options[:grid_name]}"
    calendar_data.title                     = options[:title]
    calendar_data.fire_event                = options[:fire_event]
  end
end