Le datepicker mémorise la dernière date sélectionnée
This commit is contained in:
parent
3e1ef601ce
commit
b352192647
23
js/core.js
23
js/core.js
@ -1,6 +1,6 @@
|
|||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var lang = $('html').attr('lang');
|
var lang = $('html').attr('lang');
|
||||||
|
|
||||||
// Datepicker
|
// Datepicker
|
||||||
var framadatepicker = function() {
|
var framadatepicker = function() {
|
||||||
$('.input-group.date').datepicker({
|
$('.input-group.date').datepicker({
|
||||||
@ -32,13 +32,25 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
|
|
||||||
var datepickerfocus = false; // a11y : datepicker not display on focus until there is one click on the button
|
var datepickerfocus = false; // a11y : datepicker not display on focus until there is one click on the button
|
||||||
|
var lastDate = new Date();
|
||||||
|
|
||||||
$(document).on('click','.input-group.date .input-group-addon', function() {
|
$(document).on('click','.input-group.date .input-group-addon', function() {
|
||||||
datepickerfocus = true;
|
datepickerfocus = true;
|
||||||
// Re-init datepicker config before displaying
|
// Re-init datepicker config before displaying
|
||||||
$(this).parent().datepicker(framadatepicker());
|
$(this).parent().datepicker(framadatepicker());
|
||||||
$(this).parent().datepicker('show');
|
$(this).parent().datepicker('show');
|
||||||
|
|
||||||
|
// Trick to keep the last datepicker view
|
||||||
|
if ($(this).parent().find('input').val() == '') {
|
||||||
|
$('.input-group.date input').each(function(){
|
||||||
|
if($(this).val()!='') {
|
||||||
|
lastDate = $(this).val();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$(this).parent().datepicker('setDate', lastDate);
|
||||||
|
$(this).parent().datepicker('setDate', '');
|
||||||
|
}
|
||||||
|
|
||||||
// Trick to refresh calendar
|
// Trick to refresh calendar
|
||||||
$('.datepicker-days .prev').trigger('click');
|
$('.datepicker-days .prev').trigger('click');
|
||||||
$('.datepicker-days .next').trigger('click');
|
$('.datepicker-days .next').trigger('click');
|
||||||
@ -48,8 +60,9 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
$(document).on('focus','.input-group.date input', function() {
|
$(document).on('focus','.input-group.date input', function() {
|
||||||
if(datepickerfocus) {
|
if(datepickerfocus) {
|
||||||
$(this).parent('.input-group.date').datepicker(framadatepicker());
|
// unfocus and click instead (because we are not in a11y mode anymore)
|
||||||
$(this).parent('.input-group.date').datepicker('show');
|
$(this).blur();
|
||||||
|
$(this).parent().find('.input-group-addon').trigger('click');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user