Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat; Added check for range #2341

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions daterangepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
this.autoUpdateInput = true;
this.alwaysShowCalendars = false;
this.ranges = {};
this.openRange = false;

this.opens = 'right';
if (this.element.hasClass('pull-right'))
Expand Down Expand Up @@ -278,6 +279,9 @@
if (typeof options.alwaysShowCalendars === 'boolean')
this.alwaysShowCalendars = options.alwaysShowCalendars;

if (typeof options.openRange === 'boolean')
this.openRange = options.openRange;

// update day names order to firstDay
if (this.locale.firstDay != 0) {
var iterator = this.locale.firstDay;
Expand Down Expand Up @@ -1296,6 +1300,12 @@
var cal = $(e.target).parents('.drp-calendar');
var date = cal.hasClass('left') ? this.leftCalendar.calendar[row][col] : this.rightCalendar.calendar[row][col];

if (this.startDate.isSame(date) && this.openRange) {
this.openRange = true;
} else if (this.endDate && !this.endDate.isSame(date) && !this.openRange) {
this.openRange = false;
}

//
// this function needs to do a few things:
// * alternate between selecting a start and end date for the range,
Expand Down Expand Up @@ -1358,6 +1368,11 @@
this.clickApply();
}

if (!this.openRange) {
this.setEndDate(this.startDate.clone());
this.openRange = true;
}

this.updateView();

//This is to cancel the blur event handler if the mouse was in one of the inputs
Expand Down