r90605 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90604‎ | r90605 | r90606 >
Date:21:27, 22 June 2011
Author:krinkle
Status:ok (Comments)
Tags:
Comment:
New mediawiki.page modules

First step towards cleaning up mw.util.init and removing bugus dependancies on mediawiki.util which are just added there in order to load them on every page and do something on-load.

Introducing mediawiki.page.startup (in the head) and mediawiki.page.ready (on the bottom)

Moved the following to them:
* document.ready from jquery.cient
-- Shouldn't have been in the plugin itself in the first place
* jquery.placeholder
* jquery.makeCollapsible
* mediawiki.action.view.tablesorting
* jquery.checkboxShiftClick

(This also solves part of bug 26799)
Modified paths:
  • /trunk/phase3/includes/OutputPage.php (modified) (history)
  • /trunk/phase3/resources/Resources.php (modified) (history)
  • /trunk/phase3/resources/jquery/jquery.client.js (modified) (history)
  • /trunk/phase3/resources/mediawiki.action/mediawiki.action.view.tablesorting.js (deleted) (history)
  • /trunk/phase3/resources/mediawiki.page (added) (history)
  • /trunk/phase3/resources/mediawiki.page/mediawiki.page.ready.js (added) (history)
  • /trunk/phase3/resources/mediawiki.page/mediawiki.page.startup.js (added) (history)
  • /trunk/phase3/resources/mediawiki/mediawiki.util.js (modified) (history)
  • /trunk/phase3/tests/qunit/index.html (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/qunit/index.html
@@ -16,17 +16,20 @@
1717 <script src="../../resources/jquery/jquery.js"></script>
1818 <script src="../../resources/mediawiki/mediawiki.js"></script>
1919
20 - <!-- MW: mediawiki.user|mediawiki.util -->
 20+ <!-- MW: mediawiki.page.startup -->
 21+ <script src="../../resources/mediawiki.page/mediawiki.page.startup.js"></script>
 22+ <script src="../../resources/jquery/jquery.client.js"></script>
 23+
 24+ <!-- MW: mediawiki.user|mediawiki.util|mediawiki.page.ready -->
2125 <script src="../../resources/mediawiki/mediawiki.user.js"></script>
22 - <script src="../../resources/jquery/jquery.checkboxShiftClick.js"></script>
23 - <script src="../../resources/jquery/jquery.client.js"></script>
2426 <script src="../../resources/jquery/jquery.cookie.js"></script>
 27+ <script src="../../resources/mediawiki/mediawiki.util.js"></script>
2528 <script src="../../resources/jquery/jquery.messageBox.js"></script>
 29+ <script src="../../resources/jquery/jquery.mwPrototypes.js"></script>
 30+ <script src="../../resources/mediawiki.page/mediawiki.page.ready.js"></script>
 31+ <script src="../../resources/jquery/jquery.checkboxShiftClick.js"></script>
2632 <script src="../../resources/jquery/jquery.makeCollapsible.js"></script>
27 - <script src="../../resources/jquery/jquery.mwPrototypes.js"></script>
2833 <script src="../../resources/jquery/jquery.placeholder.js"></script>
29 - <script src="../../resources/jquery/jquery.tablesorter.js"></script>
30 - <script src="../../resources/mediawiki/mediawiki.util.js"></script>
3134
3235 <!-- MW: user.options -->
3336 <script>
Index: trunk/phase3/includes/OutputPage.php
@@ -2359,7 +2359,12 @@
23602360 $wgUseAjax, $wgAjaxWatch, $wgEnableMWSuggest;
23612361
23622362 // Add base resources
2363 - $this->addModules( array( 'mediawiki.user', 'mediawiki.util', 'mediawiki.action.view.tablesorting' ) );
 2363+ $this->addModules( array(
 2364+ 'mediawiki.user',
 2365+ 'mediawiki.util',
 2366+ 'mediawiki.page.startup',
 2367+ 'mediawiki.page.ready',
 2368+ ) );
23642369 if ( $wgIncludeLegacyJavaScript ){
23652370 $this->addModules( 'mediawiki.legacy.wikibits' );
23662371 }
Index: trunk/phase3/resources/jquery/jquery.client.js
@@ -202,14 +202,4 @@
203203 return true;
204204 }
205205 };
206 -
207 - $( document ).ready( function() {
208 - var profile = $.client.profile();
209 - $( 'html' )
210 - .addClass( 'client-' + profile.name )
211 - .addClass( 'client-' + profile.name + '-' + profile.versionBase )
212 - .addClass( 'client-' + profile.layout )
213 - .addClass( 'client-' + profile.platform );
214 - } );
215 -
216206 } )( jQuery );
Index: trunk/phase3/resources/mediawiki.action/mediawiki.action.view.tablesorting.js
@@ -1,9 +0,0 @@
2 -// Lazy load jquery.tablesorter
3 -
4 -( function( $ ) {
5 - if ( $( 'table.sortable' ).length ) {
6 - mw.loader.using( 'jquery.tablesorter', function() {
7 - $( 'table.sortable' ).tablesorter();
8 - } );
9 - }
10 -} )( jQuery );
\ No newline at end of file
Index: trunk/phase3/resources/Resources.php
@@ -448,16 +448,28 @@
449449 'jquery.cookie',
450450 ),
451451 ),
 452+ 'mediawiki.page.startup' => array(
 453+ 'scripts' => 'resources/mediawiki.page/mediawiki.page.startup.js',
 454+ 'dependencies' => array(
 455+ 'jquery.client',
 456+ ),
 457+ 'position' => 'top',
 458+ ),
 459+ 'mediawiki.page.ready' => array(
 460+ 'scripts' => 'resources/mediawiki.page/mediawiki.page.ready.js',
 461+ 'dependencies' => array(
 462+ 'jquery.checkboxShiftClick',
 463+ 'jquery.makeCollapsible',
 464+ 'jquery.placeholder',
 465+ ),
 466+ ),
