Subversion Repositories Sites.tela-botanica.org

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4 david 1
<public:component>
2
<public:attach event="onpropertychange" onevent="propertyChanged()" />
3
<script>
4
 
5
var supported = /MSIE (5\.5)|[6789]/.test(navigator.userAgent) && navigator.platform == "Win32";
6
var realSrc;
7
var blankSrc = "rien.gif";
8
 
9
if (supported) fixImage();
10
 
11
function propertyChanged() {
12
   if (!supported) return;
13
 
14
   var pName = event.propertyName;
15
   if (pName != "src") return;
16
   // if not set to blank
17
   if ( ! new RegExp(blankSrc).test(src))
18
      fixImage();
19
};
20
 
21
function fixImage() {
22
   // get src
23
   var src = element.src;
24
 
25
   // check for real change
26
   if (src == realSrc) {
27
      element.src = blankSrc;
28
      return;
29
   }
30
 
31
   if ( ! new RegExp(blankSrc).test(src)) {
32
      // backup old src
33
      realSrc = src;
34
   }
35
 
36
   // test for png
37
   if ( /\.png$/.test( realSrc.toLowerCase() ) ) {
38
      // set blank image
39
      element.src = blankSrc;
40
      // set filter
41
      element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" +
42
                                     src + "',sizingMethod='scale')";
43
   }
44
}
45
 
46
</script>
47
</public:component>