diff --git a/app/assets/javascripts/posts.js b/app/assets/javascripts/posts.js index 2f05527b5..2834cd770 100644 --- a/app/assets/javascripts/posts.js +++ b/app/assets/javascripts/posts.js @@ -6,6 +6,34 @@ Danbooru.Post.initialize_all = function() { this.initialize_post_sections(); this.initialize_wiki_page_excerpt(); + this.initialize_post_image_resize_links(); + } + + Danbooru.Post.initialize_post_image_resize_links = function() { + $("#medium-file-link").click(function(e) { + var $link = $(e.target); + var $image = $("#image"); + $image.attr("src", $link.attr("href")); + $image.width($image.data("medium-width")); + $image.height($image.data("medium-height")); + e.preventDefault(); + }); + $("#large-file-link").click(function(e) { + var $link = $(e.target); + var $image = $("#image"); + $image.attr("src", $link.attr("href")); + $image.width($image.data("large-width")); + $image.height($image.data("large-height")); + e.preventDefault(); + }); + $("#original-file-link").click(function(e) { + var $link = $(e.target); + var $image = $("#image"); + $image.attr("src", $link.attr("href")); + $image.width($image.data("original-width")); + $image.height($image.data("original-height")); + e.preventDefault(); + }); } Danbooru.Post.initialize_wiki_page_excerpt = function() { diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index 9b1ec513e..067ae2b7d 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -348,7 +348,7 @@ div#page { width: 75%; float: left; margin-left: 2em; - overflow: hidden; + overflow: visible; } } @@ -359,7 +359,7 @@ div.clearfix { /*** Post previews ***/ div.post-previews { - overflow: hidden; + overflow: visible; } diff --git a/app/helpers/posts_helper.rb b/app/helpers/posts_helper.rb index 83bc4d372..1e674f013 100644 --- a/app/helpers/posts_helper.rb +++ b/app/helpers/posts_helper.rb @@ -1,16 +1,23 @@ module PostsHelper def resize_image_links(post, user) links = [] + + if post.has_medium? + links << link_to("M", post.medium_file_url, :id => "medium-file-link") + end - links << %{Original} if post.has_medium? || post.has_large? - links << %{Medium} if post.has_medium? - links << %{Large} if post.has_large? + if post.has_large? + links << link_to("L", post.large_file_url, :id => "large-file-link") + end + + if post.has_medium? || post.has_large? + links << link_to("O", post.file_url, :id => "original-file-link") + end if links.any? - html = %{