1322f46b9d3722c4e17211dffbf4faa38be04cdc
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Resources / Public / JavaScript / iecompatibility.js
1 /**
2 * This file is part of the TYPO3 CMS project.
3 *
4 * It is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License, either version 2
6 * of the License, or any later version.
7 *
8 * For the full copyright and license information, please read the
9 * LICENSE.txt file that was distributed with this source code.
10 *
11 * The TYPO3 project - inspiring people to share!
12 */
13
14
15 Element.addMethods({
16 pngHack: function(element) {
17 element = $(element);
18 var transparentGifPath = 'clear.gif';
19
20 // If there is valid element, it is an image and the image file ends with png:
21 if (Object.isElement(element) && element.tagName === 'IMG' && element.src.endsWith('.png')) {
22 var alphaImgSrc = element.src;
23 var sizingMethod = 'scale';
24 element.src = transparentGifPath;
25 }
26
27 if (alphaImgSrc) {
28 element.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="#{alphaImgSrc}",sizingMethod="#{sizingMethod}")'.interpolate(
29 {
30 alphaImgSrc: alphaImgSrc,
31 sizingMethod: sizingMethod
32 });
33 }
34
35 return element;
36 }
37 });
38
39 var IECompatibility = Class.create({
40
41 /**
42 * initializes the compatibility class
43 */
44 initialize: function() {
45 Event.observe(document, 'dom:loaded', function() {
46 $$('input[type="checkbox"]').invoke('addClassName', 'checkbox');
47 }.bind(this));
48
49 Event.observe(window, 'load', function() {
50 if (Prototype.Browser.IE) {
51 var version = parseFloat(navigator.appVersion.split(';')[1].strip().split(' ')[1]);
52 if (version === 6) {
53 $$('img').each(function(img) {
54 img.pngHack();
55 });
56 $$('#typo3-menu li ul li').each(function(li) {
57 li.setStyle({height: '21px'});
58 });
59 }
60 }
61 });
62 }
63 });
64
65 if (Prototype.Browser.IE) {
66 var TYPO3IECompatibilty = new IECompatibility();
67 }