452467 'mediawiki.util' => array(
453468 'scripts' => 'resources/mediawiki/mediawiki.util.js',
454469 'dependencies' => array(
455 - 'jquery.checkboxShiftClick',
456470 'jquery.client',
457471 'jquery.cookie',
458472 'jquery.messageBox',
459 - 'jquery.makeCollapsible',
460473 'jquery.mwPrototypes',
461 - 'jquery.placeholder',
462474 ),
463475 ),
464476 'mediawiki.libs.jpegmeta' => array(
@@ -482,9 +494,6 @@
483495 'scripts' => 'resources/mediawiki.action/mediawiki.action.view.metadata.js',
484496 'messages' => array( 'metadata-expand', 'metadata-collapse' ),
485497 ),
486 - 'mediawiki.action.view.tablesorting' => array(
487 - 'scripts' => 'resources/mediawiki.action/mediawiki.action.view.tablesorting.js',
488 - ),
489498 'mediawiki.action.watch.ajax' => array(
490499 'scripts' => 'resources/mediawiki.action/mediawiki.action.watch.ajax.js',
491500 'messages' => array(
Index: trunk/phase3/resources/mediawiki/mediawiki.util.js
@@ -57,14 +57,6 @@
5858 mw.util.tooltipAccessKeyPrefix = 'alt-shift-';
5959 }
6060
61 - /* Enable CheckboxShiftClick */
62 - $( 'input[type=checkbox]:not(.noshiftselect)' ).checkboxShiftClick();
63 -
64 - /* Emulate placeholder if not supported by browser */
65 - if ( !( 'placeholder' in document.createElement( 'input' ) ) ) {
66 - $( 'input[placeholder]' ).placeholder();
67 - }
68 -
6961 /* Fill $content var */
7062 if ( $( '#bodyContent' ).length ) {
7163 // Vector, Monobook, Chick etc.
@@ -86,9 +78,6 @@
8779 mw.util.$content = $( '#content' );
8880 }
8981
90 - /* Enable makeCollapse */
91 - $( '.mw-collapsible' ).makeCollapsible();
92 -
9382 /* Table of Contents toggle */
9483 var $tocContainer = $( '#toc' ),
9584 $tocTitle = $( '#toctitle' ),
Index: trunk/phase3/resources/mediawiki.page/mediawiki.page.startup.js
@@ -0,0 +1,13 @@
 2+( function( $ ) {
 3+
 4+ /* Client profile classes for <html> */
 5+
 6+ var prof = $.client.profile();
 7+ $( 'html' ).addClass(
 8+ 'client-' + prof.name
 9+ + ' client-' + prof.name + '-' + prof.versionBase
 10+ + ' client-' + prof.layout
 11+ + ' client-' + prof.platform
 12+ );
 13+
 14+} )( jQuery );
Property changes on: trunk/phase3/resources/mediawiki.page/mediawiki.page.startup.js
___________________________________________________________________
Added: svn:eol-style
115 + native
Index: trunk/phase3/resources/mediawiki.page/mediawiki.page.ready.js
@@ -0,0 +1,21 @@
 2+jQuery( document ).ready( function( $ ) {
 3+
 4+ /* Emulate placeholder if not supported by browser */
 5+ if ( !( 'placeholder' in document.createElement( 'input' ) ) ) {
 6+ $( 'input[placeholder]' ).placeholder();
 7+ }
 8+
 9+ /* Enable makeCollapse */
 10+ $( '.mw-collapsible' ).makeCollapsible();
 11+
 12+ /* Lazy load jquery.tablesorter */
 13+ if ( $( 'table.sortable' ).length ) {
 14+ mw.loader.using( 'jquery.tablesorter', function() {
 15+ $( 'table.sortable' ).tablesorter();
 16+ });
 17+ }
 18+
 19+ /* Enable CheckboxShiftClick */
 20+ $( 'input[type=checkbox]:not(.noshiftselect)' ).checkboxShiftClick();
 21+
 22+} );
Property changes on: trunk/phase3/resources/mediawiki.page/mediawiki.page.ready.js
___________________________________________________________________
Added: svn:eol-style
123 + native

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r80036Included client in the initial payload. Restored functionality that used to e...tparscal20:56, 11 January 2011

Comments

#Comment by Aaron Schulz (talk | contribs)   00:37, 25 June 2011

What happened to mediawiki.action.view.tablesorting?

#Comment by Krinkle (talk | contribs)   01:20, 25 June 2011

See commit message.

Moved the following to them [mediawiki.page modules]:


  • mediawiki.action.view.tablesorting

+++ trunk/phase3/resources/mediawiki.page/mediawiki.page.ready.js
+	/* Lazy load jquery.tablesorter */
+	if ( $( 'table.sortable' ).length ) {
+		mw.loader.using( 'jquery.tablesorter', function() {
+			$( 'table.sortable' ).tablesorter();
+		});
+	}
#Comment by Aaron Schulz (talk | contribs)   01:21, 25 June 2011

Of course I looked at the message, but I missed it in the diff.

#Comment by Krinkle (talk | contribs)   01:24, 25 June 2011

No problem. Thanks for going through my commits lately!

#Comment by Aaron Schulz (talk | contribs)   01:27, 25 June 2011

I should file a but against CR...the links to files that were deleted should have pathrev one lower that the rev in question (and have no diff link). That way you could see the old file that was deleted more quickly.

#Comment by Krinkle (talk | contribs)   16:59, 25 June 2011

Yeah, I hate it when it does that.

#Comment by Aaron Schulz (talk | contribs)   17:12, 25 June 2011

r90748 :)

#Comment by He7d3r (talk | contribs)   11:17, 23 February 2012

Shoudn't this be marked as a followup to r80036?

#Comment by Krinkle (talk | contribs)   12:21, 23 February 2012

Thx, done

Status & tagging log