Files
danbooru/app/components/post_navbar_component/post_navbar_component.html.erb
evazion c0f27d6e3b posts: refactor next/prev keyboard shortcuts.
On the post show page, define the next page / previous page keyboard
shortcuts in html using data-shortcut attributes instead of in
Javascript. This is consistent with how these shortcuts are defined on
the post index page.
2021-01-30 01:16:00 -06:00

70 lines
3.3 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<ul class="notice post-notice post-notice-search">
<% if has_search_navbar? %>
<li class="search-navbar" data-selected="true">
<%= link_to " prev", show_seq_post_path(post, q: search, seq: "prev"), rel: "nofollow prev", class: "prev", "data-shortcut": "a" %>
<span class="search-name">Search: <%= link_to search, posts_path(tags: search), rel: "nofollow" %></span>
<%= link_to "next ", show_seq_post_path(post, q: search, seq: "next"), rel: "nofollow next", class: "next", "data-shortcut": "d" %>
</li>
<% end %>
<% pools.each do |pool| %>
<% selected = pool_id == pool.id %>
<% first_post_id = pool.post_ids.first %>
<% last_post_id = pool.post_ids.last %>
<% previous_post_id = pool.previous_post_id(post.id) %>
<% next_post_id = pool.next_post_id(post.id) %>
<%= tag.li class: "pool-navbar pool-category-#{pool.category}", "data-selected": selected do %>
<span class="first">
<%= link_to_unless first_post_id == post.id, "«", post_path(first_post_id, q: "pool:#{pool.id}"), rel: "nofollow", title: "to page 1" %>
</span>
<span class="prev">
<%= link_to_if previous_post_id, " prev", post_path(previous_post_id.to_i, q: "pool:#{pool.id}"), rel: ["nofollow", ("prev" if selected)], title: "to page #{pool.page_number(previous_post_id)}", "data-shortcut": ("a" if selected) %>
</span>
<span class="pool-name">
<%= link_to "Pool: #{pool.pretty_name}", pool, title: "page #{pool.page_number(post.id)}/#{pool.post_count}" %>
</span>
<span class="next">
<%= link_to_if next_post_id, "next ", post_path(next_post_id.to_i, q: "pool:#{pool.id}"), rel: ["nofollow", ("next" if selected)], title: "to page #{pool.page_number(next_post_id)}", "data-shortcut": ("d" if selected) %>
</span>
<span class="last">
<%= link_to_unless last_post_id == post.id, "»", post_path(last_post_id, q: "pool:#{pool.id}"), rel: "nofollow", title: "to page #{pool.post_count}" %>
</span>
<% end %>
<% end %>
<% favgroups.each do |favgroup| %>
<% selected = favgroup_id == favgroup.id %>
<% first_post_id = favgroup.post_ids.first %>
<% last_post_id = favgroup.post_ids.last %>
<% previous_post_id = favgroup.previous_post_id(post.id) %>
<% next_post_id = favgroup.next_post_id(post.id) %>
<%= tag.li class: "favgroup-navbar", "data-selected": selected do %>
<span class="first">
<%= link_to_unless first_post_id == post.id, "«", post_path(first_post_id, q: "favgroup:#{favgroup.id}"), rel: "nofollow" %>
</span>
<span class="prev">
<%= link_to_if previous_post_id, " prev", post_path(previous_post_id.to_i, q: "favgroup:#{favgroup.id}"), rel: ["nofollow", ("prev" if selected)], "data-shortcut": ("a" if selected) %>
</span>
<span class="favgroup-name">
<%= link_to "Favgroup: #{favgroup.pretty_name}", favgroup %>
</span>
<span class="next">
<%= link_to_if next_post_id, "next ", post_path(next_post_id.to_i, q: "favgroup:#{favgroup.id}"), rel: ["nofollow", ("next" if selected)], "data-shortcut": ("d" if selected) %>
</span>
<span class="last">
<%= link_to_unless last_post_id == post.id, "»", post_path(last_post_id, q: "favgroup:#{favgroup.id}"), rel: "nofollow" %>
</span>
<% end %>
<% end %>
</ul>