MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 11: | Line 11: | ||
console.log('Found all cards:', cards); | console.log('Found all cards:', cards); | ||
// Attach a | // Attach a mousedown event listener to each card | ||
cards.on(' | cards.on('mousedown', function (event) { | ||
// Log a message when a card is clicked | // Log a message when a card is clicked | ||
console.log('Clicked on card:', this); | console.log('Clicked on card:', this); | ||
Line 20: | Line 20: | ||
// Update the fixed column content with card information | // Update the fixed column content with card information | ||
// ... (rest of your code) | |||
// | |||
// 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 | |||
event.stopPropagation(); | |||
}); | }); | ||
// Attach a | // Attach a mousedown event listener to close the fixed column | ||
$(document).on(' | $(document).on('mousedown', function (event) { | ||
// Check if the click is outside of the #show-article-wrapper and not on a card | // Check if the click is outside of the #show-article-wrapper and not on a card | ||
if (!showArticleWrapper.is(event.target) && showArticleWrapper.has(event.target).length === 0 && !$(event.target).hasClass('card')) { | if (!showArticleWrapper.is(event.target) && showArticleWrapper.has(event.target).length === 0 && !$(event.target).hasClass('card')) { |
Revision as of 11:39, 10 January 2024
$(document).ready(function () { // Log a message to the console console.log('JavaScript is working!'); // Find all elements with class "card" var cards = $('.card'); var showArticleWrapper = $('#show-article-wrapper'); // Log a message if cards are found if (cards.length > 0) { console.log('Found all cards:', cards); // Attach a mousedown event listener to each card cards.on('mousedown', function (event) { // Log a message when a card is clicked console.log('Clicked on card:', this); // Show the fixed column showArticleWrapper.css('display', 'block'); // Update the fixed column content with card information // ... (rest of your code) // Apply the fade-out effect to the #list element $('#list').addClass('fade-out'); // Prevent further propagation to the document event.stopPropagation(); }); // Attach a mousedown event listener to close the fixed column $(document).on('mousedown', function (event) { // Check if the click is outside of the #show-article-wrapper and not on a card if (!showArticleWrapper.is(event.target) && showArticleWrapper.has(event.target).length === 0 && !$(event.target).hasClass('card')) { // Remove the fade-out class when hiding the fixed column $('#list').removeClass('fade-out'); showArticleWrapper.css('display', 'none'); } }); // Hover effect for scrolling showArticleWrapper.hover(function () { // On hover, enable scrolling on #show-article-wrapper $(this).css('overflow-y', 'auto'); }, function () { // On hover out, disable scrolling on #show-article-wrapper $(this).css('overflow-y', 'hidden'); }); } else { console.log('No cards found.'); } });