From 1ef7ef49a51ce2efd09c92aa52c0b4dde8ef8743 Mon Sep 17 00:00:00 2001 From: albert Date: Fri, 30 Mar 2012 14:28:46 -0400 Subject: [PATCH] added share links, moved image resize back to notice banner style --- app/assets/javascripts/posts.js | 63 +- app/assets/javascripts/uploads.js | 2 +- app/models/post.rb | 4 + app/views/posts/partials/show/_image.html.erb | 4 + .../posts/partials/show/_notices.html.erb | 9 +- .../posts/partials/show/_options.html.erb | 8 +- app/views/posts/partials/show/_share.html.erb | 34 + app/views/posts/show.html.erb | 12 +- db/structure.sql | 5503 +++++++++++++++++ 9 files changed, 5574 insertions(+), 65 deletions(-) create mode 100644 app/views/posts/partials/show/_share.html.erb create mode 100644 db/structure.sql diff --git a/app/assets/javascripts/posts.js b/app/assets/javascripts/posts.js index f24a8a8af..f37c506a9 100644 --- a/app/assets/javascripts/posts.js +++ b/app/assets/javascripts/posts.js @@ -15,11 +15,9 @@ } if ($("#c-posts").length && $("#a-show").length) { - this.initialize_resize_links(); this.initialize_links(); this.initialize_post_sections(); this.initialize_post_image_resize_links(); - this.initialize_image_resize(); } } @@ -46,24 +44,6 @@ }); } - Danbooru.Post.initialize_resize_links = function() { - $("#resize-links").hide(); - - $("#resize-links a").click(function(e) { - var image = $("#image"); - var target = $(e.target); - image.attr("src", target.data("src")); - image.attr("width", target.data("width")); - image.attr("height", target.data("height")); - e.preventDefault(); - }); - - $("#resize-link a").click(function(e) { - $("#resize-links").toggle(); - e.preventDefault(); - }); - } - Danbooru.Post.initialize_titles = function() { $(".post-preview").each(function(i, v) { Danbooru.Post.initialize_title_for(v); @@ -92,38 +72,19 @@ $post.addClass("post-status-has-children"); } } - - Danbooru.Post.initialize_image_resize = function() { - var default_image_size = Danbooru.meta("default-image-size"); - var original_width = parseInt($("#image").data("original-width")); - var large_width = parseInt(Danbooru.meta("config-large-width")); - if ((default_image_size === "large") && (original_width > large_width)) { - $("#large-file-link").trigger("click"); - } else { - $("#original-file-link").trigger("click"); - } - } - - Danbooru.Post.build_resize_function = function(size) { - return function(e) { + Danbooru.Post.initialize_post_image_resize_links = function() { + $("#image-resize-link").click(function(e) { Danbooru.Note.Box.descale_all(); var $link = $(e.target); var $image = $("#image"); - $("#large-file-link").removeClass("active"); - $("#original-file-link").removeClass("active"); - $link.addClass("active"); $image.attr("src", $link.attr("href")); - $image.width($image.data(size + "-width")); - $image.height($image.data(size + "-height")); + $image.width($image.data("original-width")); + $image.height($image.data("original-height")); Danbooru.Note.Box.scale_all(); + $("#image-resize-notice").hide(); e.preventDefault(); - } - } - - Danbooru.Post.initialize_post_image_resize_links = function() { - $("#large-file-link").click(Danbooru.Post.build_resize_function("large")); - $("#original-file-link").click(Danbooru.Post.build_resize_function("original")); + }); } Danbooru.Post.initialize_wiki_page_excerpt = function() { @@ -149,11 +110,17 @@ Danbooru.Post.initialize_post_sections = function() { $("#post-sections li a").click(function(e) { if (e.target.hash === "#comments") { - $("#comments").fadeIn("fast"); + $("#comments").show(); $("#edit").hide(); - } else { - $("#edit").fadeIn("fast"); + $("#share").hide(); + } else if (e.target.hash === "#edit") { + $("#edit").show(); $("#comments").hide(); + $("#share").hide(); + } else { + $("#edit").hide(); + $("#comments").hide(); + $("#share").show(); } $("#post-sections li").removeClass("active"); diff --git a/app/assets/javascripts/uploads.js b/app/assets/javascripts/uploads.js index d4ff00117..76cf32f98 100644 --- a/app/assets/javascripts/uploads.js +++ b/app/assets/javascripts/uploads.js @@ -19,7 +19,7 @@ $("#upload_source").attr("name", "url"); $("#upload_file").attr("name", "file"); $("#form").attr("target", "_blank"); - $("#form").attr("action", "http://danbooru.iqdb.hanyuu.net/"); + $("#form").attr("action", "http://danbooru.iqdb.org/"); $("form").trigger("submit"); diff --git a/app/models/post.rb b/app/models/post.rb index 09e96f2e3..e41bacf1f 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -215,6 +215,10 @@ class Post < ActiveRecord::Base image_height end end + + def resize_percentage + 100 * large_image_width.to_f / image_width.to_f + end end module ApprovalMethods diff --git a/app/views/posts/partials/show/_image.html.erb b/app/views/posts/partials/show/_image.html.erb index 40c0b609a..2c63e3fab 100644 --- a/app/views/posts/partials/show/_image.html.erb +++ b/app/views/posts/partials/show/_image.html.erb @@ -1 +1,5 @@ <%= 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) %> + +<% if post.has_large? && CurrentUser.default_image_size == "large" %> +

Resized to <%= number_to_percentage post.resize_percentage, :precision => 0 %> of original (<%= link_to "view original", post.file_url, :id => "image-resize-link" %>)

+<% end %> \ No newline at end of file diff --git a/app/views/posts/partials/show/_notices.html.erb b/app/views/posts/partials/show/_notices.html.erb index 663e22241..cfd1fc969 100644 --- a/app/views/posts/partials/show/_notices.html.erb +++ b/app/views/posts/partials/show/_notices.html.erb @@ -6,7 +6,9 @@ <% if (post.is_flagged? || post.is_deleted?) && post.flags.any? %>
- This post has been flagged for deletion: <%= post_flag_reasons(post) %> +

This post has been flagged for deletion:

+ + <%= post_flag_reasons(post) %>
<% end %> @@ -19,7 +21,7 @@ <% unless post.is_status_locked? %> <%= link_to "Approve", moderator_post_approval_path(:post_id => post.id), :method => :post, :remote => true, :class => "btn" %> <% end %> - <%= link_to "Disapprove", moderator_post_disapproval_path(:post_id => post.id), :method => :post, :remote => true, :class => "btn" %> + <%= link_to "Hide from queue", moderator_post_disapproval_path(:post_id => post.id), :method => :post, :remote => true, :class => "btn" %> <% end %> @@ -27,7 +29,8 @@ <% if (post.is_flagged? || post.is_deleted?) && post.appeals.any? %>
- This post has been appealed: <%= post_appeal_reasons(post) %> +

This post has been appealed:

+ <%= post_appeal_reasons(post) %>
<% end %> diff --git a/app/views/posts/partials/show/_options.html.erb b/app/views/posts/partials/show/_options.html.erb index c4f3d5283..151f1341f 100644 --- a/app/views/posts/partials/show/_options.html.erb +++ b/app/views/posts/partials/show/_options.html.erb @@ -1,14 +1,10 @@