flatpickr 4.5.2.1 → 4.5.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/lib/flatpickr/version.rb +1 -1
  3. data/vendor/assets/javascripts/flatpickr.js +2400 -2075
  4. data/vendor/assets/javascripts/flatpickr/l10n/ar.js +42 -20
  5. data/vendor/assets/javascripts/flatpickr/l10n/at.js +55 -20
  6. data/vendor/assets/javascripts/flatpickr/l10n/az.js +73 -0
  7. data/vendor/assets/javascripts/flatpickr/l10n/be.js +57 -22
  8. data/vendor/assets/javascripts/flatpickr/l10n/bg.js +55 -20
  9. data/vendor/assets/javascripts/flatpickr/l10n/bn.js +55 -20
  10. data/vendor/assets/javascripts/flatpickr/l10n/cat.js +71 -40
  11. data/vendor/assets/javascripts/flatpickr/l10n/cs.js +57 -22
  12. data/vendor/assets/javascripts/flatpickr/l10n/cy.js +81 -29
  13. data/vendor/assets/javascripts/flatpickr/l10n/da.js +57 -22
  14. data/vendor/assets/javascripts/flatpickr/l10n/de.js +55 -20
  15. data/vendor/assets/javascripts/flatpickr/l10n/default.js +62 -32
  16. data/vendor/assets/javascripts/flatpickr/l10n/eo.js +57 -22
  17. data/vendor/assets/javascripts/flatpickr/l10n/es.js +57 -22
  18. data/vendor/assets/javascripts/flatpickr/l10n/et.js +57 -22
  19. data/vendor/assets/javascripts/flatpickr/l10n/fa.js +57 -22
  20. data/vendor/assets/javascripts/flatpickr/l10n/fi.js +57 -22
  21. data/vendor/assets/javascripts/flatpickr/l10n/fo.js +73 -0
  22. data/vendor/assets/javascripts/flatpickr/l10n/fr.js +59 -23
  23. data/vendor/assets/javascripts/flatpickr/l10n/gr.js +57 -22
  24. data/vendor/assets/javascripts/flatpickr/l10n/he.js +49 -21
  25. data/vendor/assets/javascripts/flatpickr/l10n/hi.js +55 -20
  26. data/vendor/assets/javascripts/flatpickr/l10n/hr.js +55 -20
  27. data/vendor/assets/javascripts/flatpickr/l10n/hu.js +59 -23
  28. data/vendor/assets/javascripts/flatpickr/l10n/id.js +49 -22
  29. data/vendor/assets/javascripts/flatpickr/l10n/index.js +3147 -1036
  30. data/vendor/assets/javascripts/flatpickr/l10n/is.js +71 -0
  31. data/vendor/assets/javascripts/flatpickr/l10n/it.js +56 -23
  32. data/vendor/assets/javascripts/flatpickr/l10n/ja.js +55 -20
  33. data/vendor/assets/javascripts/flatpickr/l10n/km.js +57 -22
  34. data/vendor/assets/javascripts/flatpickr/l10n/ko.js +57 -22
  35. data/vendor/assets/javascripts/flatpickr/l10n/kz.js +57 -22
  36. data/vendor/assets/javascripts/flatpickr/l10n/lt.js +57 -22
  37. data/vendor/assets/javascripts/flatpickr/l10n/lv.js +55 -20
  38. data/vendor/assets/javascripts/flatpickr/l10n/mk.js +55 -20
  39. data/vendor/assets/javascripts/flatpickr/l10n/mn.js +47 -20
  40. data/vendor/assets/javascripts/flatpickr/l10n/ms.js +56 -21
  41. data/vendor/assets/javascripts/flatpickr/l10n/my.js +57 -22
  42. data/vendor/assets/javascripts/flatpickr/l10n/nl.js +59 -23
  43. data/vendor/assets/javascripts/flatpickr/l10n/no.js +57 -22
  44. data/vendor/assets/javascripts/flatpickr/l10n/pa.js +55 -20
  45. data/vendor/assets/javascripts/flatpickr/l10n/pl.js +57 -22
  46. data/vendor/assets/javascripts/flatpickr/l10n/pt.js +55 -20
  47. data/vendor/assets/javascripts/flatpickr/l10n/ro.js +57 -22
  48. data/vendor/assets/javascripts/flatpickr/l10n/ru.js +57 -22
  49. data/vendor/assets/javascripts/flatpickr/l10n/si.js +55 -20
  50. data/vendor/assets/javascripts/flatpickr/l10n/sk.js +57 -22
  51. data/vendor/assets/javascripts/flatpickr/l10n/sl.js +57 -22
  52. data/vendor/assets/javascripts/flatpickr/l10n/sq.js +55 -20
  53. data/vendor/assets/javascripts/flatpickr/l10n/sr-cyr.js +67 -0
  54. data/vendor/assets/javascripts/flatpickr/l10n/sr.js +55 -20
  55. data/vendor/assets/javascripts/flatpickr/l10n/sv.js +57 -22
  56. data/vendor/assets/javascripts/flatpickr/l10n/th.js +57 -22
  57. data/vendor/assets/javascripts/flatpickr/l10n/tr.js +57 -22
  58. data/vendor/assets/javascripts/flatpickr/l10n/uk.js +55 -20
  59. data/vendor/assets/javascripts/flatpickr/l10n/vn.js +55 -20
  60. data/vendor/assets/javascripts/flatpickr/l10n/zh-tw.js +68 -0
  61. data/vendor/assets/javascripts/flatpickr/l10n/zh.js +55 -20
  62. data/vendor/assets/javascripts/flatpickr/plugins/confirmDate/confirmDate.js +63 -35
  63. data/vendor/assets/javascripts/flatpickr/plugins/labelPlugin/labelPlugin.js +24 -26
  64. data/vendor/assets/javascripts/flatpickr/plugins/minMaxTimePlugin.js +229 -200
  65. data/vendor/assets/javascripts/flatpickr/plugins/monthSelect/monthSelect.js +68 -51
  66. data/vendor/assets/javascripts/flatpickr/plugins/rangePlugin.js +136 -141
  67. data/vendor/assets/javascripts/flatpickr/plugins/scrollPlugin.js +43 -49
  68. data/vendor/assets/javascripts/flatpickr/plugins/weekSelect/weekSelect.js +70 -67
  69. data/vendor/assets/stylesheets/flatpickr.css +12 -1
  70. data/vendor/assets/stylesheets/flatpickr/themes/airbnb.css +12 -1
  71. data/vendor/assets/stylesheets/flatpickr/themes/confetti.css +12 -1
  72. data/vendor/assets/stylesheets/flatpickr/themes/dark.css +12 -1
  73. data/vendor/assets/stylesheets/flatpickr/themes/light.css +12 -1
  74. data/vendor/assets/stylesheets/flatpickr/themes/material_blue.css +12 -1
  75. data/vendor/assets/stylesheets/flatpickr/themes/material_green.css +12 -1
  76. data/vendor/assets/stylesheets/flatpickr/themes/material_orange.css +12 -1
  77. data/vendor/assets/stylesheets/flatpickr/themes/material_red.css +12 -1
  78. metadata +7 -2
