MediaWiki:Gadget-MonobookToolbarLang.js
Apparence
Note : après avoir enregistré la page, vous devrez forcer le rechargement complet du cache de votre navigateur pour voir les changements.
Mozilla / Firefox / Konqueror / Safari : maintenez la touche Majuscule (Shift) en cliquant sur le bouton Actualiser (Reload) ou pressez Maj-Ctrl-R (Cmd-R sur Apple Mac) ;
Firefox (sur GNU/Linux) / Chrome / Internet Explorer / Opera : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl-F5.//<nowiki>
if ( [ 'edit', 'submit' ].includes( mw.config.get( 'wgAction' ) ) ) {
mw.loader.using( [ 'ext.gadget.MonobookToolbar', 'user.options' ], function () {
var langCode = 'en';
function promptThenInsertLang() {
var input = prompt( 'Code langue', langCode );
// null when cancelling the prompt
if ( input !== null ) {
langCode = input; // remember for next prompts
MonobookToolbar.insertTags( '{{lang|' + input + '|', '}}' );
}
}
// barre d'outils « améliorée »
// https://www.mediawiki.org/wiki/Extension:WikiEditor/Toolbar_customization
if ( mw.user.options.get( 'usebetatoolbar' ) ) {
$.when(
mw.loader.using( 'ext.wikiEditor' ), $.ready
).then( function () {
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
section: 'advanced',
group: 'insert',
tools: {
modele_lang: {
label: 'Modèle {{Langue}}',
type: 'button',
icon: '/media/wikipedia/commons/e/e3/Bouton_lang.png',
action: {
type: 'callback',
execute: promptThenInsertLang
}
}
}
} );
} );
}
// barre d'outils « MonobookToolbarStandard »
if ( !mw.user.options.get( 'usebetatoolbar' ) || mw.user.options.get( 'gadget-ForceMonobookToolbar' ) ) {
MonobookToolbar.addButton( {
imageFile: '/media/wikipedia/commons/e/e3/Bouton_lang.png',
speedTip: 'Modèle {{Langue}}',
imageId: 'modele_lang',
callback: promptThenInsertLang
} );
}
} );
}
//</nowiki>