r2958 commited - Datepicker: Fixed #4691 Datepicker positioning is off if the window ha...

r2958 commited - Datepicker: Fixed #4691 Datepicker positioning is off if the window ha...


Revision: 2958
Author: kbwood.au
Date: Wed Jul 22 01:39:44 2009
Log: Datepicker: Fixed #4691 Datepicker positioning is off if the window
has almost the same height as the calendar div
http://code.google.com/p/jquery-ui/source/detail?r=2958
Modified:
/trunk/ui/ui.datepicker.js
=======================================
--- /trunk/ui/ui.datepicker.js    Wed Jul 22 01:37:28 2009
+++ /trunk/ui/ui.datepicker.js    Wed Jul 22 01:39:44 2009
@@ -693,8 +693,10 @@
        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;
    },