mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 11:31:08 +00:00
Merge pull request #327 from mouse-reeve/create-status-tabs
Covers and create status tabs
This commit is contained in:
commit
52cb5fbb0e
4 changed files with 36 additions and 26 deletions
|
@ -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');
|
||||
|
||||
if (nested) {
|
||||
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', '');
|
||||
}
|
||||
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) {
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue