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)
This commit is contained in:
Krinkle 2011-06-22 21:27:12 +00:00
parent 0de8d5299d
commit 95173d11f1
8 changed files with 66 additions and 45 deletions

View file

@ -2359,7 +2359,12 @@ $templates
$wgUseAjax, $wgAjaxWatch, $wgEnableMWSuggest;
// Add base resources
$this->addModules( array( 'mediawiki.user', 'mediawiki.util', 'mediawiki.action.view.tablesorting' ) );
$this->addModules( array(
'mediawiki.user',
'mediawiki.util',
'mediawiki.page.startup',
'mediawiki.page.ready',
) );
if ( $wgIncludeLegacyJavaScript ){
$this->addModules( 'mediawiki.legacy.wikibits' );
}

View file

@ -448,16 +448,28 @@ return array(
'jquery.cookie',
),
),
'mediawiki.page.startup' => array(
'scripts' => 'resources/mediawiki.page/mediawiki.page.startup.js',
'dependencies' => array(
'jquery.client',
),
'position' => 'top',
),
'mediawiki.page.ready' => array(
'scripts' => 'resources/mediawiki.page/mediawiki.page.ready.js',
'dependencies' => array(
'jquery.checkboxShiftClick',
'jquery.makeCollapsible',
'jquery.placeholder',
),
),
'mediawiki.util' => array(
'scripts' => 'resources/mediawiki/mediawiki.util.js',
'dependencies' => array(
'jquery.checkboxShiftClick',
'jquery.client',
'jquery.cookie',
'jquery.messageBox',
'jquery.makeCollapsible',
'jquery.mwPrototypes',
'jquery.placeholder',
),
),
'mediawiki.libs.jpegmeta' => array(
@ -482,9 +494,6 @@ return array(
'scripts' => 'resources/mediawiki.action/mediawiki.action.view.metadata.js',
'messages' => array( 'metadata-expand', 'metadata-collapse' ),
),
'mediawiki.action.view.tablesorting' => array(
'scripts' => 'resources/mediawiki.action/mediawiki.action.view.tablesorting.js',
),
'mediawiki.action.watch.ajax' => array(
'scripts' => 'resources/mediawiki.action/mediawiki.action.watch.ajax.js',
'messages' => array(

View file

@ -202,14 +202,4 @@
return true;
}
};
$( document ).ready( function() {
var profile = $.client.profile();
$( 'html' )
.addClass( 'client-' + profile.name )
.addClass( 'client-' + profile.name + '-' + profile.versionBase )
.addClass( 'client-' + profile.layout )
.addClass( 'client-' + profile.platform );
} );
} )( jQuery );

View file

@ -1,9 +0,0 @@
// Lazy load jquery.tablesorter
( function( $ ) {
if ( $( 'table.sortable' ).length ) {
mw.loader.using( 'jquery.tablesorter', function() {
$( 'table.sortable' ).tablesorter();
} );
}
} )( jQuery );

View file

@ -0,0 +1,21 @@
jQuery( document ).ready( function( $ ) {
/* Emulate placeholder if not supported by browser */
if ( !( 'placeholder' in document.createElement( 'input' ) ) ) {
$( 'input[placeholder]' ).placeholder();
}
/* Enable makeCollapse */
$( '.mw-collapsible' ).makeCollapsible();
/* Lazy load jquery.tablesorter */
if ( $( 'table.sortable' ).length ) {
mw.loader.using( 'jquery.tablesorter', function() {
$( 'table.sortable' ).tablesorter();
});
}
/* Enable CheckboxShiftClick */
$( 'input[type=checkbox]:not(.noshiftselect)' ).checkboxShiftClick();
} );

View file

@ -0,0 +1,13 @@
( function( $ ) {
/* Client profile classes for <html> */
var prof = $.client.profile();
$( 'html' ).addClass(
'client-' + prof.name
+ ' client-' + prof.name + '-' + prof.versionBase
+ ' client-' + prof.layout
+ ' client-' + prof.platform
);
} )( jQuery );

View file

@ -57,14 +57,6 @@
mw.util.tooltipAccessKeyPrefix = 'alt-shift-';
}
/* Enable CheckboxShiftClick */
$( 'input[type=checkbox]:not(.noshiftselect)' ).checkboxShiftClick();
/* Emulate placeholder if not supported by browser */
if ( !( 'placeholder' in document.createElement( 'input' ) ) ) {
$( 'input[placeholder]' ).placeholder();
}
/* Fill $content var */
if ( $( '#bodyContent' ).length ) {
// Vector, Monobook, Chick etc.
@ -86,9 +78,6 @@
mw.util.$content = $( '#content' );
}
/* Enable makeCollapse */
$( '.mw-collapsible' ).makeCollapsible();
/* Table of Contents toggle */
var $tocContainer = $( '#toc' ),
$tocTitle = $( '#toctitle' ),

View file

@ -16,17 +16,20 @@
<script src="../../resources/jquery/jquery.js"></script>
<script src="../../resources/mediawiki/mediawiki.js"></script>
<!-- MW: mediawiki.user|mediawiki.util -->
<script src="../../resources/mediawiki/mediawiki.user.js"></script>
<script src="../../resources/jquery/jquery.checkboxShiftClick.js"></script>
<!-- MW: mediawiki.page.startup -->
<script src="../../resources/mediawiki.page/mediawiki.page.startup.js"></script>
<script src="../../resources/jquery/jquery.client.js"></script>
<!-- MW: mediawiki.user|mediawiki.util|mediawiki.page.ready -->
<script src="../../resources/mediawiki/mediawiki.user.js"></script>
<script src="../../resources/jquery/jquery.cookie.js"></script>
<script src="../../resources/jquery/jquery.messageBox.js"></script>
<script src="../../resources/jquery/jquery.makeCollapsible.js"></script>
<script src="../../resources/jquery/jquery.mwPrototypes.js"></script>
<script src="../../resources/jquery/jquery.placeholder.js"></script>
<script src="../../resources/jquery/jquery.tablesorter.js"></script>
<script src="../../resources/mediawiki/mediawiki.util.js"></script>
<script src="../../resources/jquery/jquery.messageBox.js"></script>
<script src="../../resources/jquery/jquery.mwPrototypes.js"></script>
<script src="../../resources/mediawiki.page/mediawiki.page.ready.js"></script>
<script src="../../resources/jquery/jquery.checkboxShiftClick.js"></script>
<script src="../../resources/jquery/jquery.makeCollapsible.js"></script>
<script src="../../resources/jquery/jquery.placeholder.js"></script>
<!-- MW: user.options -->
<script>