< Snippets
![]() | |
---|---|
Language(s): | JavaScript |
Compatible with: | MediaWiki 1.17+ (Vector; Monobook) |
Description
On the main page (and its associated namespaces and actions (Talk, edit, history etc.) this script will put "Main Page" instead of "Article" or "Page" in the first tab. Works in both Vector and Monobook.
Native
MediaWiki version: | ≥ 1.18 |
If you are using 1.18 or higher, you can instead use the interface message "mainpage-nstab". You can do this by creating the page MediaWiki:mainpage-nstab on your wiki (requires administrator rights) with the desired label.
Code
MediaWiki version: | 1.17 |
/**
* MainPage tab
*
* @source mediawiki.org/wiki/Snippets/Main_Page_tab
* @version 2014-07-30
*/
$( function() {
var title = mw.config.get( 'wgTitle' ),
hasMainPageTab = (title === 'Main Page'); // Title of the main page
if ( hasMainPageTab ) {
$( '#ca-nstab-main' ).find( 'a' ).text( title );
}
} );
Alternative
The following requires $wgHtml5 to be set to true
.
PageTab.js
/**
* Page-tab
* Replace "Article", "Page", or whatever in page/namespace tab with custom string
*
* @rev 1
*/
$( document ).ready( function () {
var title = $.trim( $( '#mw-nstab' ).data( 'nstab' ) );
if ( title !== '' ) {
$('#ca-nstab-' + ( mw.config.get( 'wgCanonicalNamespace' ).toLowerCase() || 'main' ) ).find( 'a' ).text( title );
}
} );
Template:Page_tab
<span id="mw-nstab" data-nstab="{{{1|}}}"></span>
Usage
{{Page tab|Awesome Tab}}
This article is issued from Mediawiki. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.