http://www.mediawiki.org/wiki/Special:Code/MediaWiki/96150

Revision: 96150
Author:   krinkle
Date:     2011-09-02 21:17:54 +0000 (Fri, 02 Sep 2011)
Log Message:
-----------
Separate execution from definition (mediawiki.util.init)
* bug 30710

Also makes it easier to do unit testing, this way the module can be included 
and the test can initialize it if and when it wants to.

Modified Paths:
--------------
    trunk/phase3/resources/Resources.php
    trunk/phase3/resources/mediawiki/mediawiki.util.js
    trunk/phase3/resources/mediawiki.page/mediawiki.page.ready.js

Modified: trunk/phase3/resources/Resources.php
===================================================================
--- trunk/phase3/resources/Resources.php        2011-09-02 21:02:04 UTC (rev 
96149)
+++ trunk/phase3/resources/Resources.php        2011-09-02 21:17:54 UTC (rev 
96150)
@@ -647,6 +647,7 @@
                        'jquery.checkboxShiftClick',
                        'jquery.makeCollapsible',
                        'jquery.placeholder',
+                       'mediawiki.util',
                ),
        ),
        'mediawiki.page.startup' => array(

Modified: trunk/phase3/resources/mediawiki/mediawiki.util.js
===================================================================
--- trunk/phase3/resources/mediawiki/mediawiki.util.js  2011-09-02 21:02:04 UTC 
(rev 96149)
+++ trunk/phase3/resources/mediawiki/mediawiki.util.js  2011-09-02 21:17:54 UTC 
(rev 96150)
@@ -6,18 +6,12 @@
        // Local cache and alias
        var util = mw.util = {
 
-               /* Initialisation */
                /**
-                * @var boolean Wether or not already initialised
+                * Initialisation
+                * (don't call before document ready)
                 */
-               'initialised' : false,
                'init' : function() {
-                       if ( this.initialised === false ) {
-                               this.initialised = true;
 
-                               // Following the initialisation after the DOM 
is ready
-                               $(document).ready( function() {
-
                                        /* Set up $.messageBox */
                                        $.messageBoxNew( {
                                                'id': 'mw-js-message',
@@ -99,11 +93,6 @@
                                                        $tocToggleLink.click();
                                                }
                                        }
-                               } );
-
-                               return true;
-                       }
-                       return false;
                },
 
                /* Main body */
@@ -596,6 +585,4 @@
 
        };
 
-       util.init();
-
 } )( jQuery );

Modified: trunk/phase3/resources/mediawiki.page/mediawiki.page.ready.js
===================================================================
--- trunk/phase3/resources/mediawiki.page/mediawiki.page.ready.js       
2011-09-02 21:02:04 UTC (rev 96149)
+++ trunk/phase3/resources/mediawiki.page/mediawiki.page.ready.js       
2011-09-02 21:17:54 UTC (rev 96150)
@@ -1,5 +1,8 @@
 jQuery( document ).ready( function( $ ) {
 
+       /* Initialize utilities (messageBoxNew, profile, tooltip access keys, 
TOC etc.) */
+       mw.util.init();
+
        /* Emulate placeholder if not supported by browser */
        if ( !( 'placeholder' in document.createElement( 'input' ) ) ) {
                $( 'input[placeholder]' ).placeholder();


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to