846ce9a8fbfa3f8fecf0f46694133f70f259b1a5.svn-base 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <public:component>
  2. <public:attach event="onpropertychange" onevent="doFix()" />
  3. <script type="text/javascript">
  4. // IE5.5+ PNG Alpha Fix v1.0RC4
  5. // (c) 2004-2005 Angus Turnbull http://www.twinhelix.com
  6. // This is licensed under the CC-GNU LGPL, version 2.1 or later.
  7. // For details, see: http://creativecommons.org/licenses/LGPL/2.1/
  8. // This must be a path to a blank image. That's all the configuration you need.
  9. if (typeof blankImg == 'undefined') var blankImg = 'blank.gif';
  10. var f = 'DXImageTransform.Microsoft.AlphaImageLoader';
  11. function filt(s, m)
  12. {
  13. if (filters[f])
  14. {
  15. filters[f].enabled = s ? true : false;
  16. if (s) with (filters[f]) { src = s; sizingMethod = m }
  17. }
  18. else if (s) style.filter = 'progid:'+f+'(src="'+s+'",sizingMethod="'+m+'")';
  19. }
  20. function doFix()
  21. {
  22. // Assume IE7 is OK.
  23. if (!/MSIE (5\.5|6\.)/.test(navigator.userAgent) ||
  24. (event && !/(background|src)/.test(event.propertyName))) return;
  25. var bgImg = currentStyle.backgroundImage || style.backgroundImage;
  26. if (tagName == 'IMG')
  27. {
  28. if ((/\.png$/i).test(src))
  29. {
  30. if (currentStyle.width == 'auto' && currentStyle.height == 'auto')
  31. style.width = offsetWidth + 'px';
  32. filt(src, 'scale');
  33. src = blankImg;
  34. }
  35. else if (src.indexOf(blankImg) < 0) filt();
  36. }
  37. else if (bgImg && bgImg != 'none')
  38. {
  39. if (bgImg.match(/^url[("']+(.*\.png)[)"']+$/i))
  40. {
  41. var s = RegExp.$1;
  42. if (currentStyle.width == 'auto' && currentStyle.height == 'auto')
  43. style.width = offsetWidth + 'px';
  44. style.backgroundImage = 'none';
  45. filt(s, 'crop');
  46. // IE link fix.
  47. for (var n = 0; n < childNodes.length; n++)
  48. if (childNodes[n].style) childNodes[n].style.position = 'relative';
  49. }
  50. else filt();
  51. }
  52. }
  53. doFix();
  54. </script>
  55. </public:component>