When selecting orderby=random, hide the asc/desc dropdown.

This commit is contained in:
voussoir 2019-08-23 13:26:20 -07:00
parent 45d8f0df1a
commit f3b8c4875d

View file

@ -147,7 +147,7 @@
{% macro create_orderby_li(selected_column, selected_sorter) %} {% macro create_orderby_li(selected_column, selected_sorter) %}
<li class="search_builder_orderby_li"> <li class="search_builder_orderby_li">
<select> <select onchange="orderby_hide_direction_hook(event)">
<option value="created" {{"selected" if selected_column=="created" else ""}} >Creation date</option> <option value="created" {{"selected" if selected_column=="created" else ""}} >Creation date</option>
<option value="area" {{"selected" if selected_column=="area" else ""}} >Area</option> <option value="area" {{"selected" if selected_column=="area" else ""}} >Area</option>
<option value="width" {{"selected" if selected_column=="width" else ""}} >Width</option> <option value="width" {{"selected" if selected_column=="width" else ""}} >Width</option>
@ -158,7 +158,7 @@
<option value="tagged_at" {{"selected" if selected_column=="tagged_at" else ""}} >Recently tagged</option> <option value="tagged_at" {{"selected" if selected_column=="tagged_at" else ""}} >Recently tagged</option>
<option value="random" {{"selected" if selected_column=="random" else ""}} >Random</option> <option value="random" {{"selected" if selected_column=="random" else ""}} >Random</option>
</select> </select>
<select> <select {% if selected_column=="random" %}class="hidden"{% endif %}>
<option value="desc" {{"selected" if selected_sorter=="desc" else ""}} >Descending</option> <option value="desc" {{"selected" if selected_sorter=="desc" else ""}} >Descending</option>
<option value="asc" {{"selected" if selected_sorter=="asc" else ""}} >Ascending</option> <option value="asc" {{"selected" if selected_sorter=="asc" else ""}} >Ascending</option>
</select> </select>
@ -458,6 +458,17 @@ function orderby_remove_hook(button)
ul.removeChild(li); ul.removeChild(li);
} }
} }
function orderby_hide_direction_hook(event)
{
if (event.target.value == "random")
{
event.target.nextElementSibling.classList.add("hidden");
}
else
{
event.target.nextElementSibling.classList.remove("hidden");
}
}
function simplify_tagnames(tags) function simplify_tagnames(tags)
{ {
var new_tags = []; var new_tags = [];