|
Lines 127-132
Link Here
|
| 127 |
$(".flatpickr").each(function(){ |
127 |
$(".flatpickr").each(function(){ |
| 128 |
let options = {}; |
128 |
let options = {}; |
| 129 |
let refresh_max_date = 0; |
129 |
let refresh_max_date = 0; |
|
|
130 |
let disable_buttons = []; |
| 130 |
|
131 |
|
| 131 |
if( $(this).data("flatpickr-futuredate") === true ) { |
132 |
if( $(this).data("flatpickr-futuredate") === true ) { |
| 132 |
let original_date = $(this).val(); |
133 |
let original_date = $(this).val(); |
|
Lines 143-155
Link Here
|
| 143 |
else { |
144 |
else { |
| 144 |
options['minDate'] = new Date().fp_incr(1); |
145 |
options['minDate'] = new Date().fp_incr(1); |
| 145 |
} |
146 |
} |
|
|
147 |
disable_buttons.push(0); /* Yesterday */ |
| 146 |
} |
148 |
} |
| 147 |
if( $(this).data("flatpickr-pastinclusive") === true ) { |
149 |
if( $(this).data("flatpickr-pastinclusive") === true ) { |
| 148 |
options['maxDate'] = new Date(); /* Not today or hh:mm will be 00:00 */ |
150 |
options['maxDate'] = new Date(); /* Not today or hh:mm will be 00:00 */ |
| 149 |
refresh_max_date = 1; |
151 |
refresh_max_date = 1; |
|
|
152 |
disable_buttons.push(2); /* Tomorrow */ |
| 150 |
} |
153 |
} |
| 151 |
if( $(this).data("flatpickr-pastdate") === true ) { |
154 |
if( $(this).data("flatpickr-pastdate") === true ) { |
| 152 |
options['maxDate'] = new Date().fp_incr(-1); |
155 |
options['maxDate'] = new Date().fp_incr(-1); |
|
|
156 |
disable_buttons.push(1); /* Today */ |
| 157 |
disable_buttons.push(2); /* Tomorrow */ |
| 153 |
} |
158 |
} |
| 154 |
if ( $(this).data('flatpickr-enable-time') === true ) { |
159 |
if ( $(this).data('flatpickr-enable-time') === true ) { |
| 155 |
options['enableTime'] = true; |
160 |
options['enableTime'] = true; |
|
Lines 157-162
Link Here
|
| 157 |
} |
162 |
} |
| 158 |
|
163 |
|
| 159 |
let fp = $(this).flatpickr(options); |
164 |
let fp = $(this).flatpickr(options); |
|
|
165 |
|
| 166 |
$(disable_buttons).each(function(index, value){ |
| 167 |
$(fp.calendarContainer).find(".shortcut-buttons-flatpickr-button[data-index='"+value+"']").prop("disabled", "disabled").css("color", "#999"); |
| 168 |
}); |
| 169 |
|
| 160 |
if ( refresh_max_date ) { |
170 |
if ( refresh_max_date ) { |
| 161 |
/* Refresh the maxDate every 30 secondes to make sure the user will not |
171 |
/* Refresh the maxDate every 30 secondes to make sure the user will not |
| 162 |
be stuck with the minute passed. |
172 |
be stuck with the minute passed. |
| 163 |
- |
|
|