inviton-powerduck 0.0.121 → 0.0.123
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.
|
@@ -1,24 +1,32 @@
|
|
|
1
1
|
import { arrayRemove } from '../../../common/utils/array-remove';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
if ((window as any).__powerduckBreakpointHandler == null) {
|
|
4
|
+
(window as any).__powerduckBreakpointHandler = {
|
|
5
|
+
_breakpointsBound: false,
|
|
6
|
+
_handlers: [],
|
|
7
|
+
};
|
|
8
|
+
}
|
|
3
9
|
|
|
4
10
|
export class BreakpointHandler {
|
|
5
|
-
private static
|
|
11
|
+
private static get handlers() {
|
|
12
|
+
return (window as any).__powerduckBreakpointHandler._handlers;
|
|
13
|
+
}
|
|
6
14
|
|
|
7
15
|
static addResizeHandler(handler: () => any) {
|
|
8
16
|
BreakpointHandler.bindResizeHandler();
|
|
9
|
-
BreakpointHandler.
|
|
17
|
+
BreakpointHandler.handlers.push(handler);
|
|
10
18
|
}
|
|
11
19
|
|
|
12
20
|
static removeResizeHandler(handler: () => any) {
|
|
13
|
-
arrayRemove(BreakpointHandler.
|
|
21
|
+
arrayRemove(BreakpointHandler.handlers, handler);
|
|
14
22
|
}
|
|
15
23
|
|
|
16
24
|
static bindResizeHandler() {
|
|
17
|
-
if (
|
|
25
|
+
if ((window as any).__powerduckBreakpointHandler._breakpointsBound == true) {
|
|
18
26
|
return;
|
|
19
27
|
}
|
|
20
28
|
|
|
21
|
-
|
|
29
|
+
(window as any).__powerduckBreakpointHandler._breakpointsBound = true;
|
|
22
30
|
window.addEventListener('resize', BreakpointHandler.onWindowHasResized);
|
|
23
31
|
BreakpointHandler.onWindowHasResized();
|
|
24
32
|
}
|
|
@@ -57,7 +65,7 @@ export class BreakpointHandler {
|
|
|
57
65
|
}
|
|
58
66
|
|
|
59
67
|
private static onWindowHasResized() {
|
|
60
|
-
for (const handler of BreakpointHandler.
|
|
68
|
+
for (const handler of BreakpointHandler.handlers) {
|
|
61
69
|
try {
|
|
62
70
|
handler();
|
|
63
71
|
} catch (error) {
|
|
@@ -59,7 +59,7 @@ export interface DaterangeChangedArgs {
|
|
|
59
59
|
endTime: DateWrapper;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
const DATE_FORMAT_FOR_RANGE_PICKER = (
|
|
62
|
+
const DATE_FORMAT_FOR_RANGE_PICKER = (() => {
|
|
63
63
|
const dummyDate = new Date(Date.UTC(
|
|
64
64
|
2022,
|
|
65
65
|
11,
|
|
@@ -488,6 +488,18 @@ class DaterangePickerComponent extends TsxComponent<DaterangePickerArgs> impleme
|
|
|
488
488
|
});
|
|
489
489
|
}
|
|
490
490
|
|
|
491
|
+
shouldAddModalClick() {
|
|
492
|
+
if (!PortalUtils.treatAsMobileDevice()) {
|
|
493
|
+
return false;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
if (this.calendarPlacement == 'input-container-leftalign' || this.calendarPlacement == 'input-container-rightalign') {
|
|
497
|
+
return false;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
return true;
|
|
501
|
+
}
|
|
502
|
+
|
|
491
503
|
clearValue() {
|
|
492
504
|
this._startDate = null;
|
|
493
505
|
this._endDate = null;
|
|
@@ -500,8 +512,9 @@ class DaterangePickerComponent extends TsxComponent<DaterangePickerArgs> impleme
|
|
|
500
512
|
render(h) {
|
|
501
513
|
return (
|
|
502
514
|
<FormItemWrapper label={this.label} cssClass={this.getCssClass()} mandatory={this.mandatory} wrap={this.wrap} appendIcon={this.appendIcon} prependIcon={this.prependIcon} hint={this.hint} marginType={this.marginType} appendClicked={this.appendClicked} prependClicked={this.prependClicked} prependIconClicked={this.prependIconClicked} appendIconClicked={this.appendIconClicked} validationState={this.validationState} labelButtons={this.labelButtons} subtitle={this.subtitle}>
|
|
503
|
-
{
|
|
504
|
-
|
|
515
|
+
{this.shouldAddModalClick()
|
|
516
|
+
&& <div class="pd-daterange-picker-modalclick" onClick={(e) => { this.handleModalOpenClick(e); }}></div>}
|
|
517
|
+
|
|
505
518
|
<div style="position: relative; display: flex; align-items: center;">
|
|
506
519
|
{' '}
|
|
507
520
|
{/* Added a wrapper for input and clear button */}
|
|
@@ -337,20 +337,15 @@ import './daterangepicker.css';
|
|
|
337
337
|
selectBackward: false,
|
|
338
338
|
applyBtnClass: '',
|
|
339
339
|
singleMonth: 'auto',
|
|
340
|
-
hoveringTooltip(
|
|
340
|
+
hoveringTooltip: (
|
|
341
341
|
days,
|
|
342
342
|
startTime,
|
|
343
343
|
hoveringTime,
|
|
344
|
-
) {
|
|
345
|
-
return days > 1 ? `${days} ${translate('days')}` : '';
|
|
346
|
-
},
|
|
344
|
+
) => days > 1 ? `${days} ${translate('days')}` : '',
|
|
347
345
|
showTopbar: true,
|
|
348
346
|
swapTime: false,
|
|
349
347
|
showWeekNumbers: false,
|
|
350
|
-
getWeekNumber
|
|
351
|
-
{
|
|
352
|
-
return DateUtils.getWeekNumber(date);
|
|
353
|
-
},
|
|
348
|
+
getWeekNumber: date => DateUtils.getWeekNumber(date),
|
|
354
349
|
customOpenAnimation: null,
|
|
355
350
|
customCloseAnimation: null,
|
|
356
351
|
customArrowPrevSymbol: null,
|
|
@@ -434,11 +429,11 @@ import './daterangepicker.css';
|
|
|
434
429
|
);
|
|
435
430
|
return this;
|
|
436
431
|
},
|
|
437
|
-
setDateRange(
|
|
432
|
+
setDateRange: (
|
|
438
433
|
d1,
|
|
439
434
|
d2,
|
|
440
435
|
silent,
|
|
441
|
-
) {
|
|
436
|
+
) => {
|
|
442
437
|
if (typeof d1 == 'string' && typeof d2 == 'string') {
|
|
443
438
|
d1 = DateUtils.getDateWrapperFromFormat(d1, opt.format);
|
|
444
439
|
d2 = DateUtils.getDateWrapperFromFormat(d2, opt.format);
|
|
@@ -457,7 +452,7 @@ import './daterangepicker.css';
|
|
|
457
452
|
redraw: redrawDatePicker,
|
|
458
453
|
getDatePicker,
|
|
459
454
|
resetMonthsView,
|
|
460
|
-
destroy() {
|
|
455
|
+
destroy: () => {
|
|
461
456
|
$(self).unbind('.datepicker');
|
|
462
457
|
$(self).data('dateRangePicker', '');
|
|
463
458
|
$(self).data('date-picker-opened', null);
|
|
@@ -471,22 +466,16 @@ import './daterangepicker.css';
|
|
|
471
466
|
|
|
472
467
|
return this;
|
|
473
468
|
|
|
474
|
-
|
|
475
|
-
return (box != null && box.hasClass('date-range-picker-modalmode')) || $(window).width() <= 992;
|
|
476
|
-
}
|
|
469
|
+
const isModalDisplayMode = () => (box != null && box.hasClass('date-range-picker-modalmode')) || $(window).width() <= 992;
|
|
477
470
|
|
|
478
|
-
|
|
479
|
-
return (selfObj.contains(evt.target) || evt.target == selfObj || (selfObj.childNodes != undefined && $.inArray(evt.target, selfObj.childNodes) >= 0));
|
|
480
|
-
}
|
|
471
|
+
const IsOwnDatePickerClicked = (evt, selfObj) => selfObj.contains(evt.target) || evt.target == selfObj || (selfObj.childNodes != undefined && $.inArray(evt.target, selfObj.childNodes) >= 0);
|
|
481
472
|
|
|
482
|
-
|
|
473
|
+
const ensurePickerOpen = () => {
|
|
483
474
|
const isOpen = box.is(':visible');
|
|
484
475
|
if (!isOpen) { open(opt.duration); }
|
|
485
|
-
}
|
|
476
|
+
};
|
|
486
477
|
|
|
487
|
-
|
|
488
|
-
return (opt.calendarPlacement == 'body' || opt.calendarPlacement == null);
|
|
489
|
-
}
|
|
478
|
+
const isPlacedInBody = () => opt.calendarPlacement == 'body' || opt.calendarPlacement == null;
|
|
490
479
|
|
|
491
480
|
function init_datepicker(this: any) {
|
|
492
481
|
const self = this;
|
|
@@ -567,7 +556,7 @@ import './daterangepicker.css';
|
|
|
567
556
|
if (!opt.stickyMonths) { gotoNextMonth(this); } else { gotoNextMonth_stickily(this); }
|
|
568
557
|
});
|
|
569
558
|
|
|
570
|
-
|
|
559
|
+
const gotoNextMonth = (self) => {
|
|
571
560
|
const isMonth2 = $(self).parents('table').hasClass('month2');
|
|
572
561
|
let month = isMonth2 ? opt.month2 : opt.month1;
|
|
573
562
|
month = nextMonth(month);
|
|
@@ -586,9 +575,9 @@ import './daterangepicker.css';
|
|
|
586
575
|
}
|
|
587
576
|
|
|
588
577
|
showGap();
|
|
589
|
-
}
|
|
578
|
+
};
|
|
590
579
|
|
|
591
|
-
|
|
580
|
+
const gotoNextMonth_stickily = (self) => {
|
|
592
581
|
const nextMonth1 = nextMonth(opt.month1);
|
|
593
582
|
const nextMonth2 = nextMonth(opt.month2);
|
|
594
583
|
if (isMonthOutOfBounds(nextMonth2)) { return; }
|
|
@@ -598,13 +587,13 @@ import './daterangepicker.css';
|
|
|
598
587
|
showMonth(nextMonth1, 'month1');
|
|
599
588
|
showMonth(nextMonth2, 'month2');
|
|
600
589
|
showSelectedDays();
|
|
601
|
-
}
|
|
590
|
+
};
|
|
602
591
|
|
|
603
592
|
box.find('.prev').click(function (this: any) {
|
|
604
593
|
if (!opt.stickyMonths) { gotoPrevMonth(this); } else { gotoPrevMonth_stickily(this); }
|
|
605
594
|
});
|
|
606
595
|
|
|
607
|
-
|
|
596
|
+
const gotoPrevMonth = (self) => {
|
|
608
597
|
const isMonth2 = $(self).parents('table').hasClass('month2');
|
|
609
598
|
let month = isMonth2 ? opt.month2 : opt.month1;
|
|
610
599
|
month = prevMonth(month);
|
|
@@ -623,9 +612,9 @@ import './daterangepicker.css';
|
|
|
623
612
|
}
|
|
624
613
|
|
|
625
614
|
showGap();
|
|
626
|
-
}
|
|
615
|
+
};
|
|
627
616
|
|
|
628
|
-
|
|
617
|
+
const gotoPrevMonth_stickily = (self) => {
|
|
629
618
|
const prevMonth1 = prevMonth(opt.month1);
|
|
630
619
|
const prevMonth2 = prevMonth(opt.month2);
|
|
631
620
|
if (isMonthOutOfBounds(prevMonth1)) { return; }
|
|
@@ -635,7 +624,7 @@ import './daterangepicker.css';
|
|
|
635
624
|
showMonth(prevMonth2, 'month2');
|
|
636
625
|
showMonth(prevMonth1, 'month1');
|
|
637
626
|
showSelectedDays();
|
|
638
|
-
}
|
|
627
|
+
};
|
|
639
628
|
|
|
640
629
|
box.attr('unselectable', 'on')
|
|
641
630
|
.css('user-select', 'none')
|
|
@@ -760,7 +749,7 @@ import './daterangepicker.css';
|
|
|
760
749
|
});
|
|
761
750
|
}
|
|
762
751
|
|
|
763
|
-
|
|
752
|
+
const calcPosition = () => {
|
|
764
753
|
if (isPlacedInBody()) {
|
|
765
754
|
const offset = $(self).offset();
|
|
766
755
|
if (opt.leftOffset != null) {
|
|
@@ -824,22 +813,22 @@ import './daterangepicker.css';
|
|
|
824
813
|
box.find('.time1').insertBefore(box.find('.time2'));
|
|
825
814
|
}
|
|
826
815
|
}
|
|
827
|
-
}
|
|
816
|
+
};
|
|
828
817
|
|
|
829
|
-
|
|
818
|
+
const setModalDisplayMode = () => {
|
|
830
819
|
if (!box.hasClass('date-range-picker-modalmode')) {
|
|
831
820
|
box.addClass('date-range-picker-modalmode');
|
|
832
821
|
}
|
|
833
|
-
}
|
|
822
|
+
};
|
|
834
823
|
|
|
835
|
-
|
|
824
|
+
const removeModalDisplayMode = () => {
|
|
836
825
|
if (box.hasClass('date-range-picker-modalmode')) {
|
|
837
826
|
box.removeClass('date-range-picker-modalmode');
|
|
838
827
|
updateCalendarWidth();
|
|
839
828
|
}
|
|
840
|
-
}
|
|
829
|
+
};
|
|
841
830
|
|
|
842
|
-
|
|
831
|
+
const setDisplayMode = () => {
|
|
843
832
|
let displayMode = 'below-input';
|
|
844
833
|
if (opt.displayMode != null) {
|
|
845
834
|
displayMode = opt.displayMode() || 'below-input';
|
|
@@ -852,14 +841,12 @@ import './daterangepicker.css';
|
|
|
852
841
|
}
|
|
853
842
|
|
|
854
843
|
box.attr('data-displaymode', displayMode);
|
|
855
|
-
}
|
|
844
|
+
};
|
|
856
845
|
|
|
857
846
|
// Return the date picker wrapper element
|
|
858
|
-
|
|
859
|
-
return box;
|
|
860
|
-
}
|
|
847
|
+
const getDatePicker = () => box;
|
|
861
848
|
|
|
862
|
-
|
|
849
|
+
const open = (animationTime) => {
|
|
863
850
|
setDisplayMode();
|
|
864
851
|
calcPosition();
|
|
865
852
|
redrawDatePicker();
|
|
@@ -884,9 +871,9 @@ import './daterangepicker.css';
|
|
|
884
871
|
});
|
|
885
872
|
showGap();
|
|
886
873
|
updateCalendarWidth();
|
|
887
|
-
}
|
|
874
|
+
};
|
|
888
875
|
|
|
889
|
-
|
|
876
|
+
const checkAndSetDefaultValue = () => {
|
|
890
877
|
const __default_string = opt.getValue.call(selfDom);
|
|
891
878
|
const defaults = __default_string ? __default_string.split(opt.separator) : '';
|
|
892
879
|
|
|
@@ -910,17 +897,17 @@ import './daterangepicker.css';
|
|
|
910
897
|
|
|
911
898
|
initiated = true;
|
|
912
899
|
}
|
|
913
|
-
}
|
|
900
|
+
};
|
|
914
901
|
|
|
915
|
-
|
|
902
|
+
const getValidValue = (date: string, format: string) => {
|
|
916
903
|
try {
|
|
917
904
|
return DateUtils.getDateWrapperFromFormat(date, format);
|
|
918
905
|
} catch (error) {
|
|
919
906
|
return DateWrapper.getCurrent();
|
|
920
907
|
}
|
|
921
|
-
}
|
|
908
|
+
};
|
|
922
909
|
|
|
923
|
-
|
|
910
|
+
const calculateCalendarWidth = () => {
|
|
924
911
|
const w1 = box.find('.month1').width();
|
|
925
912
|
const w2 = opt.singleMonth == true ? 0 : box.find('.gap').outerWidth(true);
|
|
926
913
|
const w3 = opt.singleMonth == true ? 0 : box.find('.month2').width();
|
|
@@ -932,18 +919,18 @@ import './daterangepicker.css';
|
|
|
932
919
|
}
|
|
933
920
|
|
|
934
921
|
return retVal;
|
|
935
|
-
}
|
|
922
|
+
};
|
|
936
923
|
|
|
937
|
-
|
|
924
|
+
const updateCalendarWidth = () => {
|
|
938
925
|
if (isModalDisplayMode()) {
|
|
939
926
|
box.find('.month-wrapper').css('width', '');
|
|
940
927
|
return;
|
|
941
928
|
}
|
|
942
929
|
|
|
943
930
|
box.find('.month-wrapper').width(calculateCalendarWidth());
|
|
944
|
-
}
|
|
931
|
+
};
|
|
945
932
|
|
|
946
|
-
|
|
933
|
+
const renderTime = (name: 'time1' | 'time2', date: DateWrapper) => {
|
|
947
934
|
box.find(`.${name} input[type=range].hour-range`).val(date.getHours());
|
|
948
935
|
box.find(`.${name} input[type=range].minute-range`).val(date.getMinutes());
|
|
949
936
|
setTime(
|
|
@@ -951,28 +938,32 @@ import './daterangepicker.css';
|
|
|
951
938
|
getHourString(date),
|
|
952
939
|
getMinuteString(date),
|
|
953
940
|
);
|
|
954
|
-
}
|
|
941
|
+
};
|
|
942
|
+
|
|
943
|
+
const changeTime = (name: 'start' | 'end', date: DateWrapper) => {
|
|
944
|
+
if ((date as any)._dte == null) {
|
|
945
|
+
date = new DateWrapper(date);
|
|
946
|
+
}
|
|
955
947
|
|
|
956
|
-
function changeTime(name: 'start' | 'end', date: DateWrapper) {
|
|
957
948
|
opt[name] = new DateWrapper(
|
|
958
949
|
date.getFullYear(),
|
|
959
950
|
date.getMonth(),
|
|
960
951
|
date.getDate(),
|
|
961
952
|
Number((opt[`${name}Time`] as DateWrapper).getHours()),
|
|
962
953
|
Number((opt[`${name}Time`] as DateWrapper).getMinutes()),
|
|
963
|
-
);
|
|
964
|
-
}
|
|
954
|
+
).getTime();
|
|
955
|
+
};
|
|
965
956
|
|
|
966
|
-
|
|
957
|
+
const swapTime = () => {
|
|
967
958
|
renderTime('time1', opt.start);
|
|
968
959
|
renderTime('time2', opt.end);
|
|
969
|
-
}
|
|
960
|
+
};
|
|
970
961
|
|
|
971
|
-
|
|
962
|
+
const setTime = (
|
|
972
963
|
name: 'time1' | 'time2',
|
|
973
964
|
hour: string,
|
|
974
965
|
minute: string,
|
|
975
|
-
) {
|
|
966
|
+
) => {
|
|
976
967
|
hour && (box.find(`.${name} .hour-val`).text(hour));
|
|
977
968
|
minute && (box.find(`.${name} .minute-val`).text(minute));
|
|
978
969
|
switch (name) {
|
|
@@ -992,7 +983,7 @@ import './daterangepicker.css';
|
|
|
992
983
|
break;
|
|
993
984
|
}
|
|
994
985
|
|
|
995
|
-
|
|
986
|
+
const setRange = (name: 'start' | 'startTime' | 'end' | 'endTime', timePoint: DateWrapper) => {
|
|
996
987
|
opt[name] = new DateWrapper(
|
|
997
988
|
timePoint.getFullYear(),
|
|
998
989
|
timePoint.getMonth(),
|
|
@@ -1000,13 +991,13 @@ import './daterangepicker.css';
|
|
|
1000
991
|
Number(hour || getHourString(timePoint)),
|
|
1001
992
|
Number(minute || getMinuteString(timePoint)),
|
|
1002
993
|
);
|
|
1003
|
-
}
|
|
994
|
+
};
|
|
1004
995
|
checkSelectionValid();
|
|
1005
996
|
showSelectedInfo();
|
|
1006
997
|
showSelectedDays();
|
|
1007
|
-
}
|
|
998
|
+
};
|
|
1008
999
|
|
|
1009
|
-
|
|
1000
|
+
const clearSelection = () => {
|
|
1010
1001
|
opt.start = false;
|
|
1011
1002
|
opt.end = false;
|
|
1012
1003
|
box.find('.day.checked').removeClass('checked');
|
|
@@ -1016,9 +1007,9 @@ import './daterangepicker.css';
|
|
|
1016
1007
|
checkSelectionValid();
|
|
1017
1008
|
showSelectedInfo();
|
|
1018
1009
|
showSelectedDays();
|
|
1019
|
-
}
|
|
1010
|
+
};
|
|
1020
1011
|
|
|
1021
|
-
|
|
1012
|
+
const handleStart = (time: number): number => {
|
|
1022
1013
|
let r = time;
|
|
1023
1014
|
const date = new DateWrapper(time);
|
|
1024
1015
|
|
|
@@ -1058,9 +1049,9 @@ import './daterangepicker.css';
|
|
|
1058
1049
|
}
|
|
1059
1050
|
|
|
1060
1051
|
return r;
|
|
1061
|
-
}
|
|
1052
|
+
};
|
|
1062
1053
|
|
|
1063
|
-
|
|
1054
|
+
const handleEnd = (time: number): number => {
|
|
1064
1055
|
let r = time;
|
|
1065
1056
|
const date = new DateWrapper(time);
|
|
1066
1057
|
|
|
@@ -1101,9 +1092,9 @@ import './daterangepicker.css';
|
|
|
1101
1092
|
}
|
|
1102
1093
|
|
|
1103
1094
|
return r;
|
|
1104
|
-
}
|
|
1095
|
+
};
|
|
1105
1096
|
|
|
1106
|
-
|
|
1097
|
+
const dayClicked = (day) => {
|
|
1107
1098
|
if (day.hasClass('invalid')) { return; }
|
|
1108
1099
|
|
|
1109
1100
|
const time = Number(day.attr('time'));
|
|
@@ -1269,9 +1260,9 @@ import './daterangepicker.css';
|
|
|
1269
1260
|
showSelectedInfo();
|
|
1270
1261
|
showSelectedDays();
|
|
1271
1262
|
autoclose();
|
|
1272
|
-
}
|
|
1263
|
+
};
|
|
1273
1264
|
|
|
1274
|
-
|
|
1265
|
+
const weekNumberClicked = (weekNumberDom) => {
|
|
1275
1266
|
// Implement into native once needed
|
|
1276
1267
|
|
|
1277
1268
|
// var thisTime = parseInt(weekNumberDom.attr('data-start-time'), 10);
|
|
@@ -1295,9 +1286,9 @@ import './daterangepicker.css';
|
|
|
1295
1286
|
showSelectedInfo();
|
|
1296
1287
|
showSelectedDays();
|
|
1297
1288
|
autoclose();
|
|
1298
|
-
}
|
|
1289
|
+
};
|
|
1299
1290
|
|
|
1300
|
-
|
|
1291
|
+
const isValidTime = (time) => {
|
|
1301
1292
|
time = parseInt(time, 10);
|
|
1302
1293
|
if (opt.startDate && compare_day(time, opt.startDate) < 0) { return false; }
|
|
1303
1294
|
|
|
@@ -1336,7 +1327,7 @@ import './daterangepicker.css';
|
|
|
1336
1327
|
}
|
|
1337
1328
|
|
|
1338
1329
|
return true;
|
|
1339
|
-
}
|
|
1330
|
+
};
|
|
1340
1331
|
|
|
1341
1332
|
function updateSelectableRange() {
|
|
1342
1333
|
box.find('.day.invalid.tmp').removeClass('tmp invalid').addClass('valid');
|
|
@@ -1443,12 +1434,12 @@ import './daterangepicker.css';
|
|
|
1443
1434
|
}
|
|
1444
1435
|
}
|
|
1445
1436
|
|
|
1446
|
-
|
|
1437
|
+
const clearHovering = () => {
|
|
1447
1438
|
box.find('.day.hovering').removeClass('hovering');
|
|
1448
1439
|
box.find('.date-range-length-tip').hide();
|
|
1449
|
-
}
|
|
1440
|
+
};
|
|
1450
1441
|
|
|
1451
|
-
|
|
1442
|
+
const autoclose = () => {
|
|
1452
1443
|
if (opt.singleDate === true) {
|
|
1453
1444
|
if (initiated && opt.start) {
|
|
1454
1445
|
if (opt.autoClose) { closeDatePicker(); }
|
|
@@ -1458,9 +1449,9 @@ import './daterangepicker.css';
|
|
|
1458
1449
|
if (opt.autoClose) { closeDatePicker(); }
|
|
1459
1450
|
}
|
|
1460
1451
|
}
|
|
1461
|
-
}
|
|
1452
|
+
};
|
|
1462
1453
|
|
|
1463
|
-
|
|
1454
|
+
const checkSelectionValid = () => {
|
|
1464
1455
|
const days = Math.ceil((opt.end - opt.start) / 86400000) + 1;
|
|
1465
1456
|
if (opt.singleDate) { // Validate if only start is there
|
|
1466
1457
|
if (opt.start && !opt.end) { box.find('.drp_top-bar').removeClass('error').addClass('normal'); } else { box.find('.drp_top-bar').removeClass('error').removeClass('normal'); }
|
|
@@ -1494,9 +1485,9 @@ import './daterangepicker.css';
|
|
|
1494
1485
|
box.find('.day').removeClass('checked');
|
|
1495
1486
|
}
|
|
1496
1487
|
}
|
|
1497
|
-
}
|
|
1488
|
+
};
|
|
1498
1489
|
|
|
1499
|
-
|
|
1490
|
+
const showSelectedInfo = (forceValid?, silent?) => {
|
|
1500
1491
|
box.find('.start-day').html('...');
|
|
1501
1492
|
box.find('.end-day').html('...');
|
|
1502
1493
|
box.find('.selected-days').hide();
|
|
@@ -1547,17 +1538,15 @@ import './daterangepicker.css';
|
|
|
1547
1538
|
} else {
|
|
1548
1539
|
box.find('.apply-btn').addClass('disabled');
|
|
1549
1540
|
}
|
|
1550
|
-
}
|
|
1541
|
+
};
|
|
1551
1542
|
|
|
1552
|
-
|
|
1553
|
-
return Math.abs(daysFrom1970(start) - daysFrom1970(end)) + 1;
|
|
1554
|
-
}
|
|
1543
|
+
const countDays = (start, end) => Math.abs(daysFrom1970(start) - daysFrom1970(end)) + 1;
|
|
1555
1544
|
|
|
1556
|
-
|
|
1545
|
+
const setDateRange = (
|
|
1557
1546
|
date1?,
|
|
1558
1547
|
date2?,
|
|
1559
1548
|
silent?,
|
|
1560
|
-
) {
|
|
1549
|
+
) => {
|
|
1561
1550
|
if (date1.getTime() > date2.getTime()) {
|
|
1562
1551
|
let tmp = date2;
|
|
1563
1552
|
date2 = date1;
|
|
@@ -1614,9 +1603,9 @@ import './daterangepicker.css';
|
|
|
1614
1603
|
checkSelectionValid();
|
|
1615
1604
|
showSelectedInfo(false, silent);
|
|
1616
1605
|
autoclose();
|
|
1617
|
-
}
|
|
1606
|
+
};
|
|
1618
1607
|
|
|
1619
|
-
|
|
1608
|
+
const setSingleDate = (date1) => {
|
|
1620
1609
|
let valid = true;
|
|
1621
1610
|
if (opt.startDate && compare_day(date1, opt.startDate) < 0) { valid = false; }
|
|
1622
1611
|
|
|
@@ -1642,7 +1631,7 @@ import './daterangepicker.css';
|
|
|
1642
1631
|
showGap();
|
|
1643
1632
|
showSelectedInfo();
|
|
1644
1633
|
autoclose();
|
|
1645
|
-
}
|
|
1634
|
+
};
|
|
1646
1635
|
|
|
1647
1636
|
function showSelectedDays() {
|
|
1648
1637
|
if (!opt.start && !opt.end) { return; }
|
|
@@ -1688,7 +1677,7 @@ import './daterangepicker.css';
|
|
|
1688
1677
|
});
|
|
1689
1678
|
}
|
|
1690
1679
|
|
|
1691
|
-
|
|
1680
|
+
const showMonth = (date: DateWrapper, month: 'month1' | 'month2') => {
|
|
1692
1681
|
date = date.clone();
|
|
1693
1682
|
const monthName = nameMonth(date.getMonth());
|
|
1694
1683
|
box.find(`.${month} .month-name`).html(`${monthName} ${date.getFullYear()}`);
|
|
@@ -1696,7 +1685,7 @@ import './daterangepicker.css';
|
|
|
1696
1685
|
opt[month] = date;
|
|
1697
1686
|
updateSelectableRange();
|
|
1698
1687
|
bindDayEvents();
|
|
1699
|
-
}
|
|
1688
|
+
};
|
|
1700
1689
|
|
|
1701
1690
|
function bindDayEvents(): void {
|
|
1702
1691
|
box.find('.day').unbind('click').click(function (this: any) {
|
|
@@ -1719,20 +1708,16 @@ import './daterangepicker.css';
|
|
|
1719
1708
|
});
|
|
1720
1709
|
}
|
|
1721
1710
|
|
|
1722
|
-
|
|
1711
|
+
const showTime = (date: DateWrapper, name: 'time1' | 'time2') => {
|
|
1723
1712
|
box.find(`.${name}`).append(getTimeHTML());
|
|
1724
1713
|
renderTime(name, date);
|
|
1725
|
-
}
|
|
1714
|
+
};
|
|
1726
1715
|
|
|
1727
|
-
|
|
1728
|
-
return translate('month-name')[m];
|
|
1729
|
-
}
|
|
1716
|
+
const nameMonth = m => translate('month-name')[m];
|
|
1730
1717
|
|
|
1731
|
-
|
|
1732
|
-
return DateUtils.formatDate(d, opt.format);
|
|
1733
|
-
}
|
|
1718
|
+
const getDateString = d => DateUtils.formatDate(d, opt.format);
|
|
1734
1719
|
|
|
1735
|
-
|
|
1720
|
+
const showGap = () => {
|
|
1736
1721
|
showSelectedDays();
|
|
1737
1722
|
const m1 = parseInt(DateUtils.formatDate(opt.month1, 'yyyyMM'));
|
|
1738
1723
|
const m2 = parseInt(DateUtils.formatDate(opt.month2, 'yyyyMM'));
|
|
@@ -1747,12 +1732,12 @@ import './daterangepicker.css';
|
|
|
1747
1732
|
const h1 = box.find('table.month1').height();
|
|
1748
1733
|
const h2 = box.find('table.month2').height();
|
|
1749
1734
|
box.find('.gap').height(Math.max(h1, h2) + 10);
|
|
1750
|
-
}
|
|
1735
|
+
};
|
|
1751
1736
|
|
|
1752
|
-
|
|
1737
|
+
const closeDatePicker = (): void => {
|
|
1753
1738
|
if (opt.alwaysOpen) { return; }
|
|
1754
1739
|
|
|
1755
|
-
const afterAnim =
|
|
1740
|
+
const afterAnim = () => {
|
|
1756
1741
|
$(self).data('date-picker-opened', false);
|
|
1757
1742
|
$(self).trigger('datepicker-closed', {
|
|
1758
1743
|
relatedTarget: box,
|
|
@@ -1767,56 +1752,54 @@ import './daterangepicker.css';
|
|
|
1767
1752
|
$(self).trigger('datepicker-close', {
|
|
1768
1753
|
relatedTarget: box,
|
|
1769
1754
|
});
|
|
1770
|
-
}
|
|
1755
|
+
};
|
|
1771
1756
|
|
|
1772
|
-
|
|
1757
|
+
const redrawDatePicker = (): void => {
|
|
1773
1758
|
showMonth(opt.month1, 'month1');
|
|
1774
1759
|
showMonth(opt.month2, 'month2');
|
|
1775
|
-
}
|
|
1760
|
+
};
|
|
1776
1761
|
|
|
1777
|
-
|
|
1762
|
+
const compare_month = (m1: DateWrapper, m2: DateWrapper): number => {
|
|
1778
1763
|
const p = parseInt(DateUtils.formatDate(m1, 'yyyyMM')) - parseInt(DateUtils.formatDate(m2, 'yyyyMM'));
|
|
1779
1764
|
if (p > 0) { return 1; }
|
|
1780
1765
|
|
|
1781
1766
|
if (p === 0) { return 0; }
|
|
1782
1767
|
|
|
1783
1768
|
return -1;
|
|
1784
|
-
}
|
|
1769
|
+
};
|
|
1785
1770
|
|
|
1786
|
-
|
|
1771
|
+
const compare_day = (m1: DateWrapper, m2: DateWrapper): number => {
|
|
1787
1772
|
const p = parseInt(DateUtils.formatDate(m1, 'yyyyMMdd')) - parseInt(DateUtils.formatDate(m2, 'yyyyMMdd'));
|
|
1788
1773
|
if (p > 0) { return 1; }
|
|
1789
1774
|
|
|
1790
1775
|
if (p === 0) { return 0; }
|
|
1791
1776
|
|
|
1792
1777
|
return -1;
|
|
1793
|
-
}
|
|
1778
|
+
};
|
|
1794
1779
|
|
|
1795
|
-
|
|
1780
|
+
const nextMonth = (month: DateWrapper): DateWrapper => {
|
|
1796
1781
|
const retVal = month.clone();
|
|
1797
1782
|
retVal.setMonth(retVal.getMonth() + 1);
|
|
1798
1783
|
return retVal;
|
|
1799
|
-
}
|
|
1784
|
+
};
|
|
1800
1785
|
|
|
1801
|
-
|
|
1786
|
+
const prevMonth = (month: DateWrapper): DateWrapper => {
|
|
1802
1787
|
const retVal = month.clone();
|
|
1803
1788
|
retVal.setMonth(retVal.getMonth() - 1);
|
|
1804
1789
|
return retVal;
|
|
1805
|
-
}
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
function createDom() {
|
|
1790
|
+
};
|
|
1791
|
+
|
|
1792
|
+
const getTimeHTML = () => `<div class="time-current-container">`
|
|
1793
|
+
+ `<span>${translate('Time')}: <span class="hour-val">00</span>:<span class="minute-val">00</span></span>`
|
|
1794
|
+
+ `</div>`
|
|
1795
|
+
+ `<div class="hour">`
|
|
1796
|
+
+ `<label>${translate('Hour')}: <input type="range" class="hour-range" name="hour" min="0" max="23"></label>`
|
|
1797
|
+
+ `</div>`
|
|
1798
|
+
+ `<div class="minute">`
|
|
1799
|
+
+ `<label>${translate('Minute')}: <input type="range" class="minute-range" name="minute" min="0" max="59"></label>`
|
|
1800
|
+
+ `</div>`;
|
|
1801
|
+
|
|
1802
|
+
const createDom = () => {
|
|
1820
1803
|
let html = '<div class="date-range-picker-root"><div class="drpc-modal-close-button">x</div><div class="date-range-picker-wrapper';
|
|
1821
1804
|
if (opt.extraClass) { html += ` ${opt.extraClass} `; }
|
|
1822
1805
|
|
|
@@ -1982,9 +1965,9 @@ import './daterangepicker.css';
|
|
|
1982
1965
|
html += '</div></div></div>';
|
|
1983
1966
|
|
|
1984
1967
|
return $(html);
|
|
1985
|
-
}
|
|
1968
|
+
};
|
|
1986
1969
|
|
|
1987
|
-
|
|
1970
|
+
const getApplyBtnClass = (): string => {
|
|
1988
1971
|
let klass = '';
|
|
1989
1972
|
if (opt.autoClose === true) {
|
|
1990
1973
|
klass += ' hide';
|
|
@@ -1995,9 +1978,9 @@ import './daterangepicker.css';
|
|
|
1995
1978
|
}
|
|
1996
1979
|
|
|
1997
1980
|
return klass;
|
|
1998
|
-
}
|
|
1981
|
+
};
|
|
1999
1982
|
|
|
2000
|
-
|
|
1983
|
+
const getWeekHead = (): string => {
|
|
2001
1984
|
const prepend = opt.showWeekNumbers ? `<th>${translate('week-number')}</th>` : '';
|
|
2002
1985
|
if (opt.startOfWeek == 'monday') {
|
|
2003
1986
|
return `${prepend}<th>${translate('week-1')}</th>`
|
|
@@ -2016,9 +1999,9 @@ import './daterangepicker.css';
|
|
|
2016
1999
|
+ `<th>${translate('week-5')}</th>`
|
|
2017
2000
|
+ `<th>${translate('week-6')}</th>`;
|
|
2018
2001
|
}
|
|
2019
|
-
}
|
|
2002
|
+
};
|
|
2020
2003
|
|
|
2021
|
-
|
|
2004
|
+
const isMonthOutOfBounds = (month: DateWrapper): boolean => {
|
|
2022
2005
|
const date = month.clone();
|
|
2023
2006
|
const monthStart = new DateWrapper(
|
|
2024
2007
|
date.getFullYear(),
|
|
@@ -2040,9 +2023,9 @@ import './daterangepicker.css';
|
|
|
2040
2023
|
}
|
|
2041
2024
|
|
|
2042
2025
|
return false;
|
|
2043
|
-
}
|
|
2026
|
+
};
|
|
2044
2027
|
|
|
2045
|
-
|
|
2028
|
+
const getGapHTML = () => {
|
|
2046
2029
|
const html = ['<div class="gap-top-mask"></div><div class="gap-bottom-mask"></div><div class="gap-lines">'];
|
|
2047
2030
|
for (let i = 0; i < 20; i++) {
|
|
2048
2031
|
html.push('<div class="gap-line">'
|
|
@@ -2053,13 +2036,13 @@ import './daterangepicker.css';
|
|
|
2053
2036
|
}
|
|
2054
2037
|
html.push('</div>');
|
|
2055
2038
|
return html.join('');
|
|
2056
|
-
}
|
|
2039
|
+
};
|
|
2057
2040
|
|
|
2058
|
-
|
|
2041
|
+
const attributesCallbacks = (
|
|
2059
2042
|
initialObject,
|
|
2060
2043
|
callbacksArray,
|
|
2061
2044
|
today,
|
|
2062
|
-
) {
|
|
2045
|
+
) => {
|
|
2063
2046
|
const resultObject = $.extend(
|
|
2064
2047
|
true,
|
|
2065
2048
|
{},
|
|
@@ -2086,21 +2069,19 @@ import './daterangepicker.css';
|
|
|
2086
2069
|
}
|
|
2087
2070
|
|
|
2088
2071
|
return attrString;
|
|
2089
|
-
}
|
|
2072
|
+
};
|
|
2090
2073
|
|
|
2091
|
-
|
|
2092
|
-
return Math.floor(toLocalTimestamp(t) / 86400000);
|
|
2093
|
-
}
|
|
2074
|
+
const daysFrom1970 = t => Math.floor(toLocalTimestamp(t) / 86400000);
|
|
2094
2075
|
|
|
2095
|
-
|
|
2076
|
+
const toLocalTimestamp = (t) => {
|
|
2096
2077
|
if (typeof t == 'object' && t.getTime) { t = t.getTime(); }
|
|
2097
2078
|
|
|
2098
2079
|
if (typeof t == 'string' && !t.match(/\d{13}/)) { t = DateUtils.getDateWrapperFromFormat(t, opt.format).getTime(); }
|
|
2099
2080
|
|
|
2100
2081
|
return t;
|
|
2101
|
-
}
|
|
2082
|
+
};
|
|
2102
2083
|
|
|
2103
|
-
|
|
2084
|
+
const createMonthHTML = (d) => {
|
|
2104
2085
|
const days = [];
|
|
2105
2086
|
d.setDate(1);
|
|
2106
2087
|
const lastMonth = new DateWrapper(d.getTime() - 86400000);
|
|
@@ -2187,9 +2168,9 @@ import './daterangepicker.css';
|
|
|
2187
2168
|
html.push('</tr>');
|
|
2188
2169
|
}
|
|
2189
2170
|
return html.join('');
|
|
2190
|
-
}
|
|
2171
|
+
};
|
|
2191
2172
|
|
|
2192
|
-
|
|
2173
|
+
const getInnerDayHtml = (attributes: any, today: any) => {
|
|
2193
2174
|
if (opt.getCellHtml != null) {
|
|
2194
2175
|
return opt.getCellHtml({
|
|
2195
2176
|
attributesHtml: null,
|
|
@@ -2203,17 +2184,17 @@ import './daterangepicker.css';
|
|
|
2203
2184
|
opt.dayDivAttrs,
|
|
2204
2185
|
today,
|
|
2205
2186
|
)}>${showDayHTML(today.time, today.day)}</div>`;
|
|
2206
|
-
}
|
|
2187
|
+
};
|
|
2207
2188
|
|
|
2208
|
-
|
|
2189
|
+
const showDayHTML = (time, date) => {
|
|
2209
2190
|
if (opt.showDateFilter && typeof opt.showDateFilter == 'function') {
|
|
2210
2191
|
return opt.showDateFilter(time, date);
|
|
2211
2192
|
}
|
|
2212
2193
|
|
|
2213
2194
|
return date;
|
|
2214
|
-
}
|
|
2195
|
+
};
|
|
2215
2196
|
|
|
2216
|
-
|
|
2197
|
+
const getLanguages = (): any => {
|
|
2217
2198
|
if (opt.language == 'auto') {
|
|
2218
2199
|
let language = navigator.language ? navigator.language : (navigator as any).browserLanguage;
|
|
2219
2200
|
if (!language) {
|
|
@@ -2231,21 +2212,21 @@ import './daterangepicker.css';
|
|
|
2231
2212
|
} else {
|
|
2232
2213
|
return $.dateRangePickerLanguages.default;
|
|
2233
2214
|
}
|
|
2234
|
-
}
|
|
2215
|
+
};
|
|
2235
2216
|
|
|
2236
2217
|
/**
|
|
2237
2218
|
* Translate language string, try both the provided translation key, as the lower case version
|
|
2238
2219
|
*/
|
|
2239
|
-
|
|
2220
|
+
const translate = (translationKey: string): string => {
|
|
2240
2221
|
const translationKeyLowerCase = translationKey.toLowerCase();
|
|
2241
2222
|
let result = (translationKey in languages) ? languages[translationKey] : (translationKeyLowerCase in languages) ? languages[translationKeyLowerCase] : null;
|
|
2242
2223
|
const defaultLanguage = $.dateRangePickerLanguages.default;
|
|
2243
2224
|
if (result == null) { result = (translationKey in defaultLanguage) ? defaultLanguage[translationKey] : (translationKeyLowerCase in defaultLanguage) ? defaultLanguage[translationKeyLowerCase] : ''; }
|
|
2244
2225
|
|
|
2245
2226
|
return result;
|
|
2246
|
-
}
|
|
2227
|
+
};
|
|
2247
2228
|
|
|
2248
|
-
|
|
2229
|
+
const getDefaultTime = (): DateWrapper => {
|
|
2249
2230
|
let defaultTime = opt.defaultTime ? opt.defaultTime : DateWrapper.getCurrent();
|
|
2250
2231
|
|
|
2251
2232
|
if (opt.lookBehind) {
|
|
@@ -2265,9 +2246,9 @@ import './daterangepicker.css';
|
|
|
2265
2246
|
}
|
|
2266
2247
|
|
|
2267
2248
|
return defaultTime;
|
|
2268
|
-
}
|
|
2249
|
+
};
|
|
2269
2250
|
|
|
2270
|
-
|
|
2251
|
+
const resetMonthsView = (time: DateWrapper) => {
|
|
2271
2252
|
if (!time) {
|
|
2272
2253
|
time = getDefaultTime();
|
|
2273
2254
|
}
|
|
@@ -2286,6 +2267,6 @@ import './daterangepicker.css';
|
|
|
2286
2267
|
|
|
2287
2268
|
showSelectedDays();
|
|
2288
2269
|
showGap();
|
|
2289
|
-
}
|
|
2270
|
+
};
|
|
2290
2271
|
};
|
|
2291
2272
|
})($);
|