r96150 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96149‎ | r96150 | r96151 >
Date:21:17, 2 September 2011
Author:krinkle
Status:ok
Tags:
Comment:
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 (modified) (history)
  • /trunk/phase3/resources/mediawiki.page/mediawiki.page.ready.js (modified) (history)
  • /trunk/phase3/resources/mediawiki/mediawiki.util.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/Resources.php
@@ -647,6 +647,7 @@
648648 'jquery.checkboxShiftClick',
649649 'jquery.makeCollapsible',
650650 'jquery.placeholder',
 651+ 'mediawiki.util',
651652 ),
652653 ),
653654 'mediawiki.page.startup' => array(
Index: trunk/phase3/resources/mediawiki/mediawiki.util.js
@@ -6,18 +6,12 @@
77 // Local cache and alias
88 var util = mw.util = {
99
10 - /* Initialisation */
1110 /**
12 - * @var boolean Wether or not already initialised
 11+ * Initialisation
 12+ * (don't call before document ready)
1313 */
14 - 'initialised' : false,
1514 'init' : function() {
16 - if ( this.initialised === false ) {
17 - this.initialised = true;
1815
19 - // Following the initialisation after the DOM is ready
20 - $(document).ready( function() {
21 -
2216 /* Set up $.messageBox */
2317 $.messageBoxNew( {
2418 'id': 'mw-js-message',
@@ -99,11 +93,6 @@
10094 $tocToggleLink.click();
10195 }
10296 }
103 - } );
104 -
105 - return true;
106 - }
107 - return false;
10897 },
10998
11099 /* Main body */
@@ -596,6 +585,4 @@
597586
598587 };
599588
600 - util.init();
601 -
602589 } )( jQuery );
Index: trunk/phase3/resources/mediawiki.page/mediawiki.page.ready.js
@@ -1,5 +1,8 @@
22 jQuery( document ).ready( function( $ ) {
33
 4+ /* Initialize utilities (messageBoxNew, profile, tooltip access keys, TOC etc.) */
 5+ mw.util.init();
 6+
47 /* Emulate placeholder if not supported by browser */
58 if ( !( 'placeholder' in document.createElement( 'input' ) ) ) {
69 $( 'input[placeholder]' ).placeholder();

Follow-up revisions

RevisionCommit summaryAuthorDate
r96151Whitespace indention fix for r96150 (seperate to make review easier)krinkle21:19, 2 September 2011

Status & tagging log