Reposition on change

master
Vitaliy Filippov 2018-03-17 21:30:04 +03:00
parent 964930c39f
commit e5c55c9f12
2 changed files with 21 additions and 1 deletions

View File

@ -40,6 +40,18 @@ export class Calendar
{ {
html += "<a class='calendar-cancel' onclick='Calendar.instance.hideCalendar()'>"+this.close_label+"</a>"; html += "<a class='calendar-cancel' onclick='Calendar.instance.hideCalendar()'>"+this.close_label+"</a>";
Calendar.box.innerHTML = html; Calendar.box.innerHTML = html;
if (this.position)
{
// Position the div in the correct location...
var div = Calendar.box;
var xy = getOffset(this.input);
var height = this.input.clientHeight||this.input.offsetHeight;
div.style.left = (xy.left-1)+"px";
if (this.position == 'top')
div.style.top = (xy.top-div.offsetHeight)+'px';
else
div.style.top = (xy.top+height-1)+"px";
}
} }
isVisible() isVisible()
@ -267,6 +279,8 @@ export class Calendar
} }
} }
this.position = '';
if (this.start == 'years') if (this.start == 'years')
this.showYears(this.selected.getFullYear()); this.showYears(this.selected.getFullYear());
else if (this.start == 'months') else if (this.start == 'months')
@ -282,9 +296,15 @@ export class Calendar
div.style.left = (xy.left-1)+"px"; div.style.left = (xy.left-1)+"px";
if (div.offsetHeight + xy.top+height-1 >= (document.documentElement.clientHeight||document.body.clientHeight) && if (div.offsetHeight + xy.top+height-1 >= (document.documentElement.clientHeight||document.body.clientHeight) &&
xy.top-div.offsetHeight >= 0) xy.top-div.offsetHeight >= 0)
{
this.position = 'top';
div.style.top = (xy.top-div.offsetHeight)+'px'; div.style.top = (xy.top-div.offsetHeight)+'px';
}
else else
{
this.position = 'bottom';
div.style.top = (xy.top+height-1)+"px"; div.style.top = (xy.top+height-1)+"px";
}
}; };
/// Hides the currently show calendar. /// Hides the currently show calendar.

2
calendar.min.js vendored

File diff suppressed because one or more lines are too long