From bc3317704ebf0389bfe606a2010610c8affe20e0 Mon Sep 17 00:00:00 2001 From: zvevqx Date: Tue, 25 Mar 2025 13:31:38 +0100 Subject: [PATCH] filter / expand bug fix --- static/main.js | 82 ++++++++++++++++-------------------------------- static/style.css | 8 ++--- 2 files changed, 31 insertions(+), 59 deletions(-) diff --git a/static/main.js b/static/main.js index 91bfc69..0906787 100644 --- a/static/main.js +++ b/static/main.js @@ -1,62 +1,13 @@ $(document).ready(function(){ - $(".alist li").click(function(){ - console.log("lolololol"); - var ctnt = $(this).find('.content-wrapper')[0] - $(ctnt).toggleClass("open") - }); - var $limit = 45; -// $("#articles ul li a span").each(function(){ -// if ($(this).text().length > $limit){ -// var cut = $(this).text().substring(0, $limit) + " ..."; -// $(this).html(cut); -// } -// }); - -// wimg = $(".img_container").width(); -// console.log(wimg); -// $(".img_container").css("height",wimg); -// -// $(window).resize(function(){ -// wimg = $(".img_container").width(); -// console.log(wimg); -// $(".img_container").css("height",wimg); -// }) -// - - $('#gal .img_container img').click(function(){ - // $(" #gal .img_container").removeClass("fullImg"); - $(this).parent().toggleClass("fullImg"); - }); - - function sortArticles(columnClass) { - const $list = $('.alist'); - const $listItems = $list.children('li'); - - // Sort the list items based on the text of the specified column - $listItems.sort(function(a, b) { - const aText = $(a).find('.' + columnClass).text().trim().toLowerCase(); - const bText = $(b).find('.' + columnClass).text().trim().toLowerCase(); - - return aText.localeCompare(bText); - }); - - // Detach and reappend sorted items to maintain DOM structure - $list.empty().append($listItems); - } - - // Add click event to legend spans - //$('.legend li span').on('click', function() { - //// Get the class corresponding to the clicked span - //const columnClass = $(this).text().toLowerCase().replace(/\s+/g, ''); - - //// If the column exists in the article items, sort by that column - //if ($('.alist li').first().find('.' + columnClass).length > 0) { - //sortArticles(columnClass); - //} + //$(".alist li").click(function(){ + //console.log("lolololol"); + //var ctnt = $(this).find('.content-wrapper') + //$(ctnt).toggleClass("open") //}); - const sortState = {}; + + const sortState = {}; // Function to sort articles function sortArticles(columnClass) { @@ -113,6 +64,27 @@ $(document).ready(function(){ }); +$(".alist").on('click', 'li ', function(e) { + // Prevent this event from interfering with sorting or default link behavior + e.preventDefault(); + + console.log("lolololol"); + var ctnt = $(this).find('.content-wrapper'); + if (ctnt.length === 0) { + ctnt = $(this).closest('li').find('.content-wrapper'); + } + $(ctnt).toggleClass("open"); + }); + + //$(".alist").on('click', 'li', function(e) { + //// Prevent this event from interfering with sorting + //if ($(e.target).closest('.legend').length === 0) { + //console.log("lolololol"); + //var ctnt = $(this).find('.content-wrapper'); + //$(ctnt).toggleClass("open"); + //} + //}); + }) diff --git a/static/style.css b/static/style.css index a31a5b2..bb39a1c 100644 --- a/static/style.css +++ b/static/style.css @@ -250,6 +250,7 @@ a:hover{ #articles ul.alist li .content-wrapper{ height:0; + max-height: 0; overflow: hidden; color : #000; background: #fff @@ -263,13 +264,12 @@ a:hover{ .open{ height:auto !important; - transition: all 0.3s ease; - margin-top:10px; + max-height:2000px !important; + margin-top:10px; + transition: max-height 0.25s ease-in; } - - .content-wrapper{ margin:auto ; font-size:1em!important;