From 58943bb1565ebef1efda3e09d85550b73bc4eb16 Mon Sep 17 00:00:00 2001 From: pthiben Date: Sat, 18 Apr 2020 22:54:58 -0400 Subject: [PATCH] update filtering so that it also uses isotope everywhere. Fix asc/desc that did not match list view --- cps/static/js/filter_grid.js | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/cps/static/js/filter_grid.js b/cps/static/js/filter_grid.js index 0e63cea5..457b9055 100644 --- a/cps/static/js/filter_grid.js +++ b/cps/static/js/filter_grid.js @@ -26,7 +26,7 @@ var $list = $("#list").isotope({ $("#desc").click(function() { $list.isotope({ sortBy: "name", - sortAscending: false + sortAscending: true }); return; }); @@ -34,29 +34,21 @@ $("#desc").click(function() { $("#asc").click(function() { $list.isotope({ sortBy: "name", - sortAscending: true + sortAscending: false }); return; }); $("#all").click(function() { // go through all elements and make them visible - $(".sortable").each(function() { - $(this).show(); - }); - // We need to trigger the resize event to have all the grid item to re-align. - window.dispatchEvent(new Event('resize')); + $list.isotope({ filter: function() { + return true; + } }) }); $(".char").click(function() { var character = this.innerText; - $(".sortable").each(function() { - if (this.attributes["data-id"].value.charAt(0).toUpperCase() !== character) { - $(this).hide(); - } else { - $(this).show(); - } - }); - // We need to trigger the resize event to have all the grid item to re-align. - window.dispatchEvent(new Event("resize")); + $list.isotope({ filter: function() { + return this.attributes["data-id"].value.charAt(0).toUpperCase() == character; + } }) });