Sha256: c1ce3dc9b7412988801c7adb82ab8c536c5c8081736476bf59c367a308885450

Contents?: true

Size: 995 Bytes

Versions: 42

Compression:

Stored size: 995 Bytes

Contents

((exports) => {
  const formDatePicker = () => {
    $('[data-datepicker]').each((_index, node) => {
      const language = $('html').attr('lang') || 'en';
      const initialDate = $(node).data('startdate') || '';
      const pickTime = $(node).data('timepicker') === '';
      const languageProps = $(node).fdatepicker.dates[language] && $(node).fdatepicker.dates[language].format;
      let format = languageProps || 'mm/dd/yyyy';

      if (pickTime) {
        format = `${format}, hh:ii`;
      }

      $(node).fdatepicker({
        format,
        initialDate,
        language,
        pickTime,
        disableDblClickSelection: true,
        leftArrow: '<<',
        rightArrow: '>>'
      }).on('changeDate', (ev) => {
        let newDate = exports.moment.utc(ev.date).format('YYYY-MM-DDTHH:mm:ss');

        $(ev.target).siblings('input').val(newDate);
      });
    });
  };

  exports.Decidim = exports.Decidim || {};
  exports.Decidim.formDatePicker = formDatePicker;
})(window);

Version data entries

42 entries across 42 versions & 2 rubygems

Version Path
decidim-core-0.2.0 vendor/assets/javascripts/form_datepicker.js.es6
decidim-core-0.1.0 vendor/assets/javascripts/form_datepicker.js.es6