app/views/commontator/comments/create.js.erb in commontator-6.0.1 vs app/views/commontator/comments/create.js.erb in commontator-6.1.0

- old
+ new

@@ -1,12 +1,14 @@ <%= if @comment.parent.nil? partial = 'threads' extra_locals = {} + id = "commontator-thread-#{@commontator_thread.id}-new-comment" else partial = 'comments' extra_locals = { comment: @comment.parent } + id = "commontator-comment-#{@comment.parent.id}-reply" end render partial: "commontator/#{partial}/show", locals: extra_locals.merge( user: @commontator_user, thread: @commontator_thread, @@ -14,19 +16,22 @@ show_all: @commontator_show_all ) %> <% if @commontator_new_comment.nil? %> - $("#commontator-thread-<%= @commontator_thread.id %>-new-comment").hide(); + $("#<%= id %>").hide(); - $("#commontator-thread-<%= @commontator_thread.id %>-new-comment-link").fadeIn(); + $("#<%= id %>-link").fadeIn(); <% else %> - $("#commontator-thread-<%= @commontator_thread.id %>-new-comment").html("<%= escape_javascript( + $("#<%= id %>").html("<%= escape_javascript( render partial: 'form', locals: { comment: @commontator_new_comment, thread: @commontator_thread } ) %>"); <% end %> -$("#commontator-comment-<%= @comment.id %>").hide().fadeIn()[0].scrollIntoView(); +var commontatorComment = $("#commontator-comment-<%= @comment.id %>").hide().fadeIn(); +$('html, body').animate( + { scrollTop: commontatorComment.offset().top - window.innerHeight/2 }, 'fast' +); <%= javascript_proc %>