From a206c9d6acadd302bb0ed62c7095d40c10d55b3d Mon Sep 17 00:00:00 2001 From: BrokenEagle Date: Tue, 3 Mar 2020 20:48:13 +0000 Subject: [PATCH] Added a view large link to facilitate switching between image sizes - The link is placed in the Options section -- In the same place as the now defunct "Resize to image" link -- This was so that it doesn't interfere with the image when in full size --- app/javascript/src/javascripts/posts.js.erb | 43 ++++++++++++------- .../posts/partials/show/_options.html.erb | 5 +++ 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/app/javascript/src/javascripts/posts.js.erb b/app/javascript/src/javascripts/posts.js.erb index 05a9253e9..d71f7e240 100644 --- a/app/javascript/src/javascripts/posts.js.erb +++ b/app/javascript/src/javascripts/posts.js.erb @@ -302,7 +302,7 @@ Post.initialize_favlist = function() { Post.expand_image = function(e) { if (Utility.test_max_width(660)) { - // just do the default behavior + // Do the default behavior (navigate to image) return; } @@ -316,6 +316,7 @@ Post.expand_image = function(e) { $image.on("load.danbooru", function() { $image.css("animation", "sharpen 0.5s forwards"); $notice.hide(); + $("#post-option-view-large").show(); }); $notice.children().eq(0).hide(); $notice.children().eq(1).show(); // Loading message @@ -323,29 +324,39 @@ Post.expand_image = function(e) { e.preventDefault(); } +Post.view_large = function(e) { + if (Utility.test_max_width(660)) { + // Do the default behavior (navigate to image) + return; + } + + var $image = $("#image"); + var $notice = $("#image-resize-notice"); + $image.attr("src", $("#image-container").data("large-file-url")); + $image.css("filter", "blur(8px)"); + $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.danbooru", function() { + $image.css("animation", "sharpen 0.5s forwards"); + $notice.show(); + $("#post-option-view-large").hide(); + }); + Note.Box.scale_all(); + e.preventDefault(); +} + Post.initialize_post_image_resize_links = function() { $("#image-resize-link").on("click.danbooru", Post.expand_image); + $("#image-view-large-link").on("click.danbooru", Post.view_large); if ($("#image-resize-notice").length) { Utility.keydown("v", "resize", 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("filter", "blur(8px)"); - $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.danbooru", function() { - $image.css("animation", "sharpen 0.5s forwards"); - $notice.show(); - }); - Note.Box.scale_all(); - $image.data("scale-factor", 1); - e.preventDefault(); + $("#image-view-large-link").click(); } }); } diff --git a/app/views/posts/partials/show/_options.html.erb b/app/views/posts/partials/show/_options.html.erb index 81720c8ad..38960796f 100644 --- a/app/views/posts/partials/show/_options.html.erb +++ b/app/views/posts/partials/show/_options.html.erb @@ -1,4 +1,9 @@