MediaWiki:Common.js: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
Tag: Reverted
No edit summary
Tag: Manual revert
Line 111: Line 111:
     checkFiltersCleared();
     checkFiltersCleared();
     function openModal(element) {
     // Delegate the mousedown event to the '.card' elements inside the '#list' container
         console.log('Modal opening for:', element);
    $('#list').on('mousedown', '.card', function (event) {
   
        // Check if the clicked element or its parent is a link inside '.people' or '.type'
        if ($(event.target).closest('.people a, .type a').length) {
            return; // Clicked on a link inside '.people' or '.type', do nothing
        }
 
         console.log('Clicked on card:', this);
        showArticleWrapper.css('display', 'block');
 
         var cardImages = [];
         var cardImages = [];
         for (var i = 1; i <= 5; i++) {
         for (var i = 1; i <= 5; i++) {
             var imageClass = '.image' + i;
             var imageClass = '.image' + i;
             var captionClass = '.caption-image' + i;
             var captionClass = '.caption-image' + i;
             var imageElem = $(element).find(imageClass + ' img');
             var imageElem = $(this).find(imageClass + ' img');
   
 
            console.log('Processing image:', imageClass, 'Found:', imageElem.length > 0);
   
             if (imageElem.length) {
             if (imageElem.length) {
                 var captionText = $(element).find(imageClass + ' ' + captionClass).text();
                 var captionText = $(this).find(imageClass + ' ' + captionClass).text();
                console.log('Caption for', imageClass, ':', captionText);
   
                 cardImages.push({
                 cardImages.push({
                     link: $(element).find(imageClass + ' a').attr('href'),
                     link: $(this).find(imageClass + ' a').attr('href'),
                     src: imageElem.attr('src'),
                     src: imageElem.attr('src'),
                     alt: imageElem.attr('alt'),
                     alt: imageElem.attr('alt'),
Line 135: Line 138:
             }
             }
         }
         }
        console.log('Collected images:', cardImages);
   
 
         if (cardImages.length > 1) {
         if (cardImages.length > 1) {
             setupImageToggle(cardImages);
             setupImageToggle(cardImages);
Line 154: Line 156:
         var modificationDate = $(this).find('.modification-date').text();
         var modificationDate = $(this).find('.modification-date').text();
         var relatedArticlesHtml = $(this).find('.related-articles').html();
         var relatedArticlesHtml = $(this).find('.related-articles').html();
   
 
         $('#article-title').html('<p class="article-entry-number">' + entryNumber + '</p><p class="article-people">' + peopleHtml + '</p>');
         $('#article-title').html('<p class="article-entry-number">' + entryNumber + '</p><p class="article-people">' + peopleHtml + '</p>');
         var articleContentHtml = '<div class="article-title-link">';
         var articleContentHtml = '<div class="article-title-link">';
Line 162: Line 164:
         }
         }
         articleContentHtml += '</div>'; // Close the new div
         articleContentHtml += '</div>'; // Close the new div
   
 
         // Append type, entity, discipline, and subject details
         // Append type, entity, discipline, and subject details
         articleContentHtml += '<p class="article-type">' + typeHtml + '</p>' +
         articleContentHtml += '<p class="article-type">' + typeHtml + '</p>' +
Line 197: Line 199:
         '<p class="article-label-modification-date">Added on</p>' +
         '<p class="article-label-modification-date">Added on</p>' +
         '<div class="article-modification-date">' + formatSimpleDate(modificationDate) + '</div>'
         '<div class="article-modification-date">' + formatSimpleDate(modificationDate) + '</div>'
   
 
         $('#article-content').html(articleContentHtml);
         $('#article-content').html(articleContentHtml);
         $('#related-articles').html(relatedArticlesHtml);
         $('#related-articles').html(relatedArticlesHtml);
   
 
         if (relatedArticlesHtml && relatedArticlesHtml.trim().length > 0) {
         if (relatedArticlesHtml && relatedArticlesHtml.trim().length > 0) {
             $('#related-articles').html('<div class="related-articles-label">Related Articles</div><div class="related-articles-container">' + relatedArticlesHtml + '</div>').show();
             $('#related-articles').html('<div class="related-articles-label">Related Articles</div><div class="related-articles-container">' + relatedArticlesHtml + '</div>').show();
Line 206: Line 208:
             $('#related-articles').html('<div class="related-articles-label">No related articles found.</div>').show();
             $('#related-articles').html('<div class="related-articles-label">No related articles found.</div>').show();
         }
         }
   
 
         function formatSimpleDate(inputDate) {
         function formatSimpleDate(inputDate) {
             // Remove spaces from the date string
             // Remove spaces from the date string
             var dateWithoutSpaces = inputDate.replace(/\s/g, '');
             var dateWithoutSpaces = inputDate.replace(/\s/g, '');
   
       
             // Assuming dateWithoutSpaces is in the format "XX XX XX"
             // Assuming dateWithoutSpaces is in the format "XX XX XX"
             var formattedDate = dateWithoutSpaces.slice(0, 2) + '.' + dateWithoutSpaces.slice(2, 4) + '.' + dateWithoutSpaces.slice(4);
             var formattedDate = dateWithoutSpaces.slice(0, 2) + '.' + dateWithoutSpaces.slice(2, 4) + '.' + dateWithoutSpaces.slice(4);
   
       
             return formattedDate;
             return formattedDate;
         }
         }
   
 
         // Apply the fade-out effect to the #list element
         // Apply the fade-out effect to the #list element
         $('#list').addClass('fade-out');
         $('#list').addClass('fade-out');
   
 
         // Prevent further propagation to the document
         // Prevent further propagation to the document
         event.stopPropagation();
         event.stopPropagation();
    }
    // Delegate for block-view page
    $('#list').on('mousedown', '.card', function (event) {
        if ($(event.target).closest('.people a, .type a').length) {
            return;
        }
        openModal(this);
    });
    // Delegate for list-view page
    $('#list-list').on('mousedown', '.list-card', function (event) {
        if ($(event.target).closest('.people a, .type a').length) {
            return;
        }
        openModal(this);
     });
     });
      
      

Navigation menu