@@ -1,97 +1,86 @@
1
- /* flatpickr v4.5.2, @license MIT */
2
1
  (function (global, factory) {
3
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
- typeof define === 'function' && define.amd ? define(factory) :
5
- (global.minMaxTimePlugin = factory());
6
- }(this, (function () { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
+ typeof define === 'function' && define.amd ? define(factory) :
4
+ (global = global || self, global.minMaxTimePlugin = factory());
5
+ }(this, function () { 'use strict';
7
6
 
8
- var pad = function pad(number) {
9
- return ("0" + number).slice(-2);
10
- };
11
- var int = function int(bool) {
12
- return bool === true ? 1 : 0;
13
- };
7
+ var pad = function (number) { return ("0" + number).slice(-2); };
8
+ var int = function (bool) { return (bool === true ? 1 : 0); };
14
9
 
15
- var monthToStr = function monthToStr(monthNumber, shorthand, locale) {
16
- return locale.months[shorthand ? "shorthand" : "longhand"][monthNumber];
17
- };
18
- var formats = {
19
- Z: function Z(date) {
20
- return date.toISOString();
10
+ var monthToStr = function (monthNumber, shorthand, locale) { return locale.months[shorthand ? "shorthand" : "longhand"][monthNumber]; };
11
+ var formats = {
12
+ // get the date in UTC
13
+ Z: function (date) { return date.toISOString(); },
14
+ // weekday name, short, e.g. Thu
15
+ D: function (date, locale, options) {
16
+ return locale.weekdays.shorthand[formats.w(date, locale, options)];
21
17
  },
22
- D: function D(date, locale, options) {
23
- return locale.weekdays.shorthand[formats.w(date, locale, options)];
18
+ // full month name e.g. January
19
+ F: function (date, locale, options) {
20
+ return monthToStr(formats.n(date, locale, options) - 1, false, locale);
24
21
  },
25
- F: function F(date, locale, options) {
26
- return monthToStr(formats.n(date, locale, options) - 1, false, locale);
22
+ // padded hour 1-12
23
+ G: function (date, locale, options) {
24
+ return pad(formats.h(date, locale, options));
27
25
  },
28
- G: function G(date, locale, options) {
29
- return pad(formats.h(date, locale, options));
26
+ // hours with leading zero e.g. 03
27
+ H: function (date) { return pad(date.getHours()); },
28
+ // day (1-30) with ordinal suffix e.g. 1st, 2nd
29
+ J: function (date, locale) {
30
+ return locale.ordinal !== undefined
31
+ ? date.getDate() + locale.ordinal(date.getDate())
32
+ : date.getDate();
30
33
  },
31
- H: function H(date) {
32
- return pad(date.getHours());
34
+ // AM/PM
35
+ K: function (date, locale) { return locale.amPM[int(date.getHours() > 11)]; },
36
+ // shorthand month e.g. Jan, Sep, Oct, etc
37
+ M: function (date, locale) {
38
+ return monthToStr(date.getMonth(), true, locale);
33
39
  },
34
- J: function J(date, locale) {
35
- return locale.ordinal !== undefined ? date.getDate() + locale.ordinal(date.getDate()) : date.getDate();
40
+ // seconds 00-59
41
+ S: function (date) { return pad(date.getSeconds()); },
42
+ // unix timestamp
43
+ U: function (date) { return date.getTime() / 1000; },
44
+ W: function (date, _, options) {
45
+ return options.getWeek(date);
36
46
  },
37
- K: function K(date, locale) {
38
- return locale.amPM[int(date.getHours() > 11)];
47
+ // full year e.g. 2016
48
+ Y: function (date) { return date.getFullYear(); },
49
+ // day in month, padded (01-30)
50
+ d: function (date) { return pad(date.getDate()); },
51
+ // hour from 1-12 (am/pm)
52
+ h: function (date) { return (date.getHours() % 12 ? date.getHours() % 12 : 12); },
53
+ // minutes, padded with leading zero e.g. 09
54
+ i: function (date) { return pad(date.getMinutes()); },
55
+ // day in month (1-30)
56
+ j: function (date) { return date.getDate(); },
57
+ // weekday name, full, e.g. Thursday
58
+ l: function (date, locale) {
59
+ return locale.weekdays.longhand[date.getDay()];
39
60
  },
40
- M: function M(date, locale) {
41
- return monthToStr(date.getMonth(), true, locale);
42
- },
43
- S: function S(date) {
44
- return pad(date.getSeconds());
45
- },
46
- U: function U(date) {
47
- return date.getTime() / 1000;
48
- },
49
- W: function W(date, _, options) {
50
- return options.getWeek(date);
51
- },
52
- Y: function Y(date) {
53
- return date.getFullYear();
54
- },
55
- d: function d(date) {
56
- return pad(date.getDate());
57
- },
58
- h: function h(date) {
59
- return date.getHours() % 12 ? date.getHours() % 12 : 12;
60
- },
61
- i: function i(date) {
62
- return pad(date.getMinutes());
63
- },
64
- j: function j(date) {
65
- return date.getDate();
66
- },
67
- l: function l(date, locale) {
68
- return locale.weekdays.longhand[date.getDay()];
69
- },
70
- m: function m(date) {
71
- return pad(date.getMonth() + 1);
72
- },
73
- n: function n(date) {
74
- return date.getMonth() + 1;
75
- },
76
- s: function s(date) {
77
- return date.getSeconds();
78
- },
79
- w: function w(date) {
80
- return date.getDay();
81
- },
82
- y: function y(date) {
83
- return String(date.getFullYear()).substring(2);
84
- }
85
- };
61
+ // padded month number (01-12)
62
+ m: function (date) { return pad(date.getMonth() + 1); },
63
+ // the month number (1-12)
64
+ n: function (date) { return date.getMonth() + 1; },
65
+ // seconds 0-59
66
+ s: function (date) { return date.getSeconds(); },
67
+ // Unix Milliseconds
68
+ u: function (date) { return date.getTime(); },
69
+ // number of the day of the week
70
+ w: function (date) { return date.getDay(); },
71
+ // last two digits of year e.g. 16 for 2016
72
+ y: function (date) { return String(date.getFullYear()).substring(2); }
73
+ };
86
74
 
87
- var defaults = {
75
+ var defaults = {
88
76
  _disable: [],
89
77
  _enable: [],
90
78
  allowInput: false,
91
79
  altFormat: "F j, Y",
92
80
  altInput: false,
93
81
  altInputClass: "form-control input",
94
- animate: typeof window === "object" && window.navigator.userAgent.indexOf("MSIE") === -1,
82
+ animate: typeof window === "object" &&
83
+ window.navigator.userAgent.indexOf("MSIE") === -1,
95
84
  ariaDateFormat: "F j, Y",
96
85
  clickOpens: true,
97
86
  closeOnSelect: true,
@@ -105,10 +94,23 @@
105
94
  enable: [],
106
95
  enableSeconds: false,
107
96
  enableTime: false,
108
- errorHandler: function errorHandler(err) {
109
- return typeof console !== "undefined" && console.warn(err);
97
+ errorHandler: function (err) {
98
+ return typeof console !== "undefined" && console.warn(err);
99
+ },
100
+ getWeek: function (givenDate) {
101
+ var date = new Date(givenDate.getTime());
102
+ date.setHours(0, 0, 0, 0);
103
+ // Thursday in current week decides the year.
104
+ date.setDate(date.getDate() + 3 - ((date.getDay() + 6) % 7));
105
+ // January 4 is always in week 1.
106
+ var week1 = new Date(date.getFullYear(), 0, 4);
107
+ // Adjust to Thursday in week 1 and count number of weeks from date to week1.
108
+ return (1 +
109
+ Math.round(((date.getTime() - week1.getTime()) / 86400000 -
110
+ 3 +
111
+ ((week1.getDay() + 6) % 7)) /
112
+ 7));
110
113
  },
111
- getWeek: getWeek,
112
114
  hourIncrement: 1,
113
115
  ignoredFocusElements: [],
114
116
  inline: false,
@@ -140,36 +142,67 @@
140
142
  time_24hr: false,
141
143
  weekNumbers: false,
142
144
  wrap: false
143
- };
145
+ };
144
146
 
145
- var english = {
147
+ var english = {
146
148
  weekdays: {
147
- shorthand: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
148
- longhand: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
149
+ shorthand: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
150
+ longhand: [
151
+ "Sunday",
152
+ "Monday",
153
+ "Tuesday",
154
+ "Wednesday",
155
+ "Thursday",
156
+ "Friday",
157
+ "Saturday",
158
+ ]
149
159
  },
150
160
  months: {
151
- shorthand: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
152
- longhand: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
161
+ shorthand: [
162
+ "Jan",
163
+ "Feb",
164
+ "Mar",
165
+ "Apr",
166
+ "May",
167
+ "Jun",
168
+ "Jul",
169
+ "Aug",
170
+ "Sep",
171
+ "Oct",
172
+ "Nov",
173
+ "Dec",
174
+ ],
175
+ longhand: [
176
+ "January",
177
+ "February",
178
+ "March",
179
+ "April",
180
+ "May",
181
+ "June",
182
+ "July",
183
+ "August",
184
+ "September",
185
+ "October",
186
+ "November",
187
+ "December",
188
+ ]
153
189
  },
154
190
  daysInMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
155
191
  firstDayOfWeek: 0,
156
- ordinal: function ordinal(nth) {
157
- var s = nth % 100;
158
- if (s > 3 && s < 21) return "th";
159
-
160
- switch (s % 10) {
161
- case 1:
162
- return "st";
163
-
164
- case 2:
165
- return "nd";
166
-
167
- case 3:
168
- return "rd";
169
-
170
- default:
171
- return "th";
172
- }
192
+ ordinal: function (nth) {
193
+ var s = nth % 100;
194
+ if (s > 3 && s < 21)
195
+ return "th";
196
+ switch (s % 10) {
197
+ case 1:
198
+ return "st";
199
+ case 2:
200
+ return "nd";
201
+ case 3:
202
+ return "rd";
203
+ default:
204
+ return "th";
205
+ }
173
206
  },
174
207
  rangeSeparator: " to ",
175
208
  weekAbbreviation: "Wk",
@@ -177,116 +210,112 @@
177
210
  toggleTitle: "Click to toggle",
178
211
  amPM: ["AM", "PM"],
179
212
  yearAriaLabel: "Year"
180
- };
213
+ };
181
214
 
182
- var createDateFormatter = function createDateFormatter(_ref) {
183
- var _ref$config = _ref.config,
184
- config = _ref$config === void 0 ? defaults : _ref$config,
185
- _ref$l10n = _ref.l10n,
186
- l10n = _ref$l10n === void 0 ? english : _ref$l10n;
215
+ var createDateFormatter = function (_a) {
216
+ var _b = _a.config, config = _b === void 0 ? defaults : _b, _c = _a.l10n, l10n = _c === void 0 ? english : _c;
187
217
  return function (dateObj, frmt, overrideLocale) {
188
- var locale = overrideLocale || l10n;
189
-
190
- if (config.formatDate !== undefined) {
191
- return config.formatDate(dateObj, frmt, locale);
192
- }
193
-
194
- return frmt.split("").map(function (c, i, arr) {
195
- return formats[c] && arr[i - 1] !== "\\" ? formats[c](dateObj, locale, config) : c !== "\\" ? c : "";
196
- }).join("");
218
+ var locale = overrideLocale || l10n;
219
+ if (config.formatDate !== undefined) {
220
+ return config.formatDate(dateObj, frmt, locale);
221
+ }
222
+ return frmt
223
+ .split("")
224
+ .map(function (c, i, arr) {
225
+ return formats[c] && arr[i - 1] !== "\\"
226
+ ? formats[c](dateObj, locale, config)
227
+ : c !== "\\"
228
+ ? c
229
+ : "";
230
+ })
231
+ .join("");
197
232
  };
198
- };
199
- function compareDates(date1, date2, timeless) {
200
- if (timeless === void 0) {
201
- timeless = true;
202
- }
203
-
233
+ };
234
+ /**
235
+ * Compute the difference in dates, measured in ms
236
+ */
237
+ function compareDates(date1, date2, timeless) {
238
+ if (timeless === void 0) { timeless = true; }
204
239
  if (timeless !== false) {
205
- return new Date(date1.getTime()).setHours(0, 0, 0, 0) - new Date(date2.getTime()).setHours(0, 0, 0, 0);
240
+ return (new Date(date1.getTime()).setHours(0, 0, 0, 0) -
241
+ new Date(date2.getTime()).setHours(0, 0, 0, 0));
206
242
  }
207
-
208
243
  return date1.getTime() - date2.getTime();
209
- }
210
- function compareTimes(date1, date2) {
211
- return 3600 * (date1.getHours() - date2.getHours()) + 60 * (date1.getMinutes() - date2.getMinutes()) + date1.getSeconds() - date2.getSeconds();
212
- }
213
- var getWeek = function getWeek(givenDate) {
214
- var date = new Date(givenDate.getTime());
215
- date.setHours(0, 0, 0, 0);
216
- date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
217
- var week1 = new Date(date.getFullYear(), 0, 4);
218
- return 1 + Math.round(((date.getTime() - week1.getTime()) / 86400000 - 3 + (week1.getDay() + 6) % 7) / 7);
219
- };
220
-
221
- function minMaxTimePlugin(config) {
222
- if (config === void 0) {
223
- config = {};
224
- }
244
+ }
245
+ /**
246
+ * Compute the difference in times, measured in ms
247
+ */
248
+ function compareTimes(date1, date2) {
249
+ return (3600 * (date1.getHours() - date2.getHours()) +
250
+ 60 * (date1.getMinutes() - date2.getMinutes()) +
251
+ date1.getSeconds() -
252
+ date2.getSeconds());
253
+ }
225
254
 
255
+ function minMaxTimePlugin(config) {
256
+ if (config === void 0) { config = {}; }
226
257
  var state = {
227
- formatDate: createDateFormatter({}),
228
- tableDateFormat: config.tableDateFormat || "Y-m-d",
229
- defaults: {
230
- minTime: undefined,
231
- maxTime: undefined
232
- }
258
+ formatDate: createDateFormatter({}),
259
+ tableDateFormat: config.tableDateFormat || "Y-m-d",
260
+ defaults: {
261
+ minTime: undefined,
262
+ maxTime: undefined
263
+ }
233
264
  };
234
-
235
265
  function findDateTimeLimit(date) {
236
- if (config.table !== undefined) {
237
- return config.table[state.formatDate(date, state.tableDateFormat)];
238
- }
239
-
240
- return config.getTimeLimits && config.getTimeLimits(date);
266
+ if (config.table !== undefined) {
267
+ return config.table[state.formatDate(date, state.tableDateFormat)];
268
+ }
269
+ return config.getTimeLimits && config.getTimeLimits(date);
241
270
  }
242
-
243
271
  return function (fp) {
244
- return {
245
- onReady: function onReady() {
246
- state.formatDate = this.formatDate;
247
- state.defaults = {
248
- minTime: this.config.minTime && state.formatDate(this.config.minTime, "H:i"),
249
- maxTime: this.config.maxTime && state.formatDate(this.config.maxTime, "H:i")
250
- };
251
- },
252
- onChange: function onChange() {
253
- var latest = this.latestSelectedDateObj;
254
- var matchingTimeLimit = latest && findDateTimeLimit(latest);
255
-
256
- if (latest && matchingTimeLimit !== undefined) {
257
- this.set(matchingTimeLimit);
258
- fp.config.minTime.setFullYear(latest.getFullYear());
259
- fp.config.maxTime.setFullYear(latest.getFullYear());
260
- fp.config.minTime.setMonth(latest.getMonth());
261
- fp.config.maxTime.setMonth(latest.getMonth());
262
- fp.config.minTime.setDate(latest.getDate());
263
- fp.config.maxTime.setDate(latest.getDate());
264
-
265
- if (compareDates(latest, fp.config.maxTime, false) > 0) {
266
- fp.setDate(new Date(latest.getTime()).setHours(fp.config.maxTime.getHours(), fp.config.maxTime.getMinutes(), fp.config.maxTime.getSeconds(), fp.config.maxTime.getMilliseconds()), false);
267
- } else if (compareDates(latest, fp.config.minTime, false) < 0) fp.setDate(new Date(latest.getTime()).setHours(fp.config.minTime.getHours(), fp.config.minTime.getMinutes(), fp.config.minTime.getSeconds(), fp.config.minTime.getMilliseconds()), false);
268
- } else {
269
- var newMinMax = state.defaults || {
270
- minTime: undefined,
271
- maxTime: undefined
272
- };
273
- this.set(newMinMax);
274
- if (!latest) return;
275
- var _fp$config = fp.config,
276
- minTime = _fp$config.minTime,
277
- maxTime = _fp$config.maxTime;
278
-
279
- if (minTime && compareTimes(latest, minTime) < 0) {
280
- fp.setDate(new Date(latest.getTime()).setHours(minTime.getHours(), minTime.getMinutes(), minTime.getSeconds(), minTime.getMilliseconds()), false);
281
- } else if (maxTime && compareTimes(latest, maxTime) > 0) {
282
- fp.setDate(new Date(latest.getTime()).setHours(maxTime.getHours(), maxTime.getMinutes(), maxTime.getSeconds(), maxTime.getMilliseconds()));
272
+ return {
273
+ onReady: function () {
274
+ state.formatDate = this.formatDate;
275
+ state.defaults = {
276
+ minTime: this.config.minTime && state.formatDate(this.config.minTime, "H:i"),
277
+ maxTime: this.config.maxTime && state.formatDate(this.config.maxTime, "H:i")
278
+ };
279
+ },
280
+ onChange: function () {
281
+ var latest = this.latestSelectedDateObj;
282
+ var matchingTimeLimit = latest && findDateTimeLimit(latest);
283
+ if (latest && matchingTimeLimit !== undefined) {
284
+ this.set(matchingTimeLimit);
285
+ fp.config.minTime.setFullYear(latest.getFullYear());
286
+ fp.config.maxTime.setFullYear(latest.getFullYear());
287
+ fp.config.minTime.setMonth(latest.getMonth());
288
+ fp.config.maxTime.setMonth(latest.getMonth());
289
+ fp.config.minTime.setDate(latest.getDate());
290
+ fp.config.maxTime.setDate(latest.getDate());
291
+ if (compareDates(latest, fp.config.maxTime, false) > 0) {
292
+ fp.setDate(new Date(latest.getTime()).setHours(fp.config.maxTime.getHours(), fp.config.maxTime.getMinutes(), fp.config.maxTime.getSeconds(), fp.config.maxTime.getMilliseconds()), false);
293
+ }
294
+ else if (compareDates(latest, fp.config.minTime, false) < 0)
295
+ fp.setDate(new Date(latest.getTime()).setHours(fp.config.minTime.getHours(), fp.config.minTime.getMinutes(), fp.config.minTime.getSeconds(), fp.config.minTime.getMilliseconds()), false);
296
+ }
297
+ else {
298
+ var newMinMax = state.defaults || {
299
+ minTime: undefined,
300
+ maxTime: undefined
301
+ };
302
+ this.set(newMinMax);
303
+ if (!latest)
304
+ return;
305
+ var _a = fp.config, minTime = _a.minTime, maxTime = _a.maxTime;
306
+ if (minTime && compareTimes(latest, minTime) < 0) {
307
+ fp.setDate(new Date(latest.getTime()).setHours(minTime.getHours(), minTime.getMinutes(), minTime.getSeconds(), minTime.getMilliseconds()), false);
308
+ }
309
+ else if (maxTime && compareTimes(latest, maxTime) > 0) {
310
+ fp.setDate(new Date(latest.getTime()).setHours(maxTime.getHours(), maxTime.getMinutes(), maxTime.getSeconds(), maxTime.getMilliseconds()));
311
+ }
312
+ //
313
+ }
283
314
  }
284
- }
285
- }
286
- };
315
+ };
287
316
  };
288
- }
317
+ }
289
318
 
290
- return minMaxTimePlugin;
319
+ return minMaxTimePlugin;
291
320
 
292
- })));
321
+ }));