Changeset 11944

Show
Ignore:
Timestamp:
01/03/08 12:25:02 (8 months ago)
Author:
peller
Message:

Correct DnD/dropdown bidi placement. Fixes #4369, #4228. Also some size reductions. !strict

Files:
2 modified

Legend:

Unmodified
Added
Removed
  • dijit/trunk/_base/place.js

    r11841 r11944  
    1212        // get viewport size 
    1313        var w = 0, h = 0; 
     14        var de = _document.documentElement; 
     15        var dew = de.clientWidth, deh = de.clientHeight; 
    1416        if(dojo.isMozilla){ 
    1517                // mozilla 
     
    1921                // check DTD to see whether body or documentElement returns the viewport dimensions using this algorithm: 
    2022                var minw, minh, maxw, maxh; 
    21                 if(_document.body.clientWidth>_document.documentElement.clientWidth){ 
    22                         minw = _document.documentElement.clientWidth; 
    23                         maxw = _document.body.clientWidth; 
     23                var dbw = _document.body.clientWidth; 
     24                if(dbw > dew){ 
     25                        minw = dew; 
     26                        maxw = dbw; 
    2427                }else{ 
    25                         maxw = _document.documentElement.clientWidth; 
    26                         minw = _document.body.clientWidth; 
    27                 } 
    28                 if(_document.body.clientHeight>_document.documentElement.clientHeight){ 
    29                         minh = _document.documentElement.clientHeight; 
    30                         maxh = _document.body.clientHeight; 
     28                        maxw = dew; 
     29                        minw = dbw; 
     30                } 
     31                var dbh = _document.body.clientHeight; 
     32                if(dbh > deh){ 
     33                        minh = deh; 
     34                        maxh = dbh; 
    3135                }else{ 
    32                         maxh = _document.documentElement.clientHeight; 
    33                         minh = _document.body.clientHeight; 
     36                        maxh = deh; 
     37                        minh = dbh; 
    3438                } 
    3539                w = (maxw > _window.innerWidth) ? minw : maxw; 
     
    4145                w = _window.innerWidth; 
    4246                h = _window.innerHeight; 
    43         }else if(dojo.isIE && _document.documentElement && _document.documentElement.clientHeight){ 
    44                 w = _document.documentElement.clientWidth; 
    45                 h = _document.documentElement.clientHeight; 
     47        }else if(dojo.isIE && de && deh){ 
     48                w = dew; 
     49                h = deh; 
    4650        }else if(dojo.body().clientWidth){ 
    4751                // IE5, Opera 
     
    104108        } 
    105109 
    106         var best=null; 
    107         for(var i=0; i<choices.length; i++){ 
    108                 var corner = choices[i].corner; 
    109                 var pos = choices[i].pos; 
     110        var best = null; 
     111        dojo.some(choices, function(choice){ 
     112                var corner = choice.corner; 
     113                var pos = choice.pos; 
    110114 
    111115                // configure node to be displayed in given position relative to button 
     
    113117                // a tooltips size changes based on position, due to triangle) 
    114118                if(layoutNode){ 
    115                         layoutNode(node, choices[i].aroundCorner, corner); 
     119                        layoutNode(node, choice.aroundCorner, corner); 
    116120                } 
    117121 
    118122                // get node's size 
    119                 var oldDisplay = node.style.display; 
    120                 var oldVis = node.style.visibility; 
    121                 node.style.visibility = "hidden"; 
    122                 node.style.display = ""; 
     123                var style = node.style; 
     124                var oldDisplay = style.display; 
     125                var oldVis = style.visibility; 
     126                style.visibility = "hidden"; 
     127                style.display = ""; 
    123128                var mb = dojo.marginBox(node); 
    124                 node.style.display = oldDisplay; 
    125                 node.style.visibility = oldVis; 
     129                style.display = oldDisplay; 
     130                style.visibility = oldVis; 
    126131 
    127132                // coordinates and size of node with specified corner placed at pos, 
    128133                // and clipped by viewport 
    129                 var startX = (corner.charAt(1)=='L' ? pos.x : Math.max(view.l, pos.x - mb.w)), 
    130                         startY = (corner.charAt(0)=='T' ? pos.y : Math.max(view.t, pos.y -  mb.h)), 
    131                         endX = (corner.charAt(1)=='L' ? Math.min(view.l+view.w, startX+mb.w) : pos.x), 
    132                         endY = (corner.charAt(0)=='T' ? Math.min(view.t+view.h, startY+mb.h) : pos.y), 
    133                         width = endX-startX, 
    134                         height = endY-startY, 
    135                         overflow = (mb.w-width) + (mb.h-height); 
    136  
    137                 if(best==null || overflow<best.overflow){ 
     134                var startX = (corner.charAt(1) == 'L' ? pos.x : Math.max(view.l, pos.x - mb.w)), 
     135                        startY = (corner.charAt(0) == 'T' ? pos.y : Math.max(view.t, pos.y -  mb.h)), 
     136                        endX = (corner.charAt(1) == 'L' ? Math.min(view.l + view.w, startX + mb.w) : pos.x), 
     137                        endY = (corner.charAt(0) == 'T' ? Math.min(view.t + view.h, startY + mb.h) : pos.y), 
     138                        width = endX - startX, 
     139                        height = endY - startY, 
     140                        overflow = (mb.w - width) + (mb.h - height); 
     141 
     142                if(best == null || overflow < best.overflow){ 
    138143                        best = { 
    139144                                corner: corner, 
    140                                 aroundCorner: choices[i].aroundCorner, 
    141                                 x: (!dojo._isBodyLtr() && dojo.isIE && startX < 0) ? document.body.clientWidth + startX : startX, 
     145                                aroundCorner: choice.aroundCorner, 
     146                                x: startX, 
    142147                                y: startY, 
    143148                                w: width, 
     
    146151                        }; 
    147152                } 
    148                 if(overflow==0){ 
    149                         break; 
    150                 } 
    151         } 
     153                return !overflow; 
     154        }); 
    152155 
    153156        node.style.left = best.x + "px"; 
     
    194197                        corner: aroundCorners[nodeCorner], 
    195198                        pos: { 
    196                                 x: aroundNodePos.x + (nodeCorner.charAt(1)=='L' ? 0 : aroundNodeW), 
    197                                 y: aroundNodePos.y + (nodeCorner.charAt(0)=='T' ? 0 : aroundNodeH) 
     199                                x: aroundNodePos.x + (nodeCorner.charAt(1) == 'L' ? 0 : aroundNodeW), 
     200                                y: aroundNodePos.y + (nodeCorner.charAt(0) == 'T' ? 0 : aroundNodeH) 
    198201                        } 
    199202                }); 
  • dojo/trunk/_base/html.js

    r11928 r11944  
    842842                // will offset to right when there is a horizontal scrollbar. 
    843843                if(dojo.isIE && !dojo._isBodyLtr()){ 
    844                         var de = dojo.doc.documentElement; 
    845                         return scrollLeft + de.clientWidth - de.scrollWidth; // Integer 
     844                        var de = dojo.doc.body; 
     845                        return de.clientWidth - de.offsetWidth; // Integer 
    846846                } 
    847847                return scrollLeft; // Integer 
     
    10261026                        // via getAttribute()? 
    10271027                        var prop = _attrProps[name.toLowerCase()]; 
    1028                         if(prop){ 
    1029                                 return node[prop]; 
    1030                         }else{ 
    1031                                 return _hasAttr(node, name) ? node.getAttribute(name) : null; 
    1032                         } 
     1028                        return prop ? node[prop] : 
     1029                                _hasAttr(node, name) ? node.getAttribute(name) : null; 
    10331030                } 
    10341031        }