3 let unpagedSearch = null;
4 if (!$(".quick-filter").val() && !$('.l-pagination li').length) {
8 function get_page(page, search, ordering, callback) {
9 get_page_by_url('.?page=' + page + '&order=' + ordering + '&search=' + search, callback);
11 function get_page_by_url(url, callback) {
16 objectList = $('#object-list', html);
17 paginate = $('#paginate', html);
20 $(".icon-like", objectList).each(
22 ids.add($(e).attr('data-book'));
25 ids = [...ids].join(',');
28 $('#book-list').html(objectList.children());
29 $('#paginator').html(paginate.children());
30 history.replaceState({}, '', url);
31 callback && callback();
36 $("#paginator").on('click', 'a', function() {
37 get_page_by_url(url=$(this).attr('href'));
41 $(".quick-filter").each(function() {
42 let bookList = $('#' + $(this).data('for'));
43 let filterList = $('.' + $(this).data('filters'));
45 $(this).on('focus', function() {
46 filterList.addClass('filters-enabled');
48 $(this).on('blur', function() {
49 filterList.removeClass('filters-enabled');
52 $(this).on('input propertychange', function() {
53 let search = $(this).val().toLowerCase();
55 if (!search.startsWith(unpagedSearch)) {
56 get_page(1, search, 'title', function() {
57 if ($('.l-pagination li').length) {
62 bookList.children().each(function() {
64 $(".s", this).text().toLowerCase().search(search) != -1
73 $('.filter-container', filterList).children().each(function() {
75 $(this).text().toLowerCase().search(search) != -1
86 $(".l-books__sorting button").on('click', function() {
87 if ($(this).hasClass('is-active')) return;
88 $(".is-active", $(this).parent()).removeClass("is-active");
89 $(this).addClass("is-active");
90 let prop = $(this).attr('data-order');
93 // do we NOW have pages (possibly after filtering)?
94 // if we don't have pages, we can just sort here.
95 let havePages = $('.l-pagination li').length > 0;
97 $(".l-books__item").css('opacity', '0');
98 setTimeout(function() {
100 get_page(1, '', prop);
103 $(".l-books__item").each(function() {
104 $(this).css('order', $(this).attr('data-' + prop));
107 $(".l-books__item").css('order', '');
109 setTimeout(function() {
110 $(".l-books__item").css('opacity', '100%');