forked from CGM_Public/pretix_original
Fix datetimepicker annoyances
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
/*! version : 4.17.42
|
/*! version : 4.17.47
|
||||||
=========================================================
|
=========================================================
|
||||||
bootstrap-datetimejs
|
bootstrap-datetimejs
|
||||||
https://github.com/Eonasdan/bootstrap-datetimepicker
|
https://github.com/Eonasdan/bootstrap-datetimepicker
|
||||||
@@ -142,6 +142,10 @@
|
|||||||
|
|
||||||
if (d === undefined || d === null) {
|
if (d === undefined || d === null) {
|
||||||
returnMoment = moment(); //TODO should this use format? and locale?
|
returnMoment = moment(); //TODO should this use format? and locale?
|
||||||
|
} else if (moment.isDate(d) || moment.isMoment(d)) {
|
||||||
|
// If the date that is passed in is already a Date() or moment() object,
|
||||||
|
// pass it directly to moment.
|
||||||
|
returnMoment = moment(d);
|
||||||
} else if (hasTimeZone()) { // There is a string to parse and a default time zone
|
} else if (hasTimeZone()) { // There is a string to parse and a default time zone
|
||||||
// parse with the tz function which takes a default time zone if it is not in the format string
|
// parse with the tz function which takes a default time zone if it is not in the format string
|
||||||
returnMoment = moment.tz(d, parseFormats, options.useStrict, options.timeZone);
|
returnMoment = moment.tz(d, parseFormats, options.useStrict, options.timeZone);
|
||||||
@@ -336,6 +340,7 @@
|
|||||||
if (use24Hours) {
|
if (use24Hours) {
|
||||||
template.addClass('usetwentyfour');
|
template.addClass('usetwentyfour');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isEnabled('s') && !use24Hours) {
|
if (isEnabled('s') && !use24Hours) {
|
||||||
template.addClass('wider');
|
template.addClass('wider');
|
||||||
}
|
}
|
||||||
@@ -448,15 +453,15 @@
|
|||||||
widget.removeClass('pull-right');
|
widget.removeClass('pull-right');
|
||||||
}
|
}
|
||||||
|
|
||||||
// find the first parent element that has a relative css positioning
|
// find the first parent element that has a non-static css positioning
|
||||||
if (parent.css('position') !== 'relative') {
|
if (parent.css('position') === 'static') {
|
||||||
parent = parent.parents().filter(function () {
|
parent = parent.parents().filter(function () {
|
||||||
return $(this).css('position') === 'relative';
|
return $(this).css('position') !== 'static';
|
||||||
}).first();
|
}).first();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parent.length === 0) {
|
if (parent.length === 0) {
|
||||||
throw new Error('datetimepicker component should be placed within a relative positioned container');
|
throw new Error('datetimepicker component should be placed within a non-static positioned container');
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.css({
|
widget.css({
|
||||||
@@ -686,7 +691,7 @@
|
|||||||
currentDate,
|
currentDate,
|
||||||
html = [],
|
html = [],
|
||||||
row,
|
row,
|
||||||
clsName,
|
clsNames = [],
|
||||||
i;
|
i;
|
||||||
|
|
||||||
if (!hasDate()) {
|
if (!hasDate()) {
|
||||||
@@ -717,26 +722,31 @@
|
|||||||
}
|
}
|
||||||
html.push(row);
|
html.push(row);
|
||||||
}
|
}
|
||||||
clsName = '';
|
clsNames = ['day'];
|
||||||
if (currentDate.isBefore(viewDate, 'M')) {
|
if (currentDate.isBefore(viewDate, 'M')) {
|
||||||
clsName += ' old';
|
clsNames.push('old');
|
||||||
}
|
}
|
||||||
if (currentDate.isAfter(viewDate, 'M')) {
|
if (currentDate.isAfter(viewDate, 'M')) {
|
||||||
clsName += ' new';
|
clsNames.push('new');
|
||||||
}
|
}
|
||||||
if (currentDate.isSame(date, 'd') && !unset) {
|
if (currentDate.isSame(date, 'd') && !unset) {
|
||||||
clsName += ' active';
|
clsNames.push('active');
|
||||||
}
|
}
|
||||||
if (!isValid(currentDate, 'd')) {
|
if (!isValid(currentDate, 'd')) {
|
||||||
clsName += ' disabled';
|
clsNames.push('disabled');
|
||||||
}
|
}
|
||||||
if (currentDate.isSame(getMoment(), 'd')) {
|
if (currentDate.isSame(getMoment(), 'd')) {
|
||||||
clsName += ' today';
|
clsNames.push('today');
|
||||||
}
|
}
|
||||||
if (currentDate.day() === 0 || currentDate.day() === 6) {
|
if (currentDate.day() === 0 || currentDate.day() === 6) {
|
||||||
clsName += ' weekend';
|
clsNames.push('weekend');
|
||||||
}
|
}
|
||||||
row.append('<td data-action="selectDay" data-day="' + currentDate.format('L') + '" class="day' + clsName + '">' + currentDate.date() + '</td>');
|
notifyEvent({
|
||||||
|
type: 'dp.classify',
|
||||||
|
date: currentDate,
|
||||||
|
classNames: clsNames
|
||||||
|
});
|
||||||
|
row.append('<td data-action="selectDay" data-day="' + currentDate.format('L') + '" class="' + clsNames.join(' ') + '">' + currentDate.date() + '</td>');
|
||||||
currentDate.add(1, 'd');
|
currentDate.add(1, 'd');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -862,11 +872,15 @@
|
|||||||
|
|
||||||
if (options.stepping !== 1) {
|
if (options.stepping !== 1) {
|
||||||
targetMoment.minutes((Math.round(targetMoment.minutes() / options.stepping) * options.stepping)).seconds(0);
|
targetMoment.minutes((Math.round(targetMoment.minutes() / options.stepping) * options.stepping)).seconds(0);
|
||||||
|
|
||||||
|
while (options.minDate && targetMoment.isBefore(options.minDate)) {
|
||||||
|
targetMoment.add(options.stepping, 'minutes');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isValid(targetMoment)) {
|
if (isValid(targetMoment)) {
|
||||||
date = targetMoment;
|
date = targetMoment;
|
||||||
//viewDate = date.clone(); // TODO this doesn't work right on first use
|
viewDate = date.clone();
|
||||||
input.val(date.format(actualFormat));
|
input.val(date.format(actualFormat));
|
||||||
element.data('date', date.format(actualFormat));
|
element.data('date', date.format(actualFormat));
|
||||||
unset = false;
|
unset = false;
|
||||||
@@ -933,7 +947,6 @@
|
|||||||
|
|
||||||
input.blur();
|
input.blur();
|
||||||
|
|
||||||
currentViewMode = 0;
|
|
||||||
viewDate = date.clone();
|
viewDate = date.clone();
|
||||||
|
|
||||||
return picker;
|
return picker;
|
||||||
@@ -945,7 +958,7 @@
|
|||||||
|
|
||||||
parseInputDate = function (inputDate) {
|
parseInputDate = function (inputDate) {
|
||||||
if (options.parseInputDate === undefined) {
|
if (options.parseInputDate === undefined) {
|
||||||
if (!moment.isMoment(inputDate)) {
|
if (!moment.isMoment(inputDate) || inputDate instanceof Date) {
|
||||||
inputDate = getMoment(inputDate);
|
inputDate = getMoment(inputDate);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -2402,11 +2415,12 @@
|
|||||||
|
|
||||||
if (typeof options === 'object') {
|
if (typeof options === 'object') {
|
||||||
return this.each(function () {
|
return this.each(function () {
|
||||||
var $this = $(this);
|
var $this = $(this),
|
||||||
|
_options;
|
||||||
if (!$this.data('DateTimePicker')) {
|
if (!$this.data('DateTimePicker')) {
|
||||||
// create a private copy of the defaults object
|
// create a private copy of the defaults object
|
||||||
options = $.extend(true, {}, $.fn.datetimepicker.defaults, options);
|
_options = $.extend(true, {}, $.fn.datetimepicker.defaults, options);
|
||||||
$this.data('DateTimePicker', dateTimePicker($this, options));
|
$this.data('DateTimePicker', dateTimePicker($this, _options));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (typeof options === 'string') {
|
} else if (typeof options === 'string') {
|
||||||
@@ -2617,7 +2631,6 @@
|
|||||||
enabledHours: false,
|
enabledHours: false,
|
||||||
viewDate: false
|
viewDate: false
|
||||||
};
|
};
|
||||||
if (typeof module !== 'undefined') {
|
|
||||||
module.exports = $.fn.datetimepicker;
|
return $.fn.datetimepicker;
|
||||||
}
|
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ $(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("#ajaxerr").on("click", ".ajaxerr-close", ajaxErrDialog.hide);
|
$("#ajaxerr").on("click", ".ajaxerr-close", ajaxErrDialog.hide);
|
||||||
|
moment.locale($("body").attr("data-datetimelocale"));
|
||||||
|
|
||||||
$(".datetimepicker").each(function() {
|
$(".datetimepicker").each(function() {
|
||||||
$(this).datetimepicker({
|
$(this).datetimepicker({
|
||||||
@@ -141,6 +142,9 @@ $(function () {
|
|||||||
close: 'fa fa-remove'
|
close: 'fa fa-remove'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (!$(this).val()) {
|
||||||
|
$(this).data("DateTimePicker").viewDate(moment().hour(0).minute(0).second(0));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".datepickerfield").each(function() {
|
$(".datepickerfield").each(function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user