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

MediaWiki:Common.js: Difference between revisions

MediaWiki interface page
No edit summary
Tag: Manual revert
No edit summary
Line 35: Line 35:
             subCard.setAttribute('data-expanded', 'false');
             subCard.setAttribute('data-expanded', 'false');
         });
         });
    });
});
// Wait for the document to fully load
$(document).ready(function() {
    // Click event for the header or the arrow
    $('.mw-collapsible-header').click(function() {
        var parentDiv = $(this).closest('.mw-collapsible');
        var arrow = $(this).find('.mw-collapsible-arrow');
       
        // Toggle the collapse/expand state
        parentDiv.toggleClass('mw-collapsed');
       
        // Rotate the arrow accordingly
        if (parentDiv.hasClass('mw-collapsed')) {
            arrow.html('↓'); // Downward arrow
        } else {
            arrow.html('↑'); // Upward arrow
        }
     });
     });
});
});

Revision as of 03:53, 4 January 2025

/* Any JavaScript here will be loaded for all users on every page load. */
 $(function(){
  $('.card').on('mousenter', function(event){
    event.preventDefault();
    $(this).toggleClass('hovered');
  });
   $('.card').on('mouseleave', function(event){
    event.preventDefault();
    $(this).toggleClass('hovered');
  });
});
document.querySelectorAll('.sub-card').forEach(card => {
    card.addEventListener('click', function(event) {
        event.stopPropagation(); // Prevent event bubbling

        // Toggle the expanded state of the clicked card
        const isExpanded = card.getAttribute('data-expanded') === 'true';
        
        // Flip the current sub-card
        card.setAttribute('data-expanded', isExpanded ? 'false' : 'true');

        // Hide all other sub-cards
        document.querySelectorAll('.sub-card').forEach(otherCard => {
            if (otherCard !== card) {
                otherCard.setAttribute('data-expanded', 'false');
            }
        });
    });
});

document.querySelectorAll('.card').forEach(card => {
    card.addEventListener('mouseleave', function() {
        // Collapse all sub-cards when mouse leaves the main card
        document.querySelectorAll('.sub-card').forEach(subCard => {
            subCard.setAttribute('data-expanded', 'false');
        });
    });
});

// Wait for the document to fully load
$(document).ready(function() {
    // Click event for the header or the arrow
    $('.mw-collapsible-header').click(function() {
        var parentDiv = $(this).closest('.mw-collapsible');
        var arrow = $(this).find('.mw-collapsible-arrow');
        
        // Toggle the collapse/expand state
        parentDiv.toggleClass('mw-collapsed');
        
        // Rotate the arrow accordingly
        if (parentDiv.hasClass('mw-collapsed')) {
            arrow.html('↓'); // Downward arrow
        } else {
            arrow.html('↑'); // Upward arrow
        }
    });
});
Cookies help us deliver our services. By using our services, you agree to our use of cookies.