Skip to content

Commit

Permalink
Updated icons for scrolling through accordion
Browse files Browse the repository at this point in the history
  • Loading branch information
fbanados committed Dec 17, 2024
1 parent e8a151a commit edc0b65
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/morphodict/frontend/templates/morphodict/wordnet-results.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ <h3>Messages from search run</h3>
<div id="resultsContainer">
{% for result in search_results %}
{% with has_more=search_results|has_next:forloop.counter0 %}
{% with has_previous=search_results|has_previous:forloop.counter0 %}

<div class="synset" style="background-color: var(--menu-hover-bg-color); border: 4px solid var(--prose-title-color); border-radius:5px; padding: 10px; margin-left:10px; margin-right:10px; margin-top:.5cm; margin-bottom:.5cm;">
<a name="result-synset-{{result.wn_entry.nltk_name}}"></a>
Expand All @@ -22,12 +23,19 @@ <h2 class="prose__section-title">{{result.wn_entry.numbering}}. {{result.wn_entr
<p><strong>{% relabel_one 'Synonyms' %}</strong>:
<em>{{result.wn_entry.synonyms|join:", "}}</em>.</p>
{% endif %}
<a href="#" class="expand-accordion" style="text-align:right;" data-bs-toggle="collapse" data-bs-target="#synset-results-{{result.wn_entry.nltk_name}}" aria-expanded="{%if forloop.counter0 == 0 %}true{%else%}false{%endif%}" aria-controls="synset-results-{{result.wn_entry.nltk_name}}"></a>
<div style="display:flex; justify-content:flex-end;">
{% if has_previous %}
{% with previous_element=search_results|previous:forloop.counter0 %}
<a href="#result-synset-{{previous_element.wn_entry.nltk_name}}" style="text-decoration:none;" data-bs-toggle="collapse" data-bs-target="#synset-results-{{previous_element.wn_entry.nltk_name}}" aria-expanded="false" aria-controls="synset-results-{{previous_element.wn_entry.nltk_name}}" style="text-align:right;">⏪</a>
{% endwith %}
{% endif %}
<a href="#" class="expand-accordion" style="text-decoration:none;" data-bs-toggle="collapse" data-bs-target="#synset-results-{{result.wn_entry.nltk_name}}" aria-expanded="{%if forloop.counter0 == 0 %}true{%else%}false{%endif%}" aria-controls="synset-results-{{result.wn_entry.nltk_name}}"></a>
{% if has_more %}
{% with next_element=search_results|next:forloop.counter0 %}
<a href="#result-synset-{{next_element.wn_entry.nltk_name}}" data-bs-toggle="collapse" data-bs-target="#synset-results-{{next_element.wn_entry.nltk_name}}" aria-expanded="false" aria-controls="synset-results-{{next_element.wn_entry.nltk_name}}" style="text-align:right;">⏩</a>
<a href="#result-synset-{{next_element.wn_entry.nltk_name}}" style="text-decoration:none;" data-bs-toggle="collapse" data-bs-target="#synset-results-{{next_element.wn_entry.nltk_name}}" aria-expanded="false" aria-controls="synset-results-{{next_element.wn_entry.nltk_name}}" style="text-align:right;">⏩</a>
{% endwith %}
{% endif %}
</div>
</section>

<div id="synset-results-{{result.wn_entry.nltk_name}}" data-bs-parent="#resultsContainer" class="collapse {% if forloop.counter0 == 0 %}show{% endif %}">
Expand All @@ -39,6 +47,7 @@ <h2 class="prose__section-title">{{result.wn_entry.numbering}}. {{result.wn_entr
</div>
</div>
{% endwith %}
{% endwith %}
{% empty %}
<li class="search-results__no-result box box--rounded box--bad-outcome" data-cy="no-search-result">
No results found for
Expand Down
15 changes: 14 additions & 1 deletion src/morphodict/frontend/templatetags/morphodict_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,17 @@ def next(some_list, current_index):

@register.filter(name="has_next")
def has_next(some_list, current_index):
return not current_index >= len(some_list) - 1
return current_index < len(some_list) - 1


@register.filter(name="previous")
def previous(some_list, current_index):
try:
return some_list[int(current_index) - 1]
except:
return ""


@register.filter(name="has_previous")
def has_previous(some_list, current_index):
return current_index > 0

0 comments on commit edc0b65

Please sign in to comment.