Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

MediaWiki:Citizen.js: Difference between revisions

MediaWiki interface page
No edit summary
No edit summary
Line 1: Line 1:
$(document).ready(function() {
$(document).ready(function() {
   if (window.innerWidth >= 768) { // Only on desktop
   if (window.innerWidth >= 768) { // Only on desktop
     mw.hook('citizen-collapsibles-init').add(function() {
     const idsToCollapse = [
      const idsToCollapse = [
      'Muling',
        'Muling',
      'Misc',
        'Misc',
      'Anti-ban',
        'Anti-ban',
      'Anti-PK',
        'Anti-PK',
      'Trip_Settings',
        'Trip_Settings',
      'Skills_Settings',
        'Skills_Settings',
      'Equipment'
        'Equipment'
    ];
      ];


      idsToCollapse.forEach(function(rawId) {
    idsToCollapse.forEach(function(rawId) {
        var id = rawId.replace(/ /g, "_");
      var id = rawId.replace(/ /g, "_");
        var header = document.getElementById(id);
      var header = document.getElementById(id);
        if (header) {
      if (header) {
          var section = header.closest('.citizen-section-heading');
        var section = header.closest('.citizen-section-heading');
          var content = section?.nextElementSibling;
        var content = section?.nextElementSibling;
          if (section && content) {
        if (section && content) {
            section.classList.add('citizen-section-collapsed'); // manually collapse
          section.classList.add('citizen-section-collapsed'); // Add the collapsed style to the heading
            content.style.display = "none"; // manually hide content
          content.style.display = "none"; // Hide the section content manually
           }
         
          // Bind manual click event
          section.addEventListener('click', function() {
            if (content.style.display === "none") {
              content.style.display = "block";
              section.classList.remove('citizen-section-collapsed');
            } else {
              content.style.display = "none";
              section.classList.add('citizen-section-collapsed');
            }
           });
         }
         }
       });
       }
     });
     });
   }
   }
});
});

Revision as of 14:20, 25 April 2025

$(document).ready(function() {
  if (window.innerWidth >= 768) { // Only on desktop
    const idsToCollapse = [
      'Muling',
      'Misc',
      'Anti-ban',
      'Anti-PK',
      'Trip_Settings',
      'Skills_Settings',
      'Equipment'
    ];

    idsToCollapse.forEach(function(rawId) {
      var id = rawId.replace(/ /g, "_");
      var header = document.getElementById(id);
      if (header) {
        var section = header.closest('.citizen-section-heading');
        var content = section?.nextElementSibling;
        if (section && content) {
          section.classList.add('citizen-section-collapsed'); // Add the collapsed style to the heading
          content.style.display = "none"; // Hide the section content manually
          
          // Bind manual click event
          section.addEventListener('click', function() {
            if (content.style.display === "none") {
              content.style.display = "block";
              section.classList.remove('citizen-section-collapsed');
            } else {
              content.style.display = "none";
              section.classList.add('citizen-section-collapsed');
            }
          });
        }
      }
    });
  }
});