| @@ -1,4 +1,4 @@ | ||
| 1 | 1 | /* http://keith-wood.name/datepick.html |
| 2 | 2 | Datepicker for jQuery 3.7.1. |
| 3 | 3 | Written by Marc Grabanski ([email protected]) and |
| 4 | 4 | Keith Wood (kbwood{at}iinet.com.au). |
| @@ -155,9 +155,10 @@ | ||
| 155 | 155 | beforeShowDay: null, // Function that takes a date and returns an array with |
| 156 | 156 | // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or '', |
| 157 | 157 | // [2] = cell title (optional), e.g. $.datepick.noWeekends |
| 158 | 158 | onChangeMonthYear: null, // Define a callback function when the month or year is changed |
| 159 | - onHover: null, // Define a callback function when hovering over a day | |
| 159 | + onHover: null, // Define a callback function when hovering over a day | |
| 160 | + beforeSelectDay: null, // Optional (Date, instance) callback; false vetoes selection before any state change. | |
| 160 | 161 | onSelect: null, // Define a callback function when a date is selected |
| 161 | 162 | onClose: null, // Define a callback function when the datepicker is closed |
| 162 | 163 | altField: '', // Selector for an alternate field to store selected dates into |
| 163 | 164 | altFormat: '', // The date format to use for the alternate field |
| @@ -1144,11 +1145,16 @@ | ||
| 1144 | 1145 | var inst = this._getInst($(id)[0]); |
| 1145 | 1146 | var useTR = this._get(inst, 'useThemeRoller') ? 1 : 0; |
| 1146 | 1147 | if ($(td).hasClass(this._unselectableClass[useTR])) |
| 1147 | 1148 | return false; |
| 1148 | - var rangeSelect = this._get(inst, 'rangeSelect'); | |
| 1149 | - var multiSelect = this._get(inst, 'multiSelect'); | |
| 1150 | - if (rangeSelect) | |
| 1149 | + var rangeSelect = this._get(inst, 'rangeSelect'); | |
| 1150 | + var multiSelect = this._get(inst, 'multiSelect'); | |
| 1151 | + // Allow a domain validator to veto activation before native selection state changes. | |
| 1152 | + var beforeSelectDay = this._get(inst, 'beforeSelectDay'); | |
| 1153 | + if (beforeSelectDay && beforeSelectDay.apply((inst.input ? inst.input[0] : null), | |
| 1154 | + [this._daylightSavingAdjust(new Date(timestamp)), inst]) === false) | |
| 1155 | + return false; | |
| 1156 | + if (rangeSelect) | |
| 1151 | 1157 | inst.stayOpen = !inst.stayOpen; |
| 1152 | 1158 | else if (multiSelect) |
| 1153 | 1159 | inst.stayOpen = true; |
| 1154 | 1160 | if (inst.stayOpen) { |