Remove redirectToFragment() from wikibits.js
[lhc/web/wiklou.git] / skins / common / IEFixes.js
index 09f0910..545acad 100644 (file)
@@ -1,27 +1,32 @@
-// IE fixes javascript
+/**
+ * IE fixes javascript loaded by wikibits.js for IE <= 6.0
+ */
+/*global isMSIE55:true, doneIETransform:true, doneIEAlphaFix:true */
+/*global hookit:true, fixalpha:true */
 ( function ( mw, $ ) {
 
-var doneIEAlphaFix, doneIETransform, expandedURLs, fixalpha, isMSIE55,
-       relativeforfloats, setrelative;
+var expandedURLs, hasClass;
 
-isMSIE55 = window.isMSIE55 = ( window.showModalDialog && window.clipboardData && window.createPopup );
-doneIETransform = window.doneIETransform = undefined;
-doneIEAlphaFix = window.doneIEAlphaFix = undefined;
+// Also returns true for IE6, 7, 8, 9 and 10. createPopup is removed in IE11.
+// Good thing this is only loaded for IE <= 6 by wikibits.
+// Might as well set it to true.
+isMSIE55 = ( window.showModalDialog && window.clipboardData && window.createPopup );
+doneIETransform = false;
+doneIEAlphaFix = false;
 
-window.hookit = function () {
+hookit = function () {
        if ( !doneIETransform && document.getElementById && document.getElementById( 'bodyContent' ) ) {
                doneIETransform = true;
-               relativeforfloats();
                fixalpha();
        }
 };
 
 if ( document.attachEvent ) {
-       document.attachEvent( 'onreadystatechange', window.hookit );
+       document.attachEvent( 'onreadystatechange', hookit );
 }
 
 // png alpha transparency fixes
-fixalpha = window.fixalpha = function ( logoId ) {
+fixalpha = function ( logoId ) {
        // bg
        if ( isMSIE55 && !doneIEAlphaFix ) {
                var bg, imageUrl, linkFix, logoa, logospan, plogo;
@@ -73,34 +78,9 @@ if ( isMSIE55 ) {
        $( fixalpha );
 }
 
-// fix ie6 disappering float bug
-relativeforfloats = window.relativeforfloats = function () {
-       var bc, tables, divs;
-       bc = document.getElementById( 'bodyContent' );
-       if ( bc ) {
-               tables = bc.getElementsByTagName( 'table' );
-               divs = bc.getElementsByTagName( 'div' );
-               setrelative( tables );
-               setrelative( divs );
-       }
-};
-
-setrelative = window.setrelative = function ( nodes ) {
-       var i = 0;
-       while ( i < nodes.length ) {
-               if( ( ( nodes[i].style.float && nodes[i].style.float !== ( 'none' ) ||
-                       ( nodes[i].align && nodes[i].align !== ( 'none' ) ) ) &&
-                       ( !nodes[i].style.position || nodes[i].style.position !== 'relative' ) ) )
-               {
-                       nodes[i].style.position = 'relative';
-               }
-               i++;
-       }
-};
-
 // Expand links for printing
-String.prototype.hasClass = function ( classWanted ) {
-       var i = 0, classArr = this.split(/\s/);
+hasClass = function ( classText, classWanted ) {
+       var i = 0, classArr = classText.split(/\s/);
        for ( i = 0; i < classArr.length; i++ ) {
                if ( classArr[i].toLowerCase() === classWanted.toLowerCase() ) {
                        return true;
@@ -109,8 +89,6 @@ String.prototype.hasClass = function ( classWanted ) {
        return false;
 };
 
-expandedURLs = window.expandedURLs = undefined;
-
 window.onbeforeprint = function () {
        var allLinks, contentEl, expandedLink, expandedText, i;
 
@@ -121,7 +99,7 @@ window.onbeforeprint = function () {
                allLinks = contentEl.getElementsByTagName( 'a' );
 
                for ( i = 0; i < allLinks.length; i++ ) {
-                       if ( allLinks[i].className.hasClass( 'external' ) && !allLinks[i].className.hasClass( 'free' ) ) {
+                       if ( hasClass( allLinks[i].className, 'external' ) && !hasClass( allLinks[i].className, 'free' ) ) {
                                expandedLink = document.createElement( 'span' );
                                expandedText = document.createTextNode( ' (' + allLinks[i].href + ')' );
                                expandedLink.appendChild( expandedText );
@@ -132,7 +110,7 @@ window.onbeforeprint = function () {
        }
 };
 
-window.onafterprint = function() {
+window.onafterprint = function () {
        for ( var i = 0; i < expandedURLs.length; i++ ) {
                if ( expandedURLs[i] ) {
                        expandedURLs[i].removeNode( true );