|
|
Line 1: |
Line 1: |
| /** | | /* Any JavaScript here will be loaded for all users on every page load. */ |
| * Keep code in MediaWiki:Common.js to a minimum as it is unconditionally
| |
| * loaded for all users on every wiki page. If possible create a gadget that is
| |
| * enabled by default instead of adding it here (since gadgets are fully
| |
| * optimized ResourceLoader modules with possibility to add dependencies etc.)
| |
| *
| |
| * Since Common.js isn't a gadget, there is no place to declare its
| |
| * dependencies, so we have to lazy load them with mw.loader.using on demand and
| |
| * then execute the rest in the callback. In most cases these dependencies will
| |
| * be loaded (or loading) already and the callback will not be delayed. In case a
| |
| * dependency hasn't arrived yet it'll make sure those are loaded before this.
| |
| */
| |
|
| |
|
| /* global mw, $ */ | | if ( /^MediaWiki(\/.+)?$/.test( wgPageName ) && wgAction == "view" ) { |
| /* jshint strict:false, browser:true */ | | addOnloadHook(function(){ |
| | document.body.className+=" mainpage"; |
| | document.write('<style type="text/css">/*<![CDATA[*/ #lastmod, #siteSub, h1.firstHeading { display: none !important; } #content { padding-top: 1em; }/*]]>*/</style>'); /*REMOVE THIS LINE AFTER 22/01/2009 */ |
| | }) |
| | } |
|
| |
|
| mw.loader.using( ['mediawiki.user', 'mediawiki.util', 'mediawiki.notify', 'jquery.client'] ).done( function () {
| | /* Force preview for anons */ |
| /* Begin of mw.loader.using callback */ | | /* by Marc Mongenet, 2006, fr.wikipedia */ |
|
| |
|
| /**
| | function forcePreview() { |
| * Main Page layout fixes
| | if (wgUserName != null || wgAction != "edit") return; |
| *
| | saveButton = document.getElementById("wpSave"); |
| * Description: Adds an additional link to the complete list of languages available.
| | if (!saveButton) return; |
| * Maintainers: [[User:AzaToth]], [[User:R. Koot]], [[User:Alex Smotrov]]
| | saveButton.disabled = true; |
| */
| | saveButton.value = "Save page (use preview first)"; |
| if ( mw.config.get( 'wgPageName' ) === 'Main_Page' || mw.config.get( 'wgPageName' ) === 'Talk:Main_Page' ) { | | saveButton.style.fontWeight = "normal"; |
| $( function () {
| | document.getElementById("wpPreview").style.fontWeight = "bold"; |
| mw.util.addPortletLink( 'p-lang', '//meta.wikimedia.org/wiki/List_of_Wikipedias',
| |
| 'Complete list', 'interwiki-completelist', 'Complete list of Wikipedias' );
| |
| } );
| |
| } | | } |
| | addOnloadHook(forcePreview); |
| | |
| | /* End of forcePreview */ |
|
| |
|
| /** | | /** includePage ************ |
| * Redirect User:Name/skin.js and skin.css to the current skin's pages | | * force the loading of another JavaScript file |
| * (unless the 'skin' page really exists) | | * |
| * @source: http://www.mediawiki.org/wiki/Snippets/Redirect_skin.js | | * Maintainer: [[Commons:User:Dschwen]] |
| * @rev: 2
| |
| */ | | */ |
| if ( mw.config.get( 'wgArticleId' ) === 0 && mw.config.get( 'wgNamespaceNumber' ) === 2 ) {
| | |
| var titleParts = mw.config.get( 'wgPageName' ).split( '/' );
| | function includePage( name ) |
| /* Make sure there was a part before and after the slash
| | { |
| and that the latter is 'skin.js' or 'skin.css' */
| | document.write('<script type="text/javascript" src="/w/index.php?title=' |
| if ( titleParts.length == 2 ) {
| | + name |
| var userSkinPage = titleParts.shift() + '/' + mw.config.get( 'skin' );
| | + '&action=raw&ctype=text/javascript"><\/script>' |
| if ( titleParts.slice( -1 ) == 'skin.js' ) {
| | ); |
| window.location.href = mw.util.getUrl( userSkinPage + '.js' );
| |
| } else if ( titleParts.slice( -1 ) == 'skin.css' ) {
| |
| window.location.href = mw.util.getUrl( userSkinPage + '.css' );
| |
| }
| |
| }
| |
| } | | } |
| | /* End of includePage */ |
|
| |
|
| /** | | /* Including extra .js pages */ |
| * Map addPortletLink to mw.util
| |
| * @deprecated: Use mw.util.addPortletLink instead.
| |
| */
| |
| mw.log.deprecate( window, 'addPortletLink', mw.util.addPortletLink, 'Use mw.util.addPortletLink instead' );
| |
|
| |
|
| /** | | // switches for scripts |
| * Extract a URL parameter from the current URL
| | // TODO: migrate to JSConfig |
| * @deprecated: Use mw.util.getParamValue with proper escaping
| | // var load_extratabs = true; |
| */
| | var load_edittools = true; |
| mw.log.deprecate( window, 'getURLParamValue', mw.util.getParamValue, 'Use mw.util.getParamValue instead' );
| |
|
| |
|
| /** | | // extra drop down menu on editing for adding special characters |
| * Test if an element has a certain class
| | includePage( 'MediaWiki:Edittools.js' ); |
| * @deprecated: Use $(element).hasClass() instead.
| |
| */
| |
| mw.log.deprecate( window, 'hasClass', function ( element, className ) {
| |
| return $( element ).hasClass( className );
| |
| }, 'Use jQuery.hasClass() instead' );
| |
|
| |
|
| /** | | //Editpage scripts |
| * @source www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL
| | if (wgAction=='edit' || wgAction == 'submit') |
| * @rev 6
| | importScript('MediaWiki:Editpage.js') |
| */
| |
| var extraCSS = mw.util.getParamValue( 'withCSS' ),
| |
| extraJS = mw.util.getParamValue( 'withJS' );
| |
|
| |
|
| if ( extraCSS ) {
| | /* End of extra pages */ |
| if ( extraCSS.match( /^MediaWiki:[^&<>=%#]*\.css$/ ) ) {
| |
| mw.loader.load( '/w/index.php?title=' + extraCSS + '&action=raw&ctype=text/css', 'text/css' );
| |
| } else {
| |
| mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withCSS value' } );
| |
| }
| |
| }
| |
| | |
| if ( extraJS ) {
| |
| if ( extraJS.match( /^MediaWiki:[^&<>=%#]*\.js$/ ) ) {
| |
| mw.loader.load( '/w/index.php?title=' + extraJS + '&action=raw&ctype=text/javascript' );
| |
| } else {
| |
| mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withJS value' } );
| |
| }
| |
| }
| |
| | |
| /**
| |
| * WikiMiniAtlas
| |
| *
| |
| * Description: WikiMiniAtlas is a popup click and drag world map.
| |
| * This script causes all of our coordinate links to display the WikiMiniAtlas popup button.
| |
| * The script itself is located on meta because it is used by many projects.
| |
| * See [[Meta:WikiMiniAtlas]] for more information.
| |
| * Maintainers: [[User:Dschwen]]
| |
| */
| |
| ( function () {
| |
| var require_wikiminiatlas = false;
| |
| var coord_filter = /geohack/;
| |
| $( function () {
| |
| $( 'a.external.text' ).each( function( key, link ) {
| |
| if ( link.href && coord_filter.exec( link.href ) ) {
| |
| require_wikiminiatlas = true;
| |
| // break from loop
| |
| return false;
| |
| }
| |
| } );
| |
| if ( $( 'div.kmldata' ).length ) {
| |
| require_wikiminiatlas = true;
| |
| }
| |
| if ( require_wikiminiatlas ) {
| |
| mw.loader.load( '//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript' );
| |
| }
| |
| } );
| |
| } )();
| |
|
| |
|
| /** | | /** |
Line 359: |
Line 291: |
|
| |
|
| mw.hook( 'wikipage.content' ).add( createNavigationBarToggleButton ); | | mw.hook( 'wikipage.content' ).add( createNavigationBarToggleButton ); |
|
| |
| /**
| |
| * Uploadwizard_newusers
| |
| * Switches in a message for non-autoconfirmed users at [[Wikipedia:Upload]]
| |
| *
| |
| * Maintainers: [[User:Krimpet]]
| |
| */
| |
| function uploadwizard_newusers() {
| |
| if ( mw.config.get( 'wgNamespaceNumber' ) === 4 && mw.config.get( 'wgTitle' ) === 'Upload' && mw.config.get( 'wgAction' ) === 'view' ) {
| |
| var oldDiv = document.getElementById( 'autoconfirmedusers' ),
| |
| newDiv = document.getElementById( 'newusers' );
| |
| if ( oldDiv && newDiv ) {
| |
| var userGroups = mw.config.get( 'wgUserGroups' );
| |
| if ( userGroups ) {
| |
| for ( var i = 0; i < userGroups.length; i++ ) {
| |
| if ( userGroups[i] === 'autoconfirmed' ) {
| |
| oldDiv.style.display = 'block';
| |
| newDiv.style.display = 'none';
| |
| return;
| |
| }
| |
| }
| |
| }
| |
| oldDiv.style.display = 'none';
| |
| newDiv.style.display = 'block';
| |
| return;
| |
| }
| |
| }
| |
| }
| |
|
| |
| $(uploadwizard_newusers);
| |
|
| |
| /**
| |
| * Magic editintros ****************************************************
| |
| *
| |
| * Description: Adds editintros on disambiguation pages and BLP pages.
| |
| * Maintainers: [[User:RockMFR]]
| |
| */
| |
| function addEditIntro( name ) {
| |
| $( '.mw-editsection, #ca-edit' ).find( 'a' ).each( function ( i, el ) {
| |
| el.href = $( this ).attr( 'href' ) + '&editintro=' + name;
| |
| } );
| |
| }
| |
|
| |
| if ( mw.config.get( 'wgNamespaceNumber' ) === 0 ) {
| |
| $( function () {
| |
| if ( document.getElementById( 'disambigbox' ) ) {
| |
| addEditIntro( 'Template:Disambig_editintro' );
| |
| }
| |
| } );
| |
|
| |
| $( function () {
| |
| var cats = mw.config.get('wgCategories');
| |
| if ( !cats ) {
| |
| return;
| |
| }
| |
| if ( $.inArray( 'Living people', cats ) !== -1 || $.inArray( 'Possibly living people', cats ) !== -1 ) {
| |
| addEditIntro( 'Template:BLP_editintro' );
| |
| }
| |
| } );
| |
| }
| |
|
| |
| /* End of mw.loader.using callback */
| |
| } );
| |
| /* DO NOT ADD CODE BELOW THIS LINE */
| |