gremmie@1: $(document).ready(function() { bgneal@126: var postText = $('#id_comment'); bgneal@126: var postButton = $('#comment-form-post'); bgneal@126: postButton.click(function () { bgneal@126: var text = $.trim(postText.val()); bgneal@126: if (text.length == 0) { bgneal@126: alert('Please enter some text.'); bgneal@126: return false; bgneal@126: } bgneal@126: postButton.attr('disabled', 'disabled').val('Posting Comment...'); bgneal@126: $.ajax({ bgneal@126: url: '/comments/post/', bgneal@126: type: 'POST', bgneal@126: data: { bgneal@126: comment : text, bgneal@126: content_type : $('#id_content_type').val(), bgneal@126: object_pk : $('#id_object_pk').val() gremmie@1: }, bgneal@126: dataType: 'html', bgneal@126: success: function (data, textStatus) { bgneal@126: postText.val(''); gremmie@1: $('#comment-list').append(data); gremmie@1: var lastLi = $('#comment-list > li:last'); gremmie@1: lastLi.hide(); gremmie@1: lastLi.fadeIn(3000); bgneal@126: postButton.removeAttr('disabled').val('Post Comment'); gremmie@1: var count = $('#comment-count'); gremmie@1: if (count.length) { gremmie@1: count.html(parseInt(count.html()) + 1); gremmie@1: } gremmie@1: }, bgneal@126: error: function (xhr, textStatus, ex) { bgneal@126: alert('Oops, an error occurred. ' + xhr.statusText + ' - ' + bgneal@126: xhr.responseText); bgneal@126: postButton.removeAttr('disabled').val('Post Comment'); bgneal@126: } bgneal@126: }); gremmie@1: return false; gremmie@1: }); gremmie@1: $('a.comment-flag').click(function () { gremmie@1: var id = this.id; gremmie@1: if (id.match(/fc-(\d+)/)) { gremmie@1: id = RegExp.$1; gremmie@1: if (confirm('Only flag a comment if you feel it is spam, abuse, violates site rules, ' + gremmie@1: 'or is not appropriate. ' + gremmie@1: 'A moderator will be notified and will review the comment. ' + gremmie@1: 'Are you sure you want to flag this comment?')) { bgneal@99: $.ajax({ bgneal@99: url: '/comments/flag/', bgneal@99: type: 'POST', bgneal@99: data: {id: id}, bgneal@99: dataType: 'text', bgneal@99: success: function (response, textStatus) { bgneal@99: alert(response); bgneal@99: }, bgneal@99: error: function (xhr, textStatus, ex) { bgneal@99: alert('Oops, an error occurred: ' + xhr.statusText + ' - ' + xhr.responseText); bgneal@99: } bgneal@99: }); gremmie@1: } gremmie@1: } gremmie@1: return false; gremmie@1: }); gremmie@1: });