houdini/client/js/common/apply-pikaday.js

14 lines
564 B
JavaScript
Raw Normal View History

const bind = require('attr-binder')
const Pikaday = require('pikaday')
const moment = require('moment')
bind('apply-pikaday', function(field, format) {
const setDefaultDate = field.getAttribute('pikaday-setDefaultDate')
const maxDate_str = field.getAttribute('pikaday-maxDate')
const maxDate = maxDate_str ? moment(maxDate_str) : undefined
const defaultDate_str = field.getAttribute('pikaday-defaultDate')
const defaultDate = defaultDate_str ? moment(defaultDate_str) : undefined
new Pikaday({format, setDefaultDate, field, maxDate, defaultDate})
})