diff --git a/app/assets/javascripts/posts.js b/app/assets/javascripts/posts.js index f0146be48..1d588b7ae 100644 --- a/app/assets/javascripts/posts.js +++ b/app/assets/javascripts/posts.js @@ -18,6 +18,7 @@ this.initialize_links(); this.initialize_post_sections(); this.initialize_post_image_resize_links(); + this.initialize_post_image_resize_to_window_link(); this.place_jlist_ads(); } } @@ -88,6 +89,37 @@ }); } + Danbooru.Post.initialize_post_image_resize_to_window_link = function() { + $("#image-resize-to-window-link").click(function(e) { + var $img = $("#image"); + + Danbooru.Note.Box.descale_all(); + + if (($img.data("scale_factor") === 1) || ($img.data("scale_factor") === undefined)) { + $img.data("original_width", $img.width()); + $img.data("original_height", $img.height()); + var client_width = $(window).width() - $("#sidebar").width() - 75; + var client_height = $(window).height(); + + if ($img.width() > client_width) { + var ratio = client_width / $img.width(); + $img.data("scale_factor", ratio); + $img.css("width", $img.width() * ratio); + $img.css("height", $img.height() * ratio); + console.log("ratio=%f", ratio); + } + } else { + $img.data("scale_factor", 1); + $img.width($img.data("original_width")); + $img.height($img.data("original_height")); + } + + Danbooru.Note.Box.scale_all(); + Danbooru.Post.place_jlist_ads() + e.preventDefault(); + }); + } + Danbooru.Post.initialize_wiki_page_excerpt = function() { $("#wiki-page-excerpt").hide(); diff --git a/app/views/posts/partials/show/_information.html.erb b/app/views/posts/partials/show/_information.html.erb index 5724108d8..eab65adb1 100644 --- a/app/views/posts/partials/show/_information.html.erb +++ b/app/views/posts/partials/show/_information.html.erb @@ -13,7 +13,6 @@
  • Source: <%= post_source_tag(post) %>
  • Rating: <%= post.pretty_rating %>
  • Score: <%= post.score %> <% if CurrentUser.is_privileged? %>(vote <%= link_to "up", post_votes_path(:post_id => post.id, :score => "up"), :remote => true, :method => :post %>/<%= link_to "down", post_votes_path(:post_id => post.id, :score => "down"), :remote => true, :method => :post %>)<% end %>
  • -
  • ID: <%= post.id %>
  • Status: <% if post.is_pending? %> @@ -32,4 +31,5 @@ Active <% end %>
  • +
  • ID: <%= post.id %>
  • \ No newline at end of file diff --git a/app/views/posts/partials/show/_options.html.erb b/app/views/posts/partials/show/_options.html.erb index d2ece3649..344cdc5a6 100644 --- a/app/views/posts/partials/show/_options.html.erb +++ b/app/views/posts/partials/show/_options.html.erb @@ -2,8 +2,9 @@ <% if CurrentUser.is_member? %>
  • <%= link_to "Favorite", favorites_path(:post_id => post.id), :remote => true, :method => :post, :id => "add-to-favorites" %>
  • <%= link_to "Unfavorite", favorite_path(post), :remote => true, :method => :delete, :id => "remove-from-favorites" %>
  • -
  • <%= link_to "Pool", "#", :id => "pool" %>
  • -
  • <%= link_to "Note", "#", :id => "translate", :title => "Shortcut is CTRL+N" %>
  • +
  • <%= link_to "Add to pool", "#", :id => "pool" %>
  • +
  • <%= link_to "Add note", "#", :id => "translate", :title => "Shortcut is CTRL+N" %>
  • +
  • <%= link_to "Resize to window", "#", :id => "image-resize-to-window-link" %>
  • <%= link_to "Find similar", "http://danbooru.iqdb.org/db-search.php?url=http://#{Danbooru.config.hostname}#{post.preview_file_url}" %>
  • <% unless post.is_status_locked? %>