add post image resize to window option
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
<li>Source: <%= post_source_tag(post) %></li>
|
||||
<li>Rating: <%= post.pretty_rating %></li>
|
||||
<li>Score: <span id="score-for-post-<%= post.id %>"><%= post.score %></span> <% 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 %></li>
|
||||
<li>ID: <%= post.id %></li>
|
||||
<li>
|
||||
Status:
|
||||
<% if post.is_pending? %>
|
||||
@@ -32,4 +31,5 @@
|
||||
Active
|
||||
<% end %>
|
||||
</li>
|
||||
<li>ID: <%= post.id %></li>
|
||||
</ul>
|
||||
@@ -2,8 +2,9 @@
|
||||
<% if CurrentUser.is_member? %>
|
||||
<li><%= link_to "Favorite", favorites_path(:post_id => post.id), :remote => true, :method => :post, :id => "add-to-favorites" %></li>
|
||||
<li><%= link_to "Unfavorite", favorite_path(post), :remote => true, :method => :delete, :id => "remove-from-favorites" %></li>
|
||||
<li><%= link_to "Pool", "#", :id => "pool" %></li>
|
||||
<li><%= link_to "Note", "#", :id => "translate", :title => "Shortcut is CTRL+N" %></li>
|
||||
<li><%= link_to "Add to pool", "#", :id => "pool" %></li>
|
||||
<li><%= link_to "Add note", "#", :id => "translate", :title => "Shortcut is CTRL+N" %></li>
|
||||
<li><%= link_to "Resize to window", "#", :id => "image-resize-to-window-link" %></li>
|
||||
<li><%= link_to "Find similar", "http://danbooru.iqdb.org/db-search.php?url=http://#{Danbooru.config.hostname}#{post.preview_file_url}" %></li>
|
||||
|
||||
<% unless post.is_status_locked? %>
|
||||
|
||||
Reference in New Issue
Block a user