From f11069a34ad0ea555e7516742c543ef1225fd7d5 Mon Sep 17 00:00:00 2001 From: albert Date: Sun, 3 Mar 2013 16:01:05 -0500 Subject: [PATCH] fixes #738 --- app/assets/javascripts/comments.js | 4 +++- app/assets/javascripts/utility.js | 12 +++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/comments.js b/app/assets/javascripts/comments.js index ad0df857f..182ee5a86 100644 --- a/app/assets/javascripts/comments.js +++ b/app/assets/javascripts/comments.js @@ -50,7 +50,9 @@ Danbooru.Comment.initialize_response_link = function() { $("a.expand-comment-response").click(function(e) { $(e.target).hide(); - $(e.target).closest("div.new-comment").find("form").slideDown("fast"); + var $form = $(e.target).closest("div.new-comment").find("form"); + $form.slideDown("fast"); + Danbooru.scroll_to($form); e.preventDefault(); }); diff --git a/app/assets/javascripts/utility.js b/app/assets/javascripts/utility.js index a2132cc2d..b3cf2fa3c 100644 --- a/app/assets/javascripts/utility.js +++ b/app/assets/javascripts/utility.js @@ -2,18 +2,20 @@ Danbooru.meta = function(key) { return $("meta[name=" + key + "]").attr("content"); } + + Danbooru.scroll_to = function(element) { + $('html, body').animate({ + scrollTop: element.offset().top - 10 + }, 250); + } Danbooru.notice = function(msg) { $('#notice').html(msg).addClass("ui-state-highlight").removeClass("ui-state-error").fadeIn("fast"); - var scroll_top = $("#notice"); } Danbooru.error = function(msg) { $('#notice').html(msg).removeClass("ui-state-highlight").addClass("ui-state-error").fadeIn("fast"); - var scroll_top = $("#notice"); - $('html, body').animate({ - scrollTop: scroll_top - }, 250); + Danbooru.scroll_to($("#notice")); } Danbooru.is_subset = function(array, subarray) {