Changeset 11955
- Timestamp:
- 01/04/08 13:01:53 (8 months ago)
- Files:
-
- 1 modified
-
dojo/trunk/_base/html.js (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dojo/trunk/_base/html.js
r11944 r11955 41 41 }else{ 42 42 var eles = _d.all[id]; 43 if(!eles){ return; } 44 if(!eles.length){ return eles; } 43 if(!eles || !eles.length){ return eles; } 45 44 // if more than 1, choose first with the correct id 46 45 var i=0; … … 55 54 }else{ 56 55 dojo.byId = function(id, doc){ 57 if(dojo.isString(id)){ 58 return (doc || dojo.doc).getElementById(id); 59 }else{ 60 return id; // DomNode 61 } 56 return dojo.isString(id) ? (doc || dojo.doc).getElementById(id) : id; // DomNode 62 57 } 63 58 } … … 190 185 if(refNode.firstChild){ 191 186 return _insertBefore(node, refNode.firstChild); // boolean 192 }else{193 refNode.appendChild(node);194 return true; // boolean195 187 } 196 break;188 // else fallthrough... 197 189 default: // aka: last 198 190 refNode.appendChild(node); … … 222 214 var _dcm = document.compatMode; 223 215 // client code may have to adjust if compatMode varies across iframes 224 dojo.boxModel = (_dcm=="BackCompat")||(_dcm=="QuirksMode")||(dojo.isIE<6) ? "border-box" : "content-box";216 dojo.boxModel = _dcm == "BackCompat" || _dcm == "QuirksMode" || dojo.isIE<6 ? "border-box" : "content-box"; // FIXME: remove IE < 6 support? 225 217 } 226 218 … … 334 326 =====*/ 335 327 336 dojo._getOpacity = (dojo.isIE ? function(node){ 337 try{ 338 return (node.filters.alpha.opacity / 100); // Number 339 }catch(e){ 340 return 1; // Number 341 } 342 } : function(node){ 343 return dojo.getComputedStyle(node).opacity; 344 } 345 ); 328 dojo._getOpacity = dojo.isIE ? function(node){ 329 try{ 330 return node.filters.alpha.opacity / 100; // Number 331 }catch(e){ 332 return 1; // Number 333 } 334 } : function(node){ 335 return dojo.getComputedStyle(node).opacity; 336 }; 346 337 347 338 /*===== … … 359 350 =====*/ 360 351 361 dojo._setOpacity = (dojo.isIE ? function(/*DomNode*/node, /*Number*/opacity){ 362 if(opacity == 1){ 363 // on IE7 Alpha(Filter opacity=100) makes text look fuzzy so remove it altogether (bug #2661) 364 node.style.cssText = node.style.cssText.replace(/FILTER:[^;]*;?/i, ""); 365 if(node.nodeName.toLowerCase() == "tr"){ 366 dojo.query("> td", node).forEach(function(i){ 367 i.style.cssText = i.style.cssText.replace(/FILTER:[^;]*;?/i, ""); 368 }); 369 } 370 }else{ 371 var o = "Alpha(Opacity="+(opacity*100)+")"; 372 node.style.filter = o; 373 } 352 dojo._setOpacity = dojo.isIE ? function(/*DomNode*/node, /*Number*/opacity){ 353 if(opacity == 1){ 354 // on IE7 Alpha(Filter opacity=100) makes text look fuzzy so remove it altogether (bug #2661) 355 var filterRE = /FILTER:[^;]*;?/i; 356 node.style.cssText = node.style.cssText.replace(filterRE, ""); 374 357 if(node.nodeName.toLowerCase() == "tr"){ 375 358 dojo.query("> td", node).forEach(function(i){ 376 i.style. filter = o;359 i.style.cssText = i.style.cssText.replace(filterRE, ""); 377 360 }); 378 361 } 379 return opacity; 380 } : function(node, opacity){ 381 return node.style.opacity = opacity; 382 } 383 ); 362 }else{ 363 var o = "Alpha(Opacity="+ opacity * 100 +")"; 364 node.style.filter = o; 365 } 366 if(node.nodeName.toLowerCase() == "tr"){ 367 dojo.query("> td", node).forEach(function(i){ 368 i.style.filter = o; 369 }); 370 } 371 return opacity; 372 } : function(node, opacity){ 373 return node.style.opacity = opacity; 374 }; 384 375 385 376 var _pixelNamesCache = { … … 397 388 } 398 389 if( 399 (type.indexOf("margin") >= 0)||400 // (type.indexOf("border") >= 0)||401 (type.indexOf("padding") >= 0)||402 (type.indexOf("width") >= 0)||403 (type.indexOf("height") >= 0)||404 (type.indexOf("max") >= 0)||405 (type.indexOf("min") >= 0)||406 (type.indexOf("offset") >= 0)390 type.indexOf("margin") >= 0 || 391 // type.indexOf("border") >= 0 || 392 type.indexOf("padding") >= 0 || 393 type.indexOf("width") >= 0 || 394 type.indexOf("height") >= 0 || 395 type.indexOf("max") >= 0 || 396 type.indexOf("min") >= 0 || 397 type.indexOf("offset") >= 0 407 398 ){ 408 399 _pixelNamesCache[type] = true; … … 669 660 // u: optional. unit measure to use for other measures. Defaults to "px". 670 661 u = u || "px"; 671 with(node.style){ 672 if(!isNaN(l)){ left = l+u; } 673 if(!isNaN(t)){ top = t+u; } 674 if(w>=0){ width = w+u; } 675 if(h>=0){ height = h+u; } 676 } 662 var s = node.style; 663 if(!isNaN(l)){ s.left = l+u; } 664 if(!isNaN(t)){ s.top = t+u; } 665 if(w>=0){ s.width = w+u; } 666 if(h>=0){ s.height = h+u; } 677 667 } 678 668 … … 826 816 827 817 var de = dojo.doc.documentElement; 828 if(dojo.isIE >= 7){ 829 return {x: de.getBoundingClientRect().left, y: de.getBoundingClientRect().top}; // Object 830 }else{ 818 //FIXME: use this instead? var de = d.compatMode == "BackCompat" ? d.body : d.documentElement; 819 820 return (dojo.isIE >= 7) ? 821 {x: de.getBoundingClientRect().left, y: de.getBoundingClientRect().top} 822 : 831 823 // IE 6.0 832 return{x: dojo._isBodyLtr() || window.parent == window ?824 {x: dojo._isBodyLtr() || window.parent == window ? 833 825 de.clientLeft : de.offsetWidth - de.clientWidth - de.clientLeft, 834 826 y: de.clientTop}; // Object 835 }836 827 }; 837 828 … … 841 832 // must call this function to fix this error, otherwise the position 842 833 // will offset to right when there is a horizontal scrollbar. 834 var d = dojo.doc; 843 835 if(dojo.isIE && !dojo._isBodyLtr()){ 844 var de = d ojo.doc.body;845 return de.clientWidth - de.offsetWidth; // Integer836 var de = d.compatMode == "BackCompat" ? d.body : d.documentElement; 837 return scrollLeft + de.clientWidth - de.scrollWidth; // Integer 846 838 } 847 839 return scrollLeft; // Integer 848 840 } 849 841 850 842 dojo._abs = function(/*DomNode*/node, /*Boolean?*/includeScroll){ 851 843 // summary: