MediaWiki:Common.js: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
Tag: Reverted
No edit summary
Tags: Manual revert Reverted
Line 37: Line 37:
         communityListFeatured.hide();
         communityListFeatured.hide();
         console.log("Community List Featured should now be hidden");
         console.log("Community List Featured should now be hidden");
        console.log("Filter clicked, updating borders");
        setTimeout(updateBorder, 100); // Delayed to account for the time it takes to apply the filter
     });
     });


Line 91: Line 93:
      
      
     function updateBorder() {
     function updateBorder() {
        console.log("Running updateBorder function");
        // Filter only items that are truly visible and not hidden by CSS
         var visibleItems = $('#list-list div.filtered-list-item').filter(function() {
         var visibleItems = $('#list-list div.filtered-list-item').filter(function() {
             return $(this).css('display') !== 'none';
             return $(this).css('display') !== 'none';
         });
         });
        console.log("Number of truly visible items:", visibleItems.length);


         $('#list-list div.filtered-list-item').css('border-bottom', 'none');
         // If there's only one visible item, add the border
         if (visibleItems.length === 1) {
         if (visibleItems.length === 1) {
             visibleItems.css('border-bottom', '1px solid black');
             visibleItems.css('border-bottom', '1px solid black');
            console.log("Added bottom border to the single visible item");
        } else {
            console.log("More than one item visible, no bottom border added");
         }
         }
     }
     }


    // Create a MutationObserver to monitor changes in the list
    var observer = new MutationObserver(function(mutations) {
        mutations.forEach(function(mutation) {
            if (mutation.type === 'attributes' && mutation.attributeName === 'style') {
                updateBorder();
            }
        });
    });
    // Start observing the list for attribute changes
    $('#list-list div.filtered-list-item').each(function() {
        observer.observe(this, { attributes: true });
    });


    // Initial call to set the border correctly on page load
// Run the function on page load
    updateBorder();
updateBorder();
      
      
     // Delegate the mousedown event to the '.card' elements inside the '#list' container
     // Delegate the mousedown event to the '.card' elements inside the '#list' container

Navigation menu