Searching, filtering fixes.
[wolnelektury.git] / src / catalogue / static / 2022 / book / filter.js
index 43b6c4e..2ff4262 100644 (file)
         $(".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;
                 }, 200);
             }
         }, 200);
-    });
+    }
     
 })(jQuery);