Changeset 311
- Timestamp:
- 06/20/08 16:29:02 (21 months ago)
- Files:
-
- 1 modified
-
trunk/ui/ui.datepicker.js (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ui/ui.datepicker.js
r301 r311 102 102 speed: 'normal', // Speed of display/closure 103 103 beforeShowDay: null, // Function that takes a date and returns an array with 104 // [0] = true if selectable, false if not, 105 // [1] = custom CSS class name(s) or '', 104 // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or '', 106 105 // [2] = cell title (optional), e.g. $.datepicker.noWeekends 107 106 beforeShow: null, // Function that takes an input field and … … 445 444 $(input).parents().each(function() { 446 445 isFixed |= $(this).css('position') == 'fixed'; 446 return !isFixed; 447 447 }); 448 448 if (isFixed && $.browser.opera) { // correction for Opera when fixed and scrolled … … 460 460 $('.ui-datepicker', inst._datepickerDiv[0])[0].offsetWidth); 461 461 // and adjust position before showing 462 offset = $.datepicker._checkOffset(inst, offset );462 offset = $.datepicker._checkOffset(inst, offset, isFixed); 463 463 inst._datepickerDiv.css({position: ($.datepicker._inDialog && $.blockUI ? 464 464 'static' : (isFixed ? 'fixed' : 'absolute')), display: 'none', … … 484 484 /* Generate the date picker content. */ 485 485 _updateDatepicker: function(inst) { 486 inst._datepickerDiv.empty().append(inst._generateDatepicker()); 486 var dims = {width: inst._datepickerDiv.width() + 4, 487 height: inst._datepickerDiv.height() + 4}; 488 inst._datepickerDiv.empty().append(inst._generateDatepicker()). 489 find('iframe.ui-datepicker-cover'). 490 css({width: dims.width, height: dims.height}); 487 491 var numMonths = inst._getNumberOfMonths(); 488 492 if (numMonths[0] != 1 || numMonths[1] != 1) … … 501 505 502 506 /* Check positioning to remain on screen. */ 503 _checkOffset: function(inst, offset) { 504 var isFixed = inst._datepickerDiv.css('position') == 'fixed'; 507 _checkOffset: function(inst, offset, isFixed) { 505 508 var pos = inst._input ? $.datepicker._findPos(inst._input[0]) : null; 506 var browserWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;507 var browserHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;508 var scrollX = (isFixed ? 0 : document.documentElement.scrollLeft || document.body.scrollLeft);509 var scrollY = (isFixed ? 0 : document.documentElement.scrollTop || document.body.scrollTop);509 var browserWidth = window.innerWidth || document.documentElement.clientWidth; 510 var browserHeight = window.innerHeight || document.documentElement.clientHeight; 511 var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft; 512 var scrollY = document.documentElement.scrollTop || document.body.scrollTop; 510 513 // reposition date picker horizontally if outside the browser window 511 if ((offset.left + inst._datepickerDiv.width() - 512 (isFixed && $.browser.msie ? document.documentElement.scrollLeft : 0)) > 513 (browserWidth + scrollX)) 514 offset.left = Math.max(scrollX, 515 pos[0] + (inst._input ? $(inst._input[0]).width() : null) - inst._datepickerDiv.width() - 514 if ((offset.left + inst._datepickerDiv.width() - scrollX) > browserWidth) 515 offset.left = Math.max((isFixed ? 0 : scrollX), 516 pos[0] + (inst._input ? inst._input.width() : 0) - (isFixed ? scrollX : 0) - inst._datepickerDiv.width() - 516 517 (isFixed && $.browser.opera ? document.documentElement.scrollLeft : 0)); 518 else 519 offset.left -= (isFixed ? scrollX : 0); 517 520 // reposition date picker vertically if outside the browser window 518 if ((offset.top + inst._datepickerDiv.height() - 519 (isFixed && $.browser.msie ? document.documentElement.scrollTop : 0)) > 520 (browserHeight + scrollY)) 521 offset.top = Math.max(scrollY, 522 pos[1] - (this._inDialog ? 0 : inst._datepickerDiv.height()) - 521 if ((offset.top + inst._datepickerDiv.height() - scrollY) > browserHeight) 522 offset.top = Math.max((isFixed ? 0 : scrollY), 523 pos[1] - (isFixed ? scrollY : 0) - (this._inDialog ? 0 : inst._datepickerDiv.height()) - 523 524 (isFixed && $.browser.opera ? document.documentElement.scrollTop : 0)); 525 else 526 offset.top -= (isFixed ? scrollY : 0); 524 527 return offset; 525 528 },