« MediaWiki:Common.js » : différence entre les versions
De WikiMetz : Encyclopédie sur l'Histoire de Metz, l'encyclopédie de Metz
Aucun résumé des modifications |
Aucun résumé des modifications |
||
| Ligne 25 : | Ligne 25 : | ||
if ($('.watermark-photo').length === 0) return; | if ($('.watermark-photo').length === 0) return; | ||
const link = $('.fullImageLink'); | |||
if (!link.length) return; | |||
const watermark = $('<div class="wm-overlay"></div>'); | |||
link.append(watermark); | |||
}); | }); | ||
}); | }); | ||
Version du 14 février 2026 à 10:44
/* Tout JavaScript présent ici sera exécuté par tous les utilisateurs à chaque chargement de page. */
mw.loader.using('user', function () {
document.addEventListener('copy', function (e) {
const selection = window.getSelection().toString();
const copyrightNotice = '\n— Source : WikiMetz (https://www.wikimetz.fr)';
const copyText = selection + copyrightNotice;
e.preventDefault();
if (e.clipboardData) {
e.clipboardData.setData('text/plain', copyText);
} else if (window.clipboardData) {
window.clipboardData.setData('Text', copyText);
}
});
});
mw.loader.using('mediawiki.util', function () {
$(function () {
// Vérifie qu'on est sur une page Fichier
if (mw.config.get('wgCanonicalNamespace') !== 'File') return;
// Vérifie la présence du template {{Moi}}
if ($('.watermark-photo').length === 0) return;
const link = $('.fullImageLink');
if (!link.length) return;
const watermark = $('<div class="wm-overlay"></div>');
link.append(watermark);
});
});
WikiMetz : Encyclopédie sur l'Histoire de Metz
