Sha256: 9efe22ed4900599035c33ad06a8af113c7e0f48a8c6d79080a1fc0e7f30a55d5

Contents?: true

Size: 785 Bytes

Versions: 1

Compression:

Stored size: 785 Bytes

Contents

document.addEventListener("spree:load", function() {
  flatpickr.setDefaults({
    altInput: true,
    time_24hr: true,
    altInputClass: 'flatpickr-alt-input',
    locale: Spree.translations.flatpickr_locale
  })

  var dateFrom = flatpickr('.datePickerFrom', {
    onChange: function(selectedDates) {
      dateTo.set('minDate', selectedDates[0])
    }
  })

  var dateTo = flatpickr('.datePickerTo', {
    onChange: function(selectedDates) {
      dateFrom.set('maxDate', selectedDates[0])
    }
  })

  flatpickr('.datepicker', {})
})

document.addEventListener("turbo:before-cache", function() {
  document.querySelectorAll('.datePickerFrom, .datePickerTo, .datepicker').forEach(function(element) {
    if (element._flatpickr) {
      element._flatpickr.destroy()
    }
  })
})

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spree_backend-4.8.4 app/assets/javascripts/spree/backend/global/flatpickr.es6