diff --git a/app/assets/javascripts/posts.js b/app/assets/javascripts/posts.js index 704fded73..4a3262c06 100644 --- a/app/assets/javascripts/posts.js +++ b/app/assets/javascripts/posts.js @@ -304,19 +304,45 @@ $("#image-resize-link").click(function(e) { var $link = $(e.target); var $image = $("#image"); + var $notice = $("#image-resize-notice"); $image.attr("src", $link.attr("href")); $image.css("opacity", "0.25"); $image.width($image.data("original-width")); $image.height($image.data("original-height")); $image.on("load", function() { $image.css("opacity", "1"); - $("#image-resize-notice").hide(); + $notice.hide(); }); - $("#image-resize-notice").html("Loading..."); + $notice.children().eq(0).hide(); + $notice.children().eq(1).show(); // Loading message Danbooru.Note.Box.scale_all(); $image.data("scale_factor", 1); e.preventDefault(); }); + + if ($("#image-resize-notice").length && Danbooru.meta("enable-js-navigation") === "true") { + $(document).bind("keypress", "v", function(e) { + if ($("#image-resize-notice").is(":visible")) { + $("#image-resize-link").click(); + } else { + var $image = $("#image"); + var $notice = $("#image-resize-notice"); + $image.attr("src", $("#image-container").data("large-file-url")); + $image.css("opacity", "0.25"); + $image.width($image.data("large-width")); + $image.height($image.data("large-height")); + $notice.children().eq(0).show(); + $notice.children().eq(1).hide(); // Loading message + $image.on("load", function() { + $image.css("opacity", "1"); + $notice.show(); + }); + Danbooru.Note.Box.scale_all(); + $image.data("scale_factor", 1); + e.preventDefault(); + } + }); + } } Danbooru.Post.initialize_post_image_resize_to_window_link = function() { diff --git a/app/views/posts/partials/show/_notices.html.erb b/app/views/posts/partials/show/_notices.html.erb index 69e80a7dd..9d8aab3d3 100644 --- a/app/views/posts/partials/show/_notices.html.erb +++ b/app/views/posts/partials/show/_notices.html.erb @@ -59,8 +59,9 @@ <% end %> -<% if post.has_large? && CurrentUser.default_image_size == "large" %> -
- Resized to <%= number_to_percentage post.resize_percentage.floor, :precision => 0 %> of original (<%= link_to "view original", post.file_url, :id => "image-resize-link" %>) +<% if post.has_large? %> +
"> + Resized to <%= number_to_percentage post.resize_percentage.floor, :precision => 0 %> of original (<%= link_to "view original", post.file_url, :id => "image-resize-link" %>) + Loading...
<% end %> diff --git a/app/views/static/keyboard_shortcuts.html.erb b/app/views/static/keyboard_shortcuts.html.erb index 825300e87..5a71a5d76 100644 --- a/app/views/static/keyboard_shortcuts.html.erb +++ b/app/views/static/keyboard_shortcuts.html.erb @@ -29,6 +29,7 @@
  • d Next post
  • f Favorite post
  • r Go to random post
  • +
  • v Toggle between sample and full size