adt-js-components 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adt-js-components",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "JavaScript components for Nette framework",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -9,7 +9,9 @@ const locale = document.querySelector('html').getAttribute('lang');
9
9
  function initTime(input, options) {
10
10
  $(input).timepicker({
11
11
  scrollDefault: 'now',
12
- timeFormat: options.format
12
+ timeFormat: options.format,
13
+ minTime: options.minTime,
14
+ maxTime: options.maxTime
13
15
  });
14
16
  }
15
17
 
@@ -20,18 +22,19 @@ function initDate(input, options) {
20
22
  time_24hr: true,
21
23
  locale: require(`flatpickr/dist/l10n/${locale}.js`).default[locale],
22
24
  defaultDate: options.value,
23
- minDate: options.minDate
25
+ minDate: options.minDate ? new Date(options.minDate) : null,
26
+ maxDate: options.maxDate ? new Date(options.maxDate) : null
24
27
  });
25
28
  }
26
29
 
27
30
  function run(options) {
28
31
  $.nette.ext('live').after(function($el) {
29
32
  $el.find('[data-adt-date-input]').each(function() {
30
- var options = $(this).data('adt-date-input');
33
+ const data = $(this).data('adt-date-input');
34
+
35
+ const options = $(this).data('adt-date-input');
31
36
  options.type = $(this).attr('type');
32
- options.value = $(this).attr('value');
33
- options.minDate = $(this).data('min-date') !== undefined ? $(this).data('min-date') : null;
34
-
37
+
35
38
  $(this).attr('type', 'text');
36
39
  if (options.type === 'time') {
37
40
  initTime(this, options);