File: alphaImageLoader.php

package info (click to toggle)
horde3 3.0.4-4sarge7
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 15,980 kB
  • ctags: 16,295
  • sloc: php: 68,726; xml: 2,382; sql: 498; makefile: 74; sh: 63; pascal: 6
file content (77 lines) | stat: -rw-r--r-- 1,928 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
/**
 * $Horde: horde/js/alphaImageLoader.php,v 1.2.8.1 2005/01/03 12:25:39 jan Exp $
 *
 * Copyright 2004-2005 Charles J. Hagenbuch <chuck@horde.org>
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 */

@define('HORDE_BASE', dirname(__FILE__) . '/..');
require_once HORDE_BASE . '/lib/core.php';

$registry = &Registry::singleton(HORDE_SESSION_NONE);

/* This should be cached. */
$mod_gmt = gmdate('D, d M Y H:i:s', filemtime(__FILE__)) . ' GMT';
header('Last-Modified: ' . $mod_gmt);
header('Cache-Control: public, max-age=86400');
header('Content-Type: text/x-component');

?>
<public:component>
<public:attach event="onpropertychange" for="element" onEvent="propertyChanged()" />
<script language="JavaScript">

var needHack = needHack();
var transparentImage = "<?php echo $registry->getImageDir('horde') ?>/blank.gif";

pngHack();

function propertyChanged()
{
    if (event.propertyName == "src") {
        pngHack();
    }
}

function pngHack()
{
    if (!needHack) {
        return;
    }

    var w = element.width;
    var h = element.height;
    var src = element.src;
    if (src.indexOf(transparentImage) != -1) {
        // Already fixed.
        return;
    }

    if (src.indexOf("png") == -1) {
        element.runtimeStyle.filter = "";
        return;
    }

    element.src = transparentImage;
    element.width = w;
    element.height = h;
    element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
}

function needHack()
{
    var pos = navigator.userAgent.indexOf("MSIE ");
    if (pos == -1) {
        return false;
    }

    var version = navigator.userAgent.substring(pos + 5);

    return (((version.indexOf("5.5") == 0) || (version.indexOf("6") == 0)) && (navigator.platform == ("Win32")));
}

</script>
</public:component>