blob: 4d664d9d88d37b01910ec545087c1808e1e13419 (
plain)
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
/**
* This is a slightly modified version of Eric Advidsson's pngbehavior.htc
* script at http://webfx.eae.net/dhtml/pngbehavior/pngbehavior.html
*
* For usage see license at http://webfx.eae.net/license.html
*
* It also includes some printing fixes from:
* http://www.scss.com.au/family/andrew/webdesign/pngbehavior/
*
* As well as restricting the versions of IE that it will match, since IE 7 now
* deals properly with transparent PNGs.
*
* @url $URL$
* @date $Date: 2006-11-13 18:57:43 +0000 (Mon, 13 Nov 2006) $
* @version $Revision: 11730 $
* @author $Author: xris $
*
/**/
<public:component>
<public:attach event="onpropertychange" onevent="propertyChanged()" />
<public:attach event="onbeforeprint" for="window" onevent="beforePrint()" />
<public:attach event="onafterprint" for="window" onevent="afterPrint()" />
<script type="text/javascript">
// Set this to the URL of your 1x1 transparent gif
var blankSrc = "/skins/default/img/spacer.gif";
// Only interact with valid browsers. Everything after IE 6 supports
// transparent PNGs natively (yay!)
var supported = /MSIE (5\.5|6)/.test(navigator.userAgent) && navigator.platform == "Win32";
/******************************************************************************/
var realSrc;
if (supported)
fixImage();
function propertyChanged() {
if (supported && event.propertyName == 'src') {
var i = element.src.lastIndexOf(blankSrc);
if (i == -1 || i != element.src.length - blankSrc.length) {
fixImage();
}
}
}
function fixImage() {
if (!supported) return;
// Don't set the image to itself (i.e. catch stupid web designer errors)
if (element.src == realSrc && element.runtimeStyle.filter != "") {
element.src = blankSrc;
return;
}
// Backup the old src
if ( ! new RegExp(blankSrc).test(element.src))
realSrc = element.src;
// Test for png
if ( realSrc && /\.png$/.test( realSrc.toLowerCase() ) ) {
// Make sure that width and height are preserved
var width = element.width;
var height = element.height;
// Set blank image
element.src = blankSrc;
// Set filter
element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"
+ encodeURI(realSrc) + "',sizingMethod='scale')";
// Restore width and height
element.width = width;
element.height = height;
}
// Otherwise, remove the filter
else
element.runtimeStyle.filter = "";
}
function beforePrint() {
if (realSrc) {
supported = false;
element.src = realSrc;
element.runtimeStyle.filter = '';
supported = true;
}
}
function afterPrint() {
if (realSrc) {
var rs = realSrc;
realSrc = null;
element.src = rs;
}
}
</script>
</public:component>
|