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.
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
<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" %>
|
||||
<%= 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" %>
|
||||
<%= link_to "next ›", show_seq_post_path(post, q: search, seq: "next"), rel: "nofollow next", class: "next", "data-shortcut": "d" %>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
</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)}" %>
|
||||
<%= 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">
|
||||
@@ -28,7 +28,7 @@
|
||||
</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)}" %>
|
||||
<%= 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">
|
||||
@@ -50,7 +50,7 @@
|
||||
</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)] %>
|
||||
<%= 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">
|
||||
@@ -58,7 +58,7 @@
|
||||
</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)] %>
|
||||
<%= 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">
|
||||
|
||||
@@ -19,7 +19,6 @@ Post.EDIT_DIALOG_WIDTH = 720;
|
||||
Post.initialize_all = function() {
|
||||
|
||||
if ($("#c-posts").length) {
|
||||
this.initialize_shortcuts();
|
||||
this.initialize_saved_searches();
|
||||
}
|
||||
|
||||
@@ -175,26 +174,6 @@ Post.swipe_prev = function(e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
Post.nav_prev = function(e) {
|
||||
var href = "";
|
||||
|
||||
if ($(".paginator a[rel~=prev], .post-notice-search a[rel~=prev]").length) {
|
||||
location.href = $("a[rel~=prev]").attr("href");
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
Post.nav_next = function(e) {
|
||||
var href = "";
|
||||
|
||||
if ($(".paginator a[rel~=next], .post-notice-search a[rel~=next]").length) {
|
||||
location.href = $("a[rel~=next]").attr("href");
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
Post.swipe_next = function(e) {
|
||||
if ($(".paginator a[rel~=next ]").length) {
|
||||
location.href = $(".paginator a[rel~=next]").attr("href");
|
||||
@@ -203,13 +182,6 @@ Post.swipe_next = function(e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
Post.initialize_shortcuts = function() {
|
||||
if ($("#a-show").length) {
|
||||
Utility.keydown("a", "prev_page", Post.nav_prev);
|
||||
Utility.keydown("d", "next_page", Post.nav_next);
|
||||
}
|
||||
}
|
||||
|
||||
Post.initialize_links = function() {
|
||||
$("#copy-notes").on("click.danbooru", function(e) {
|
||||
var current_post_id = $("meta[name=post-id]").attr("content");
|
||||
|
||||
Reference in New Issue
Block a user