Fix: date picker that doesn't appear when clicking on calendar icon
This commit is contained in:
parent
d8c70a5f77
commit
e4fbed487a
@ -25,16 +25,19 @@ $(document).ready(function() {
|
||||
language: lang,
|
||||
todayHighlight: true,
|
||||
beforeShowDay: function (date) {
|
||||
var $selected_days = [];
|
||||
// Retrieve selected dates from text fields
|
||||
var selected_days = [];
|
||||
$('#selected-days').find('input[id^="day"]').each(function () {
|
||||
if ($(this).val() != '') {
|
||||
$selected_days.push($(this).val());
|
||||
selected_days.push($(this).val());
|
||||
}
|
||||
});
|
||||
for (var i = 0; i < $selected_days.length; i++) {
|
||||
var $selected_date = $selected_days[i].split('/');
|
||||
|
||||
if (date.getFullYear() == $selected_date[2] && (date.getMonth() + 1) == $selected_date[1] && date.getDate() == $selected_date[0]) {
|
||||
// Disable selected dates in DatePicker
|
||||
for (var i = 0; i < selected_days.length; i++) {
|
||||
var selected_date = selected_days[i].split('/');
|
||||
|
||||
if (date.getFullYear() == selected_date[2] && (date.getMonth() + 1) == selected_date[1] && date.getDate() == selected_date[0]) {
|
||||
return {
|
||||
classes: 'disabled selected'
|
||||
};
|
||||
@ -44,6 +47,16 @@ $(document).ready(function() {
|
||||
});
|
||||
};
|
||||
|
||||
$(document).on('click', '.input-group.date .input-group-addon', function () {
|
||||
// Re-init datepicker config before displaying
|
||||
init_datepicker();
|
||||
$(this).parent().datepicker('show');
|
||||
|
||||
// Trick to refresh calendar
|
||||
$('.datepicker-days .prev').trigger('click');
|
||||
$('.datepicker-days .next').trigger('click');
|
||||
});
|
||||
|
||||
// Complete the date fields when use partialy fill it (eg: 15/01 could become 15/01/2016)
|
||||
|
||||
var leftPad = function (text, pad) {
|
||||
@ -53,7 +66,7 @@ $(document).ready(function() {
|
||||
$(document).on('change', '.input-group.date input', function () {
|
||||
// Complete field if needed
|
||||
var val = $(this).val();
|
||||
var capture = /([0-9]+)(?:\/([0-9]+))?/.exec(val);
|
||||
var capture = /^([0-9]+)(?:\/([0-9]+))?$/.exec(val);
|
||||
|
||||
if (capture) {
|
||||
var inputDay = leftPad(capture[1], "00"); // 5->05, 15->15
|
||||
|
22
js/core.js
22
js/core.js
@ -2,28 +2,6 @@ $(document).ready(function() {
|
||||
|
||||
window.lang = $('html').attr('lang');
|
||||
|
||||
var datepickerfocus = false; // a11y : datepicker not display on focus until there is one click on the button
|
||||
|
||||
$(document).on('click','.input-group.date .input-group-addon', function() {
|
||||
datepickerfocus = true;
|
||||
// Re-init datepicker config before displaying
|
||||
$(this).parent().datepicker(init_datepicker());
|
||||
$(this).parent().datepicker('show');
|
||||
|
||||
// Trick to refresh calendar
|
||||
$('.datepicker-days .prev').trigger('click');
|
||||
$('.datepicker-days .next').trigger('click');
|
||||
// .active must be clicable in order to unfill the form
|
||||
$('.datepicker-days .active').removeClass('disabled');
|
||||
});
|
||||
|
||||
$(document).on('focus','.input-group.date input', function() {
|
||||
if(datepickerfocus) {
|
||||
$(this).parent('.input-group.date').datepicker(init_datepicker());
|
||||
$(this).parent('.input-group.date').datepicker('show');
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* adminstuds.php
|
||||
**/
|
||||
|
Loading…
Reference in New Issue
Block a user