}
/* Fill $content var */
- if ( $( '#bodyContent' ).length ) {
- // Vector, Monobook, Chick etc.
- util.$content = $( '#bodyContent' );
-
- } else if ( $( '#mw_contentholder' ).length ) {
- // Modern
- util.$content = $( '#mw_contentholder' );
-
- } else if ( $( '#article' ).length ) {
- // Standard, CologneBlue
- util.$content = $( '#article' );
+ util.$content = ( function () {
+ var $content, selectors = [
+ // The preferred standard for setting $content (class="mw-body")
+ // You may also use (class="mw-body mw-body-primary") if you use
+ // mw-body in multiple locations.
+ // Or class="mw-body-primary" if you want $content to be deeper
+ // in the dom than mw-body
+ '.mw-body-primary',
+ '.mw-body',
+
+ /* Legacy fallbacks for setting the content */
+ // Vector, Monobook, Chick, etc... based skins
+ '#bodyContent',
+
+ // Modern based skins
+ '#mw_contentholder',
+
+ // Standard, CologneBlue
+ '#article',
+
+ // #content is present on almost all if not all skins. Most skins (the above cases)
+ // have #content too, but as an outer wrapper instead of the article text container.
+ // The skins that don't have an outer wrapper do have #content for everything
+ // so it's a good fallback
+ '#content',
+
+ // If nothing better is found fall back to our bodytext div that is guaranteed to be here
+ '#mw-content-text',
+
+ // Should never happen... well, it could if someone is not finished writing a skin and has
+ // not inserted bodytext yet. But in any case <body> should always exist
+ 'body'
+ ];
+ for ( var i = 0, l = selectors.length; i < l; i++ ) {
+ $content = $( selectors[i] ).first();
+ if ( $content.length ) {
+ return $content;
+ }
+ }
- } else {
- // #content is present on almost all if not all skins. Most skins (the above cases)
- // have #content too, but as an outer wrapper instead of the article text container.
- // The skins that don't have an outer wrapper do have #content for everything
- // so it's a good fallback
- util.$content = $( '#content' );
- }
+ // Make sure we don't unset util.$content if it was preset and we don't find anything
+ return util.$content;
+ } )();
// Table of contents toggle
$tocTitle = $( '#toctitle' );
/*
* @var jQuery
- * A jQuery object that refers to the page-content element
+ * A jQuery object that refers to the content area element
* Populated by init().
*/
$content: null,
<!-- contentholder does nothing by default, but it allows users to style the text inside
the content area without affecting the meaning of 'em' in #mw_content, which is used
for the margins -->
- <div id="mw_contentholder">
+ <div id="mw_contentholder" class="mw-body">
<div class='mw-topboxes'>
<div id="mw-js-message" style="display:none;"<?php $this->html('userlangattributes')?>></div>
<div class="mw-topbox" id="siteSub"><?php $this->msg('tagline') ?></div>