blob: 6e9856263b792f98d5f5a1da72b18480287b0399 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
$("document").ready(function() {
$("#gAddCommentButton").click(function(event) {
event.preventDefault();
if (!$("#gAddCommentForm").length) {
$.get($(this).attr("href"),
{},
function(data) {
$("#gCommentDetail").append(data);
ajaxify_comment_form();
});
}
});
$("#gNoComments").click(function(event) {
event.preventDefault();
if (!$("#gAddCommentForm").length) {
$.get($(this).attr("href"),
{},
function(data) {
$("#gCommentDetail").append(data);
ajaxify_comment_form();
});
$("#gNoCommentsYet").remove();
}
});
});
function ajaxify_comment_form() {
$("#gComments form").ajaxForm({
dataType: "json",
success: function(data) {
if (data.form) {
$("#gComments form").replaceWith(data.form);
ajaxify_comment_form();
}
if (data.result == "success") {
$.get(data.resource, function(data, textStatus) {
$("#gComments .gBlockContent ul:first").append("<li>"+data+"</li>");
$("#gComments .gBlockContent ul:first li:last").effect("highlight", {color: "#cfc"}, 8000);
$("#gAddCommentForm").hide(2000).remove();
$("#gNoCommentsYet").hide(2000);
});
}
}
});
}
|