2020-03-17 00:55:35 +08:00
|
|
|
(function() {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
$(document).on('click', '[data-toggle="date-time-picker"]', function(ev) {
|
|
|
|
ev.preventDefault();
|
|
|
|
ev.stopPropagation();
|
|
|
|
|
2023-09-28 19:33:17 +08:00
|
|
|
const dt = $(this);
|
2023-08-03 15:58:34 +08:00
|
|
|
|
2023-09-28 19:33:17 +08:00
|
|
|
if (dt.data('DateTimePicker')) {
|
|
|
|
dt.data('DateTimePicker').show();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const linkedMin = dt.data('linked-min');
|
|
|
|
const linkedMax = dt.data('linked-max');
|
2023-08-03 15:58:34 +08:00
|
|
|
|
|
|
|
let options = {
|
2023-09-28 19:33:17 +08:00
|
|
|
ignoreReadonly: true,
|
|
|
|
useCurrent: false
|
|
|
|
}
|
|
|
|
|
|
|
|
if (linkedMin) {
|
|
|
|
if ($(linkedMin).val()) {
|
|
|
|
options.minDate = moment($(linkedMin).val(), $(linkedMin).data('dateFormat')).toDate();
|
2023-08-03 15:58:34 +08:00
|
|
|
}
|
2023-09-28 19:33:17 +08:00
|
|
|
|
|
|
|
$(linkedMin).on("dp.change", function (e) {
|
|
|
|
dt.data("DateTimePicker").minDate(e.date);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (linkedMax) {
|
|
|
|
if ($(linkedMax).val()) {
|
|
|
|
options.maxDate = moment($(linkedMax).val(), $(linkedMax).data('dateFormat')).toDate();
|
|
|
|
}
|
|
|
|
|
|
|
|
$(linkedMax).on("dp.change", function (e) {
|
|
|
|
dt.data("DateTimePicker").maxDate(e.date);
|
|
|
|
});
|
2023-08-03 15:58:34 +08:00
|
|
|
}
|
2020-03-17 00:55:35 +08:00
|
|
|
|
|
|
|
if (dt.data('DateTimePicker')) {
|
|
|
|
dt.data('DateTimePicker').destroy();
|
|
|
|
}
|
|
|
|
|
2023-01-05 18:14:34 +08:00
|
|
|
if (dt.data('positioningVertical')) {
|
|
|
|
options.widgetPositioning = { vertical: dt.data('positioningVertical') };
|
|
|
|
}
|
|
|
|
|
|
|
|
dt.datetimepicker(options);
|
2020-03-17 00:55:35 +08:00
|
|
|
dt.data('DateTimePicker').show();
|
|
|
|
});
|
|
|
|
|
2022-12-02 18:01:40 +08:00
|
|
|
$(document).on('mousedown', '[data-toggle="clear-date-time-picker"]', function() {
|
2020-03-17 00:55:35 +08:00
|
|
|
let dt = $(`#${$(this).data('target')}`);
|
2023-10-30 22:14:12 +08:00
|
|
|
if (dt.data('dateTimePicker')) {
|
|
|
|
dt.data('dateTimePicker').clearDate();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-03-17 00:55:35 +08:00
|
|
|
if (!dt.data('DateTimePicker')) dt.datetimepicker({ useCurrent: false });
|
|
|
|
dt.data('DateTimePicker').clear();
|
|
|
|
dt.val('');
|
|
|
|
});
|
|
|
|
}());
|