mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-01 22:11:16 +00:00
Improves tabbing javascript for create status tabs
This commit is contained in:
parent
b7f8055ede
commit
b7bc089d86
2 changed files with 11 additions and 21 deletions
|
@ -32,26 +32,25 @@ function rate_stars(e) {
|
|||
}
|
||||
|
||||
function tabChange(e) {
|
||||
var target = e.target.closest('li')
|
||||
var identifier = target.getAttribute('data-id');
|
||||
var target = e.target.closest('li');
|
||||
|
||||
var parent_element = target.parentElement
|
||||
var parent_element = target.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', '');
|
||||
}
|
||||
}
|
||||
|
||||
parent_element.querySelectorAll('[aria-selected="true"]')
|
||||
.forEach(t => t.setAttribute("aria-selected", false));
|
||||
e.target.parentElement.setAttribute("aria-selected", true);
|
||||
|
||||
parent_element.querySelectorAll('li')
|
||||
.forEach(t => t.className='');
|
||||
target.className += ' is-active';
|
||||
}
|
||||
|
||||
function nestedTabChange(e) {
|
||||
var target = e.target.closest('li')
|
||||
var identifier = target.getAttribute('data-id');
|
||||
var parent_element = target.parentElement.closest('li').parentElement;
|
||||
|
||||
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;
|
||||
|
|
|
@ -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