Reposition on change
parent
964930c39f
commit
e5c55c9f12
20
calendar.js
20
calendar.js
|
@ -40,6 +40,18 @@ export class Calendar
|
|||
{
|
||||
html += "<a class='calendar-cancel' onclick='Calendar.instance.hideCalendar()'>"+this.close_label+"</a>";
|
||||
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()
|
||||
|
@ -267,6 +279,8 @@ export class Calendar
|
|||
}
|
||||
}
|
||||
|
||||
this.position = '';
|
||||
|
||||
if (this.start == 'years')
|
||||
this.showYears(this.selected.getFullYear());
|
||||
else if (this.start == 'months')
|
||||
|
@ -282,9 +296,15 @@ export class Calendar
|
|||
div.style.left = (xy.left-1)+"px";
|
||||
if (div.offsetHeight + xy.top+height-1 >= (document.documentElement.clientHeight||document.body.clientHeight) &&
|
||||
xy.top-div.offsetHeight >= 0)
|
||||
{
|
||||
this.position = 'top';
|
||||
div.style.top = (xy.top-div.offsetHeight)+'px';
|
||||
}
|
||||
else
|
||||
{
|
||||
this.position = 'bottom';
|
||||
div.style.top = (xy.top+height-1)+"px";
|
||||
}
|
||||
};
|
||||
|
||||
/// Hides the currently show calendar.
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue