includes/clientside/ie-png.js
changeset 294 444c34a3886b
equal deleted inserted replaced
293:fbe306070c40 294:444c34a3886b
       
     1 // ScriptingMagic PNG hack for IE
       
     2 // Source: http://www.scriptingmagic.com/Topics/IE%20Specific/PNG%20Transparency/
       
     3 
       
     4 if ( typeof ScriptingMagic == "undefined" )
       
     5 {
       
     6   var ScriptingMagic = {}
       
     7 }
       
     8 ScriptingMagic.fixPNG = function() {};
       
     9 var smFixPNGOnload = (
       
    10   function()
       
    11   {
       
    12     if ( !document.all || window.opera )
       
    13     {
       
    14       return;
       
    15     }
       
    16     var a = parseFloat(navigator.appVersion.match(/MSIE (\d.*)/)[1]);
       
    17     if ( ( a < 5.5 ) || ( a >= 7 ) )
       
    18     {
       
    19       return;
       
    20     }
       
    21     if ( document.styleSheets.length == 0 )
       
    22     {
       
    23       document.body.appendChild(document.createElement("style"));
       
    24     }
       
    25     var src_clause = 'src=\'"+this.nextSibling.src.replace(/\'/g,"%27")+"\')"';
       
    26     document.styleSheets[document.styleSheets.length-1].addRule(".sm-iepng-backdrop", 'position: absolute; z-index: expression(this.nextSibling.currentStyle.zIndex); top: expression(this.nextSibling.offsetTop); left: expression(this.nextSibling.offsetLeft); height: expression(this.nextSibling.offsetHeight); width: expression(this.nextSibling.offsetWidth); filter: expression("progid:DXImageTransform.Microsoft.AlphaImageLoader(' + src_clause + ');');
       
    27     window.ScriptingMagic.fixPNG = function(b)
       
    28     {
       
    29       b.style.filter="alpha(opacity=0)";
       
    30       var c = document.createElement("div");
       
    31       c.className = "sm-iepng-backdrop";
       
    32       if ( b.currentStyle.position.match(/^static$/i) )
       
    33       {
       
    34         b.style.position = "relative";
       
    35       }
       
    36       b.parentNode.insertBefore(c,b);
       
    37       c = null
       
    38     };
       
    39     var b = [], c, d, e, f;
       
    40     var g = document.getElementsByTagName("img");
       
    41     for ( c = 0, d = g.length; c < d; c++ )
       
    42     {
       
    43       b[b.length] = g[c];
       
    44     }
       
    45     var h = document.getElementsByTagName("input");
       
    46     for ( c = 0, d = h.length; c < d; c++ )
       
    47     {
       
    48       e = h[c];
       
    49       if ( e.type && e.type.match(/^image$/i) )
       
    50       {
       
    51         b[b.length] = e;
       
    52       }
       
    53     }
       
    54     for ( c = 0, d = b.length; c < d; c++ )
       
    55     {
       
    56       e = b[c];
       
    57       window.ScriptingMagic.fixPNG(e);
       
    58     }
       
    59     a = b = c = d = e = f = g = h = null;
       
    60   }
       
    61 );
       
    62 
       
    63 addOnloadHook(smFixPNGOnload);
       
    64 
       
    65 ScriptingMagic.fixPNG.version = 1.4;
       
    66 ScriptingMagic.fixPNG.release = new Date("Jan 1, 2007");
       
    67