Add a global parameter to enable tag filtering with books. re #46

Also fix many problem with util.js
This commit is contained in:
Sébastien Lucas 2013-07-03 23:36:38 +02:00
parent 1a92d7e1c1
commit 35d6a5ab4e
3 changed files with 19 additions and 9 deletions

View file

@ -139,7 +139,7 @@
/* /*
* Filter on tags to book list * Filter on tags to book list
* Only works with the OPDS catalog for now * Only works with the OPDS catalog
* Usage : array ("I only want to see books using the tag : Tag1" => "Tag1", * Usage : array ("I only want to see books using the tag : Tag1" => "Tag1",
* "I only want to see books not using the tag : Tag1" => "!Tag1", * "I only want to see books not using the tag : Tag1" => "!Tag1",
* "I want to see every books" => "", * "I want to see every books" => "",
@ -195,4 +195,11 @@
"address.from" => "cops@slucas.fr" "address.from" => "cops@slucas.fr"
); );
/*
* Use filter in HTML catalog
* 1 : Yes (enable)
* 0 : No
*/
$config['cops_html_tag_filter'] = "1";
?> ?>

View file

@ -80,7 +80,8 @@
"thumbnailUrl" => "fetch.php?height=70&id={0}&db={1}"), "thumbnailUrl" => "fetch.php?height=70&id={0}&db={1}"),
"config" => array ( "config" => array (
"use_fancyapps" => $config ["cops_use_fancyapps"], "use_fancyapps" => $config ["cops_use_fancyapps"],
"max_item_per_page" => $config['cops_max_item_per_page'])); "max_item_per_page" => $config['cops_max_item_per_page'],
"html_tag_filter" => $config['cops_html_tag_filter']));
} }
$out ["containsBook"] = 0; $out ["containsBook"] = 0;

10
util.js
View file

@ -23,7 +23,7 @@ function updateCookie (id) {
} }
var name = $(id).attr('id'); var name = $(id).attr('id');
var value = $(id).val (); var value = $(id).val ();
$.cookie(name, value); $.cookie(name, value, { expires: 365 });
} }
function updateCookieFromCheckbox (id) { function updateCookieFromCheckbox (id) {
@ -237,12 +237,14 @@ function updatePage (data) {
debug_log (elapsed ()); debug_log (elapsed ());
if ($.cookie('toolbar') === 1) { $("#tool").show (); } if ($.cookie('toolbar') === '1') { $("#tool").show (); }
if (currentData.containsBook === 1) { if (currentData.containsBook === 1) {
$("#sortForm").show (); $("#sortForm").show ();
if (getCurrentOption ("html_tag_filter") === "1") {
$("#filter ul").empty (); $("#filter ul").empty ();
updateFilters (); updateFilters ();
handleFilterEvents (); handleFilterEvents ();
}
} else { } else {
$("#sortForm").hide (); $("#sortForm").hide ();
} }
@ -270,7 +272,7 @@ function updatePage (data) {
} }
}); });
if (getCurrentOption ("use_fancyapps") === 1) { if (getCurrentOption ("use_fancyapps") === "1") {
$(".fancydetail").click(function(event){ $(".fancydetail").click(function(event){
event.preventDefault(); event.preventDefault();
before = new Date (); before = new Date ();
@ -306,7 +308,7 @@ function updatePage (data) {
function ajaxifyLinks () { function ajaxifyLinks () {
if (isPushStateEnabled) { if (isPushStateEnabled) {
var links = $("a[href^='index']"); var links = $("a[href^='index']");
if (getCurrentOption ("use_fancyapps") === 1) { links = links.not (".fancydetail"); } if (getCurrentOption ("use_fancyapps") === "1") { links = links.not (".fancydetail"); }
links.click (function (event) { links.click (function (event) {
event.preventDefault(); event.preventDefault();