Lines 760-805
$("#placeBookingModal").on("show.bs.modal", function (e) {
Link Here
|
760 |
} |
760 |
} |
761 |
|
761 |
|
762 |
// Add hints for days before the start range and after the end range |
762 |
// Add hints for days before the start range and after the end range |
763 |
let leadDays = 2; |
763 |
const leadDays = 2; |
764 |
let trailDays = 3; |
764 |
const trailDays = 3; |
765 |
periodPicker.calendarContainer.addEventListener( |
765 |
periodPicker.calendarContainer.addEventListener( |
766 |
"mouseover", |
766 |
"mouseover", |
767 |
function (e) { |
767 |
function (event) { |
768 |
const target = e.target; |
768 |
const target = event.target; |
769 |
const startDate = periodPicker.selectedDates[0] |
|
|
770 |
? dayjs(periodPicker.selectedDates[0]).startOf( |
771 |
"day" |
772 |
) |
773 |
: null; |
774 |
|
775 |
if (target.classList.contains("flatpickr-day")) { |
769 |
if (target.classList.contains("flatpickr-day")) { |
776 |
const hoverDate = dayjs(target.dateObj).startOf( |
770 |
const hoverDate = dayjs(target.dateObj).startOf( |
777 |
"day" |
771 |
"day" |
778 |
); |
772 |
); |
779 |
let leadStart; |
773 |
const startDate = periodPicker.selectedDates[0] |
780 |
let leadEnd; |
774 |
? dayjs(periodPicker.selectedDates[0]).startOf( |
781 |
const trailStart = hoverDate |
775 |
"day" |
782 |
.add(0, "day") |
776 |
) |
783 |
.startOf("day"); |
777 |
: null; |
784 |
const trailEnd = hoverDate |
778 |
|
785 |
.add(trailDays, "day") |
779 |
const leadStart = startDate |
786 |
.startOf("day"); |
780 |
? startDate.subtract(leadDays, "day") |
787 |
|
781 |
: hoverDate.subtract(leadDays, "day"); |
788 |
if (!startDate) { |
782 |
const leadEnd = startDate ? startDate : hoverDate; |
789 |
leadStart = hoverDate |
783 |
const trailStart = hoverDate; |
790 |
.subtract(leadDays, "day") |
784 |
const trailEnd = hoverDate.add(trailDays, "day"); |
791 |
.startOf("day"); |
|
|
792 |
leadEnd = hoverDate |
793 |
.subtract(0, "day") |
794 |
.startOf("day"); |
795 |
} else { |
796 |
leadStart = startDate |
797 |
.subtract(leadDays, "day") |
798 |
.startOf("day"); |
799 |
leadEnd = startDate |
800 |
.subtract(0, "day") |
801 |
.startOf("day"); |
802 |
} |
803 |
|
785 |
|
804 |
periodPicker.calendarContainer |
786 |
periodPicker.calendarContainer |
805 |
.querySelectorAll(".flatpickr-day") |
787 |
.querySelectorAll(".flatpickr-day") |
Lines 808-864
$("#placeBookingModal").on("show.bs.modal", function (e) {
Link Here
|
808 |
dayElem.dateObj |
790 |
dayElem.dateObj |
809 |
).startOf("day"); |
791 |
).startOf("day"); |
810 |
|
792 |
|
811 |
if (elemDate.isSame(leadStart)) { |
793 |
dayElem.classList.toggle( |
812 |
dayElem.classList.add("leadRangeStart"); |
794 |
"leadRangeStart", |
813 |
} else { |
795 |
elemDate.isSame(leadStart) |
814 |
dayElem.classList.remove( |
796 |
); |
815 |
"leadRangeStart" |
797 |
dayElem.classList.toggle( |
816 |
); |
798 |
"leadRange", |
817 |
} |
799 |
elemDate.isSameOrAfter(leadStart) && |
818 |
|
800 |
elemDate.isBefore(leadEnd) |
819 |
if ( |
801 |
); |
820 |
elemDate >= leadStart && |
802 |
dayElem.classList.toggle( |
821 |
elemDate < leadEnd |
803 |
"leadRangeEnd", |
822 |
) { |
804 |
elemDate.isSame(leadEnd) |
823 |
dayElem.classList.add("leadRange"); |
805 |
); |
824 |
} else { |
806 |
dayElem.classList.toggle( |
825 |
dayElem.classList.remove("leadRange"); |
807 |
"trailRangeStart", |
826 |
} |
808 |
elemDate.isSame(trailStart) |
827 |
|
809 |
); |
828 |
if (elemDate.isSame(leadEnd)) { |
810 |
dayElem.classList.toggle( |
829 |
dayElem.classList.add("leadRangeEnd"); |
811 |
"trailRange", |
830 |
} else { |
812 |
elemDate.isAfter(trailStart) && |
831 |
dayElem.classList.remove( |
813 |
elemDate.isSameOrBefore(trailEnd) |
832 |
"leadRangeEnd" |
814 |
); |
833 |
); |
815 |
dayElem.classList.toggle( |
834 |
} |
816 |
"trailRangeEnd", |
835 |
|
817 |
elemDate.isSame(trailEnd) |
836 |
if (elemDate.isSame(trailStart)) { |
818 |
); |
837 |
dayElem.classList.add( |
|
|
838 |
"trailRangeStart" |
839 |
); |
840 |
} else { |
841 |
dayElem.classList.remove( |
842 |
"trailRangeStart" |
843 |
); |
844 |
} |
845 |
|
846 |
if ( |
847 |
elemDate > trailStart && |
848 |
elemDate <= trailEnd |
849 |
) { |
850 |
dayElem.classList.add("trailRange"); |
851 |
} else { |
852 |
dayElem.classList.remove("trailRange"); |
853 |
} |
854 |
|
855 |
if (elemDate.isSame(trailEnd)) { |
856 |
dayElem.classList.add("trailRangeEnd"); |
857 |
} else { |
858 |
dayElem.classList.remove( |
859 |
"trailRangeEnd" |
860 |
); |
861 |
} |
862 |
}); |
819 |
}); |
863 |
} |
820 |
} |
864 |
} |
821 |
} |
865 |
- |
|
|