Changeset 311

Show
Ignore:
Timestamp:
06/20/08 16:29:02 (21 months ago)
Author:
kbwood.au
Message:

Correct datepicker placement when used in static areas
Correct select coverage in IE 6-

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/ui/ui.datepicker.js

    r301 r311  
    102102                speed: 'normal', // Speed of display/closure 
    103103                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 '',  
    106105                        // [2] = cell title (optional), e.g. $.datepicker.noWeekends 
    107106                beforeShow: null, // Function that takes an input field and 
     
    445444                $(input).parents().each(function() { 
    446445                        isFixed |= $(this).css('position') == 'fixed'; 
     446                        return !isFixed; 
    447447                }); 
    448448                if (isFixed && $.browser.opera) { // correction for Opera when fixed and scrolled 
     
    460460                        $('.ui-datepicker', inst._datepickerDiv[0])[0].offsetWidth); 
    461461                // and adjust position before showing 
    462                 offset = $.datepicker._checkOffset(inst, offset); 
     462                offset = $.datepicker._checkOffset(inst, offset, isFixed); 
    463463                inst._datepickerDiv.css({position: ($.datepicker._inDialog && $.blockUI ? 
    464464                        'static' : (isFixed ? 'fixed' : 'absolute')), display: 'none', 
     
    484484        /* Generate the date picker content. */ 
    485485        _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}); 
    487491                var numMonths = inst._getNumberOfMonths(); 
    488492                if (numMonths[0] != 1 || numMonths[1] != 1) 
     
    501505 
    502506        /* 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) { 
    505508                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; 
    510513                // 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() - 
    516517                                (isFixed && $.browser.opera ? document.documentElement.scrollLeft : 0)); 
     518                else 
     519                        offset.left -= (isFixed ? scrollX : 0); 
    517520                // 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()) - 
    523524                                (isFixed && $.browser.opera ? document.documentElement.scrollTop : 0)); 
     525                else 
     526                        offset.top -= (isFixed ? scrollY : 0); 
    524527                return offset; 
    525528        },