From e3767fdad46a46dd12705026bdd6d54344965741 Mon Sep 17 00:00:00 2001 From: waki <107737@gmail.com> Date: Mon, 10 Dec 2018 17:57:12 +0600 Subject: [PATCH] fix bug (see: changelog) --- CHANGELOG.md | 3 +++ lightpick.js | 19 +++++++++++++++++++ package.json | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a87226..152b734 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lightpick.js b/lightpick.js index 9022334..4cb608c 100644 --- a/lightpick.js +++ b/lightpick.js @@ -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'); } diff --git a/package.json b/package.json index c2160a6..26931e7 100644 --- a/package.json +++ b/package.json @@ -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": {