Merge branch 'janeczku:master' into master

This commit is contained in:
quarz12 2022-01-26 10:38:39 +01:00 committed by GitHub
commit 326d6e7b9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 13 deletions

View File

@ -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) {

View File

@ -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: $("<div>").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: $("<div>").text(this.textContent).html(),
})
);

View File

@ -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() ) %}
<li>
<a href="{{ url_for('shelf.add_to_shelf', book_id=entry.id, shelf_id=shelf.id) }}"
<a data-href="{{ url_for('shelf.add_to_shelf', book_id=entry.id, shelf_id=shelf.id) }}"
data-remove-href="{{ url_for('shelf.remove_from_shelf', book_id=entry.id, shelf_id=shelf.id) }}"
data-shelf-action="add"
>
@ -275,7 +275,7 @@
{% if books_shelfs %}
{% for shelf in g.shelves_access %}
{% if shelf.id in books_shelfs %}
<a href="{{ url_for('shelf.remove_from_shelf', book_id=entry.id, shelf_id=shelf.id) }}"
<a data-href="{{ url_for('shelf.remove_from_shelf', book_id=entry.id, shelf_id=shelf.id) }}"
data-add-href="{{ url_for('shelf.add_to_shelf', book_id=entry.id, shelf_id=shelf.id) }}"
class="btn btn-sm btn-default" role="button" data-shelf-action="remove"
>
@ -309,13 +309,13 @@
{% block js %}
<script type="text/template" id="template-shelf-add">
<li>
<a href="<%= add %>" data-remove-href="<%= remove %>" data-shelf-action="add">
<a data-href="<%= add %>" data-remove-href="<%= remove %>" data-shelf-action="add">
<%= content %>
</a>
</li>
</script>
<script type="text/template" id="template-shelf-remove">
<a href="<%= remove %>" data-add-href="<%= add %>" class="btn btn-sm btn-default" data-shelf-action="remove">
<a data-href="<%= remove %>" data-add-href="<%= add %>" class="btn btn-sm btn-default" data-shelf-action="remove">
<span class="glyphicon glyphicon-remove"></span> <%= content %>
</a>
</script>