Skip to content

Commit

Permalink
Merge branch 'master' of github.com:dangrossman/bootstrap-daterangepi…
Browse files Browse the repository at this point in the history
…cker
  • Loading branch information
dangrossman committed Apr 11, 2019
2 parents 8f2848e + 80758ca commit fc790d9
Showing 1 changed file with 44 additions and 20 deletions.
64 changes: 44 additions & 20 deletions daterangepicker.js
Expand Up @@ -858,7 +858,7 @@

var html, selected, minDate, maxDate = this.maxDate;

if (this.maxSpan && (!this.maxDate || this.startDate.clone().add(this.maxSpan).isAfter(this.maxDate)))
if (this.maxSpan && (!this.maxDate || this.startDate.clone().add(this.maxSpan).isBefore(this.maxDate)))
maxDate = this.startDate.clone().add(this.maxSpan);

if (side == 'left') {
Expand Down Expand Up @@ -1037,44 +1037,68 @@
containerTop = this.element.offset().top - this.container.outerHeight() - parentOffset.top;
else
containerTop = this.element.offset().top + this.element.outerHeight() - parentOffset.top;

// Force the container to it's actual width
this.container.css({
top: 0,
left: 0,
right: 'auto'
});
var containerWidth = this.container.outerWidth();

this.container[this.drops == 'up' ? 'addClass' : 'removeClass']('drop-up');

if (this.opens == 'left') {
this.container.css({
top: containerTop,
right: parentRightEdge - this.element.offset().left - this.element.outerWidth(),
left: 'auto'
});
if (this.container.offset().left < 0) {
var containerRight = parentRightEdge - this.element.offset().left - this.element.outerWidth();
if (containerWidth + containerRight > $(window).width()) {
this.container.css({
top: containerTop,
right: 'auto',
left: 9
});
} else {
this.container.css({
top: containerTop,
right: containerRight,
left: 'auto'
});
}
} else if (this.opens == 'center') {
this.container.css({
top: containerTop,
left: this.element.offset().left - parentOffset.left + this.element.outerWidth() / 2
- this.container.outerWidth() / 2,
right: 'auto'
});
if (this.container.offset().left < 0) {
var containerLeft = this.element.offset().left - parentOffset.left + this.element.outerWidth() / 2
- containerWidth / 2;
if (containerLeft < 0) {
this.container.css({
top: containerTop,
right: 'auto',
left: 9
});
} else if (containerLeft + containerWidth > $(window).width()) {
this.container.css({
top: containerTop,
left: 'auto',
right: 0
});
} else {
this.container.css({
top: containerTop,
left: containerLeft,
right: 'auto'
});
}
} else {
this.container.css({
top: containerTop,
left: this.element.offset().left - parentOffset.left,
right: 'auto'
});
if (this.container.offset().left + this.container.outerWidth() > $(window).width()) {
var containerLeft = this.element.offset().left - parentOffset.left;
if (containerLeft + containerWidth > $(window).width()) {
this.container.css({
top: containerTop,
left: 'auto',
right: 0
});
} else {
this.container.css({
top: containerTop,
left: containerLeft,
right: 'auto'
});
}
}
},
Expand Down

0 comments on commit fc790d9

Please sign in to comment.