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