Le datepicker mémorise la dernière date sélectionnée

This commit is contained in:
FramaJosephK 2015-02-26 17:06:09 +01:00
parent 3e1ef601ce
commit b352192647

View File

@ -32,6 +32,7 @@ $(document).ready(function() {
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() {
datepickerfocus = true;
@ -39,6 +40,17 @@ $(document).ready(function() {
$(this).parent().datepicker(framadatepicker());
$(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
$('.datepicker-days .prev').trigger('click');
$('.datepicker-days .next').trigger('click');
@ -48,8 +60,9 @@ $(document).ready(function() {
$(document).on('focus','.input-group.date input', function() {
if(datepickerfocus) {
$(this).parent('.input-group.date').datepicker(framadatepicker());
$(this).parent('.input-group.date').datepicker('show');
// unfocus and click instead (because we are not in a11y mode anymore)
$(this).blur();
$(this).parent().find('.input-group-addon').trigger('click');
}
});
/**