Add a button to clear all filters. re #46
This commit is contained in:
parent
886b2673d3
commit
5b6918488c
14
util.js
14
util.js
|
@ -121,7 +121,10 @@ function getTagList () {
|
||||||
|
|
||||||
function doFilter () {
|
function doFilter () {
|
||||||
$(".books").removeClass("filtered");
|
$(".books").removeClass("filtered");
|
||||||
if (jQuery.isEmptyObject(filterList)) { return; }
|
if (jQuery.isEmptyObject(filterList)) {
|
||||||
|
updateFilters ();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$(".se").each (function(){
|
$(".se").each (function(){
|
||||||
var taglist = ", " + $(this).text() + ", ";
|
var taglist = ", " + $(this).text() + ", ";
|
||||||
|
@ -169,6 +172,8 @@ function updateFilters () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$("#filter ul").append ("<li>_CLEAR_</li>");
|
||||||
|
|
||||||
// Sort the list alphabetically
|
// Sort the list alphabetically
|
||||||
$('#filter ul li').sortElements(function(a, b){
|
$('#filter ul li').sortElements(function(a, b){
|
||||||
return $(a).text() > $(b).text() ? 1 : -1;
|
return $(a).text() > $(b).text() ? 1 : -1;
|
||||||
|
@ -178,6 +183,13 @@ function updateFilters () {
|
||||||
function handleFilterEvents () {
|
function handleFilterEvents () {
|
||||||
$("#filter ul").on ("click", "li", function(){
|
$("#filter ul").on ("click", "li", function(){
|
||||||
var filter = $(this).text ();
|
var filter = $(this).text ();
|
||||||
|
if (filter === "_CLEAR_") {
|
||||||
|
filterList = {};
|
||||||
|
$("#filter ul li").removeClass ("filter-exclude");
|
||||||
|
$("#filter ul li").removeClass ("filter-include");
|
||||||
|
doFilter ();
|
||||||
|
return;
|
||||||
|
}
|
||||||
switch ($(this).attr("class")) {
|
switch ($(this).attr("class")) {
|
||||||
case "filter-include" :
|
case "filter-include" :
|
||||||
$(this).attr("class", "filter-exclude");
|
$(this).attr("class", "filter-exclude");
|
||||||
|
|
Loading…
Reference in a new issue