Utilisateur:Florian COLLIN/SubmitAction.js
De EverybodyWiki Bios & Wiki
Note : après avoir publié vos modifications, il se peut que vous deviez forcer le rechargement complet du cache de votre navigateur pour voir les changements.
- Firefox / Safari : maintenez la touche Maj (Shift) en cliquant sur le bouton Actualiser ou appuyez sur Ctrl + F5 ou Ctrl + R (⌘ + R sur un Mac).
- Google Chrome : appuyez sur Ctrl + Maj + R (⌘ + Shift + R sur un Mac).
- Internet Explorer / Edge : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl + F5.
- Opera : appuyez sur Ctrl + F5.
/* @author : Florian COLLIN
*
* @date : décembre 2020
*
* [[Catégorie:Gadgets|SubmitAction]]
*/
if ( mw.config.get( 'wgNamespaceNumber' ) >= 0 ) {
mw.loader.using( [ 'user', 'mediawiki.util' ], function () {
$( function ( $ ) {
var lang = mw.config.get( 'wgUserLanguage' ),
messages = {
fr: {
'SubmitAction-name': 'Modifier',
'SubmitAction-summary': 'Modification de [['+ mw.config.get( 'wgPageName' ).replace( /_/g, ' ' ) +']].',
'SubmitAction-description': 'Modifier la page'
},
en: {
'SubmitAction-name': 'Edit',
'SubmitAction-summary': 'Edit of [['+ mw.config.get( 'wgPageName' ).replace( /_/g, ' ' ) +']].',
'SubmitAction-description': 'Edit this page'
},
de: {
'SubmitAction-name': '',
'SubmitAction-summary': '',
'SubmitAction-description': ''
},
it: {
'SubmitAction-name': '',
'SubmitAction-summary': '',
'SubmitAction-description': ''
}
},
$editPortlet = $( '#ca-edit' ),
skin = mw.config.get( 'skin' ),
summaryPrefix,
portletLink,
$editZeroPortlet;
mw.messages.set( messages.en );
if ( lang !== 'en' && lang in messages ) {
mw.messages.set( messages[ lang ] );
}
if ( !mw.config.get( 'wgIsProbablyEditable' ) ) {
return;
}
if ( typeof window.EditZeroth_summary !== 'undefined' ) {
summaryPrefix = window.EditZeroth_summary;
} else {
summaryPrefix = mw.msg( 'SubmitAction-summary' );
}
portletLink = mw.util.addPortletLink(
( skin === 'vector' || skin === 'timeless' ) ? 'p-views' : 'p-cactions',
mw.util.getUrl( null, { action: 'submit', summary: summaryPrefix } ),
mw.msg( 'SubmitAction-name' ),
'ca-edit-0',
mw.msg( 'SubmitAction-description' ),
'',
( $editPortlet.length > 0 && $editPortlet.next().length > 0 ) ? $editPortlet.next() : null
);
$editZeroPortlet = $( portletLink );
if ( skin === 'monobook' ) {
$editZeroPortlet.after( ' ' );
}
if ( $editPortlet.hasClass( 'istalk' ) ) {
$editZeroPortlet.addClass( 'istalk' );
}
if ( $editPortlet.hasClass( 'selected' ) ) {
if ( mw.util.getParamValue( 'section' ) === '0' ) {
$editPortlet.removeClass( 'selected' );
$editZeroPortlet.addClass( 'selected' );
}
}
} );
} );
}