$(document).ready(function() { $(".voteLink").ajaxLink({ commandSuccess: function(response, element) { var $scoreBox = $(element).closest(".scoreBox").find(".value"); $scoreBox.html(response.data.Score); Core.Highlighter.highligh($scoreBox); } }); $(".bestAnswerButton").ajaxLink({ commandSuccess: function(response, element) { $("#answersBox .bestAnswer").removeClass("bestAnswer"); $(element).closest(".answerBox").addClass("bestAnswer"); } }); $(".deleteAnswerLink").ajaxLink({ confirm: "Вы уверены, что хотите удалить ответ?", commandSuccess: function(response, element) { $(element).closest(".answerBox").addClass("removed"); } }); $(".commentLink").ajaxLink({ verb: "GET", cancel: function($link) { var $postContainer = $link.closest(".postMetadata"); if ($postContainer.find(".fastComment").length > 0) { $postContainer.find(".fastComment").show(); Core.Highlighter.highligh($postContainer.find(".fastComment")); return true; } return false; }, success: function(response, $link) { var $postContainer = $link.closest(".postMetadata"); $postContainer.append(response.views["view"]); initCommentForm($postContainer); } }); /* $(".commentLink").click(function() { $this = $(this); $postContainer = $(this).closest(".postMetadata"); if ($postContainer.find(".fastComment").length > 0) { $postContainer.find(".fastComment").show(); Core.Highlighter.highligh($postContainer.find(".fastComment")); return false; } Core.BusyIndicator.show($postContainer); $.get($this.attr('href'), function(data) { $postContainer.append(data); Core.BusyIndicator.hide($postContainer); initCommentForm($postContainer); }); return false; })*/ }); function initCommentForm($postContainer) { var captchaContainet = $postContainer.find(".captchaPlaceholder"); var $fastComment = $postContainer.find(".fastComment"); if (captchaContainet.length > 0) { $(".fastComment").each(function(index, item) { if (item != $fastComment[0]) { $(item).remove(); } }); Recaptcha.create( "6LcFSwgAAAAAALDo-5VryV_V7WxE0olPdLGaQl6F", captchaContainet[0], { theme: "red", callback: Recaptcha.focus_response_field }); } $postContainer.find(".fastComment FORM").exAjaxForm({ commandFailure: function(data) { $postContainer.find(".fastComment").replaceWith(data.views["form"]); initCommentForm($postContainer); }, commandSuccess: function(data) { $postContainer.find(".fastComment").remove(); var commentsContainer = $postContainer.parent().find(".comments"); if (commentsContainer.length > 0) { $postContainer.parent().find(".comments").replaceWith(data.views["comments"]); } else { $postContainer.parent().append(data.views["comments"]); } } }); $postContainer.find(".fastComment .cancelLink").click(function() { $(this).closest(".fastComment").hide(); return false; }); }