Sha256: 7173164bf3f117f6657132b93737d2bd3a06cd94a4f5593f3e4b88775722ec43

Contents?: true

Size: 1.16 KB

Versions: 5

Compression:

Stored size: 1.16 KB

Contents

Trestle.setupDatePicker = function(selectedDates, dateStr, instance) {
  if ($(instance.input).data('allow-clear')) {
    $('<a href="#">')
      .on('click', function(e) {
        e.preventDefault();
        instance.clear();
      })
      .addClass('clear-datepicker')
      .insertBefore(instance.altInput);
  }
};

Trestle.init(function(e, root) {
  $(root).find('input[type="date"][data-picker="true"]').flatpickr({
    allowInput: true,
    altInput:   true,
    altFormat:  Trestle.i18n["admin.datepicker.formats.date"] || "m/d/Y",
    onReady:    Trestle.setupDatePicker
  });

  $(root).find('input[type="datetime"][data-picker="true"], input[type="datetime-local"][data-picker="true"]').flatpickr({
    enableTime: true,
    allowInput: true,
    altInput:   true,
    altFormat:  Trestle.i18n["admin.datepicker.formats.datetime"] || "m/d/Y h:i K",
    onReady:    Trestle.setupDatePicker
  });

  $(root).find('input[type="time"][data-picker="true"]').flatpickr({
    enableTime: true,
    noCalendar: true,
    allowInput: true,
    altInput:   true,
    altFormat:  Trestle.i18n["admin.datepicker.formats.time"] || "h:i K",
    onReady:    Trestle.setupDatePicker
  });
});

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
trestle-0.8.12 app/assets/javascripts/trestle/components/_datepicker.js
trestle-0.8.11 app/assets/javascripts/trestle/components/_datepicker.js
trestle-0.8.10 app/assets/javascripts/trestle/components/_datepicker.js
trestle-0.8.9 app/assets/javascripts/trestle/components/_datepicker.js
trestle-0.8.8 app/assets/javascripts/trestle/components/_datepicker.js