mirror of
https://github.com/wagtail/wagtail.git
synced 2024-12-01 11:41:20 +01:00
Remove highlighting for calendar day when switching months in the datetimepicker
This commit is contained in:
parent
5b10a4969d
commit
78a489b53f
@ -71,6 +71,24 @@ function insertRichTextDeleteControl(elem) {
|
||||
});
|
||||
}
|
||||
|
||||
// Compare two date objects. Ignore minutes and seconds.
|
||||
function dateEqual(x, y) {
|
||||
return x.getDate() === y.getDate() &&
|
||||
x.getMonth() === y.getMonth() &&
|
||||
x.getYear() === y.getYear()
|
||||
}
|
||||
|
||||
/*
|
||||
Remove the xdsoft_current css class from markup unless the selected date is currently in view.
|
||||
Keep the normal behaviour if the home button is clicked.
|
||||
*/
|
||||
function hideCurrent(current, input) {
|
||||
var selected = new Date(input[0].value);
|
||||
if (!dateEqual(selected, current)) {
|
||||
$(this).find('.xdsoft_datepicker .xdsoft_current:not(.xdsoft_today)').removeClass('xdsoft_current');
|
||||
}
|
||||
}
|
||||
|
||||
function initDateChooser(id, opts) {
|
||||
if (window.dateTimePickerTranslations) {
|
||||
$('#' + id).datetimepicker($.extend({
|
||||
@ -81,13 +99,15 @@ function initDateChooser(id, opts) {
|
||||
i18n: {
|
||||
lang: window.dateTimePickerTranslations
|
||||
},
|
||||
lang: 'lang'
|
||||
lang: 'lang',
|
||||
onGenerate: hideCurrent
|
||||
}, opts || {}));
|
||||
} else {
|
||||
$('#' + id).datetimepicker($.extend({
|
||||
timepicker: false,
|
||||
scrollInput: false,
|
||||
format: 'Y-m-d'
|
||||
format: 'Y-m-d',
|
||||
onGenerate: hideCurrent
|
||||
}, opts || {}));
|
||||
}
|
||||
}
|
||||
@ -121,11 +141,13 @@ function initDateTimeChooser(id, opts) {
|
||||
i18n: {
|
||||
lang: window.dateTimePickerTranslations
|
||||
},
|
||||
language: 'lang'
|
||||
language: 'lang',
|
||||
onGenerate: hideCurrent
|
||||
}, opts || {}));
|
||||
} else {
|
||||
$('#' + id).datetimepicker($.extend({
|
||||
format: 'Y-m-d H:i'
|
||||
format: 'Y-m-d H:i',
|
||||
onGenerate: hideCurrent
|
||||
}, opts || {}));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user