diff --git a/app/javascript/src/javascripts/notes.js b/app/javascript/src/javascripts/notes.js index 05ddb56af..e6e186545 100644 --- a/app/javascript/src/javascripts/notes.js +++ b/app/javascript/src/javascripts/notes.js @@ -414,8 +414,6 @@ let Note = { return; } let $image = $("#image"); - $container.height($image.height()); - $container.width($image.width()); if (Note.embed) { let large_width = parseFloat($image.data('large-width')); let ratio = $image.width() / large_width; @@ -843,15 +841,13 @@ let Note = { }, create_note: function(e, x, y, w, h) { - var offset = $("#image").offset(); - if (w > 9 || h > 9) { /* minimum note size: 10px */ if (w <= 9) { w = 10; } else if (h <= 9) { h = 10; } - Note.create(x - offset.left, y - offset.top, w, h); + Note.create(x, y, w, h); } $(".note-container").css('visibility', 'visible'); @@ -907,18 +903,18 @@ let Note = { } if (Note.TranslationMode.Drag.dragging) { if (Note.TranslationMode.Drag.dragDistanceX >= 0) { - Note.TranslationMode.Drag.x = Note.TranslationMode.Drag.dragStartX; + Note.TranslationMode.Drag.x = Note.TranslationMode.Drag.dragStartX - offset.left; Note.TranslationMode.Drag.w = Note.TranslationMode.Drag.dragDistanceX; } else { - Note.TranslationMode.Drag.x = Note.TranslationMode.Drag.dragStartX + Note.TranslationMode.Drag.dragDistanceX; + Note.TranslationMode.Drag.x = Note.TranslationMode.Drag.dragStartX - offset.left + Note.TranslationMode.Drag.dragDistanceX; Note.TranslationMode.Drag.w = -Note.TranslationMode.Drag.dragDistanceX; } if (Note.TranslationMode.Drag.dragDistanceY >= 0) { - Note.TranslationMode.Drag.y = Note.TranslationMode.Drag.dragStartY; + Note.TranslationMode.Drag.y = Note.TranslationMode.Drag.dragStartY - offset.top; Note.TranslationMode.Drag.h = Note.TranslationMode.Drag.dragDistanceY; } else { - Note.TranslationMode.Drag.y = Note.TranslationMode.Drag.dragStartY + Note.TranslationMode.Drag.dragDistanceY; + Note.TranslationMode.Drag.y = Note.TranslationMode.Drag.dragStartY - offset.top + Note.TranslationMode.Drag.dragDistanceY; Note.TranslationMode.Drag.h = -Note.TranslationMode.Drag.dragDistanceY; } diff --git a/app/javascript/src/javascripts/posts.js.erb b/app/javascript/src/javascripts/posts.js.erb index 2a70b8be5..ef6731983 100644 --- a/app/javascript/src/javascripts/posts.js.erb +++ b/app/javascript/src/javascripts/posts.js.erb @@ -300,7 +300,7 @@ Post.initialize_favlist = function() { }); } -Post.expand_image = function(e) { +Post.view_original = function(e) { if (Utility.test_max_width(660)) { // Do the default behavior (navigate to image) return; @@ -347,9 +347,17 @@ Post.view_large = function(e) { e.preventDefault(); } +Post.toggle_fit_window = function(e) { + $("#image").toggleClass("fit-width"); + Note.Box.scale_all(); + Post.resize_ugoira_controls(); + e.preventDefault(); +}; + Post.initialize_post_image_resize_links = function() { - $("#image-resize-link").on("click.danbooru", Post.expand_image); + $("#image-resize-link").on("click.danbooru", Post.view_original); $("#image-view-large-link").on("click.danbooru", Post.view_large); + $(document).on("click.danbooru", ".image-resize-to-window-link", Post.toggle_fit_window); if ($("#image-resize-notice").length) { Utility.keydown("v", "resize", function(e) { diff --git a/app/javascript/src/styles/base/020_base.scss b/app/javascript/src/styles/base/020_base.scss index d26ff614b..d9cb265cf 100644 --- a/app/javascript/src/styles/base/020_base.scss +++ b/app/javascript/src/styles/base/020_base.scss @@ -151,6 +151,16 @@ ul.list-inline { } } +.fit-width { + max-width: 100%; + height: auto !important; +} + +.fit-height { + max-height: 90vh; + height: auto !important; +} + .mobile-only { display: none; @media (max-width: 660px) { display: initial; } diff --git a/app/javascript/src/styles/specific/notes.scss b/app/javascript/src/styles/specific/notes.scss index 240c0c0fa..bab2c00b3 100644 --- a/app/javascript/src/styles/specific/notes.scss +++ b/app/javascript/src/styles/specific/notes.scss @@ -1,5 +1,6 @@ .note-container { - position: absolute; + display: inline-block; + position: relative; div.note-body { position: absolute; diff --git a/app/javascript/src/styles/specific/posts.scss b/app/javascript/src/styles/specific/posts.scss index 2e6037235..00ad7f2c3 100644 --- a/app/javascript/src/styles/specific/posts.scss +++ b/app/javascript/src/styles/specific/posts.scss @@ -341,12 +341,6 @@ div#c-posts { margin: 1em 0 0.5em; } - /* This ensures the image appears above the note container, but beneath any notes. */ - #image { - position: relative; - z-index: 50; - } - .pool-name, .search-name { word-wrap: break-word; } diff --git a/app/javascript/src/styles/specific/z_responsive.scss b/app/javascript/src/styles/specific/z_responsive.scss index d349b51da..e775572a5 100644 --- a/app/javascript/src/styles/specific/z_responsive.scss +++ b/app/javascript/src/styles/specific/z_responsive.scss @@ -92,11 +92,6 @@ } } - img#image { - max-width: 100%; - height: auto; - } - .user-disable-cropped-false { article.post-preview { width: 33.3%; diff --git a/app/views/posts/partials/show/_image.html.erb b/app/views/posts/partials/show/_image.html.erb index 6d60c2f4c..194fbc7d0 100644 --- a/app/views/posts/partials/show/_image.html.erb +++ b/app/views/posts/partials/show/_image.html.erb @@ -1,3 +1,3 @@ <% if policy(post).visible? %> - <%= image_tag(post.file_url_for(CurrentUser.user), :width => post.image_width_for(CurrentUser.user), :height => post.image_height_for(CurrentUser.user), :id => "image", "data-original-width" => post.image_width, "data-original-height" => post.image_height, "data-large-width" => post.large_image_width, "data-large-height" => post.large_image_height, "data-tags" => post.tag_string, :alt => post.presenter.humanized_essential_tag_string, "data-uploader" => post.uploader.name, "data-rating" => post.rating, "data-flags" => post.status_flags, "data-parent-id" => post.parent_id, "data-has-children" => post.has_children?, "data-has-active-children" => post.has_active_children?, "data-score" => post.score, "data-fav-count" => post.fav_count, "itemprop" => "contentUrl") %> + <%= image_tag(post.file_url_for(CurrentUser.user), width: post.image_width_for(CurrentUser.user), height: post.image_height_for(CurrentUser.user), id: "image", class: "fit-width", "data-original-width": post.image_width, "data-original-height": post.image_height, "data-large-width": post.large_image_width, "data-large-height": post.large_image_height, "data-tags": post.tag_string, alt: post.presenter.humanized_essential_tag_string, "data-uploader": post.uploader.name, "data-rating": post.rating, "data-flags": post.status_flags, "data-parent-id": post.parent_id, "data-has-children": post.has_children?, "data-has-active-children": post.has_active_children?, "data-score": post.score, "data-fav-count": post.fav_count, "itemprop": "contentUrl") %> <% end %> diff --git a/app/views/posts/partials/show/_options.html.erb b/app/views/posts/partials/show/_options.html.erb index b81cf3f56..fbd5e7098 100644 --- a/app/views/posts/partials/show/_options.html.erb +++ b/app/views/posts/partials/show/_options.html.erb @@ -1,4 +1,9 @@