[Core JS] wikibits.js / IEFixes clean up
authorKrinkle <krinkle@users.mediawiki.org>
Mon, 26 Dec 2011 16:12:07 +0000 (16:12 +0000)
committerKrinkle <krinkle@users.mediawiki.org>
Mon, 26 Dec 2011 16:12:07 +0000 (16:12 +0000)
* fix on-the-loose fixalpha() call
-- Calls should not be dangling loose like that
-- Removed local calls from skins and installer
-- instead calling from the IEFixes script (which is loaded raw by wikibits which is loaded from the bottom, as are all legacy scripts)
* Removing usage of 'skinpath' and 'skin' globals in wikibits.js, those aren't globals per se since introduction of mw.config and $wgLegacyJavaScriptGlobals
* Wrapping wikibits.js in closure to avoid leakage of "local" variables. This shouldn't break anything as it is loaded through resource loader which, in production mode, wraps it in a closure anyway.
* adding explicit posision=>bottom for wikibits. 'bottom' is default but repeating here since it must not change for legacy reasons.

includes/installer/WebInstallerOutput.php
resources/Resources.php
skins/MonoBook.php
skins/Vector.php
skins/common/IEFixes.js
skins/common/wikibits.js

index a28cda0..ac97b37 100644 (file)
@@ -232,7 +232,6 @@ class WebInstallerOutput {
                href="http://www.mediawiki.org/"
                title="Main Page"></a>
        </div>
-       <script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script>
        <div class="portal"><div class="body">
 <?php
        echo $this->parent->parse( wfMsgNoTrans( 'config-sidebar' ), true );
index efbbab3..9e0d689 100644 (file)
@@ -833,6 +833,7 @@ return array(
                'localBasePath' => $GLOBALS['wgStyleDirectory'],
                'dependencies' => 'mediawiki.language',
                'messages' => array( 'showtoc', 'hidetoc' ),
+               'position' => 'bottom',
        ),
        'mediawiki.legacy.wikiprintable' => array(
                'styles' => array( 'common/wikiprintable.css' => array( 'media' => 'print' ) ),
index b799fbc..0e10b5b 100644 (file)
@@ -109,7 +109,6 @@ class MonoBookTemplate extends BaseTemplate {
                                + Linker::tooltipAndAccesskeyAttribs('p-logo') ); ?>
 
        </div>
-       <script type="<?php $this->text('jsmimetype') ?>"> if (window.isMSIE55) fixalpha(); </script>
 <?php
        $this->renderPortals( $this->data['sidebar'] );
 ?>
index 1779566..4b6433d 100644 (file)
@@ -238,9 +238,6 @@ class VectorTemplate extends BaseTemplate {
                        <div style="clear:both"></div>
                </div>
                <!-- /footer -->
-               <!-- fixalpha -->
-               <script type="<?php $this->text( 'jsmimetype' ) ?>"> if ( window.isMSIE55 ) fixalpha(); </script>
-               <!-- /fixalpha -->
                <?php $this->printTrail(); ?>
 
        </body>
index 7f3b9c0..427d41c 100644 (file)
@@ -63,6 +63,12 @@ window.fixalpha = function( logoId ) {
        }
 };
 
+if( isMSIE55 ) {
+       // Legacy modules are loaded from the bottom
+       // No need to wait for DOMContentReady or window.onload
+       fixalpha();
+}
+
 // fix ie6 disappering float bug
 window.relativeforfloats = function() {
        var bc = document.getElementById( 'bodyContent' );
index 682034a..a6ba268 100644 (file)
@@ -1,4 +1,7 @@
-// MediaWiki JavaScript support functions
+/**
+ * MediaWiki legacy wikibits
+ */
+(function(){
 
 window.clientPC = navigator.userAgent.toLowerCase(); // Get client info
 window.is_gecko = /gecko/.test( clientPC ) &&
@@ -47,7 +50,7 @@ if ( /msie ([0-9]{1,}[\.0-9]{0,})/.exec( clientPC ) != null
 }
 
 // Global external objects used by this script.
-/*extern ta, stylepath, skin */
+/*extern ta */
 
 // add any onload functions in this hook (please don't hard-code any events in the xhtml source)
 window.doneOnloadHook = undefined;
@@ -116,20 +119,20 @@ window.appendCSS = function( text ) {
 };
 
 // Special stylesheet links for Monobook only (see bug 14717)
-if ( typeof stylepath != 'undefined' && skin == 'monobook' ) {
+var skinpath = mw.config.get( 'stylepath' ) + '/' + mw.config.get( 'skin' );
+if ( mw.config.get( 'skin' ) === 'monobook' ) {
        if ( opera6_bugs ) {
-               importStylesheetURI( stylepath + '/' + skin + '/Opera6Fixes.css' );
+               importStylesheetURI( skinpath + '/Opera6Fixes.css' );
        } else if ( opera7_bugs ) {
-               importStylesheetURI( stylepath + '/' + skin + '/Opera7Fixes.css' );
+               importStylesheetURI( skinpath + '/Opera7Fixes.css' );
        } else if ( opera95_bugs ) {
-               importStylesheetURI( stylepath + '/' + skin + '/Opera9Fixes.css' );
+               importStylesheetURI( skinpath + '/Opera9Fixes.css' );
        } else if ( ff2_bugs ) {
-               importStylesheetURI( stylepath + '/' + skin + '/FF2Fixes.css' );
+               importStylesheetURI( skinpath + '/FF2Fixes.css' );
        }
 }
 
-
-if ( 'wgBreakFrames' in window && window.wgBreakFrames ) {
+if ( mw.config.get( 'wgBreakFrames' ) ) {
        // Un-trap us from framesets
        if ( window.top != window ) {
                window.top.location = window.location;
@@ -581,7 +584,7 @@ window.jsMsg = function( message, className ) {
 window.injectSpinner = function( element, id ) {
        var spinner = document.createElement( 'img' );
        spinner.id = 'mw-spinner-' + id;
-       spinner.src = stylepath + '/common/images/spinner.gif';
+       spinner.src = mw.config.get( 'stylepath' ) + '/common/images/spinner.gif';
        spinner.alt = spinner.title = '...';
        if( element.nextSibling ) {
                element.parentNode.insertBefore( spinner, element.nextSibling );
@@ -666,5 +669,7 @@ window.removeHandler = function( element, remove, handler ) {
 hookEvent( 'load', runOnloadHook );
 
 if ( ie6_bugs ) {
-       importScriptURI( stylepath + '/common/IEFixes.js' );
+       importScriptURI( mw.config.get( 'stylepath' ) + '/common/IEFixes.js' );
 }
+
+})();