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
This commit is contained in:
BrokenEagle
2020-03-03 20:48:13 +00:00
parent e844a06e61
commit a206c9d6ac
2 changed files with 32 additions and 16 deletions

View File

@@ -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();
}
});
}