diff --git a/public/script.js b/public/script.js index 993cccbd1..c9ee565b7 100644 --- a/public/script.js +++ b/public/script.js @@ -1250,15 +1250,14 @@ function applyFavFilter(enabled) { const selector = ['#rm_print_characters_block .character_select', '#rm_print_characters_block .group_select'].join(','); if (enabled) { $(selector).each(function () { - if ($(this).children(".flex-container").children(".ch_fav").length !== 0) { - $(this).children(".flex-container").children(".ch_fav").val().toLowerCase().includes(true) - ? $(this).show() - : $(this).hide(); + if ($(this).find(".ch_fav").length !== 0) { + const shouldBeDisplayed = $(this).find(".ch_fav").val().toLowerCase().includes(true); + $(this).toggleClass('hiddenByFav', !shouldBeDisplayed); } }); } else { - $(selector).show(); + $(selector).removeClass('hiddenByFav'); } } @@ -3939,17 +3938,9 @@ $(document).ready(function () { $("#character_search_bar").on("input", function () { const selector = ['#rm_print_characters_block .character_select', '#rm_print_characters_block .group_select'].join(','); const searchValue = $(this).val().trim().toLowerCase(); - const selectedTagId = $('#rm_tag_filter .tag.selected').attr('id'); if (!searchValue) { - $(selector).each(function () { - if (selectedTagId && !isElementTagged(this, selectedTagId)) { - $(this).hide(); - } - else { - $(this).show(); - } - }) + $(selector).removeClass('hiddenBySearch'); } else { $(selector).each(function () { const isValidSearch = $(this) @@ -3958,23 +3949,9 @@ $(document).ready(function () { .toLowerCase() .includes(searchValue); - if (isValidSearch) { - if (selectedTagId && !isElementTagged(this, selectedTagId)) { - $(this).hide(); - } - else { - $(this).show(); - } - } - else { - $(this).hide(); - } + $(this).toggleClass('hiddenBySearch', !isValidSearch); }); } - - if (selectedTagId) { - applyFilterToList(selectedTagId) - } }); $("#filter_by_fav").click(function () { diff --git a/public/style.css b/public/style.css index 8097c4a62..0252f75eb 100644 --- a/public/style.css +++ b/public/style.css @@ -3060,7 +3060,7 @@ a { display: none; } -.hiddenByTag { +.hiddenByTag, .hiddenByFav, .hiddenBySearch { display: none !important; }