Datepicker: Fixed #4691 Datepicker positioning is off if the window has almost the same height as the calendar div

This commit is contained in:
Keith Wood 2009-07-22 08:39:44 +00:00
parent ef4000d9df
commit 1df4659b7d

View File

@ -693,8 +693,10 @@ $.extend(Datepicker.prototype, {
offset.top -= (isFixed && offset.top == (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
// now check if datepicker is showing outside window viewport - move to a better place if so.
offset.left -= (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ? Math.abs(offset.left + dpWidth - viewWidth) : 0;
offset.top -= (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ? Math.abs(offset.top + dpHeight + inputHeight*2 - viewHeight) : 0;
offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
Math.abs(offset.left + dpWidth - viewWidth) : 0);
offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
Math.abs(offset.top + dpHeight + inputHeight * 2 - viewHeight) : 0);
return offset;
},