From 17b4643b7c55fedd9b3b6e81283980befa6360e5 Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Tue, 25 Jan 2022 19:30:17 +0100 Subject: [PATCH] fix #2285 (Fix for shelf handling in caliblur theme) --- cps/static/js/caliBlur.js | 10 +++++----- cps/static/js/details.js | 8 ++++---- cps/templates/detail.html | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cps/static/js/caliBlur.js b/cps/static/js/caliBlur.js index 3203c255..f99779bd 100644 --- a/cps/static/js/caliBlur.js +++ b/cps/static/js/caliBlur.js @@ -270,7 +270,7 @@ if ($("body.book").length > 0) { if (position + $("#add-to-shelves").width() > $(window).width()) { positionOff = position + $("#add-to-shelves").width() - $(window).width(); - adsPosition = position - positionOff - 5 + adsPosition = position - positionOff - 5; $("#add-to-shelves").attr("style", "left: " + adsPosition + "px !important; right: auto; top: " + topPos + "px"); } else { $("#add-to-shelves").attr("style", "left: " + position + "px !important; right: auto; top: " + topPos + "px"); @@ -429,7 +429,7 @@ if($("body.advsearch").length > 0) { if (position + $("#add-to-shelves").width() > $(window).width()) { positionOff = position + $("#add-to-shelves").width() - $(window).width(); - adsPosition = position - positionOff - 5 + adsPosition = position - positionOff - 5; $("#add-to-shelves").attr("style", "left: " + adsPosition + "px !important; right: auto; top: " + topPos + "px"); } else { $("#add-to-shelves").attr("style", "left: " + position + "px !important; right: auto; top: " + topPos + "px"); @@ -479,12 +479,12 @@ if ($.trim($("#add-to-shelves").html()).length === 0) { $("#add-to-shelf").addClass("empty-ul"); } -shelfLength = $("#add-to-shelves li").length -emptyLength = 0 +shelfLength = $("#add-to-shelves li").length; +emptyLength = 0; $("#add-to-shelves").on("click", "li a", function () { console.log("#remove-from-shelves change registered"); - emptyLength++ + emptyLength++; setTimeout(function () { if (emptyLength >= shelfLength) { diff --git a/cps/static/js/details.js b/cps/static/js/details.js index f559234e..6f99595d 100644 --- a/cps/static/js/details.js +++ b/cps/static/js/details.js @@ -59,10 +59,10 @@ $("#archived_cb").on("change", function() { ) }; - $("#shelf-actions").on("click", "[data-shelf-action]", function (e) { + $("#add-to-shelves, #remove-from-shelves").on("click", "[data-shelf-action]", function (e) { e.preventDefault(); $.ajax({ - url: this.href, + url: $(this).data('href'), method:"post", data: {csrf_token:$("input[name='csrf_token']").val()}, }) @@ -72,7 +72,7 @@ $("#archived_cb").on("change", function() { case "add": $("#remove-from-shelves").append( templates.remove({ - add: this.href, + add: $this.data('href'), remove: $this.data("remove-href"), content: $("
").text(this.textContent).html() }) @@ -82,7 +82,7 @@ $("#archived_cb").on("change", function() { $("#add-to-shelves").append( templates.add({ add: $this.data("add-href"), - remove: this.href, + remove: $this.data('href'), content: $("
").text(this.textContent).html(), }) ); diff --git a/cps/templates/detail.html b/cps/templates/detail.html index c8d7d527..eb32f8fe 100644 --- a/cps/templates/detail.html +++ b/cps/templates/detail.html @@ -260,7 +260,7 @@ {% for shelf in g.shelves_access %} {% if not shelf.id in books_shelfs and ( not shelf.is_public or g.user.role_edit_shelfs() ) %}
  • - @@ -275,7 +275,7 @@ {% if books_shelfs %} {% for shelf in g.shelves_access %} {% if shelf.id in books_shelfs %} - @@ -309,13 +309,13 @@ {% block js %}