MediaWiki:Common.js: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Tag: Reverted
Line 18: Line 18:
     }
     }


     // Check if the specific element exists on the page
     // Setup images in original Entry pages
     if ($('#show-article-wrapper-entry').length > 0 || $('#show-article-wrapper').length > 0) {
     if ($('#show-article-wrapper-entry').length > 0 || $('#show-article-wrapper').length > 0) {
         var images = []; // Initialize an empty array to store the images
         var images = []; // Initialize an empty array to store the images
        // Find all image containers within the article content and extract the necessary information
         $('.article-images .image-container').each(function() {
         $('.article-images .image-container').each(function() {
             var img = $(this).find('img');
             var img = $(this).find('img');
Line 41: Line 39:
     }
     }
      
      
     // Using delegated event handling for both #list and #list-list
     // FILTERS
$('#list, #list-list').on('mousedown', '.filtered-value-option', function(event) {
$('#list, #list-list').on('mousedown', '.filtered-value-option', function(event) {
    console.log("Filter clicked within context:", this);
    console.log("Filter clicked within context:", this);
Line 59: Line 57:
    console.log("Parents of event target:", $(event.target).parents());
    console.log("Parents of event target:", $(event.target).parents());
});
});
    //cleaned uppppppppppppppppppp
    $('#list, #list-list').on('mousedown', '.filtered-value-option', function(event) {
        // Determine the context based on whether the clicked element is within #list or #list-list
        var context = $(this).closest('#list').length ? '#list' : '#list-list';
   
        // Call a function to update the visibility of communityFeatured based on the active filters within the context
        updateCommunityFeaturedVisibility(context);
    });
   
    function updateCommunityFeaturedVisibility(context) {
        // Check if there are any checked filters within the given context
        var checkedFilters = $(context + ' .filtered-value-option input[type="checkbox"]:checked').length;
   
        // Show or hide communityFeatured based on whether there are checked filters
        if (checkedFilters === 0) {
            communityFeatured.show();
        } else {
            communityFeatured.hide();
        }
    }// end of cleaned uppppppppppppppppppp
   


     // Format paragraphs
     // Format paragraphs
Line 114: Line 134:
     }  
     }  
      
      
 
/* // Function to check if filters are cleared and update visibility of community elements
   
// Function to check if filters are cleared and update visibility of community elements
function checkFiltersCleared(selector, communityElement) {
function checkFiltersCleared(selector, communityElement) {
    var checkedFilters = $(selector + ' .filtered-value-option input[type="checkbox"]:checked');
    var checkedFilters = $(selector + ' .filtered-value-option input[type="checkbox"]:checked');
Line 128: Line 146:
        communityElement.hide(); // Hide the element if any filters are active
        communityElement.hide(); // Hide the element if any filters are active
    }
    }
}
} */


     // Event delegation for filter changes in both block and list views
/*     // Event delegation for filter changes in both block and list views
     $('#list, #list-list').on('change', '.filtered-value-option input[type="checkbox"]', function() {
     $('#list, #list-list').on('change', '.filtered-value-option input[type="checkbox"]', function() {
         // Determine the closest list or list-list element to identify the context
         // Determine the closest list or list-list element to identify the context
Line 146: Line 164:
     selectors.forEach(function(selector) {
     selectors.forEach(function(selector) {
         checkFiltersCleared(selector, communityFeatured);
         checkFiltersCleared(selector, communityFeatured);
    }); */
    // simplify
    // Event delegation for filter changes in both block and list views
    $('#list, #list-list').on('change', '.filtered-value-option input[type="checkbox"]', function() {
        // Call the new function to update the visibility of communityFeatured based on current filters
        updateCommunityFeaturedVisibility();
     });
     });
    // Perform initial check on page load or when the script is initially run
    updateCommunityFeaturedVisibility();


// Function to check if all filters are cleared and return boolean
// Function to check if all filters are cleared and return boolean

Navigation menu