MediaWiki:Common.js: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
Tag: Manual revert
No edit summary
Line 125: Line 125:
     function processEventCards() {
     function processEventCards() {
         $('.card.event').each(function() {
         $('.card.event').each(function() {
             var existingContainer = $(this).find('.container-people-date');
             var $card = $(this);
   
            var existingContainer = $card.find('.container-people-date');
             // If the container doesn't exist, create and append it
 
             // Create container if missing
             if (existingContainer.length === 0) {
             if (existingContainer.length === 0) {
                 existingContainer = $('<div class="container-people-date"></div>');
                 existingContainer = $('<div class="container-people-date"></div>');
                 $(this).append(existingContainer); // Temporarily append to ensure it's in the DOM
                 $card.append(existingContainer); // temp placement
             }
             }
   
 
             // Ensure the .people and .date elements are inside the container
             // Detach people and date
             var people = $(this).find('.people').detach();
             var people = $card.find('.people').detach();
             var date = $(this).find('.date').detach();
             var date = $card.find('.date').detach();
            existingContainer.append(people).append(date);
 
   
             // BLOCK VIEW (gallery)
             // Decide where to place the container
             if ($card.closest('.home-chronicle-block').length) {
             if ($(this).closest('.home-chronicle-block').length) {
                 existingContainer.append(people).append(date);
                 // Check if it's already correctly placed, if not, move it
 
                if (!existingContainer.is($(this).find('.title').next())) {
                 // Place container after title
                    $(this).find('.title').after(existingContainer);
                 if (!existingContainer.is($card.find('.title').next())) {
                }
                     $card.find('.title').after(existingContainer);
            } else if ($(this).closest('.home-chronicle-list').length) {
                 // Check if it's already correctly placed, if not, move it
                 if (!existingContainer.is($(this).find('.title').prev())) {
                     $(this).find('.title').before(existingContainer);
                 }
                 }
            // LIST VIEW
            } else if ($card.closest('.home-chronicle-list').length) {
                // Only append .people into container
                existingContainer.empty().append(people);
                // Place container before title
                $card.find('.title').before(existingContainer);
                // Place date after title
                $card.find('.title').after(date);
             }
             }
         });
         });

Navigation menu