This commit is contained in:
albert
2013-03-03 16:01:05 -05:00
parent 7c4e933bea
commit f11069a34a
2 changed files with 10 additions and 6 deletions

View File

@@ -50,7 +50,9 @@
Danbooru.Comment.initialize_response_link = function() { Danbooru.Comment.initialize_response_link = function() {
$("a.expand-comment-response").click(function(e) { $("a.expand-comment-response").click(function(e) {
$(e.target).hide(); $(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(); e.preventDefault();
}); });

View File

@@ -3,17 +3,19 @@
return $("meta[name=" + key + "]").attr("content"); return $("meta[name=" + key + "]").attr("content");
} }
Danbooru.scroll_to = function(element) {
$('html, body').animate({
scrollTop: element.offset().top - 10
}, 250);
}
Danbooru.notice = function(msg) { Danbooru.notice = function(msg) {
$('#notice').html(msg).addClass("ui-state-highlight").removeClass("ui-state-error").fadeIn("fast"); $('#notice').html(msg).addClass("ui-state-highlight").removeClass("ui-state-error").fadeIn("fast");
var scroll_top = $("#notice");
} }
Danbooru.error = function(msg) { Danbooru.error = function(msg) {
$('#notice').html(msg).removeClass("ui-state-highlight").addClass("ui-state-error").fadeIn("fast"); $('#notice').html(msg).removeClass("ui-state-highlight").addClass("ui-state-error").fadeIn("fast");
var scroll_top = $("#notice"); Danbooru.scroll_to($("#notice"));
$('html, body').animate({
scrollTop: scroll_top
}, 250);
} }
Danbooru.is_subset = function(array, subarray) { Danbooru.is_subset = function(array, subarray) {