Lines 101-118
Link Here
|
101 |
label: __("or"), |
101 |
label: __("or"), |
102 |
onClick: (index, fp) => { |
102 |
onClick: (index, fp) => { |
103 |
let date; |
103 |
let date; |
|
|
104 |
let hh = 23, mm = 59; |
104 |
switch (index) { |
105 |
switch (index) { |
105 |
case 0: |
106 |
case 0: |
106 |
date = new Date().fp_incr(-1); |
107 |
date = new Date().fp_incr(-1); |
107 |
break; |
108 |
break; |
108 |
case 1: |
109 |
case 1: |
109 |
date = new Date(); |
110 |
date = new Date(); |
|
|
111 |
if ( $(fp.input).data("flatpickr-pastinclusive") === true ) { |
112 |
hh = date.getHours(); |
113 |
mm = date.getMinutes(); |
114 |
} |
110 |
break; |
115 |
break; |
111 |
case 2: |
116 |
case 2: |
112 |
date = new Date().fp_incr(1); |
117 |
date = new Date().fp_incr(1); |
113 |
break; |
118 |
break; |
114 |
} |
119 |
} |
115 |
date.setHours(23, 59, 0, 0); |
120 |
date.setHours(hh, mm, 0, 0); |
116 |
fp.setDate(date); |
121 |
fp.setDate(date); |
117 |
} |
122 |
} |
118 |
}) |
123 |
}) |
Lines 121-126
Link Here
|
121 |
$(document).ready(function(){ |
126 |
$(document).ready(function(){ |
122 |
$(".flatpickr").each(function(){ |
127 |
$(".flatpickr").each(function(){ |
123 |
let options = {}; |
128 |
let options = {}; |
|
|
129 |
let refresh_max_date = 0; |
124 |
|
130 |
|
125 |
if( $(this).data("flatpickr-futuredate") === true ) { |
131 |
if( $(this).data("flatpickr-futuredate") === true ) { |
126 |
let original_date = $(this).val(); |
132 |
let original_date = $(this).val(); |
Lines 139-145
Link Here
|
139 |
} |
145 |
} |
140 |
} |
146 |
} |
141 |
if( $(this).data("flatpickr-pastinclusive") === true ) { |
147 |
if( $(this).data("flatpickr-pastinclusive") === true ) { |
142 |
options['maxDate'] = "today"; |
148 |
options['maxDate'] = new Date(); /* Not today or hh:mm will be 00:00 */ |
|
|
149 |
refresh_max_date = 1; |
143 |
} |
150 |
} |
144 |
if( $(this).data("flatpickr-pastdate") === true ) { |
151 |
if( $(this).data("flatpickr-pastdate") === true ) { |
145 |
options['maxDate'] = new Date().fp_incr(-1); |
152 |
options['maxDate'] = new Date().fp_incr(-1); |
Lines 149-155
Link Here
|
149 |
options['dateFormat'] = flatpickr_dateformat_string + " " + flatpickr_timeformat_string; |
156 |
options['dateFormat'] = flatpickr_dateformat_string + " " + flatpickr_timeformat_string; |
150 |
} |
157 |
} |
151 |
|
158 |
|
152 |
$(this).flatpickr(options); |
159 |
let fp = $(this).flatpickr(options); |
|
|
160 |
if ( refresh_max_date ) { |
161 |
/* Refresh the maxDate every 30 secondes to make sure the user will not |
162 |
be stuck with the minute passed */ |
163 |
setInterval(() => { fp.set("maxDate", new Date()) }, 30000); |
164 |
} |
153 |
}); |
165 |
}); |
154 |
}); |
166 |
}); |
155 |
</script> |
167 |
</script> |
156 |
- |
|
|