X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/2aff714cb52d85d39824728d70b3272bb4fd5064..aed70facf3a26e27b1a96b04cad8139de600e42f:/src/catalogue/static/2022/book/filter.js diff --git a/src/catalogue/static/2022/book/filter.js b/src/catalogue/static/2022/book/filter.js index 43b6c4e40..2ff426234 100644 --- a/src/catalogue/static/2022/book/filter.js +++ b/src/catalogue/static/2022/book/filter.js @@ -95,8 +95,19 @@ $(".is-active", $(this).parent()).removeClass("is-active"); $(this).addClass("is-active"); let prop = $(this).attr('data-order'); + $(".l-books__sorting select").val(prop); + if (prop == '-') prop = ''; + resort(prop); + }); + $(".l-books__sorting select").on('change', function() { + let prop = $(this).val(); + $(".is-active", $(this).parent()).removeClass("is-active"); + $("[data-order='" + prop +"']", $(this).parent()).addClass("is-active"); + if (prop == '-') prop = ''; + resort(prop); + }); - + function resort(prop) { // do we NOW have pages (possibly after filtering)? // if we don't have pages, we can just sort here. let havePages = $('.l-pagination li').length > 0; @@ -118,6 +129,6 @@ }, 200); } }, 200); - }); + } })(jQuery);