Aller au contenu

MediaWiki:Commons.js

De Wikiquestia

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).
  •  Edge : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl + F5.
document.addEventListener('DOMContentLoaded', function () {
  // Add click event listeners to all elements with the class "toggle-column"
  document.querySelectorAll('.toggle-column').forEach(function (element) {
    element.addEventListener('click', function () {
      const target = this.getAttribute('data-target'); // Get the target column ID
      // Hide all columns
      document.querySelectorAll('.infobox-column').forEach(function (column) {
        column.style.display = 'none';
      });
      // Show the selected column
      document.getElementById(target).style.display = 'block';

      // Update the styling of the active title
      document.querySelectorAll('.toggle-column').forEach(function (title) {
        title.style.fontWeight = 'normal';
      });
      this.style.fontWeight = 'bold';
    });
  });
});