Merge branch 'main' of github.com:mouse-reeve/bookwyrm into main

This commit is contained in:
Mouse Reeve 2020-11-08 20:15:57 -08:00
commit 9ac94543b9
4 changed files with 36 additions and 26 deletions

View file

@ -31,22 +31,23 @@ function rate_stars(e) {
return true;
}
function tabChange(e) {
function tabChange(e, nested) {
var target = e.target.closest('li')
var identifier = target.getAttribute('data-id');
var parent_element = target.parentElement.closest('li').parentElement;
var tabs = parent_element.getElementsByTagName('label');
for (i = 0; i < tabs.length; i++) {
var tab = tabs[i].parentElement;
if (tab.getAttribute('data-id') == identifier) {
tab.className += ' is-active';
} else {
tab.className = tab.className.replace('is-active', '');
}
if (nested) {
var parent_element = target.parentElement.closest('li').parentElement;
} else {
var parent_element = target.parentElement;
}
var el = document.getElementById(identifier);
parent_element.querySelectorAll('[aria-selected="true"]')
.forEach(t => t.setAttribute("aria-selected", false));
target.querySelector('[role="tab"]').setAttribute("aria-selected", true);
parent_element.querySelectorAll('li')
.forEach(t => t.className='');
target.className = 'is-active';
}
function ajaxPost(form) {

View file

@ -21,7 +21,13 @@
<ul>
{% for book in shelf.books %}
<li class="{% if shelf_counter == 1 and forloop.first %}is-active{% endif %}" data-id="tab-book-{{ book.id }}">
<label for="book-{{ book.id }}" onclick="tabChange(event)"><a>{% include 'snippets/book_cover.html' with book=book size="medium" %}</a></label>
<label for="book-{{ book.id }}" onclick="tabChange(event, nested=true)">
<div role="tab" tabindex="0" aria-selected="{% if shelf_counter == 1 and forloop.first %}true{% else %}false{% endif %}">
<a>
{% include 'snippets/book_cover.html' with book=book size="medium" %}
</a>
</div>
</label>
</li>
{% endfor %}
</ul>

View file

@ -2,15 +2,27 @@
{% load fr_display %}
<div class="tabs is-boxed">
<ul>
<ul role="tablist">
<li class="is-active" data-id="tab-review-{{ book.id }}" data-category="tab-option-{{ book.id }}">
<label for="review-{{ book.id }}" onclick="tabChange(event)"><a>Review</a></label>
<label for="review-{{ book.id }}">
<div onclick="tabChange(event)" role="tab" aria-selected="true" tabindex="0">
<a>Review</a>
</div>
</label>
</li>
<li data-id="tab-comment-{{ book.id }}" data-category="tab-option-{{ book.id }}">
<label for="comment-{{ book.id}}" onclick="tabChange(event)"><a>Comment</a></label>
<label for="comment-{{ book.id}}">
<div onclick="tabChange(event)" role="tab" tabindex="0">
<a>Comment</a>
</div>
</label>
</li>
<li data-id="tab-quotation-{{ book.id }}" data-category="tab-option-{{ book.id }}">
<label for="quote-{{ book.id }}" onclick="tabChange(event)"><a>Quote</a></label>
<label for="quote-{{ book.id }}">
<div onclick="tabChange(event)" role="tab" tabindex="0">
<a>Quote</a>
</div>
</label>
</li>
</ul>
</div>
@ -22,7 +34,7 @@
<div>
<input class="toggle-control" type="radio" name="status-tabs-{{ book.id }}" id="comment-{{ book.id }}">
{% include 'snippets/create_status_form.html' with type="comment" placeholder="Some thougts on '"|add:book.title|add:"'" %}
{% include 'snippets/create_status_form.html' with type="comment" placeholder="Some thoughts on '"|add:book.title|add:"'" %}
</div>
<div>

View file

@ -38,14 +38,6 @@
<ul class="dropdown-content">
{% for shelf in request.user.shelf_set.all %}
<li>
{% if shelf.identifier == 'reading' and active_shelf.identifier != 'reading' %}
<div class="dropdown-item pt-0 pb-0">
<label class="button is-small" for="start-reading-{{ uuid }}" role="button" tabindex="0">
{{ shelf.name }}
</label>
{% include 'snippets/start_reading_modal.html' %}
</div>
{% else %}
<form class="dropdown-item pt-0 pb-0" name="shelve" action="/shelve/" method="post">
{% csrf_token %}
<input type="hidden" name="book" value="{{ book.id }}">
@ -54,7 +46,6 @@
{% if shelf in book.shelf_set.all %}<span class="icon icon-check"></span>{% endif %}
</button>
</form>
{% endif %}
</li>
{% endfor %}
</ul>