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 121: Line 121:
             }
             }
         });
         });
      
     }
        // Additional functionality for checking consecutive .card.event
        $('.home-chronicle-block div.list-container .card.event, .home-chronicle-list div.list-container .card.event').each(function() {
            checkConsecutiveEvents($(this));
        });
    }
   
    function checkConsecutiveEvents(element) {
        if (element.next().hasClass('card') && element.next().hasClass('event')) {
            console.log("multiple consecutive card events");
            $('.home-chronicle-list div.list-container div.card.event').removeClass('alone-card-event');
        } else {
            console.log("alone card events");
            $('.home-chronicle-list div.list-container div.card.event').addClass('alone-card-event');
        }
    }
   
    function updateCardEventBorders() {
        // Reset previously set classes for both block and list views
        $('.home-chronicle-block div.list-container div.card.event, .home-chronicle-list div.list-container div.card.event').removeClass('first-in-series next-in-series');
   
        // Update borders for block view cards
        updateBordersForView('.home-chronicle-block div.list-container');
   
        // Update borders for list view cards
        updateBordersForView('.home-chronicle-list div.list-container');
    }
   
    function updateBordersForView(selector) {
        $(selector + ' div.card.event').each(function() {
            var $current = $(this);
   
            // Find the next visible .card.event element, skipping hidden ones
            var $nextVisibleEvent = $current.nextAll('.card.event').not(':hidden').first();
   
            // Check if there is a visible .card.event following the current one
            if ($nextVisibleEvent.length) {
                // Apply 'first-in-series' if the current card is not preceded by a visible .card.event
                if (!$current.prevAll('.card.event').not(':hidden').first().length) {
                    $current.addClass('first-in-series');
                }
   
                // The next visible card event gets 'next-in-series'
                $nextVisibleEvent.addClass('next-in-series');
            }
        });
    }   


     function processEventCards() {
     function processEventCards() {
Line 215: Line 169:
         processEventCards();
         processEventCards();
         updateViews();
         updateViews();
        updateCardEventBorders();


         $('.home-list-view-button').click(function() {
         $('.home-list-view-button').click(function() {
Line 231: Line 184:
             processEventCards();
             processEventCards();
             updateViews();
             updateViews();
            updateCardEventBorders();
 
       
             // Remove active class from block view button and add to list view button
             // Remove active class from block view button and add to list view button
             $('.home-block-view-button').removeClass('active-view-button');
             $('.home-block-view-button').removeClass('active-view-button');
Line 261: Line 213:
             processEventCards();
             processEventCards();
             updateViews();
             updateViews();
            updateCardEventBorders();
             $('.home-list-view-button').removeClass('active-view-button');
             $('.home-list-view-button').removeClass('active-view-button');
             $('.home-block-view-button').addClass('active-view-button');
             $('.home-block-view-button').addClass('active-view-button');
Line 286: Line 237:
             processEventCards();
             processEventCards();
             updateViews();
             updateViews();
            updateCardEventBorders();
             $('.home-chronicle-block-button').addClass('active-view-button');
             $('.home-chronicle-block-button').addClass('active-view-button');
             $('.home-random-block-button').removeClass('active-view-button');
             $('.home-random-block-button').removeClass('active-view-button');
Line 299: Line 249:
             processEventCards();
             processEventCards();
             updateViews();
             updateViews();
            updateCardEventBorders();
             $('.home-random-block-button').addClass('active-view-button');
             $('.home-random-block-button').addClass('active-view-button');
             $('.home-chronicle-block-button').removeClass('active-view-button');
             $('.home-chronicle-block-button').removeClass('active-view-button');
Line 312: Line 261:
             processEventCards();
             processEventCards();
             updateViews();
             updateViews();
            updateCardEventBorders();
             $('.home-alphabetical-block-button').addClass('active-view-button');
             $('.home-alphabetical-block-button').addClass('active-view-button');
             $('.home-chronicle-block-button').removeClass('active-view-button');
             $('.home-chronicle-block-button').removeClass('active-view-button');
Line 326: Line 274:
             processEventCards();
             processEventCards();
             updateViews();
             updateViews();
            updateCardEventBorders();
             $('.home-chronicle-list-button').addClass('active-view-button');
             $('.home-chronicle-list-button').addClass('active-view-button');
             $('.home-random-list-button').removeClass('active-view-button');
             $('.home-random-list-button').removeClass('active-view-button');
Line 339: Line 286:
             processEventCards();
             processEventCards();
             updateViews();
             updateViews();
            updateCardEventBorders();
             $('.home-random-list-button').addClass('active-view-button');
             $('.home-random-list-button').addClass('active-view-button');
             $('.home-chronicle-list-button').removeClass('active-view-button');
             $('.home-chronicle-list-button').removeClass('active-view-button');
Line 352: Line 298:
             processEventCards();
             processEventCards();
             updateViews();
             updateViews();
            updateCardEventBorders();
             $('.home-alphabetical-list-button').addClass('active-view-button');
             $('.home-alphabetical-list-button').addClass('active-view-button');
             $('.home-chronicle-list-button').removeClass('active-view-button');
             $('.home-chronicle-list-button').removeClass('active-view-button');
Line 370: Line 315:
         processEventCards();
         processEventCards();
         updateViews();
         updateViews();
        updateCardEventBorders();


         $('.list-view-button').click(function() {
         $('.list-view-button').click(function() {
Line 387: Line 331:
             processEventCards();
             processEventCards();
             updateViews();
             updateViews();
            updateCardEventBorders();
          
          
             // Remove active class from block view button and add to list view button
             // Remove active class from block view button and add to list view button
Line 418: Line 361:
             processEventCards();
             processEventCards();
             updateViews();
             updateViews();
            updateCardEventBorders();
             $('.list-view-button').removeClass('active-view-button');
             $('.list-view-button').removeClass('active-view-button');
             $('.block-view-button').addClass('active-view-button');
             $('.block-view-button').addClass('active-view-button');
Line 443: Line 385:
             processEventCards();
             processEventCards();
             updateViews();
             updateViews();
            updateCardEventBorders();
             $('.chronicle-block-button').addClass('active-view-button');
             $('.chronicle-block-button').addClass('active-view-button');
             $('.random-block-button').removeClass('active-view-button');
             $('.random-block-button').removeClass('active-view-button');
Line 456: Line 397:
             processEventCards();
             processEventCards();
             updateViews();
             updateViews();
            updateCardEventBorders();
             $('.random-block-button').addClass('active-view-button');
             $('.random-block-button').addClass('active-view-button');
             $('.chronicle-block-button').removeClass('active-view-button');
             $('.chronicle-block-button').removeClass('active-view-button');
Line 469: Line 409:
             processEventCards();
             processEventCards();
             updateViews();
             updateViews();
            updateCardEventBorders();
             $('.alphabetical-block-button').addClass('active-view-button');
             $('.alphabetical-block-button').addClass('active-view-button');
             $('.chronicle-block-button').removeClass('active-view-button');
             $('.chronicle-block-button').removeClass('active-view-button');
Line 483: Line 422:
             processEventCards();
             processEventCards();
             updateViews();
             updateViews();
            updateCardEventBorders();
             $('.chronicle-list-button').addClass('active-view-button');
             $('.chronicle-list-button').addClass('active-view-button');
             $('.random-list-button').removeClass('active-view-button');
             $('.random-list-button').removeClass('active-view-button');
Line 496: Line 434:
             processEventCards();
             processEventCards();
             updateViews();
             updateViews();
            updateCardEventBorders();
             $('.random-list-button').addClass('active-view-button');
             $('.random-list-button').addClass('active-view-button');
             $('.chronicle-list-button').removeClass('active-view-button');
             $('.chronicle-list-button').removeClass('active-view-button');
Line 509: Line 446:
             processEventCards();
             processEventCards();
             updateViews();
             updateViews();
            updateCardEventBorders();
             $('.alphabetical-list-button').addClass('active-view-button');
             $('.alphabetical-list-button').addClass('active-view-button');
             $('.chronicle-list-button').removeClass('active-view-button');
             $('.chronicle-list-button').removeClass('active-view-button');
Line 541: Line 477:
         processEventCards();
         processEventCards();
         updateViews();
         updateViews();
        updateCardEventBorders();
     });
     });


Line 679: Line 614:
         processEventCards();
         processEventCards();
         updateViews();
         updateViews();
        updateCardEventBorders();
     });
     });
      
      
Line 691: Line 625:
         processEventCards();
         processEventCards();
         updateViews();
         updateViews();
        updateCardEventBorders();
     });
     });


Navigation menu