]> source.dussan.org Git - jquery-ui.git/commitdiff
Datepicker: Fixed #4691 Datepicker positioning is off if the window has almost the...
authorKeith Wood <kbwood.au@gmail.com>
Wed, 22 Jul 2009 08:39:44 +0000 (08:39 +0000)
committerKeith Wood <kbwood.au@gmail.com>
Wed, 22 Jul 2009 08:39:44 +0000 (08:39 +0000)
ui/ui.datepicker.js

index 5f1891fd8fb09ffdbba6ced5d0f37c3839a35c4d..a2bc36623ca230e79ccb452e139e5b14ad9c4f5f 100644 (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;
        },