<!--SEARCHBROWSE Descriptive page name, messages and instructions-->
<h2 class="heading">
  <% if @collection %>
    <%= link_to(@collection.title, @collection) %> > <%= t(".page_heading") %>
  <% elsif @medium %>
    <%= link_to t(".page_heading"), media_index_path %> > <%= @medium.name %>
  <% else %>
    <%= link_to t(".page_heading"), media_index_path %>
  <% end %>
</h2>
<p>You can search this page by pressing <kbd>ctrl F</kbd> / <kbd>cmd F</kbd> and typing in what you are looking for.</p>
<% if @collection %>
  <h3 class="landmark heading"><%= ts("Filters") %></h3>
  <%= form_tag "", method: :get, class: "filter", id: "media-filter" do %>
    <fieldset>
      <p title="<%=ts("Choose media type") %>">
        <%= select_tag :media_id, options_for_select(["All Media Types"] + @media.map(&:name), params[:media_id]) %>
        <%= submit_tag ts("Show") %>
      </p>
    </fieldset>
  <% end %>
<% end %>
<!--/descriptions-->

<!--main content-->
<% if @fandoms_by_letter && !@fandoms_by_letter.empty? %>
  <h3 class="landmark heading"><%= ts("Alphabet Navigation") %></h3>
  <ul class="alphabet actions" id="alphabet" role="navigation">
    <% for letter in @fandoms_by_letter.keys %>
      <li><%= link_to letter, "#letter-#{letter}" %></li>
    <% end %>
  </ul>
  <h3 class="landmark heading"><%= ts("Alphabetised List of Fandoms") %></h3>
  <ol class="alphabet fandom index group <%= "collection" if @collection %>">
    <% @fandoms_by_letter.each_pair do |letter, fandoms| %>
      <li id="letter-<%= letter %>" class="letter listbox group">
        <h3 class="heading">
          <%= letter %>
          <span class="action top" title="top">
            <%= link_to "&#8593;".html_safe, "#alphabet" %>
          </span>
        </h3>
        <ul class="tags index group">
          <% for fandom in fandoms %>
            <li>
              <%= link_to_tag_works(fandom, collection: @collection) %>
              <% if fandom.respond_to?(:count) %>
                (<%= fandom.count %>)
              <% elsif @counts&.key?(fandom.id) %>
                (<%= @counts[fandom.id] %>)
              <% end %>
            </li>
          <% end %>
        </ul>
      </li>
    <% end %>
  </ol>
<% else %>
  <h3 class="heading"><%= ts("No fandoms found") %></h3>
<% end %>
<!--/content-->
