@wernfried/daterangepicker 4.17.1 → 4.17.2
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/API_Doc.md +28 -28
- package/README.md +5 -5
- package/dist/esm/daterangepicker.js +128 -118
- package/dist/esm/daterangepicker.min.js +2 -2
- package/dist/global/daterangepicker.js +128 -118
- package/dist/global/daterangepicker.min.js +2 -2
- package/package.json +1 -1
package/API_Doc.md
CHANGED
|
@@ -31,10 +31,6 @@ Useful to remove any manually added elements.</p>
|
|
|
31
31
|
<dt><a href="#event_hide.daterangepicker">"hide.daterangepicker" (this)</a></dt>
|
|
32
32
|
<dd><p>Emitted when the picker is hidden</p>
|
|
33
33
|
</dd>
|
|
34
|
-
<dt><a href="#event_outsideClick.daterangepicker">"outsideClick.daterangepicker" (this)</a></dt>
|
|
35
|
-
<dd><p>Emitted when user clicks outside the picker.
|
|
36
|
-
Use option <code>onOutsideClick</code> to define the default action, then you may not need to handle this event.</p>
|
|
37
|
-
</dd>
|
|
38
34
|
<dt><a href="#event_showCalendar.daterangepicker">"showCalendar.daterangepicker" (this)</a></dt>
|
|
39
35
|
<dd><p>Emitted when the calendar(s) are shown.
|
|
40
36
|
Only useful when <a href="#Ranges">Ranges</a> are used.</p>
|
|
@@ -43,19 +39,23 @@ Only useful when <a href="#Ranges">Ranges</a> are used.</p>
|
|
|
43
39
|
<dd><p>Emitted when the calendar(s) are hidden.
|
|
44
40
|
Only useful when <a href="#Ranges">Ranges</a> are used.</p>
|
|
45
41
|
</dd>
|
|
42
|
+
<dt><a href="#event_outsideClick.daterangepicker">"outsideClick.daterangepicker" (this)</a></dt>
|
|
43
|
+
<dd><p>Emitted when user clicks outside the picker.
|
|
44
|
+
Use option <code>onOutsideClick</code> to define the default action, then you may not need to handle this event.</p>
|
|
45
|
+
</dd>
|
|
46
46
|
<dt><a href="#event_dateChange.daterangepicker">"dateChange.daterangepicker" (this, side)</a></dt>
|
|
47
47
|
<dd><p>Emitted when the date changed. Does not trigger when time is changed,
|
|
48
48
|
use <a href="#event_timeChange.daterangepicker">"timeChange.daterangepicker"</a> to handle it</p>
|
|
49
49
|
</dd>
|
|
50
|
+
<dt><a href="#event_timeChange.daterangepicker">"timeChange.daterangepicker" (this, side)</a></dt>
|
|
51
|
+
<dd><p>Emitted when the time changed. Does not trigger when date is changed</p>
|
|
52
|
+
</dd>
|
|
50
53
|
<dt><a href="#event_apply.daterangepicker">"apply.daterangepicker" (this)</a></dt>
|
|
51
54
|
<dd><p>Emitted when the <code>Apply</code> button is clicked, or when a predefined <a href="#Ranges">Ranges</a> is clicked</p>
|
|
52
55
|
</dd>
|
|
53
56
|
<dt><a href="#event_cancel.daterangepicker">"cancel.daterangepicker" (this)</a></dt>
|
|
54
57
|
<dd><p>Emitted when the <code>Cancel</code> button is clicked</p>
|
|
55
58
|
</dd>
|
|
56
|
-
<dt><a href="#event_timeChange.daterangepicker">"timeChange.daterangepicker" (this, side)</a></dt>
|
|
57
|
-
<dd><p>Emitted when the time changed. Does not trigger when date is changed</p>
|
|
58
|
-
</dd>
|
|
59
59
|
<dt><a href="#event_inputChanged.daterangepicker">"inputChanged.daterangepicker" (this)</a></dt>
|
|
60
60
|
<dd><p>Emitted when the date is changed through <code><input></code> element. Event is only triggered when date string is valid and date value has changed</p>
|
|
61
61
|
</dd>
|
|
@@ -431,11 +431,11 @@ Emitted when the picker is hidden
|
|
|
431
431
|
| --- | --- | --- |
|
|
432
432
|
| this | [<code>DateRangePicker</code>](#DateRangePicker) | The daterangepicker object |
|
|
433
433
|
|
|
434
|
-
<a name="
|
|
434
|
+
<a name="event_showCalendar.daterangepicker"></a>
|
|
435
435
|
|
|
436
|
-
## "
|
|
437
|
-
Emitted when
|
|
438
|
-
|
|
436
|
+
## "showCalendar.daterangepicker" (this)
|
|
437
|
+
Emitted when the calendar(s) are shown.
|
|
438
|
+
Only useful when [Ranges](#Ranges) are used.
|
|
439
439
|
|
|
440
440
|
**Kind**: event emitted
|
|
441
441
|
|
|
@@ -443,10 +443,10 @@ Use option `onOutsideClick` to define the default action, then you may not need
|
|
|
443
443
|
| --- | --- | --- |
|
|
444
444
|
| this | [<code>DateRangePicker</code>](#DateRangePicker) | The daterangepicker object |
|
|
445
445
|
|
|
446
|
-
<a name="
|
|
446
|
+
<a name="event_hideCalendar.daterangepicker"></a>
|
|
447
447
|
|
|
448
|
-
## "
|
|
449
|
-
Emitted when the calendar(s) are
|
|
448
|
+
## "hideCalendar.daterangepicker" (this)
|
|
449
|
+
Emitted when the calendar(s) are hidden.
|
|
450
450
|
Only useful when [Ranges](#Ranges) are used.
|
|
451
451
|
|
|
452
452
|
**Kind**: event emitted
|
|
@@ -455,11 +455,11 @@ Only useful when [Ranges](#Ranges) are used.
|
|
|
455
455
|
| --- | --- | --- |
|
|
456
456
|
| this | [<code>DateRangePicker</code>](#DateRangePicker) | The daterangepicker object |
|
|
457
457
|
|
|
458
|
-
<a name="
|
|
458
|
+
<a name="event_outsideClick.daterangepicker"></a>
|
|
459
459
|
|
|
460
|
-
## "
|
|
461
|
-
Emitted when
|
|
462
|
-
|
|
460
|
+
## "outsideClick.daterangepicker" (this)
|
|
461
|
+
Emitted when user clicks outside the picker.
|
|
462
|
+
Use option `onOutsideClick` to define the default action, then you may not need to handle this event.
|
|
463
463
|
|
|
464
464
|
**Kind**: event emitted
|
|
465
465
|
|
|
@@ -480,21 +480,22 @@ use ["timeChange.daterangepicker"](#event_timeChange.daterangepicker) to handle
|
|
|
480
480
|
| this | [<code>DateRangePicker</code>](#DateRangePicker) | The daterangepicker object |
|
|
481
481
|
| side | <code>string</code> | Either `'start'` or `'end'` indicating whether startDate or endDate was changed. `null` when `singleDatePicker: true` |
|
|
482
482
|
|
|
483
|
-
<a name="
|
|
483
|
+
<a name="event_timeChange.daterangepicker"></a>
|
|
484
484
|
|
|
485
|
-
## "
|
|
486
|
-
Emitted when the
|
|
485
|
+
## "timeChange.daterangepicker" (this, side)
|
|
486
|
+
Emitted when the time changed. Does not trigger when date is changed
|
|
487
487
|
|
|
488
488
|
**Kind**: event emitted
|
|
489
489
|
|
|
490
490
|
| Param | Type | Description |
|
|
491
491
|
| --- | --- | --- |
|
|
492
492
|
| this | [<code>DateRangePicker</code>](#DateRangePicker) | The daterangepicker object |
|
|
493
|
+
| side | <code>string</code> | Either `'start'` or `'end'` indicating whether startDate or endDate was changed |
|
|
493
494
|
|
|
494
|
-
<a name="
|
|
495
|
+
<a name="event_apply.daterangepicker"></a>
|
|
495
496
|
|
|
496
|
-
## "
|
|
497
|
-
Emitted when the `
|
|
497
|
+
## "apply.daterangepicker" (this)
|
|
498
|
+
Emitted when the `Apply` button is clicked, or when a predefined [Ranges](#Ranges) is clicked
|
|
498
499
|
|
|
499
500
|
**Kind**: event emitted
|
|
500
501
|
|
|
@@ -502,17 +503,16 @@ Emitted when the `Cancel` button is clicked
|
|
|
502
503
|
| --- | --- | --- |
|
|
503
504
|
| this | [<code>DateRangePicker</code>](#DateRangePicker) | The daterangepicker object |
|
|
504
505
|
|
|
505
|
-
<a name="
|
|
506
|
+
<a name="event_cancel.daterangepicker"></a>
|
|
506
507
|
|
|
507
|
-
## "
|
|
508
|
-
Emitted when the
|
|
508
|
+
## "cancel.daterangepicker" (this)
|
|
509
|
+
Emitted when the `Cancel` button is clicked
|
|
509
510
|
|
|
510
511
|
**Kind**: event emitted
|
|
511
512
|
|
|
512
513
|
| Param | Type | Description |
|
|
513
514
|
| --- | --- | --- |
|
|
514
515
|
| this | [<code>DateRangePicker</code>](#DateRangePicker) | The daterangepicker object |
|
|
515
|
-
| side | <code>string</code> | Either `'start'` or `'end'` indicating whether startDate or endDate was changed |
|
|
516
516
|
|
|
517
517
|
<a name="event_inputChanged.daterangepicker"></a>
|
|
518
518
|
|
package/README.md
CHANGED
|
@@ -20,8 +20,8 @@ Above samples are based on the [original repository](https://github.com/dangross
|
|
|
20
20
|
```html
|
|
21
21
|
<script type="text/javascript" src="https://cdn.jsdelivr.net/jquery/latest/jquery.min.js"></script>
|
|
22
22
|
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/luxon@3.5.0/build/global/luxon.min.js"></script>
|
|
23
|
-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.17.
|
|
24
|
-
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.17.
|
|
23
|
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.17.2/dist/global/daterangepicker.min.js"></script>
|
|
24
|
+
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.17.2/css/daterangepicker.min.css" rel="stylesheet" />
|
|
25
25
|
|
|
26
26
|
<input type="text" id="picker" />
|
|
27
27
|
|
|
@@ -43,11 +43,11 @@ Above samples are based on the [original repository](https://github.com/dangross
|
|
|
43
43
|
"imports": {
|
|
44
44
|
"jquery": "https://cdn.jsdelivr.net/npm/jquery@4.0.0/+esm",
|
|
45
45
|
"luxon": "https://cdn.jsdelivr.net/npm/luxon@3.7.2/+esm",
|
|
46
|
-
"daterangepicker": "https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.17.
|
|
46
|
+
"daterangepicker": "https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.17.2/+esm"
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
</script>
|
|
50
|
-
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.17.
|
|
50
|
+
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.17.2/css/daterangepicker.min.css" rel="stylesheet" />
|
|
51
51
|
|
|
52
52
|
<input type="text" id="picker" />
|
|
53
53
|
|
|
@@ -68,7 +68,7 @@ Above samples are based on the [original repository](https://github.com/dangross
|
|
|
68
68
|
```html
|
|
69
69
|
<script ...></script>
|
|
70
70
|
<link type="text/css" href="https://cdn.jsdelivr.net/npm/bulma@1.0.4/css/bulma.min.css" rel="stylesheet" />
|
|
71
|
-
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.17.
|
|
71
|
+
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.17.2/css/daterangepicker.bulma.min.css" rel="stylesheet" />
|
|
72
72
|
|
|
73
73
|
<input type="text" id="picker" />
|
|
74
74
|
|
|
@@ -336,29 +336,16 @@ class DateRangePicker {
|
|
|
336
336
|
}
|
|
337
337
|
}
|
|
338
338
|
}
|
|
339
|
-
if (!this.timePicker) {
|
|
340
|
-
if (this.minDate)
|
|
341
|
-
this.minDate = this.minDate.startOf("day");
|
|
342
|
-
if (this.maxDate)
|
|
343
|
-
this.maxDate = this.maxDate.endOf("day");
|
|
344
|
-
}
|
|
345
339
|
if (this.singleDatePicker) {
|
|
346
340
|
this.#endDate = this.#startDate;
|
|
347
341
|
} else if (this.#endDate < this.#startDate) {
|
|
348
342
|
console.error(`Option 'endDate' ${this.#endDate} must not be earlier than 'startDate' ${this.#startDate}`);
|
|
349
343
|
}
|
|
350
|
-
if (
|
|
351
|
-
this.
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
} else if (!this.singleDatePicker && Array.isArray(options.altInput) && options.altInput.length === 2) {
|
|
356
|
-
this.altInput = options.altInput.every((x) => typeof x === "string" && $(x).is("input:text")) ? options.altInput : null;
|
|
357
|
-
} else {
|
|
358
|
-
const note = `Value of "altInput" must be ` + (this.singleDatePicker ? "a string" : "an array of two string elements");
|
|
359
|
-
console.error(`Option 'altInput' ${JSON.stringify(options.altInput)} is not valid
|
|
360
|
-
`, note);
|
|
361
|
-
}
|
|
344
|
+
if (!this.timePicker) {
|
|
345
|
+
if (this.minDate) this.minDate = this.minDate.startOf("day");
|
|
346
|
+
if (this.maxDate) this.maxDate = this.maxDate.endOf("day");
|
|
347
|
+
this.#startDate = this.#startDate.startOf("day");
|
|
348
|
+
this.#endDate = this.#endDate.endOf("day");
|
|
362
349
|
}
|
|
363
350
|
if (options.warnings !== void 0)
|
|
364
351
|
console.warn(`Option 'warnings' not used anymore. Listen to event 'violated.daterangepicker'`);
|
|
@@ -375,6 +362,8 @@ class DateRangePicker {
|
|
|
375
362
|
console.error(`Value of startDate "${this.#startDate}" violates ${vio.find((x) => x.reason.startsWith("isInvalid")).reason}`);
|
|
376
363
|
} else {
|
|
377
364
|
const newDate = vio.filter((x) => x.new != null).at(-1).new;
|
|
365
|
+
if (process.env.JEST_WORKER_ID == null)
|
|
366
|
+
console.warn(`Correcting startDate from ${this.#startDate} to ${newDate}`);
|
|
378
367
|
this.#startDate = newDate;
|
|
379
368
|
}
|
|
380
369
|
}
|
|
@@ -385,12 +374,27 @@ class DateRangePicker {
|
|
|
385
374
|
console.error(`Value of endDate "${this.#endDate}" violates ${vio.find((x) => x.reason.startsWith("isInvalid")).reason}`);
|
|
386
375
|
} else {
|
|
387
376
|
const newDate = vio.filter((x) => x.new != null).at(-1).new;
|
|
377
|
+
if (process.env.JEST_WORKER_ID == null)
|
|
378
|
+
console.warn(`Correcting endDate from ${this.#endDate} to ${newDate}`);
|
|
388
379
|
this.#endDate = newDate;
|
|
389
380
|
}
|
|
390
381
|
}
|
|
391
382
|
}
|
|
392
383
|
}
|
|
393
384
|
}
|
|
385
|
+
if (["function", "string"].includes(typeof options.altFormat))
|
|
386
|
+
this.altFormat = options.altFormat;
|
|
387
|
+
if (typeof options.altInput === "string" || Array.isArray(options.altInput)) {
|
|
388
|
+
if (this.singleDatePicker && typeof options.altInput === "string") {
|
|
389
|
+
this.altInput = $(options.altInput).is("input:text") ? options.altInput : null;
|
|
390
|
+
} else if (!this.singleDatePicker && Array.isArray(options.altInput) && options.altInput.length === 2) {
|
|
391
|
+
this.altInput = options.altInput.every((x) => typeof x === "string" && $(x).is("input:text")) ? options.altInput : null;
|
|
392
|
+
} else {
|
|
393
|
+
const note = `Value of "altInput" must be ` + (this.singleDatePicker ? "a string" : "an array of two string elements");
|
|
394
|
+
console.error(`Option 'altInput' ${JSON.stringify(options.altInput)} is not valid
|
|
395
|
+
`, note);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
394
398
|
if (typeof options.opens === "string") {
|
|
395
399
|
if (["left", "right", "center"].includes(options.opens))
|
|
396
400
|
this.opens = options.opens;
|
|
@@ -467,10 +471,6 @@ class DateRangePicker {
|
|
|
467
471
|
if (typeof cb === "function")
|
|
468
472
|
this.callback = cb;
|
|
469
473
|
if (!this.timePicker) {
|
|
470
|
-
if (this.#startDate)
|
|
471
|
-
this.#startDate = this.#startDate.startOf("day");
|
|
472
|
-
if (this.#endDate)
|
|
473
|
-
this.#endDate = this.#endDate.endOf("day");
|
|
474
474
|
this.container.find(".calendar-time").hide();
|
|
475
475
|
}
|
|
476
476
|
if (this.timePicker && this.autoApply)
|
|
@@ -532,6 +532,7 @@ class DateRangePicker {
|
|
|
532
532
|
set endDate(val) {
|
|
533
533
|
this.#endDate = val;
|
|
534
534
|
}
|
|
535
|
+
/* #region Set startDate/endDate */
|
|
535
536
|
/**
|
|
536
537
|
* Sets the date range picker's currently selected start date to the provided date.<br>
|
|
537
538
|
* `startDate` must be a `luxon.DateTime` or `Date` or `string` according to {@link ISO-8601} or a string matching `locale.format`.<br>
|
|
@@ -650,6 +651,7 @@ class DateRangePicker {
|
|
|
650
651
|
}
|
|
651
652
|
}
|
|
652
653
|
}
|
|
654
|
+
/* #endregion */
|
|
653
655
|
logDate(date) {
|
|
654
656
|
return this.timePicker ? date.toISO({ suppressMilliseconds: true }) : date.toISODate();
|
|
655
657
|
}
|
|
@@ -927,6 +929,7 @@ class DateRangePicker {
|
|
|
927
929
|
return result;
|
|
928
930
|
}
|
|
929
931
|
}
|
|
932
|
+
/* #region Rendering */
|
|
930
933
|
/**
|
|
931
934
|
* Updates the picker when calendar is initiated or any date has been selected.
|
|
932
935
|
* Could be useful after running {@link #DateRangePicker+setStartDate|setStartDate} or {@link #DateRangePicker+setEndDate|setRange}
|
|
@@ -1369,6 +1372,8 @@ class DateRangePicker {
|
|
|
1369
1372
|
this.container.find("button.applyBtn").prop("disabled", true);
|
|
1370
1373
|
}
|
|
1371
1374
|
}
|
|
1375
|
+
/* #endregion */
|
|
1376
|
+
/* #region Move/Show/Hide */
|
|
1372
1377
|
/**
|
|
1373
1378
|
* Place the picker at the right place in the document
|
|
1374
1379
|
* @private
|
|
@@ -1512,25 +1517,6 @@ class DateRangePicker {
|
|
|
1512
1517
|
}
|
|
1513
1518
|
}
|
|
1514
1519
|
/**
|
|
1515
|
-
* Closes the picker when user clicks outside
|
|
1516
|
-
* @param {external:jQuery} e - The Event target
|
|
1517
|
-
* @emits "outsideClick.daterangepicker"
|
|
1518
|
-
* @private
|
|
1519
|
-
*/
|
|
1520
|
-
outsideClick(e) {
|
|
1521
|
-
var target = $(e.target);
|
|
1522
|
-
if (
|
|
1523
|
-
// ie modal dialog fix
|
|
1524
|
-
e.type === "focusin" || target.closest(this.element).length || target.closest(this.container).length || target.closest(".calendar-table").length
|
|
1525
|
-
) return;
|
|
1526
|
-
if (this.onOutsideClick === "cancel") {
|
|
1527
|
-
this.#startDate = this.oldStartDate;
|
|
1528
|
-
this.#endDate = this.oldEndDate;
|
|
1529
|
-
}
|
|
1530
|
-
this.hide();
|
|
1531
|
-
this.element.trigger("outsideClick.daterangepicker", this);
|
|
1532
|
-
}
|
|
1533
|
-
/**
|
|
1534
1520
|
* Shows calendar when user selects "Custom Ranges"
|
|
1535
1521
|
* @emits "showCalendar.daterangepicker"
|
|
1536
1522
|
*/
|
|
@@ -1547,30 +1533,26 @@ class DateRangePicker {
|
|
|
1547
1533
|
this.container.removeClass("show-calendar");
|
|
1548
1534
|
this.element.trigger("hideCalendar.daterangepicker", this);
|
|
1549
1535
|
}
|
|
1536
|
+
/* #endregion */
|
|
1537
|
+
/* #region Handle mouse related events */
|
|
1550
1538
|
/**
|
|
1551
|
-
*
|
|
1539
|
+
* Closes the picker when user clicks outside
|
|
1552
1540
|
* @param {external:jQuery} e - The Event target
|
|
1541
|
+
* @emits "outsideClick.daterangepicker"
|
|
1553
1542
|
* @private
|
|
1554
1543
|
*/
|
|
1555
|
-
|
|
1556
|
-
var
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
this.
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
this.#startDate =
|
|
1563
|
-
this.#endDate =
|
|
1564
|
-
if (!this.timePicker) {
|
|
1565
|
-
this.#startDate.startOf("day");
|
|
1566
|
-
this.#endDate.endOf("day");
|
|
1567
|
-
}
|
|
1568
|
-
if (!this.alwaysShowCalendars)
|
|
1569
|
-
this.hideCalendars();
|
|
1570
|
-
if (this.element.triggerHandler("beforeHide.daterangepicker", this))
|
|
1571
|
-
this.updateView();
|
|
1572
|
-
this.clickApply();
|
|
1544
|
+
outsideClick(e) {
|
|
1545
|
+
var target = $(e.target);
|
|
1546
|
+
if (
|
|
1547
|
+
// ie modal dialog fix
|
|
1548
|
+
e.type === "focusin" || target.closest(this.element).length || target.closest(this.container).length || target.closest(".calendar-table").length
|
|
1549
|
+
) return;
|
|
1550
|
+
if (this.onOutsideClick === "cancel") {
|
|
1551
|
+
this.#startDate = this.oldStartDate;
|
|
1552
|
+
this.#endDate = this.oldEndDate;
|
|
1573
1553
|
}
|
|
1554
|
+
this.hide();
|
|
1555
|
+
this.element.trigger("outsideClick.daterangepicker", this);
|
|
1574
1556
|
}
|
|
1575
1557
|
/**
|
|
1576
1558
|
* Move calendar to previous month
|
|
@@ -1694,6 +1676,33 @@ class DateRangePicker {
|
|
|
1694
1676
|
$(el).removeClass("range-hover");
|
|
1695
1677
|
});
|
|
1696
1678
|
}
|
|
1679
|
+
/* #endregion */
|
|
1680
|
+
/* #region Select values by Mouse */
|
|
1681
|
+
/**
|
|
1682
|
+
* Set date values after user selected a date
|
|
1683
|
+
* @param {external:jQuery} e - The Event target
|
|
1684
|
+
* @private
|
|
1685
|
+
*/
|
|
1686
|
+
clickRange(e) {
|
|
1687
|
+
var label = e.target.getAttribute("data-range-key");
|
|
1688
|
+
this.chosenLabel = label;
|
|
1689
|
+
if (label == this.locale.customRangeLabel) {
|
|
1690
|
+
this.showCalendars();
|
|
1691
|
+
} else {
|
|
1692
|
+
var dates = this.ranges[label];
|
|
1693
|
+
this.#startDate = dates[0];
|
|
1694
|
+
this.#endDate = dates[1];
|
|
1695
|
+
if (!this.timePicker) {
|
|
1696
|
+
this.#startDate.startOf("day");
|
|
1697
|
+
this.#endDate.endOf("day");
|
|
1698
|
+
}
|
|
1699
|
+
if (!this.alwaysShowCalendars)
|
|
1700
|
+
this.hideCalendars();
|
|
1701
|
+
if (this.element.triggerHandler("beforeHide.daterangepicker", this))
|
|
1702
|
+
this.updateView();
|
|
1703
|
+
this.clickApply();
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1697
1706
|
/**
|
|
1698
1707
|
* User clicked a date
|
|
1699
1708
|
* @param {external:jQuery} e - The Event target
|
|
@@ -1808,64 +1817,6 @@ class DateRangePicker {
|
|
|
1808
1817
|
}
|
|
1809
1818
|
}
|
|
1810
1819
|
/**
|
|
1811
|
-
* User clicked `Apply` button
|
|
1812
|
-
* @emits "apply.daterangepicker"
|
|
1813
|
-
* @private
|
|
1814
|
-
*/
|
|
1815
|
-
clickApply() {
|
|
1816
|
-
this.hide();
|
|
1817
|
-
this.element.trigger("apply.daterangepicker", this);
|
|
1818
|
-
}
|
|
1819
|
-
/**
|
|
1820
|
-
* User clicked `Cancel` button
|
|
1821
|
-
* @emits "cancel.daterangepicker"
|
|
1822
|
-
* @private
|
|
1823
|
-
*/
|
|
1824
|
-
clickCancel() {
|
|
1825
|
-
this.#startDate = this.oldStartDate;
|
|
1826
|
-
this.#endDate = this.oldEndDate;
|
|
1827
|
-
this.hide();
|
|
1828
|
-
this.element.trigger("cancel.daterangepicker", this);
|
|
1829
|
-
}
|
|
1830
|
-
/**
|
|
1831
|
-
* Calender month moved
|
|
1832
|
-
* @param {external:jQuery} e - The Event target
|
|
1833
|
-
* @private
|
|
1834
|
-
*/
|
|
1835
|
-
monthOrYearChanged(e) {
|
|
1836
|
-
var isLeft = $(e.target).closest(".drp-calendar").hasClass("left"), leftOrRight = isLeft ? "left" : "right", cal = this.container.find(".drp-calendar." + leftOrRight);
|
|
1837
|
-
var month = parseInt(cal.find(".monthselect").val(), 10);
|
|
1838
|
-
var year = cal.find(".yearselect").val();
|
|
1839
|
-
if (!isLeft) {
|
|
1840
|
-
if (year < this.#startDate.year || year == this.#startDate.year && month < this.#startDate.month) {
|
|
1841
|
-
month = this.#startDate.month;
|
|
1842
|
-
year = this.#startDate.year;
|
|
1843
|
-
}
|
|
1844
|
-
}
|
|
1845
|
-
if (this.minDate) {
|
|
1846
|
-
if (year < this.minDate.year || year == this.minDate.year && month < this.minDate.month) {
|
|
1847
|
-
month = this.minDate.month;
|
|
1848
|
-
year = this.minDate.year;
|
|
1849
|
-
}
|
|
1850
|
-
}
|
|
1851
|
-
if (this.maxDate) {
|
|
1852
|
-
if (year > this.maxDate.year || year == this.maxDate.year && month > this.maxDate.month) {
|
|
1853
|
-
month = this.maxDate.month;
|
|
1854
|
-
year = this.maxDate.year;
|
|
1855
|
-
}
|
|
1856
|
-
}
|
|
1857
|
-
if (isLeft) {
|
|
1858
|
-
this.leftCalendar.month = this.leftCalendar.month.set({ year, month });
|
|
1859
|
-
if (this.linkedCalendars)
|
|
1860
|
-
this.rightCalendar.month = this.leftCalendar.month.plus({ month: 1 });
|
|
1861
|
-
} else {
|
|
1862
|
-
this.rightCalendar.month = this.rightCalendar.month.set({ year, month });
|
|
1863
|
-
if (this.linkedCalendars)
|
|
1864
|
-
this.leftCalendar.month = this.rightCalendar.month.minus({ month: 1 });
|
|
1865
|
-
}
|
|
1866
|
-
this.updateCalendars();
|
|
1867
|
-
}
|
|
1868
|
-
/**
|
|
1869
1820
|
* User clicked a time
|
|
1870
1821
|
* @param {external:jQuery} e - The Event target
|
|
1871
1822
|
* @emits "timeChange.daterangepicker"
|
|
@@ -1924,6 +1875,65 @@ class DateRangePicker {
|
|
|
1924
1875
|
this.element.trigger("timeChange.daterangepicker", [this, this.singleDatePicker ? null : side]);
|
|
1925
1876
|
}
|
|
1926
1877
|
/**
|
|
1878
|
+
* Calender month moved
|
|
1879
|
+
* @param {external:jQuery} e - The Event target
|
|
1880
|
+
* @private
|
|
1881
|
+
*/
|
|
1882
|
+
monthOrYearChanged(e) {
|
|
1883
|
+
var isLeft = $(e.target).closest(".drp-calendar").hasClass("left"), leftOrRight = isLeft ? "left" : "right", cal = this.container.find(".drp-calendar." + leftOrRight);
|
|
1884
|
+
var month = parseInt(cal.find(".monthselect").val(), 10);
|
|
1885
|
+
var year = cal.find(".yearselect").val();
|
|
1886
|
+
if (!isLeft) {
|
|
1887
|
+
if (year < this.#startDate.year || year == this.#startDate.year && month < this.#startDate.month) {
|
|
1888
|
+
month = this.#startDate.month;
|
|
1889
|
+
year = this.#startDate.year;
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
if (this.minDate) {
|
|
1893
|
+
if (year < this.minDate.year || year == this.minDate.year && month < this.minDate.month) {
|
|
1894
|
+
month = this.minDate.month;
|
|
1895
|
+
year = this.minDate.year;
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1898
|
+
if (this.maxDate) {
|
|
1899
|
+
if (year > this.maxDate.year || year == this.maxDate.year && month > this.maxDate.month) {
|
|
1900
|
+
month = this.maxDate.month;
|
|
1901
|
+
year = this.maxDate.year;
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
if (isLeft) {
|
|
1905
|
+
this.leftCalendar.month = this.leftCalendar.month.set({ year, month });
|
|
1906
|
+
if (this.linkedCalendars)
|
|
1907
|
+
this.rightCalendar.month = this.leftCalendar.month.plus({ month: 1 });
|
|
1908
|
+
} else {
|
|
1909
|
+
this.rightCalendar.month = this.rightCalendar.month.set({ year, month });
|
|
1910
|
+
if (this.linkedCalendars)
|
|
1911
|
+
this.leftCalendar.month = this.rightCalendar.month.minus({ month: 1 });
|
|
1912
|
+
}
|
|
1913
|
+
this.updateCalendars();
|
|
1914
|
+
}
|
|
1915
|
+
/**
|
|
1916
|
+
* User clicked `Apply` button
|
|
1917
|
+
* @emits "apply.daterangepicker"
|
|
1918
|
+
* @private
|
|
1919
|
+
*/
|
|
1920
|
+
clickApply() {
|
|
1921
|
+
this.hide();
|
|
1922
|
+
this.element.trigger("apply.daterangepicker", this);
|
|
1923
|
+
}
|
|
1924
|
+
/**
|
|
1925
|
+
* User clicked `Cancel` button
|
|
1926
|
+
* @emits "cancel.daterangepicker"
|
|
1927
|
+
* @private
|
|
1928
|
+
*/
|
|
1929
|
+
clickCancel() {
|
|
1930
|
+
this.#startDate = this.oldStartDate;
|
|
1931
|
+
this.#endDate = this.oldEndDate;
|
|
1932
|
+
this.hide();
|
|
1933
|
+
this.element.trigger("cancel.daterangepicker", this);
|
|
1934
|
+
}
|
|
1935
|
+
/* #endregion */
|
|
1936
|
+
/**
|
|
1927
1937
|
* Update the picker with value from `<input>` element.<br>
|
|
1928
1938
|
* Input values must be given in format of `locale.format`. Invalid values are handles by `violated.daterangepicker` Event
|
|
1929
1939
|
* @emits "inputChanged.daterangepicker"
|