Changeset 11944
- Timestamp:
- 01/03/08 12:25:02 (8 months ago)
- Files:
-
- 2 modified
-
dijit/trunk/_base/place.js (modified) (7 diffs)
-
dojo/trunk/_base/html.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dijit/trunk/_base/place.js
r11841 r11944 12 12 // get viewport size 13 13 var w = 0, h = 0; 14 var de = _document.documentElement; 15 var dew = de.clientWidth, deh = de.clientHeight; 14 16 if(dojo.isMozilla){ 15 17 // mozilla … … 19 21 // check DTD to see whether body or documentElement returns the viewport dimensions using this algorithm: 20 22 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; 24 27 }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; 31 35 }else{ 32 maxh = _document.documentElement.clientHeight;33 minh = _document.body.clientHeight;36 maxh = deh; 37 minh = dbh; 34 38 } 35 39 w = (maxw > _window.innerWidth) ? minw : maxw; … … 41 45 w = _window.innerWidth; 42 46 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; 46 50 }else if(dojo.body().clientWidth){ 47 51 // IE5, Opera … … 104 108 } 105 109 106 var best =null;107 for(var i=0; i<choices.length; i++){108 var corner = choice s[i].corner;109 var pos = choice s[i].pos;110 var best = null; 111 dojo.some(choices, function(choice){ 112 var corner = choice.corner; 113 var pos = choice.pos; 110 114 111 115 // configure node to be displayed in given position relative to button … … 113 117 // a tooltips size changes based on position, due to triangle) 114 118 if(layoutNode){ 115 layoutNode(node, choice s[i].aroundCorner, corner);119 layoutNode(node, choice.aroundCorner, corner); 116 120 } 117 121 118 122 // 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 = ""; 123 128 var mb = dojo.marginBox(node); 124 node.style.display = oldDisplay;125 node.style.visibility = oldVis;129 style.display = oldDisplay; 130 style.visibility = oldVis; 126 131 127 132 // coordinates and size of node with specified corner placed at pos, 128 133 // 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){ 138 143 best = { 139 144 corner: corner, 140 aroundCorner: choice s[i].aroundCorner,141 x: (!dojo._isBodyLtr() && dojo.isIE && startX < 0) ? document.body.clientWidth + startX :startX,145 aroundCorner: choice.aroundCorner, 146 x: startX, 142 147 y: startY, 143 148 w: width, … … 146 151 }; 147 152 } 148 if(overflow==0){ 149 break; 150 } 151 } 153 return !overflow; 154 }); 152 155 153 156 node.style.left = best.x + "px"; … … 194 197 corner: aroundCorners[nodeCorner], 195 198 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) 198 201 } 199 202 }); -
dojo/trunk/_base/html.js
r11928 r11944 842 842 // will offset to right when there is a horizontal scrollbar. 843 843 if(dojo.isIE && !dojo._isBodyLtr()){ 844 var de = dojo.doc. documentElement;845 return scrollLeft + de.clientWidth - de.scrollWidth; // Integer844 var de = dojo.doc.body; 845 return de.clientWidth - de.offsetWidth; // Integer 846 846 } 847 847 return scrollLeft; // Integer … … 1026 1026 // via getAttribute()? 1027 1027 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; 1033 1030 } 1034 1031 }