#1938: Add random post keyboard shortcut

This commit is contained in:
Toks
2014-06-08 14:34:36 -04:00
parent a56c1f3350
commit abfd48d58a
4 changed files with 21 additions and 7 deletions

View File

@@ -15,11 +15,7 @@
e.preventDefault();
});
if ($("#image").length) {
$(document).bind("keypress", "shift+o", function(e) {
Danbooru.Post.approve(Danbooru.meta("post-id"));
});
if ($("#image").length) { // post page or bookmarklet upload page
$(document).bind("keypress", "shift+e", function(e) {
if (!$("#edit-dialog").length) {
$("#edit").show();
@@ -34,6 +30,22 @@
e.preventDefault();
});
}
if ($("#c-posts").length && $("#a-show").length) {
$(document).bind("keypress", "shift+o", function(e) {
Danbooru.Post.approve(Danbooru.meta("post-id"));
});
$(document).bind("keypress", "r", function(e) {
$("#random-post")[0].click();
});
}
if ($("#c-posts").length && $("#a-index").length) {
$(document).bind("keypress", "r", function(e) {
$("#random-post")[0].click();
});
}
}
Danbooru.Shortcuts.nav_scroll_down = function() {

View File

@@ -9,7 +9,7 @@
<li><%= link_to "Edit subscriptions", tag_subscriptions_path %></li>
<% end %>
<li><%= link_to "Random post", random_posts_path(:tags => params[:tags]) %></li>
<li><%= link_to "Random post", random_posts_path(:tags => params[:tags]), :id => "random-post" %></li>
<li><%= link_to "Mobile version", mobile_posts_path(:tags => params[:tags]) %></li>
</ul>

View File

@@ -3,7 +3,7 @@
<li><%= link_to "Favorite", favorites_path(:post_id => post.id), :remote => true, :method => :post, :id => "add-to-favorites", :title => "Shortcut is F" %></li>
<li><%= link_to "Unfavorite", favorite_path(post), :remote => true, :method => :delete, :id => "remove-from-favorites" %></li>
<li><%= link_to "Edit", "#", :id => "side-edit-link" %></li>
<li id="random-post-list"><%= link_to "Random post", random_posts_path(:tags => params[:tags]) %></li>
<li id="random-post-list"><%= link_to "Random post", random_posts_path(:tags => params[:tags]), :id => "random-post" %></li>
<li id="add-to-pool-list"><%= link_to "Add to pool", "#", :id => "pool" %></li>
<% if post.is_note_locked? %>
<li id="add-notes-list"><span id="note-locked-notice">Note locked</span></li>

View File

@@ -10,6 +10,7 @@
<li><kbd class="key">q</kbd> Search</li>
<li><kbd class="key">w</kbd> Scroll up</li>
<li><kbd class="key">s</kbd> Scroll down</li>
<li><kbd class="key">r</kbd> Go to random post</li>
</ul>
</section>
@@ -27,6 +28,7 @@
<li><kbd class="key">a</kbd> Previous post</li>
<li><kbd class="key">d</kbd> Next post</li>
<li><kbd class="key">f</kbd> Favorite post</li>
<li><kbd class="key">r</kbd> Go to random post</li>
</ul>
</section>
</div>