mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
62 lines
1.6 KiB
Plaintext
62 lines
1.6 KiB
Plaintext
$(document).ready(function() {
|
|
var onClickButtons = function(index, fp) {
|
|
var date;
|
|
switch (index) {
|
|
case 0:
|
|
date = new Date();
|
|
break;
|
|
}
|
|
fp.setDate(date, true);
|
|
}
|
|
window.FLATPICKR_DATE_DEFAULT = {
|
|
altInput: true,
|
|
altFormat: Spree.translations.flatpickr_date_format,
|
|
dateFormat: "Y-m-d",
|
|
locale: I18n.base_locale,
|
|
plugins: [
|
|
ShortcutButtonsPlugin({
|
|
button: [{
|
|
label: Spree.translations.today
|
|
}],
|
|
label: "or",
|
|
onClick: onClickButtons
|
|
}),
|
|
labelPlugin({})
|
|
]
|
|
}
|
|
window.FLATPICKR_DATETIME_DEFAULT = Object.assign(
|
|
{},
|
|
window.FLATPICKR_DATE_DEFAULT,
|
|
{
|
|
altInput: true,
|
|
altFormat: Spree.translations.flatpickr_datetime_format,
|
|
dateFormat: "Y-m-d H:i",
|
|
enableTime: true,
|
|
time_24hr: true,
|
|
plugins: [
|
|
ShortcutButtonsPlugin({
|
|
button: [{
|
|
label: Spree.translations.now
|
|
}],
|
|
label: "or",
|
|
onClick: onClickButtons
|
|
}),
|
|
labelPlugin({})
|
|
]
|
|
}
|
|
);
|
|
flatpickr(".datetimepicker", window.FLATPICKR_DATETIME_DEFAULT);
|
|
$('a.close').click(function(event){
|
|
event.preventDefault();
|
|
$(this).parent().slideUp(250);
|
|
});
|
|
|
|
// Spree locates hidden with prev(), which with our current version of jQuery
|
|
// does not locate the hidden field, resulting in the delete failing. This
|
|
// handler updates the hidden field, fixing the problem.
|
|
$('body').on('click', 'a.remove_fields', function() {
|
|
$(this).next("input[type=hidden]").val("1");
|
|
return false;
|
|
});
|
|
});
|