2 * IE fixes javascript loaded by wikibits.js for IE <= 6.0
4 /*global isMSIE55:true, doneIETransform:true, doneIEAlphaFix:true */
5 /*global hookit:true, fixalpha:true */
8 var expandedURLs
, hasClass
;
10 // Also returns true for IE6, 7, 8, 9 and 10. createPopup is removed in IE11.
11 // Good thing this is only loaded for IE <= 6 by wikibits.
12 // Might as well set it to true.
13 isMSIE55
= ( window
.showModalDialog
&& window
.clipboardData
&& window
.createPopup
);
14 doneIETransform
= false;
15 doneIEAlphaFix
= false;
17 hookit = function () {
18 if ( !doneIETransform
&& document
.getElementById
&& document
.getElementById( 'bodyContent' ) ) {
19 doneIETransform
= true;
24 if ( document
.attachEvent
) {
25 document
.attachEvent( 'onreadystatechange', hookit
);
28 // png alpha transparency fixes
29 fixalpha = function ( logoId
) {
31 if ( isMSIE55
&& !doneIEAlphaFix
) {
32 var bg
, imageUrl
, linkFix
, logoa
, logospan
, plogo
;
33 plogo
= document
.getElementById( logoId
|| 'p-logo' );
38 logoa
= plogo
.getElementsByTagName('a')[0];
43 bg
= logoa
.currentStyle
.backgroundImage
;
44 imageUrl
= bg
.substring( 5, bg
.length
- 2 );
46 doneIEAlphaFix
= true;
48 if ( imageUrl
.substr( imageUrl
.length
- 4 ).toLowerCase() === '.png' ) {
49 logospan
= logoa
.appendChild( document
.createElement( 'span' ) );
51 logoa
.style
.backgroundImage
= 'none';
52 logospan
.style
.filter
= 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=' + imageUrl
+ ')';
53 logospan
.style
.height
= '100%';
54 logospan
.style
.position
= 'absolute';
55 logospan
.style
.width
= logoa
.currentStyle
.width
;
56 logospan
.style
.cursor
= 'hand';
57 // Center image with hack for IE5.5
58 if ( document
.documentElement
.dir
=== 'rtl' ) {
59 logospan
.style
.right
= '50%';
60 logospan
.style
.setExpression( 'marginRight', '"-" + (this.offsetWidth / 2) + "px"' );
62 logospan
.style
.left
= '50%';
63 logospan
.style
.setExpression( 'marginLeft', '"-" + (this.offsetWidth / 2) + "px"' );
65 logospan
.style
.top
= '50%';
66 logospan
.style
.setExpression( 'marginTop', '"-" + (this.offsetHeight / 2) + "px"' );
68 linkFix
= logoa
.appendChild( logoa
.cloneNode() );
69 linkFix
.style
.position
= 'absolute';
70 linkFix
.style
.height
= '100%';
71 linkFix
.style
.width
= '100%';
81 // Expand links for printing
82 hasClass = function ( classText
, classWanted
) {
83 var i
= 0, classArr
= classText
.split(/\s/);
84 for ( i
= 0; i
< classArr
.length
; i
++ ) {
85 if ( classArr
[i
].toLowerCase() === classWanted
.toLowerCase() ) {
92 window
.onbeforeprint = function () {
93 var allLinks
, contentEl
, expandedLink
, expandedText
, i
;
96 contentEl
= document
.getElementById( 'content' );
99 allLinks
= contentEl
.getElementsByTagName( 'a' );
101 for ( i
= 0; i
< allLinks
.length
; i
++ ) {
102 if ( hasClass( allLinks
[i
].className
, 'external' ) && !hasClass( allLinks
[i
].className
, 'free' ) ) {
103 expandedLink
= document
.createElement( 'span' );
104 expandedText
= document
.createTextNode( ' (' + allLinks
[i
].href
+ ')' );
105 expandedLink
.appendChild( expandedText
);
106 allLinks
[i
].parentNode
.insertBefore( expandedLink
, allLinks
[i
].nextSibling
);
107 expandedURLs
[i
] = expandedLink
;
113 window
.onafterprint = function () {
114 for ( var i
= 0; i
< expandedURLs
.length
; i
++ ) {
115 if ( expandedURLs
[i
] ) {
116 expandedURLs
[i
].removeNode( true );
121 }( mediaWiki
, jQuery
) );