MediaWiki:InterProject.js
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.
// <source lang="JavaScript">
/**
* Taken from [[commons:MediaWiki:InterProject.js]]
* Workaround for [[bugzilla:708]] via [[Template:InterProject]].
* Originally based on code from [[wikt:de:MediaWiki:Common.js]] by [[wikt:de:User:Melancholie]],
* cleaned up and modified for compatibility with the Vector skin.
*
* XXX: The current implementation requires that this code run _before_ jQuery.ready, otherwise
* the new portal won't have the collapse/uncollapse event handlers attached. This is fragile
* and should be fixed somehow; ideally, the Vector extension would expose a function we could
* call to attach the handlers after the fact, if necessary.
*
* Maintainer(s): [[User:Ilmari Karonen]]
*/
$( function () {
if ( document.getElementById('p-interproject') ) return; // avoid double inclusion
var interPr = document.getElementById('interProject');
var sisterPr = document.getElementById('sisterProjects');
if (!interPr) return;
var toolBox = document.getElementById('p-tb');
var panel;
if (toolBox) {
panel = toolBox.parentNode;
} else {
// stupid incompatible skins...
var panelIds = ['panel', 'column-one', 'mw_portlets', 'mw-panel'];
for (var i = 0; !panel && i < panelIds.length; i++) {
panel = document.getElementById(panelIds[i]);
}
// can't find a place for the portlet, try to undo hiding
if (!panel) {
mw.util.addCSS( '#interProject, #sisterProjects { display: block; }' );
return;
}
}
var interProject = document.createElement("div");
interProject.id = "p-interproject";
interProject.className = (skin == "vector" ? "portal" : "portlet");
interProject.innerHTML =
'<h5>' +
(sisterPr && sisterPr.firstChild ? sisterPr.firstChild.innerHTML : "Sister Projects") +
'<\/h5><div class="' + (skin == "vector" ? "body" : "pBody") +'">' +
interPr.innerHTML + '<\/div>';
if (toolBox && toolBox.nextSibling) {
panel.insertBefore(interProject, toolBox.nextSibling);
} else {
panel.appendChild(interProject);
}
} );
mw.util.addCSS( '#interProject, #sisterProjects { display: none; }' );
// </source>