Files
gallery3/modules/comment/js/comment.js
T

46 lines
1.3 KiB
JavaScript
Raw Normal View History

2008-11-16 07:14:12 +00:00
$("document").ready(function() {
$("#g-admin-comment-button").click(function(event) {
event.preventDefault();
if (!$("#g-comment-form").length) {
$.get($(this).attr("href"),
{},
function(data) {
$("#g-comment-detail").append(data);
ajaxify_comment_form();
});
}
});
$("#g-no-comments").click(function(event) {
event.preventDefault();
if (!$("#g-comment-form").length) {
$.get($(this).attr("href"),
{},
function(data) {
$("#g-comment-detail").append(data);
ajaxify_comment_form();
});
$("#g-no-comments-yet").remove();
}
});
2008-11-16 07:14:12 +00:00
});
function ajaxify_comment_form() {
$("#g-comments form").ajaxForm({
2008-12-25 01:34:17 +00:00
dataType: "json",
success: function(data) {
if (data.form) {
$("#g-comments form").replaceWith(data.form);
2008-12-31 03:29:25 +00:00
ajaxify_comment_form();
}
if (data.result == "success" && data.resource) {
$.get(data.resource, function(data, textStatus) {
$("#g-comments .g-block-content ul:first").append("<li>"+data+"</li>");
$("#g-comments .g-block-content ul:first li:last").effect("highlight", {color: "#cfc"}, 8000);
$("#g-comment-form").hide(2000).remove();
$("#g-no-comments-yet").hide(2000);
});
2008-11-16 07:14:12 +00:00
}
}
});
}