Skip to content
This repository has been archived by the owner on Mar 20, 2022. It is now read-only.

Commit

Permalink
fix bug (see: changelog)
Browse files Browse the repository at this point in the history
  • Loading branch information
wakirin committed Dec 10, 2018
1 parent 9dc1861 commit e3767fd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog
All notable changes to this project will be documented in this file.

[1.2.7] - 2018-12-10
* fix bug when used both options `repick` and `minDays` (on repick date `minDays` was ignored)

[1.2.6] - 2018-11-08
* new option: orientation
* new option: disableWeekends
Expand Down
19 changes: 19 additions & 0 deletions lightpick.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,25 @@
}
}

if (opts.repick && (opts.minDays || opts.maxDays) && opts.startDate && opts.endDate) {
var tempStartDate = moment(opts.repickTrigger == opts.field ? opts.endDate : opts.startDate);

if (opts.minDays) {
if (date.isBetween(moment(tempStartDate).subtract(opts.minDays - 1, 'day'), moment(tempStartDate).add(opts.minDays - 1, 'day'), 'day')) {
day.className.push('is-disabled');
}
}

if (opts.maxDays) {
if (date.isSameOrBefore(moment(tempStartDate).subtract(opts.maxDays, 'day'), 'day')) {
day.className.push('is-disabled');
}
else if (date.isSameOrAfter(moment(tempStartDate).add(opts.maxDays, 'day'), 'day')) {
day.className.push('is-disabled');
}
}
}

if (date.isSame(new Date(), 'day')) {
day.className.push('is-today');
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lightpick",
"version": "1.2.6",
"version": "1.2.7",
"description": "Javascript date range picker - lightweight, no jQuery",
"main": "lightpick.js",
"scripts": {
Expand Down

0 comments on commit e3767fd

Please sign in to comment.