4,554
edits
No edit summary |
No edit summary |
||
Line 7: | Line 7: | ||
var filteredCards = $('.filtered-list-item'); | var filteredCards = $('.filtered-list-item'); | ||
var showArticleWrapper = $('#show-article-wrapper'); | var showArticleWrapper = $('#show-article-wrapper'); | ||
var list = $('#list'); | |||
var originalListWidth = list.width(); // Store the original width | |||
if (communityFeatured.length && filteredCards.length >= 2) { | if (communityFeatured.length && filteredCards.length >= 2) { | ||
Line 140: | Line 142: | ||
checkFiltersCleared(); | checkFiltersCleared(); | ||
// Function to open the modal and adjust the list | |||
function openModal(cardElement) { | function openModal(cardElement) { | ||
console.log('Clicked on card:', cardElement); | console.log('Clicked on card:', cardElement); | ||
showArticleWrapper.css('display', 'block'); | showArticleWrapper.css('display', 'block'); | ||
var wrapperWidth = showArticleWrapper.outerWidth(true); | |||
list.width(originalListWidth - wrapperWidth).css('margin-right', wrapperWidth + 'px'); | |||
// Extract and handle the information from the cardElement | // Extract and handle the information from the cardElement | ||
Line 248: | Line 253: | ||
// Prevent further propagation to the document | // Prevent further propagation to the document | ||
event.stopPropagation(); | event.stopPropagation(); | ||
} | |||
// Function to close the modal and revert the list changes | |||
function closeModal() { | |||
showArticleWrapper.hide(); | |||
list.width(originalListWidth).css('margin-right', '0'); | |||
} | } | ||
Line 255: | Line 266: | ||
return; // Clicked on a link inside '.people' or '.type', do nothing | return; // Clicked on a link inside '.people' or '.type', do nothing | ||
} | } | ||
openModal( | openModal(); | ||
}); | }); | ||
Line 310: | Line 321: | ||
$('#list, #list-list').removeClass('fade-out'); | $('#list, #list-list').removeClass('fade-out'); | ||
showArticleWrapper.css('display', 'none'); | showArticleWrapper.css('display', 'none'); | ||
closeModal(); | |||
}); | }); | ||
// Revert changes when clicking outside the modal | |||
$(document).on('mousedown', function(event) { | |||
if (!showArticleWrapper.is(event.target) && showArticleWrapper.has(event.target).length === 0) { | |||
closeModal(); | |||
} | |||
}); | |||
// Hover effect for scrolling | // Hover effect for scrolling |