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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user