]> git.proxmox.com Git - extjs.git/blame - extjs/build/welcome/css/iepngfix.htc
add extjs 6.0.1 sources
[extjs.git] / extjs / build / welcome / css / iepngfix.htc
CommitLineData
6527f429
DM
1<public:component>\r
2<script type="text/javascript">\r
3\r
4// IE5.5+ PNG Alpha Fix v2.0 Alpha\r
5// (c) 2004-2009 Angus Turnbull http://www.twinhelix.com\r
6\r
7// This is licensed under the GNU LGPL, version 2.1 or later.\r
8// For details, see: http://creativecommons.org/licenses/LGPL/2.1/\r
9\r
10var IEPNGFix = window.IEPNGFix || {};\r
11IEPNGFix.data = IEPNGFix.data || {};\r
12\r
13\r
14// CONFIG: blankImg is the path to blank.gif, *relative to the HTML document*.\r
15// Try either:\r
16// * An absolute path like: '/images/blank.gif'\r
17// * A path relative to this HTC file like: thisFolder + 'blank.gif'\r
18var thisFolder = document.URL.replace(/(\\|\/)[^\\\/]*$/, '/');\r
19//IEPNGFix.blankImg = thisFolder + 'blank.gif';\r
20IEPNGFix.blankImg = '/css/blank.gif';\r
21\r
22\r
23IEPNGFix.fix = function(elm, src, t) {\r
24 // Applies an image 'src' to an element 'elm' using the DirectX filter.\r
25 // If 'src' is null, filter is disabled.\r
26 // Disables the 'hook' to prevent infinite recursion on setting BG/src.\r
27 // 't' = type, where background tile = 0, background = 1, IMG SRC = 2.\r
28\r
29 var h = this.hook.enabled;\r
30 this.hook.enabled = 0;\r
31\r
32 var f = 'DXImageTransform.Microsoft.AlphaImageLoader';\r
33 src = (src || '').replace(/\(/g, '%28').replace(/\)/g, '%29');\r
34\r
35 if (\r
36 src && !(/IMG|INPUT/.test(elm.nodeName) && (t != 2)) &&\r
37 elm.currentStyle.width == 'auto' && elm.currentStyle.height == 'auto'\r
38 ) {\r
39 if (elm.offsetWidth) {\r
40 elm.style.width = elm.offsetWidth + 'px';\r
41 }\r
42 if (elm.clientHeight) {\r
43 elm.style.height = elm.clientHeight + 'px';\r
44 }\r
45 if (elm.currentStyle.display == 'inline') {\r
46 elm.style.display = 'inline-block';\r
47 }\r
48 }\r
49\r
50 if (t == 1) {\r
51 elm.style.backgroundImage = 'url("' + this.blankImg + '")';\r
52 }\r
53 if (t == 2) {\r
54 elm.src = this.blankImg;\r
55 }\r
56\r
57 if (elm.filters[f]) {\r
58 elm.filters[f].enabled = src ? true : false;\r
59 if (src) {\r
60 elm.filters[f].src = src;\r
61 }\r
62 } else if (src) {\r
63 elm.style.filter = 'progid:' + f + '(src="' + src +\r
64 '",sizingMethod="' + (t == 2 ? 'scale' : 'crop') + '")';\r
65 }\r
66\r
67 this.hook.enabled = h;\r
68};\r
69\r
70\r
71IEPNGFix.process = function(elm, init) {\r
72 // Checks the onpropertychange event (on first 'init' run, a fake event)\r
73 // and calls the filter-applying-functions.\r
74\r
75 if (\r
76 !/MSIE (5\.5|6)/.test(navigator.userAgent) ||\r
77 typeof elm.filters == 'unknown'\r
78 ) {\r
79 return;\r
80 }\r
81 if (!this.data[elm.uniqueID]) {\r
82 this.data[elm.uniqueID] = {\r
83 className: ''\r
84 };\r
85 }\r
86 var data = this.data[elm.uniqueID],\r
87 evt = init ? { propertyName: 'src,backgroundImage' } : event,\r
88 isSrc = /src/.test(evt.propertyName),\r
89 isBg = /backgroundImage/.test(evt.propertyName),\r
90 isPos = /width|height|background(Pos|Rep)/.test(evt.propertyName),\r
91 isClass = !init && ((elm.className != data.className) &&\r
92 (elm.className || data.className));\r
93 if (!(isSrc || isBg || isPos || isClass)) {\r
94 return;\r
95 }\r
96 data.className = elm.className;\r
97 var blank = this.blankImg.match(/([^\/]+)$/)[1],\r
98 eS = elm.style,\r
99 eCS = elm.currentStyle;\r
100\r
101 // Required for Whatever:hover - erase set BG if className changes.\r
102 if (\r
103 isClass && (eS.backgroundImage.indexOf('url(') == -1 ||\r
104 eS.backgroundImage.indexOf(blank) > -1)\r
105 ) {\r
106 return setTimeout(function() {\r
107 eS.backgroundImage = '';\r
108 }, 0);\r
109 }\r
110\r
111 // Foregrounds.\r
112 if (isSrc && elm.src && { IMG: 1, INPUT: 1 }[elm.nodeName]) {\r
113 if ((/\.png/i).test(elm.src)) {\r
114 if (!elm.oSrc) {\r
115 // MM rollover compat\r
116 elm.oSrc = elm.src;\r
117 }\r
118 this.fix(elm, elm.src, 2);\r
119 } else if (elm.src.indexOf(blank) == -1) {\r
120 this.fix(elm, '');\r
121 }\r
122 }\r
123\r
124 // Backgrounds.\r
125 var bgSrc = eCS.backgroundImage || eS.backgroundImage;\r
126 if ((bgSrc + elm.src).indexOf(blank) == -1) {\r
127 var bgPNG = bgSrc.match(/url[("']+(.*\.png[^\)"']*)[\)"']/i);\r
128 if (bgPNG) {\r
129 if (this.tileBG && !{ IMG: 1, INPUT: 1 }[elm.nodeName]) {\r
130 this.tileBG(elm, bgPNG[1]);\r
131 this.fix(elm, '', 1);\r
132 } else {\r
133 if (data.tiles && data.tiles.src) {\r
134 this.tileBG(elm, '');\r
135 }\r
136 this.fix(elm, bgPNG[1], 1);\r
137 this.childFix(elm);\r
138 }\r
139 } else {\r
140 if (data.tiles && data.tiles.src) {\r
141 this.tileBG(elm, '');\r
142 }\r
143 this.fix(elm, '');\r
144 }\r
145 } else if ((isPos || isClass) && data.tiles && data.tiles.src) {\r
146 this.tileBG(elm, data.tiles.src);\r
147 }\r
148\r
149 if (init) {\r
150 this.hook.enabled = 1;\r
151 elm.attachEvent('onpropertychange', this.hook);\r
152 }\r
153};\r
154\r
155\r
156IEPNGFix.childFix = function(elm) {\r
157 // "hasLayout" fix for unclickable children inside PNG backgrounds.\r
158 var tags = [\r
159 'a',\r
160 'input',\r
161 'select',\r
162 'textarea',\r
163 'button',\r
164 'iframe',\r
165 'object'\r
166 ],\r
167 t = tags.length,\r
168 tFix = [];\r
169 while (t--) {\r
170 var pFix = elm.all.tags(tags[t]),\r
171 e = pFix.length;\r
172 while (e--) {\r
173 tFix.push(pFix[e]);\r
174 }\r
175 }\r
176 t = tFix.length;\r
177 if (t && (/relative|absolute/i).test(elm.currentStyle.position)) {\r
178 alert('IEPNGFix: Unclickable children of element:' +\r
179 '\n\n<' + elm.nodeName + (elm.id && ' id=' + elm.id) + '>');\r
180 }\r
181 while (t--) {\r
182 if (!(/relative|absolute/i).test(tFix[t].currentStyle.position)) {\r
183 tFix[t].style.position = 'relative';\r
184 }\r
185 }\r
186};\r
187\r
188\r
189IEPNGFix.hook = function() {\r
190 if (IEPNGFix.hook.enabled) {\r
191 IEPNGFix.process(element, 0);\r
192 }\r
193};\r
194\r
195\r
196IEPNGFix.process(element, 1);\r
197\r
198</script>\r
199</public:component>\r