MediaWiki:Common.js
De Encyclopédie-de-L'AFN_1830-1962
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.
/* Cette fonction ajoute un "onclick" sur chaque titre, qui lancera un appel à toogleTitle() lors d'un clic sur ceux ci */
/*
function ImplementToogleOnclick() {
for( var titleLevel = 1 ; titleLevel < 7 ; titleLevel++) {
var titleList = document.getElementsByTagName('h' + titleLevel)
var nb = titleList.length
for( var b = 0 ; b < nb ; b++) {
titleList[b].setAttribute('onclick', "toogleTitle(this)");
}
}
}
addOnloadHook(ImplementToogleOnclick)
*/
/* Cette fonction, quand invoquée, fait disparaitre ou réaparaitre le contenu placé sous un titre jusqu'au prochain titre de niveau egal ou supérieur
(= un h3 s'arrete au prochain h2 ou h3 mais continuera s'il rencontre un h4 ou h5) */
/*
function toogleTitle(p_this) {
var p_niveau = p_this.nodeName.substring(1,2) //le 1 de h1 (ou 2 de h2, etc.)
//construction de l'expression reguliere permettant le trouver le prochain titre de niveau égal ou supérieur
var stopMatch = "(h1"
for(var a = 2 ; a <= p_niveau ; a++) {
stopMatch += "|h"+a
}
stopMatch += ")"
reg = new RegExp(stopMatch, "i" )
//on ajoute une classe (neko_toogle_cache) au titre pour savoir s'il est en mode replié
if( p_this.className != "neko_toogle_cache") { //il faut replier
p_this.className = "neko_toogle_cache"
var display_to_put = "none"
} else { //il faut faire déplier
p_this.className = ""
var display_to_put = "block"
}
var nextSiblingNode = p_this.nextSibling
while( nextSiblingNode ) {
if( nextSiblingNode.nodeName.match(reg) ) break; //on a atteint le titre "bloquant" suivant = stop
if( nextSiblingNode.style) { //certains nodes sont des nodes texte et n'ont pas de style.
nextSiblingNode.style.display = display_to_put
if( nextSiblingNode.className = "neko_toogle_cache") nextSiblingNode.className = "" // x
}
nextSiblingNode = nextSiblingNode.nextSibling //on passe au voisin suivant
}
}
*/
var customizeToolbar = function () {
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
"comment": {
label: 'Comment',
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/3/37/Btn_toolbar_commentaire.png',
action: {
type: 'encapsulate',
options: {
pre: "<!-- ",
post: " -->"
}
}
}
}
} );
/* Your code goes here */
};
/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) {
mw.loader.using( 'user.options' ).then( function () {
// This can be the string "0" if the user disabled the preference ([[phab:T54542#555387]])
if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
$.when(
mw.loader.using( 'ext.wikiEditor' ), $.ready
).then( customizeToolbar );
}
} );
}