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();
|
|
|
|
|
|
|
|
let dt = $(this);
|
2023-08-03 15:58:34 +08:00
|
|
|
let selectedDate = {};
|
|
|
|
|
|
|
|
$('.calendar-input').slice(0, 2).each(function(index, element) {
|
|
|
|
if ($(element).val().length > 0 ) {
|
|
|
|
selectedDate.index = index;
|
|
|
|
selectedDate.date = $(element).val();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
let options = {
|
|
|
|
ignoreReadonly: true
|
|
|
|
};
|
|
|
|
|
|
|
|
if (selectedDate.date) {
|
|
|
|
if (selectedDate.index == 0) {
|
|
|
|
options.minDate = new Date(selectedDate.date);
|
|
|
|
} else if (selectedDate.index == 1) {
|
|
|
|
options.maxDate = new Date(selectedDate.date);
|
|
|
|
}
|
|
|
|
}
|
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')}`);
|
|
|
|
if (!dt.data('DateTimePicker')) dt.datetimepicker({ useCurrent: false });
|
|
|
|
dt.data('DateTimePicker').clear();
|
|
|
|
dt.val('');
|
|
|
|
});
|
|
|
|
}());
|